body{
  background-color: var(--bg);
  color: var(--font-color);
  font-family: var(--font-family);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button{
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible{
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/*
 * Estrutura: as alturas do cabeçalho, placar e rodapé acompanham a altura da tela.
 * A quadra (16:9) ocupa o que sobra, e toda a coluna usa a largura da quadra,
 * assim tudo fica alinhado e cabe na tela sem rolagem.
 */
.app{
  --pad: clamp(10px, 2.5vh, 28px);
  --gap: clamp(8px, 2vh, 20px);
  --header-h: clamp(44px, 8vh, 72px);
  --score-h: clamp(56px, 15vh, 132px);
  --footer-h: clamp(28px, 5vh, 44px);
  --court-max-h: calc(100vh - 2 * var(--pad) - var(--header-h) - var(--score-h) - var(--footer-h) - 3 * var(--gap));

  width: min(100% - 2 * var(--pad), 1500px, var(--court-max-h) * 16 / 9);
  min-width: min(100% - 2 * var(--pad), 560px);
  margin: 0 auto;
  padding: var(--pad) 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  container-type: inline-size;
}

@supports (height: 100dvh){
  .app{
    --court-max-h: calc(100dvh - 2 * var(--pad) - var(--header-h) - var(--score-h) - var(--footer-h) - 3 * var(--gap));
  }
}

/* Cabeçalho */
.topbar{
  min-height: var(--header-h);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 20px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 0.24em;
  font-family: var(--font-display);
  font-size: clamp(28px, calc(var(--header-h) * 0.58), 42px);
  line-height: 1;
  letter-spacing: 0.02em;
}

.brand__lusm{ font-weight: 400; }
.brand__pong{ font-weight: 700; }

.brand__ball{
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.topbar__right{
  display: flex;
  align-items: center;
  gap: 16px;
}

.summary{
  font-size: 13px;
  letter-spacing: 0.12em;
}

.icon-btn{
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid var(--font-color);
  border-radius: 50%;
  background: transparent;
}

.topbar__buttons{
  display: flex;
  gap: 10px;
}

.sound-toggle .icon-sound-off{ display: none; }
.sound-toggle[aria-pressed="false"] .icon-sound-on{ display: none; }
.sound-toggle[aria-pressed="false"] .icon-sound-off{ display: block; }
.sound-toggle[aria-pressed="false"]{ opacity: 0.7; }

.theme-toggle .icon-moon{ display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun{ display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon{ display: block; }

/* Placar */
.scoreboard{
  height: var(--score-h);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
}

.score{
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.2s ease;
}

.score--center{
  align-items: center;
  gap: 4px;
  padding-bottom: calc(var(--score-h) * 0.08);
}

.score--right{ align-items: flex-end; }

.score__label{
  font-size: 12px;
  letter-spacing: 0.16em;
}

.score__value{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--score-h) * 0.82);
  line-height: 0.85;
}

.score__rally{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--score-h) * 0.27);
  line-height: 1;
}

.score.is-loser{ opacity: 0.6; }
.score.is-winner .score__label{ font-weight: 600; }
.score.is-winner .score__value{ color: var(--accent); }

/* Quadra: as telas internas usam unidades da própria quadra (cqh/cqw) e encolhem junto. */
.court{
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: clamp(14px, 2.4cqw, 24px);
  overflow: hidden;
  background: var(--court);
  container-type: size;
}

.court canvas{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.overlay{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2.6cqh, 20px);
  padding: clamp(8px, 3cqh, 24px);
  overflow: auto;
}

/* Menu inicial */
.overlay--menu{ color: var(--court-line); }

.overlay__title{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 15cqh, 88px);
  line-height: 0.9;
}

.option-group{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1.4cqh, 8px);
}

.option-group__label{
  font-size: clamp(10px, 2.2cqh, 12px);
  letter-spacing: 0.16em;
}

.option-group__pills{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 1.2cqw, 10px);
}

.pill{
  min-height: clamp(30px, 8cqh, 44px);
  min-width: clamp(40px, 6cqw, 56px);
  padding: 0 clamp(10px, 2cqw, 18px);
  border: 2px solid var(--line-soft);
  border-radius: 999px;
  background: transparent;
  color: var(--court-line);
  font-size: clamp(12px, 2.8cqh, 15px);
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pill:hover{ border-color: var(--court-line); }

.pill[aria-pressed="true"]{
  border-color: var(--court-line);
  background: var(--court-line);
  color: var(--court);
}

.cta{
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: clamp(34px, 9cqh, 48px);
  margin-top: clamp(0px, 1cqh, 6px);
  padding: 0 clamp(16px, 2.6cqw, 24px);
  border: 0;
  border-radius: 999px;
  background: var(--court-line);
  color: var(--court);
  font-size: clamp(12px, 2.8cqh, 15px);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.cta__ball{
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

/* Pausa */
.overlay--pause{
  background: color-mix(in srgb, var(--court) 55%, transparent);
}

.pause-card{
  width: min(100%, 340px);
  padding: clamp(14px, 5cqh, 28px) clamp(16px, 3.4cqw, 32px);
  border-radius: 20px;
  background: var(--card);
  color: var(--card-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.8cqh, 10px);
}

.pause-card__title{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 13cqh, 72px);
  line-height: 0.9;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.btn{
  min-height: clamp(34px, 9cqh, 48px);
  padding: 0 clamp(16px, 2.6cqw, 24px);
  border-radius: 999px;
  font-size: clamp(12px, 2.8cqh, 15px);
  font-weight: 600;
  letter-spacing: 0.06em;
}

.pause-card .btn{ width: 100%; }

.btn--solid{
  border: 0;
  background: var(--card-ink);
  color: var(--card);
}

.btn--outline{
  border: 2px solid var(--card-ink);
  background: transparent;
  color: var(--card-ink);
}

/* Fim de jogo */
.overlay--end{
  background: var(--accent);
  color: var(--ink);
}

.end__kicker{
  font-size: clamp(14px, 3.7cqh, 20px);
  font-weight: 600;
  letter-spacing: 0.22em;
}

.end__title{
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(36px, 20cqh, 116px);
  line-height: 0.88;
  text-align: center;
}

.end__actions{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.btn--ink{
  border: 0;
  background: var(--ink);
  color: var(--on-ink);
}

.btn--ink-outline{
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
}

/* Rodapé */
.footer{
  min-height: var(--footer-h);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  font-size: clamp(11px, 1.8vh, 13px);
}

.keys{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}

.keys__item{
  display: flex;
  align-items: center;
  gap: 8px;
}

kbd{
  font-family: inherit;
  border: 2px solid var(--font-color);
  border-radius: 6px;
  padding: 1px 7px;
}

@container (max-width: 1000px){
  .copyright__extra{ display: none; }
  .footer, .keys{ column-gap: 14px; }
  .keys__item{ gap: 5px; }
  kbd{ padding: 1px 5px; }
}

/* Quadra muito baixa (celular): esconde o título do menu para as opções caberem. */
@container (max-height: 260px){
  .overlay__title{ display: none; }
  .overlay{ gap: 6px; padding: 6px; }
  .pill, .cta{ min-height: 28px; }
}

@container (max-width: 600px){
  .summary{ display: none; }
}

/* Celular: a coluna usa a largura toda e a página pode rolar. */
@media (max-width: 640px){
  .app{
    width: calc(100% - 2 * var(--pad));
    min-width: 0;
  }
  .scoreboard{ height: auto; }
  .score__value{ font-size: 64px; }
  .score__rally{ font-size: 28px; }
}
