/* ==========================================================================
   Nupy: base em preto, branco e cinza. Cor só nas peças, animações e destaques.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #111111;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --surface: #f5f5f5;
  --surface-2: #ebebeb;
  --tile-border: #d2d2d2;
  --tile-active: #8a8a8a;
  --tile-future: #efefef;
  --absent: #7a7a7a;
  --key: #e2e2e2;
  --key-fg: #111111;
  --key-absent: #f2f2f2;
  --key-absent-fg: #bdbdbd;
  --correct: #22a565;
  --present: #e5ab22;
  --gold: #f5b301;
  --danger: #e5484d;
  --navy: #1f3c88; /* azul-marinho do Nupy (a coleira do logo) */
  --on-color: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 10px 30px rgb(0 0 0 / 8%);
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.25);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --header: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #1f1f22;
    --fg: #f2f2f3;
    --muted: #a1a1a8;
    --line: #38383d;
    --surface: #2a2a2e;
    --surface-2: #34343a;
    --tile-border: #4b4b52;
    --tile-active: #8a8a92;
    --tile-future: #2c2c31;
    --absent: #4f4f56;
    --key: #44444b;
    --key-fg: #f2f2f3;
    --key-absent: #2a2a2f;
    --key-absent-fg: #6b6b73;
    --correct: #27a96a;
    --present: #d9a32a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px rgb(0 0 0 / 30%);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #1f1f22;
  --fg: #f2f2f3;
  --muted: #a1a1a8;
  --line: #38383d;
  --surface: #2a2a2e;
  --surface-2: #34343a;
  --tile-border: #4b4b52;
  --tile-active: #8a8a92;
  --tile-future: #2c2c31;
  --absent: #4f4f56;
  --key: #44444b;
  --key-fg: #f2f2f3;
  --key-absent: #2a2a2f;
  --key-absent-fg: #6b6b73;
  --correct: #27a96a;
  --present: #d9a32a;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px rgb(0 0 0 / 30%);
}

/* ---- base ---------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.3s,
    color 0.3s;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  line-height: 1.15;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

svg {
  display: block;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.82rem;
}
.center {
  text-align: center;
}

/* ---- cabeçalho ------------------------------------------------------------- */

.top {
  flex: none;
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.logo {
  display: flex;
  gap: 4px;
  text-decoration: none;
  perspective: 400px;
}

.logo-tile {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 15px;
  /* Snoopy: cara branca e orelhas pretas; o contorno some no tema em que ele não faz falta */
  background: #fff;
  color: #111;
  border: 2px solid var(--fg);
  animation: logo-in 0.7s var(--spring) both;
  animation-delay: calc(var(--i) * 110ms + 0.1s);
}
.logo-tile.ear {
  background: #111;
  color: #fff;
}
.logo-tile.ear:first-child {
  rotate: -7deg;
}
.logo-tile.ear:last-child {
  rotate: 7deg;
}
/* o U é a coleira: azul-marinho com a plaquinha dourada pendurada */
.logo-tile.collar {
  position: relative;
  background: var(--navy);
  color: #fff;
}
.logo-tile.collar::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--bg);
  translate: -50% 0;
  transform-origin: 50% -10px;
  animation: tag-swing 2.4s ease-in-out 1s infinite;
}
.logo:hover .logo-tile {
  animation: jump 0.5s ease both;
  animation-delay: calc(var(--i) * 70ms);
}

.top-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.15s;
}
.icon-btn:hover {
  background: var(--surface);
}
.icon-btn:active {
  transform: scale(0.9);
}
.icon-btn.small {
  width: 28px;
  height: 28px;
}
.icon-btn.small svg {
  width: 16px;
  height: 16px;
}
#btn-theme svg {
  animation: spin-in 0.5s var(--spring);
}

/* ---- telas --------------------------------------------------------------- */

.screen {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  animation: screen-in 0.4s var(--ease) both;
}

.screen-title {
  font-size: 1.7rem;
  margin: 6px 0 16px;
}

.eyebrow {
  margin: 8px 0 6px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}
.card.enter {
  animation: rise 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 90ms + 0.05s);
}
.card h2 {
  font-size: 1.02rem;
  margin: 0 0 10px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  flex: 1;
}
.card-head .icon svg {
  width: 20px;
  height: 20px;
}

/* ---- botões e campos ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.12s,
    background 0.25s,
    color 0.25s,
    opacity 0.2s;
}
.btn:active {
  transform: scale(0.97);
}
.btn svg {
  width: 18px;
  height: 18px;
}
.btn.primary {
  background: var(--fg);
  color: var(--bg);
}
.btn.big {
  width: 100%;
  padding: 15px 22px;
  font-size: 1.05rem;
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
}
.btn.ghost:hover {
  color: var(--fg);
}
.btn.danger {
  background: var(--danger);
  color: #fff;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.btn.loading {
  pointer-events: none;
  opacity: 0.6;
}
.btn.round {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.5rem;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.link-btn svg {
  width: 16px;
  height: 16px;
}

.input {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.2s;
}
.input:focus {
  outline: none;
  border-color: var(--fg);
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.field-label:first-child {
  margin-top: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 6px;
}
.segmented.compact {
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
}
.segmented.compact .seg {
  padding: 10px 4px;
  font-size: 0.9rem;
}
.seg {
  display: grid;
  gap: 1px;
  padding: 10px 8px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.25s,
    color 0.25s,
    transform 0.15s;
}
.seg:active {
  transform: scale(0.96);
}
.seg small {
  font-size: 0.74rem;
  color: var(--muted);
  transition: color 0.25s;
}
.seg.active {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}
.seg.active small {
  color: color-mix(in srgb, var(--bg) 70%, transparent);
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.stepper-value {
  min-width: 2ch;
  font-size: 2.1rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.bump {
  animation: bump 0.3s var(--spring);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 16px;
  cursor: pointer;
}
.switch-row > span:first-child {
  display: grid;
  gap: 2px;
}
.switch {
  position: relative;
  flex: none;
}
.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch-track {
  display: block;
  position: relative;
  width: 52px;
  height: 31px;
  border-radius: 99px;
  background: var(--line);
  transition: background 0.25s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
  transition: transform 0.3s var(--spring);
}
.switch input:checked + .switch-track {
  background: var(--correct);
}
.switch input:checked + .switch-track::after {
  transform: translateX(21px);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 11px;
  border-radius: 99px;
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 600;
  animation: pop-in 0.35s var(--spring) both;
}

.row-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---- início --------------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 14px 0 12px;
}
.hero-title {
  margin: 0;
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  animation: rise 0.5s var(--ease) both;
}
.greet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0 0;
  color: var(--muted);
}
.greet b {
  color: var(--fg);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mode-card {
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 14px 8px 12px;
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  text-align: center;
  text-decoration: none;
  transition:
    transform 0.2s var(--spring),
    box-shadow 0.2s;
  animation: pop-in 0.45s var(--spring) both;
  animation-delay: calc(var(--i) * 80ms + 0.2s);
}
.mode-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.mode-card:active {
  transform: scale(0.97);
}
.mode-card .muted {
  font-size: 0.78rem;
}
.mode-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 800;
}
.mode-status svg {
  width: 14px;
  height: 14px;
}
.mode-card.done .mode-status {
  background: transparent;
  color: var(--muted);
}
.mode-card.done .mode-status:has(svg) {
  color: var(--correct);
}

.join-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.code-input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-weight: 800;
  font-size: 1.25rem;
  padding-left: calc(14px + 0.4em);
}
.code-input::placeholder {
  letter-spacing: 0.2em;
  font-weight: 600;
  font-size: 1rem;
}

/* ---- jogo ---------------------------------------------------------------- */

.screen.game-screen,
.screen.room:has(> .match) {
  max-width: none;
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px 0;
}
.game-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.game-title strong {
  font-size: 1.15rem;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--surface);
  font-weight: 800;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  transition:
    background 0.3s,
    color 0.3s;
}
.timer svg {
  width: 16px;
  height: 16px;
}
.timer.warn {
  background: var(--danger);
  color: #fff;
  animation: pulse 1s ease-in-out infinite;
}

.play {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.boards {
  --tile: 52px;
  --gap: calc(var(--tile) * 0.12);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), max-content);
  align-content: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 12px;
  perspective: 900px;
}

.board {
  position: relative;
  display: grid;
  gap: var(--gap);
  align-content: start;
}
.board.intro {
  animation: board-in 0.55s var(--spring) both;
  animation-delay: calc(var(--b) * 90ms);
}

.row {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-w, var(--tile)));
  gap: var(--gap);
}

/* --tile é a altura; nos tabuleiros, --tile-w pode ser maior quando falta altura */
.tile {
  width: var(--tile-w, var(--tile));
  height: var(--tile);
  display: grid;
  place-items: center;
  border: max(2px, calc(var(--tile) * 0.055)) solid var(--tile-border);
  border-radius: calc(var(--tile) * 0.14);
  background: transparent;
  color: var(--fg);
  font-size: min(var(--tile) * 0.8, var(--tile-w, var(--tile)) * 0.56);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  transition:
    border-color 0.15s,
    background-color 0.15s,
    opacity 0.4s;
}
.row.future .tile {
  border-color: transparent;
  background: var(--tile-future);
}
.row.current .tile {
  cursor: pointer;
}
.row.current .tile.filled {
  border-color: var(--tile-active);
}
.row.current .tile.cursor {
  border-bottom-width: max(5px, calc(var(--tile) * 0.13));
  border-bottom-color: var(--fg);
}
.tile[data-state] {
  color: var(--on-color);
}
.tile[data-state='c'] {
  background: var(--correct);
  border-color: var(--correct);
}
.tile[data-state='p'] {
  background: var(--present);
  border-color: var(--present);
}
.tile[data-state='a'] {
  background: var(--absent);
  border-color: var(--absent);
}

.tile.pop {
  animation: pop 0.13s ease-out;
}
.tile.flip {
  animation: flip 0.48s ease-in-out;
}
.tile.jump {
  animation: jump 0.6s ease both;
  animation-delay: calc(var(--i) * 90ms);
}
.row.shake {
  animation: shake 0.5s;
}

.board.solved .row.future .tile {
  opacity: 0.35;
}

.board-word {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tile) * 0.6);
  translate: -50% 0;
  padding: 5px 14px;
  border-radius: 99px;
  background: var(--fg);
  color: var(--bg);
  font-size: max(13px, calc(var(--tile) * 0.34));
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  scale: 0.5;
  pointer-events: none;
  transition:
    opacity 0.3s,
    scale 0.45s var(--spring);
}
.board.failed .board-word {
  opacity: 1;
  scale: 1;
}

/* teclado */

.keyboard {
  flex: none;
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 6px calc(10px + env(safe-area-inset-bottom));
}
.krow {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.key {
  flex: 1;
  min-width: 0;
  height: clamp(42px, 6.6dvh, 56px);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--key);
  color: var(--key-fg);
  font: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition:
    background-color 0.3s,
    color 0.3s,
    transform 0.08s;
}
.key:active {
  transform: scale(0.93);
}
.key-enter {
  flex: 1.65;
  font-size: 0.82rem;
  text-transform: none;
}
.key-back {
  flex: 1.35;
}
.key-back svg {
  width: 22px;
  height: 22px;
}
.key[data-state='c'] {
  background: var(--correct);
  color: #fff;
}
.key[data-state='p'] {
  background: var(--present);
  color: #fff;
}
.key[data-state='a'] {
  background: var(--key-absent);
  color: var(--key-absent-fg);
}
.key[data-state='multi'] {
  color: #fff;
  text-shadow: 0 1px 2px rgb(0 0 0 / 40%);
}
.key.lit {
  animation: key-lit 0.4s var(--spring);
}

/* ---- partida multiplayer -------------------------------------------------- */

.match {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.match-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 14px 4px;
}
.match-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.round-label {
  font-weight: 800;
}
.timers {
  display: flex;
  gap: 6px;
}

.stage-pills {
  display: flex;
  gap: 4px;
}
.pill {
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  transition:
    background 0.35s,
    color 0.35s,
    transform 0.35s var(--spring);
}
.pill.active {
  background: var(--fg);
  color: var(--bg);
  transform: scale(1.08);
}
.pill.past {
  background: color-mix(in srgb, var(--correct) 22%, var(--surface-2));
  color: var(--fg);
}

.opponents {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 6px 14px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}
.opponents::-webkit-scrollbar {
  display: none;
}
.opp {
  flex: none;
  min-width: 112px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  animation: pop-in 0.4s var(--spring) both;
  transition:
    box-shadow 0.3s,
    opacity 0.3s;
}
.opp.done {
  box-shadow: inset 0 0 0 2px var(--correct);
}
.opp.offline {
  opacity: 0.45;
}
.opp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}
.opp-name {
  font-weight: 800;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.opp-status {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.opp-status svg {
  width: 13px;
  height: 13px;
  color: var(--correct);
}
.opp-boards {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}
.opp.hidden-progress .opp-boards {
  display: none;
}
.mini {
  display: grid;
  grid-template-columns: repeat(5, 6px);
  gap: 1.5px;
  transition: opacity 0.4s;
}
.mini i {
  width: 6px;
  height: 6px;
  border-radius: 1.5px;
  background: var(--tile-future);
}
.mini i[data-state='c'] {
  background: var(--correct);
}
.mini i[data-state='p'] {
  background: var(--present);
}
.mini i[data-state='a'] {
  background: var(--absent);
}
.mini i.new {
  animation: mini-pop 0.4s var(--spring) both;
  animation-delay: calc(var(--i) * 60ms);
}
.mini.solved {
  opacity: 0.55;
}

.play-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.done-box {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  gap: 2px;
  min-width: min(320px, calc(100% - 32px));
  padding: 16px 22px;
  border-radius: 18px;
  background: var(--fg);
  color: var(--bg);
  text-align: center;
  box-shadow: var(--shadow);
  translate: -50% calc(100% + 40px);
  visibility: hidden;
  transition:
    translate 0.55s var(--spring),
    visibility 0s 0.55s;
}
.done-box.show {
  translate: -50% 0;
  visibility: visible;
  transition: translate 0.55s var(--spring);
}
.done-box strong {
  font-size: 1.2rem;
}
.done-box .muted {
  color: color-mix(in srgb, var(--bg) 65%, transparent);
}

.stage-flash {
  position: absolute;
  top: 42%;
  left: 50%;
  z-index: 3;
  display: grid;
  gap: 4px;
  padding: 18px 30px;
  border-radius: 22px;
  background: var(--fg);
  color: var(--bg);
  text-align: center;
  box-shadow: var(--shadow);
  translate: -50% -50%;
  opacity: 0;
  pointer-events: none;
}
.stage-flash.show {
  animation: stage-flash 1.7s var(--ease) both;
}
.stage-flash strong {
  font-size: clamp(2rem, 9vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.stage-flash span {
  font-size: 0.9rem;
  opacity: 0.75;
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.countdown.show {
  opacity: 1;
}
.countdown span {
  font-size: clamp(110px, 32vw, 220px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  animation: count-in 0.95s var(--ease) both;
}
.countdown span.go {
  color: var(--correct);
  animation: go-in 0.7s var(--spring) both;
}

.net-banner {
  position: fixed;
  top: calc(var(--header) + 10px);
  left: 50%;
  z-index: 20;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  translate: -50% 0;
  animation: toast-in 0.35s var(--spring);
}
.net-banner svg {
  width: 16px;
  height: 16px;
}
.room.offline .net-banner {
  display: inline-flex;
}

/* ---- lobby ---------------------------------------------------------------- */

.room-code {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 16px;
  perspective: 600px;
}
.code-tile {
  --tile: clamp(56px, 17vw, 74px);
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
  animation: code-in 0.7s var(--spring) both;
  animation-delay: calc(var(--i) * 120ms + 0.1s);
}
.room-code.sad .code-tile {
  border-color: var(--absent);
}

.players {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg);
  animation: player-in 0.5s var(--spring) both;
  animation-delay: calc(var(--i) * 60ms);
  transition: opacity 0.3s;
}
.player.leaving {
  animation: player-out 0.26s ease forwards;
}
.player.offline {
  opacity: 0.45;
}
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-2);
  font-weight: 900;
  transition:
    background 0.35s,
    color 0.35s,
    transform 0.35s var(--spring);
}
.player.ready .avatar {
  background: var(--correct);
  color: #fff;
  transform: rotate(-6deg) scale(1.05);
}
.player-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.host svg {
  width: 18px;
  height: 18px;
  color: var(--gold);
  animation: pop-in 0.4s var(--spring) both;
}
.player-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}
.player-status svg {
  width: 16px;
  height: 16px;
}
.player.ready .player-status {
  color: var(--correct);
}
.count {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.lobby-actions:has(> [hidden]) {
  grid-template-columns: 1fr;
}
.ready-btn.on {
  background: var(--correct);
  color: #fff;
}
.hint {
  min-height: 1.3em;
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.leave-btn {
  width: 100%;
  margin-top: 8px;
}

/* ---- resultados ------------------------------------------------------------- */

.result-title {
  margin: 4px 0 18px;
  text-align: center;
  font-size: clamp(1.45rem, 5.5vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  animation: title-in 0.7s var(--spring) both 0.1s;
}
.result-title.big {
  font-size: clamp(2rem, 8vw, 2.8rem);
  margin-bottom: 4px;
}

.ranking {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rank-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  animation: rank-in 0.55s var(--spring) both;
  animation-delay: calc(var(--i) * 130ms + 0.2s);
}
.rank-row.me .rank-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.rank-row.winner {
  background: color-mix(in srgb, var(--gold) 18%, var(--bg));
  box-shadow: inset 0 0 0 2px var(--gold);
}
.rank-pos {
  display: grid;
  place-items: center;
  font-weight: 900;
}
.rank-pos svg {
  width: 20px;
  height: 20px;
  color: var(--gold);
}
.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.rank-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.rank-score small {
  color: var(--muted);
  font-weight: 700;
}
.dots {
  display: inline-flex;
  gap: 3px;
}
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.dots i.on {
  background: var(--correct);
}
.rank-time {
  min-width: 52px;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.final-ranking .rank-score {
  display: grid;
  gap: 0;
  text-align: right;
}

.words-block {
  display: grid;
  gap: 10px;
}
.word-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.word-group > .small {
  width: 100%;
  font-weight: 800;
}
.word-row,
.example .row,
.result-words .row {
  --tile: 32px;
  --gap: 3px;
}
.word-row .tile {
  font-size: 16px;
  border-width: 0;
  animation: tile-in 0.5s var(--spring) both;
  animation-delay: calc(var(--d, 0) * 160ms + var(--i) * 55ms + 0.3s);
}

.scoreboard {
  display: grid;
  gap: 8px;
}
.score-row {
  display: grid;
  grid-template-columns: minmax(60px, 120px) 1fr 24px;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.score-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.score-bar {
  height: 10px;
  border-radius: 99px;
  background: var(--bg);
  overflow: hidden;
}
.score-bar i {
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: inherit;
  background: var(--fg);
  transform-origin: left;
  animation: grow 0.8s var(--ease) both;
  animation-delay: calc(var(--i) * 100ms + 0.3s);
}
.score-row.me .score-bar i {
  background: var(--correct);
}

/* ---- final ------------------------------------------------------------------ */

.final {
  text-align: center;
}
.final .card {
  text-align: left;
}
.trophy {
  position: relative;
  width: 190px;
  height: 190px;
  margin: 0 auto;
  display: grid;
  place-items: center;
}
.rays {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(color-mix(in srgb, var(--gold) 35%, transparent) 0 9deg, transparent 9deg 18deg);
  mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation:
    fade-in 1s ease both 0.6s,
    spin 16s linear infinite;
}
.trophy-cup {
  position: relative;
  width: 140px;
  animation:
    trophy-drop 1.1s var(--spring) both 0.15s,
    float 3s ease-in-out 1.4s infinite;
}
.trophy-cup svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 12px 18px rgb(245 179 1 / 35%));
}
.trophy .shine {
  animation: shine 2.6s ease-in-out infinite 1.5s;
}
.trophy .star {
  transform-origin: 60px 39px;
  animation: twinkle 2.2s ease-in-out infinite 1.3s;
}
.trophy.tie .rays {
  display: none;
}
.trophy.tie svg {
  filter: grayscale(1);
  opacity: 0.6;
}
.final-actions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}
details.card summary {
  cursor: pointer;
  font-weight: 800;
  margin-bottom: 4px;
}
details.card[open] summary {
  margin-bottom: 12px;
}
details.card .words-block {
  margin-top: 12px;
}

/* ---- janelas e avisos --------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 45%);
  overflow-y: auto;
  animation: fade-in 0.2s ease;
}
.overlay.out {
  animation: fade-out 0.22s ease forwards;
}
.dialog {
  position: relative;
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px 20px 20px;
  border-radius: 22px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 24px 70px rgb(0 0 0 / 35%);
  animation: dialog-in 0.4s var(--spring);
}
.dialog.wide {
  width: min(520px, 100%);
}
.overlay.out .dialog {
  animation: dialog-out 0.22s ease forwards;
}
.dialog-title {
  margin: 0 32px 14px 0;
  font-size: 1.35rem;
}
.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.dialog-actions .btn {
  flex: 1;
}

.name-form {
  display: grid;
  gap: 12px;
}
.name-form p {
  margin: 0;
}
.shake {
  animation: shake 0.45s;
}

#toasts {
  position: fixed;
  top: calc(var(--header) + 10px);
  left: 50%;
  z-index: 60;
  display: grid;
  justify-items: center;
  gap: 8px;
  translate: -50% 0;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.92rem;
  font-weight: 800;
  box-shadow: var(--shadow);
  animation: toast-in 0.35s var(--spring);
}
.toast.out {
  animation: toast-out 0.3s ease forwards;
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.loading,
.empty-state {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 60px 0;
  text-align: center;
}
.empty-state h2 {
  margin: 0;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--line);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---- ajuda, estatísticas e resultado do dia ----------------------------------------- */

.help p {
  margin: 0 0 8px;
}
.help h3,
.stats h3 {
  margin: 20px 0 8px;
  font-size: 1.05rem;
}
.example {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}
.example p {
  margin: 0;
  font-size: 0.9rem;
}
.example .tile {
  font-size: 16px;
}
.rules {
  margin: 0;
  padding-left: 18px;
  line-height: 1.55;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
}
.tab {
  flex: 1;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.25s,
    color 0.25s;
}
.tab.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 3px rgb(0 0 0 / 12%);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 8px;
  margin: 10px 0;
  text-align: center;
}
.stat {
  animation: pop-in 0.45s var(--spring) both;
}
.stat strong {
  display: block;
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}
.stat span {
  color: var(--muted);
  font-size: 0.75rem;
}
.mode-stats h4,
.stats h4 {
  margin: 14px 0 6px;
  font-size: 0.85rem;
}
.dist {
  display: grid;
  gap: 4px;
}
.dist-row {
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}
.dist-bar {
  width: var(--w);
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--absent);
  color: #fff;
  text-align: right;
  transform-origin: left;
  animation: grow 0.7s var(--ease) both;
  animation-delay: calc(var(--i) * 60ms + 0.15s);
}
.dist-bar.hl {
  background: var(--correct);
}
.best-times {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.best-times li {
  display: flex;
  justify-content: space-between;
}

.result-words {
  display: grid;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.result-words .tile {
  font-size: 16px;
  border-width: 0;
  animation: tile-in 0.5s var(--spring) both;
  animation-delay: calc(var(--i) * 70ms + 0.15s);
}
.next-word {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  margin: 16px 0 4px;
}
.next-word strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}
.other-modes {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  text-align: center;
}
.other-modes .row-btns {
  margin: 0;
}

/* ---- troca de tema (círculo saindo do botão) ------------------------------------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-new(root) {
  animation: theme-reveal 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- animações ---------------------------------------------------------------- */

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes logo-in {
  0% {
    opacity: 0;
    transform: rotateX(90deg) translateY(-6px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}
@keyframes tag-swing {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(14deg);
  }
  75% {
    transform: rotate(-14deg);
  }
}
@keyframes spin-in {
  from {
    transform: rotate(-120deg) scale(0.5);
    opacity: 0;
  }
}
@keyframes pop {
  40% {
    transform: scale(1.13);
  }
}
@keyframes flip {
  0% {
    transform: rotateX(0);
  }
  50% {
    transform: rotateX(-90deg);
  }
  100% {
    transform: rotateX(0);
  }
}
@keyframes jump {
  0%,
  100% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-32%);
  }
  60% {
    transform: translateY(6%);
  }
  80% {
    transform: translateY(-4%);
  }
}
@keyframes shake {
  10%,
  90% {
    transform: translateX(-2px);
  }
  20%,
  80% {
    transform: translateX(4px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-8px);
  }
  40%,
  60% {
    transform: translateX(8px);
  }
}
@keyframes board-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.9);
  }
}
@keyframes key-lit {
  40% {
    transform: scale(1.12);
  }
}
@keyframes mini-pop {
  from {
    transform: scale(0);
  }
}
@keyframes stage-flash {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  15% {
    opacity: 1;
    transform: scale(1.06);
  }
  25% {
    transform: scale(1);
  }
  75% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-24px) scale(0.95);
  }
}
@keyframes count-in {
  0% {
    opacity: 0;
    transform: scale(2.4);
  }
  30% {
    opacity: 1;
    transform: scale(0.92);
  }
  45% {
    transform: scale(1.04);
  }
  60% {
    transform: scale(1);
  }
  100% {
    opacity: 0.15;
    transform: scale(0.85);
  }
}
@keyframes go-in {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-10deg);
  }
}
@keyframes pulse {
  50% {
    transform: scale(1.06);
  }
}
@keyframes code-in {
  0% {
    opacity: 0;
    transform: rotateY(90deg) translateY(-10px);
  }
  60% {
    opacity: 1;
    transform: rotateY(-14deg);
  }
  100% {
    transform: none;
  }
}
@keyframes player-in {
  from {
    opacity: 0;
    transform: translateX(-14px) scale(0.95);
  }
}
@keyframes player-out {
  to {
    opacity: 0;
    transform: translateX(14px) scale(0.95);
  }
}
@keyframes title-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.92);
  }
}
@keyframes rank-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}
@keyframes tile-in {
  from {
    opacity: 0;
    transform: rotateX(90deg);
  }
}
@keyframes grow {
  from {
    transform: scaleX(0);
  }
}
@keyframes bump {
  40% {
    transform: scale(1.3);
  }
}
@keyframes spin {
  to {
    rotate: 360deg;
  }
}
@keyframes trophy-drop {
  0% {
    opacity: 0;
    transform: translateY(-140px) scale(0.5) rotate(-14deg);
  }
  60% {
    opacity: 1;
    transform: translateY(10px) scale(1.06) rotate(4deg);
  }
  100% {
    transform: none;
  }
}
@keyframes float {
  50% {
    transform: translateY(-7px);
  }
}
@keyframes shine {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}
@keyframes twinkle {
  0%,
  100% {
    transform: scale(0.8) rotate(0);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.15) rotate(20deg);
    opacity: 1;
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
}
@keyframes dialog-out {
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.9);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
}
@keyframes theme-reveal {
  from {
    clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0));
  }
  to {
    clip-path: circle(150vmax at var(--vt-x, 100%) var(--vt-y, 0));
  }
}

@media (max-width: 600px) {
  .match-bar {
    padding: 8px 12px 0;
  }
  .opponents {
    padding: 4px 12px 2px;
  }
  .opp {
    min-width: 92px;
    padding: 6px 8px;
  }
  .opp-boards {
    gap: 4px;
    margin-top: 4px;
  }
  .mini {
    grid-template-columns: repeat(5, 4px);
    gap: 1px;
  }
  .mini i {
    width: 4px;
    height: 4px;
    border-radius: 1px;
  }
}

@media (max-width: 380px) {
  .mode-grid {
    gap: 6px;
  }
  .rank-row {
    gap: 8px;
    padding: 9px 10px;
  }
  .dots {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
