:root {
  /* Paleta ESPN: azul-marinho, azul do placar, amarelo, branco */
  --bg: #050e2a; --card: #0a1d52; --sheet: #0b2a6f; --line: rgba(255,255,255,.16); --row: rgba(255,255,255,.06);
  --text: #ffffff; --muted: #a9b7db; --accent: #ffd23f;
  --me: #ffd23f; --opp: #ffffff; --good: #3ac27a; --bad: #e5533d;
  --fs-s: 14px; --fs-m: 16px; --fs-l: 22px; --fs-xl: 34px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs-m)/1.35 Inter, system-ui, -apple-system, sans-serif; }
p { margin: 0; }
h1 { font-size: var(--fs-xl); font-weight: 800; margin: 0; line-height: 1.1; letter-spacing: -0.01em; }
.eyebrow { font-size: var(--fs-s); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sheet .eyebrow { font-size: var(--fs-m); }
.muted { color: var(--muted); }
.legend { font-size: var(--fs-s); color: var(--muted); }

/* Layout */
#app { display: flex; flex-direction: column; gap: 16px; padding: 16px; max-width: 480px; margin: 0 auto; }
#courtWrap { display: flex; flex-direction: column; align-items: center; }
#court { width: 100%; max-width: 448px; height: auto; border-radius: 10px; display: block; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
#panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Sheet: painel de ação, compacta. 3 tamanhos (13/14/18), 3 cores, blocos com o mesmo espaçamento */
.sheet { background: var(--sheet); border-top: 3px solid var(--accent); border-radius: 14px 14px 0 0; padding: 0 14px calc(6px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; box-shadow: 0 -10px 30px rgba(0,0,0,.6); transition: transform .22s ease; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.35); margin: 6px auto 2px; flex: 0 0 auto; }
.sheet .block { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-height: 32px; }
.sheet .block.head { justify-content: space-between; }
.sheet .eyebrow { font-size: 12px; }
.sheet .title { font-size: 16px; font-weight: 700; line-height: 1.25; }
.sheet .line { font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--text); }
.sheet .line.muted { color: var(--muted); font-weight: 400; }
.sheet .line.small { font-size: 12px; font-weight: 400; color: var(--muted); }
.sheet .score { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sheet button.primary { margin-top: 8px; min-height: 44px; font-size: 16px; }
/* Quadro de notas parciais (destaque do feedback) */
.parts { display: flex; gap: 8px; width: 100%; }
.parts .cell { flex: 1; background: rgba(255,255,255,.07); border-radius: 10px; padding: 8px 6px 7px; text-align: center; min-width: 0; }
.parts .lbl { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.parts .val { font-size: 22px; font-weight: 800; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.parts .bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); margin-top: 6px; overflow: hidden; }
.parts .bar i { display: block; height: 100%; border-radius: 2px; }
.sheet.collapsed { transform: translateY(calc(100% - 54px)); overflow: hidden; }
#start { gap: 10px; }
#start h1 { font-size: 26px; }
.sub { font-size: 18px; color: var(--muted); font-weight: 500; }

/* Modo colapsado: quadra inteira entre o placar e a alça da sheet */
body.collapsed #court { width: auto; max-width: 100%; height: calc(100vh - var(--barH, 78px) - 54px - 24px); height: calc(100dvh - var(--barH, 78px) - 54px - 24px); }

/* Bloco empilhado: dica, mini animação didática e chips */
.sheet .block.stack { flex-direction: column; align-items: stretch; gap: 8px; }
#demo { display: flex; flex-direction: column; gap: 6px; }
#demo canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; border-radius: 10px; background: #0a1d52; }
#demo .line { font-size: 13px; line-height: 1.25; color: var(--muted); }
#demo .line b { color: var(--text); font-weight: 700; }

/* Chips do segundo passo (tipo de golpe / tipo de saque) */
.chips { display: flex; gap: 6px; width: 100%; }
.chips button { flex: 1; min-height: 36px; background: rgba(255,255,255,.08); color: var(--text); border: 2px solid var(--line); border-radius: 8px; font: 700 13px Inter, system-ui, sans-serif; cursor: pointer; padding: 0 4px; }
.chips button.on { background: var(--accent); color: #111; border-color: var(--accent); }

/* Segmento de pontos */
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; min-height: 44px; background: rgba(255,255,255,.08); color: var(--text); border: 2px solid var(--line); border-radius: 10px; font: 700 var(--fs-m) Inter, system-ui, sans-serif; cursor: pointer; }
.seg button.on { background: var(--accent); color: #111; border-color: var(--accent); }

/* Botões */
button.primary, button.secondary { width: 100%; min-height: 56px; border: 0; border-radius: 12px; padding: 14px 16px; font: 800 18px/1 Inter, system-ui, sans-serif; cursor: pointer; }
button.primary { background: var(--accent); color: #111; }
button.primary:disabled { background: rgba(255,255,255,.1); color: var(--muted); cursor: default; }
button.secondary { background: rgba(255,255,255,.1); color: var(--text); border: 1px solid var(--line); }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Placar fixo no topo, estilo broadcast */
.scorebar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto; align-items: stretch; width: 100%; max-width: 560px; margin: 0 auto; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: linear-gradient(180deg, #123a8f 0%, #0b2a6f 100%); border: 0; border-bottom: 2px solid #ffd23f; color: var(--text); font: 700 var(--fs-m) Inter, system-ui, sans-serif; text-align: left; cursor: pointer; font-variant-numeric: tabular-nums; gap: 0 12px; }
.scorebar .row { grid-column: 1; display: flex; align-items: center; gap: 8px; height: 30px; }
.scorebar .row.me { border-bottom: 1px solid var(--line); }
.scorebar .srv { width: 12px; height: 12px; border-radius: 50%; background: transparent; flex: 0 0 12px; }
.scorebar .srv.on { background: #d4ff3a; box-shadow: 0 0 6px #d4ff3a; }
.scorebar .name { flex: 1; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; font-size: var(--fs-m); }
.scorebar .sets { display: flex; gap: 10px; font-size: var(--fs-l); font-weight: 800; }
.scorebar .sets span { min-width: 16px; text-align: center; }
.scorebar .sets span.cur { color: var(--accent); }
.scorebar .pts { min-width: 40px; height: 26px; display: inline-flex; align-items: center; justify-content: center; background: #fff; color: #061a4a; border-radius: 4px; font-size: var(--fs-m); font-weight: 800; }
.scorebar .tag { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 8px; border-left: 1px solid var(--line); color: var(--accent); font-size: var(--fs-l); font-weight: 800; line-height: 1; }
.scorebar .tag small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; font-weight: 700; }

/* Estatísticas em tela cheia */
.overlay { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; }
.overlayInner { flex: 1 1 auto; overflow-y: auto; width: 100%; max-width: 560px; margin: 0 auto; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 16px; }
.overlayFoot { flex: 0 0 auto; width: 100%; max-width: 560px; margin: 0 auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--sheet); border-top: 3px solid var(--accent); display: flex; flex-direction: column; gap: 8px; }

/* Tabelas estilo box score */
table.box { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--card); border-radius: 8px; overflow: hidden; }
table.box th, table.box td { padding: 10px 14px; text-align: left; white-space: nowrap; }
table.box th { font-size: var(--fs-s); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 2px solid var(--line); }
table.box td { border-bottom: 1px solid var(--line); }
table.box tbody tr:nth-child(even) td { background: var(--row); }
table.box tbody tr:last-child td { border-bottom: 0; }
table.box .num { text-align: right; font-weight: 700; }
table.box td.wrap { white-space: normal; }
table.box tr.me td:first-child { box-shadow: inset 3px 0 0 var(--me); }
table.box tr.opp td:first-child { box-shadow: inset 3px 0 0 var(--opp); }
.tableWrap { overflow-x: auto; }
.score td.team { font-weight: 700; }
.score td.big { font-size: var(--fs-l); font-weight: 800; text-align: right; }
.score tbody tr:nth-child(even) td { background: transparent; }
#notes { display: flex; flex-direction: column; font-size: var(--fs-s); color: var(--muted); }
#notes div { padding: 8px 0; border-top: 1px solid var(--line); }
#notes div:first-child { border-top: 0; }

/* Sheet sempre fixa no rodapé, em qualquer tela: ação na zona do polegar */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 64vh; overflow-y: auto; margin: 0 auto; max-width: 560px; }
.sheet button.primary { position: sticky; bottom: 0; }
@media (min-width: 600px) { .sheet { border-radius: 14px 14px 0 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Conta, ranking, idioma */
.sheet .block.head h1 { font-size: 20px; white-space: nowrap; }
table.box.compact th, table.box.compact td { padding: 9px 8px; }
.acct { display: flex; align-items: center; gap: 8px; }
.home { display: flex; flex-direction: column; gap: 10px; }
.home .line { color: var(--muted); }
button.mini { min-height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--text); font: 700 12px Inter, system-ui, sans-serif; cursor: pointer; }
.who { font-size: 12px; font-weight: 700; color: var(--accent); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .block.foot { justify-content: space-between; border-bottom: 0; padding-bottom: 0; }
.lang { position: relative; display: inline-flex; align-items: center; height: 32px; padding: 0 30px 0 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); color: var(--text); font: 700 12px/1 Inter, system-ui, sans-serif; letter-spacing: .06em; cursor: pointer; flex: 0 0 auto; }
.lang select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 16px; }
.lang::after { content: ''; position: absolute; right: 12px; top: 10px; width: 6px; height: 6px; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); }
.lang .dot { width: 14px; height: 14px; border-radius: 50%; margin-right: 8px; background: linear-gradient(135deg, #ffd23f 50%, #3ac27a 50%); }
/* Arquibancadas laterais: só em telas largas */
.stand { display: none; }
@media (min-width: 900px) {
  #courtWrap { position: relative; }
  .stand { display: block; position: absolute; top: 0; bottom: 0; width: 180px; height: 100%; border-radius: 10px; }
  #standL { right: 100%; margin-right: 14px; }
  #standR { left: 100%; margin-left: 14px; }
}
input.field { width: 100%; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--text); padding: 0 14px; font: 500 16px Inter, system-ui, sans-serif; }
input.field:focus { outline: 2px solid var(--accent); }
#rankRows tr.me td { color: var(--accent); font-weight: 700; }
input.field.code { text-align: center; font-size: 20px; letter-spacing: .25em; font-variant-numeric: tabular-nums; }
#codeRow { display: grid; gap: 8px; }
#codeRow .mini { justify-self: center; }
