:root {
  --bg: #0d1512;
  --bg-2: #12201b;
  --card: #16241f;
  --card-hi: #1c2e28;
  --ink: #eef6f2;
  --ink-soft: #9db5ab;
  --line: #2a3d36;
  --green: #2fa865;
  --green-hi: #56c98a;
  --yellow: #d9a92b;
  --yellow-hi: #f4d06f;
  --gray: #3a4743;
  --empty: #1a2823;
  --danger: #e5484d;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  /* Six rows + keyboard + header must fit one screen, phone or laptop. */
  --tile: min(15vw, 62px, calc((100vh - 340px) / 6.6));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image: radial-gradient(ellipse 900px 600px at 50% -10%, rgba(47, 168, 101, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 30%, rgba(217, 169, 43, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 360px);
  background-repeat: no-repeat;
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
}

body.urgent {
  background-image: radial-gradient(ellipse 900px 600px at 50% -10%, rgba(229, 72, 77, 0.2), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 360px);
}

[hidden] {
  display: none !important;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}

.narrow {
  max-width: 560px;
  margin: 0 auto;
}

.center {
  text-align: center;
}

.screen-title {
  margin: 8px 0 16px;
  font-size: 30px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-text {
  background: linear-gradient(135deg, var(--green-hi), var(--yellow-hi));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tiles {
  display: inline-flex;
  gap: 4px;
}

.mini-tile {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
  color: #fff;
}

.mini-tile.g {
  background: var(--green);
}
.mini-tile.y {
  background: var(--yellow);
}

.tagline {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  margin: -6px 0 18px;
}

.eyebrow {
  color: var(--ink-soft);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin: 6px 0 10px;
}

.card {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title.small {
  margin-top: 16px;
  font-size: 14px;
  color: var(--ink-soft);
}

.count {
  background: var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
}

.field {
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0a110e;
  color: var(--ink);
  font-size: 16px;
}

.field:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 168, 101, 0.25);
}

.code-field {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 800;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-hi);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  filter: brightness(1.12);
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-hi), var(--green));
  border-color: transparent;
  color: #06140d;
  box-shadow: 0 8px 22px -10px rgba(47, 168, 101, 0.8);
}

.btn-block {
  width: 100%;
  margin-bottom: 10px;
}

.btn-big {
  min-height: 54px;
  font-size: 17px;
}

.btn-small {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 13px;
}

.btn-outline-small {
  background: transparent;
  min-height: 38px;
  padding: 7px 12px;
  font-size: 13px;
}

.btn-danger-outline {
  border-color: rgba(229, 72, 77, 0.5);
  color: #ffb4b6;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 12px;
}

.mode-tab {
  flex: 1;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font: 700 14px inherit;
  font-family: inherit;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--green);
  color: #06140d;
}

.role-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.role-choice-btn {
  padding: 11px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  font: 600 13px inherit;
  font-family: inherit;
  cursor: pointer;
}

.role-choice-btn.selected {
  border-color: var(--green);
  color: var(--ink);
  background: rgba(47, 168, 101, 0.14);
}

.error-banner {
  background: rgba(229, 72, 77, 0.14);
  border: 1px solid rgba(229, 72, 77, 0.5);
  color: #ffc9ca;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

.footer-note {
  color: var(--ink-soft);
  font-size: 13px;
}

.demo-row {
  display: flex;
  justify-content: center;
  margin: 18px 0 6px;
}

.open-rooms-list {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.open-room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}

.open-room-row span {
  color: var(--ink-soft);
  font-size: 13px;
}

.connecting {
  padding-top: 30vh;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--green);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Top bar ---------- */

.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.room-chip {
  margin-right: auto;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.room-chip strong {
  color: var(--ink);
  letter-spacing: 2px;
}

/* ---------- Lobby ---------- */

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

.invite-qr {
  flex: 0 0 auto;
  width: 124px;
  height: 124px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
}

.qr-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.invite-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.invite-code {
  margin: 2px 0 10px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--green-hi);
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qr-full {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 8, 6, 0.9);
  display: grid;
  place-items: center;
  padding: 16px;
}

.qr-full-card {
  text-align: center;
  width: min(92vw, 560px);
}

.qr-full-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 14px;
}

.qr-full-code {
  background: #fff;
  border-radius: 20px;
  padding: 14px;
  aspect-ratio: 1;
}

.qr-full-room {
  font-size: 22px;
  margin: 14px 0 4px;
}

.qr-full-room strong {
  letter-spacing: 4px;
  color: var(--green-hi);
}

.lobby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  animation: slide-in 0.3s ease both;
}

.lobby-player.off {
  opacity: 0.55;
}

.lp-name {
  flex: 1;
  font-weight: 600;
}

.you {
  color: var(--ink-soft);
  font-style: normal;
  font-weight: 500;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green), #1b6d43);
  font-weight: 800;
  flex: 0 0 auto;
}

.chip-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 5px 10px;
  font: 600 12px inherit;
  font-family: inherit;
  cursor: pointer;
}

.setting-label {
  margin: 4px 0 6px;
  font-size: 13px;
  color: var(--ink-soft);
}

.seg {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.seg-btn {
  flex: 1;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: 700 14px inherit;
  font-family: inherit;
  cursor: pointer;
}

.seg-btn.on {
  background: var(--green);
  border-color: var(--green);
  color: #06140d;
}

.waiting-card {
  text-align: center;
}

.dots {
  display: inline-flex;
  gap: 6px;
}

.dots i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--green);
  animation: bob 1s ease-in-out infinite;
}

.dots i:nth-child(2) {
  background: var(--yellow);
  animation-delay: 0.15s;
}

.dots i:nth-child(3) {
  background: var(--gray);
  animation-delay: 0.3s;
}

@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}

.rules-mini p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.rules-mini b {
  color: var(--ink);
}

/* ---------- Tiles ---------- */

.row {
  display: grid;
  grid-template-columns: repeat(var(--len, 5), var(--tile));
  gap: 6px;
  justify-content: center;
}

.tile {
  width: var(--tile);
  height: var(--tile);
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: calc(var(--tile) * 0.5);
  font-weight: 900;
  text-transform: none;
  color: #fff;
  user-select: none;
}

.tile.empty {
  background: var(--empty);
  border: 2px solid #22342e;
}

.tile.typing {
  background: rgba(255, 255, 255, 0.02);
  border: 2px solid #4a6459;
}

.tile.typing.filled {
  border-color: #6f8a80;
}

.tile.g {
  background: var(--green);
}
.tile.y {
  background: var(--yellow);
}
.tile.b {
  background: var(--gray);
}

.tile.pop {
  animation: pop 0.12s ease;
}

@keyframes pop {
  50% {
    transform: scale(1.12);
  }
}

/* The colour shows only from the middle of the flip, like the real thing. */
.tile.flip {
  animation: flip 0.5s ease both;
}

@keyframes flip {
  0% {
    transform: rotateX(0);
    background: transparent;
    border: 2px solid #6f8a80;
  }
  49% {
    background: transparent;
    border: 2px solid #6f8a80;
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

.row.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

.row.sending .tile {
  animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    border-color: var(--green-hi);
  }
}

/* Tile size follows the round's word length so 6 letters still fit a phone. */
.board {
  --tile: min(calc((100vw - 32px - (var(--len, 5) - 1) * 6px) / var(--len, 5)), 62px, calc((100vh - 340px) / 6.6));
  display: grid;
  gap: 6px;
  justify-content: center;
  margin: 6px 0 14px;
}

.board.solved .row:has(.tile.g:nth-child(5)) .tile {
  animation: flip 0.5s ease both, win-bounce 0.5s ease 1.2s;
}

@keyframes win-bounce {
  40% {
    transform: translateY(-14px);
  }
  70% {
    transform: translateY(3px);
  }
}

/* ---------- Round ---------- */

.round-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.round-no {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.len-chip {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 99px;
  background: rgba(217, 169, 43, 0.16);
  color: var(--yellow-hi);
  font-size: 12px;
  font-weight: 700;
}

.round-no strong {
  color: var(--ink);
  font-size: 18px;
}

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

.time-track {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.time-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-hi));
  transform-origin: left;
  transition: transform 0.25s linear;
}

body.urgent .time-fill {
  background: linear-gradient(90deg, var(--danger), #ff8a8d);
}

body.urgent .time-label {
  color: #ff8a8d;
  animation: beat 1s ease-in-out infinite;
}

@keyframes beat {
  50% {
    transform: scale(1.15);
  }
}

.time-label {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

.my-score {
  font-weight: 800;
  color: var(--yellow-hi);
  white-space: nowrap;
}

.play-grid {
  display: grid;
  /* minmax(0, …): a long rivals strip scrolls inside instead of widening the page. */
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.play-main,
.play-side {
  min-width: 0;
}

.play-side {
  order: -1;
}

.side-title {
  display: none;
}

/* On phones the rivals are a compact strip above the board. */
.rivals {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
}

.rivals::-webkit-scrollbar {
  display: none;
}

.rival {
  flex: 0 0 auto;
  width: 72px;
  text-align: center;
  padding: 6px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: border-color 0.3s;
}

.rival.solved {
  border-color: var(--green);
  background: rgba(47, 168, 101, 0.1);
  animation: glow 1.2s ease;
}

@keyframes glow {
  0% {
    box-shadow: 0 0 0 0 rgba(86, 201, 138, 0.8);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(86, 201, 138, 0);
  }
}

.rival.out {
  opacity: 0.6;
}

.rival.off {
  opacity: 0.4;
}

.mini-board {
  display: grid;
  gap: 2px;
  justify-content: center;
}

.mini-row {
  display: grid;
  grid-template-columns: repeat(var(--len, 5), 10px);
  gap: 2px;
}

.mini {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--empty);
  font-style: normal;
}

.mini.g {
  background: var(--green);
}
.mini.y {
  background: var(--yellow);
}
.mini.b {
  background: var(--gray);
}

.rival-name {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rival-status {
  font-size: 11px;
  color: var(--ink-soft);
}

/* Spectators / round-end: bigger boards with letters, wrapping grid. */
.rivals.big {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  overflow: visible;
}

.rivals.big .rival {
  width: auto;
  padding: 10px 6px;
}

.rivals.big .mini-row {
  grid-template-columns: repeat(var(--len, 5), 22px);
  gap: 3px;
}

.rivals.big .mini {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

.rivals.big .rival-name {
  font-size: 14px;
}

.watch .secret-chip,
.secret-chip {
  text-align: center;
  background: rgba(217, 169, 43, 0.14);
  border: 1px dashed var(--yellow);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
}

.secret-chip strong {
  letter-spacing: 4px;
  color: var(--yellow-hi);
}

.keyboard {
  display: grid;
  gap: 6px;
  max-width: 560px;
  margin: 0 auto;
}

.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 48px;
  height: 52px;
  border: 0;
  border-radius: 7px;
  background: #4b5a55;
  color: #fff;
  font: 800 16px inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
  transition: background 0.3s, transform 0.06s;
}

.key:active {
  transform: scale(0.94);
  filter: brightness(1.2);
}

.key.wide {
  flex: 1.6 1 0;
  max-width: 72px;
  font-size: 13px;
}

.key.g {
  background: var(--green);
}
.key.y {
  background: var(--yellow);
}
.key.b {
  background: #26302d;
  color: #7f918a;
}

.done-banner {
  text-align: center;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 4px;
  animation: slide-in 0.4s ease both;
}

.done-banner.good {
  background: rgba(47, 168, 101, 0.16);
  border: 1px solid var(--green);
}

.done-banner.bad {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.db-title {
  font-size: 20px;
  font-weight: 800;
}

.db-title strong {
  color: var(--yellow-hi);
}

.db-break,
.db-wait {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.admin-skip {
  margin-top: 16px;
  opacity: 0.8;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Round end ---------- */

.answer-reveal {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.answer-reveal .tile {
  --tile: min(16vw, 68px);
}

.my-result {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 700;
}

.my-result strong {
  color: var(--yellow-hi);
}

.round-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.round-results li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.rr-name {
  font-weight: 700;
}

.rr-detail {
  flex: 1;
  color: var(--ink-soft);
  font-size: 12px;
}

.rr-pts {
  font-weight: 800;
  color: var(--green-hi);
}

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  animation: slide-in 0.35s ease both;
}

.lb-row.me {
  background: rgba(47, 168, 101, 0.14);
  outline: 1px solid rgba(47, 168, 101, 0.5);
}

.lb-rank {
  width: 26px;
  text-align: center;
  font-weight: 800;
}

.lb-name {
  flex: 1;
  font-weight: 600;
}

.lb-gain {
  font-size: 12px;
  font-weight: 800;
  color: var(--green-hi);
}

.lb-gain.zero {
  color: var(--ink-soft);
}

.lb-score {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 46px;
  text-align: right;
}

.all-boards summary {
  cursor: pointer;
  font-weight: 700;
}

.all-boards[open] summary {
  margin-bottom: 12px;
}

.next-note {
  color: var(--ink-soft);
}

/* ---------- Game over ---------- */

.podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: 8px;
  margin: 10px 0 18px;
}

.pod {
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.pod.p1 {
  animation-delay: 0.5s;
}
.pod.p2 {
  animation-delay: 0.25s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
}

.pod-avatar {
  width: 52px;
  height: 52px;
  margin: 0 auto 6px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green-hi), var(--green));
  color: #06140d;
}

.pod.p1 .pod-avatar {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--yellow-hi), var(--yellow));
}

.pod-name {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pod-score {
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 6px;
}

.pod-block {
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 26px;
}

.pod.p1 .pod-block {
  height: 110px;
  border-color: var(--yellow);
}
.pod.p2 .pod-block {
  height: 80px;
}
.pod.p3 .pod-block {
  height: 60px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 2px;
  text-align: center;
}

.stat span {
  font-size: 24px;
}

.stat small {
  color: var(--ink-soft);
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.word-list span {
  background: var(--green);
  border-radius: 8px;
  padding: 5px 10px;
  font-weight: 800;
  letter-spacing: 2px;
}

/* ---------- Intro ---------- */

.intro-screen {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.3s;
}

.intro-screen.intro-out {
  opacity: 0;
}

.intro-tiles {
  display: flex;
  gap: 6px;
}

.intro-tile {
  --tile: min(13vw, 64px);
  animation: flip 0.6s ease both;
}

.intro-title {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 12px;
  margin: 14px 0 6px;
  color: var(--yellow-hi);
  animation: slide-in 0.5s ease 1s both;
}

.intro-subtitle {
  color: var(--ink-soft);
  max-width: 320px;
  animation: slide-in 0.5s ease 1.3s both;
}

.intro-skip-hint {
  color: #5f776d;
  font-size: 12px;
  margin-top: 30px;
}

/* ---------- FX ---------- */

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: calc(70px + env(safe-area-inset-top));
  gap: 6px;
}

.toast {
  background: #0a110e;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast 2.6s ease both;
}

.toast.bad {
  border-color: rgba(229, 72, 77, 0.6);
}
.toast.good {
  border-color: var(--green);
}
.toast.gold {
  border-color: var(--yellow);
  color: var(--yellow-hi);
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  10%,
  85% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear both;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}

/* ---------- Help ---------- */

.howto-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-hi);
  font-size: 20px;
  cursor: pointer;
  z-index: 40;
  box-shadow: var(--shadow);
}

/* The keyboard owns the bottom of the screen during a round. */
body[data-phase="round"] .howto-fab {
  display: none;
}

.howto-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(4, 8, 6, 0.75);
  display: grid;
  place-items: center;
  padding: 16px;
}

.howto-card {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.howto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.howto-header h2 {
  margin: 0;
  font-size: 20px;
}

.howto-close {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}

.howto-body {
  font-size: 14px;
  line-height: 1.55;
  color: #d3e3dc;
}

.howto-body ul {
  padding-left: 0;
  list-style: none;
}

.howto-example {
  --tile: 44px;
  margin: 10px 0;
}

.inapp-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #3a2c08;
  color: #ffe6a8;
  padding: 10px 14px;
  font-size: 13px;
}

.inapp-banner button {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
}

/* ---------- Bigger screens ---------- */

@media (min-width: 900px) {
  .play-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .play-side {
    order: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    max-height: calc(100vh - 140px);
    overflow: auto;
  }

  .side-title {
    display: block;
    margin: 0 0 10px;
    font-size: 15px;
  }

  .play-side .rivals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
  }

  .play-side .rival {
    width: auto;
  }

  .key {
    height: 58px;
    max-width: 52px;
  }
}

@media (max-height: 700px) and (max-width: 899px) {
  .key {
    height: 46px;
  }
}

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

/* ---------- 📺 Sunum ekranı ---------- */

/* Nothing on the shared screen is clickable: no buttons, no help, no top bar. */
body.tv-mode .top-bar,
body.tv-mode .howto-fab,
body.tv-mode #app button,
body.tv-mode .action-bar {
  display: none !important;
}

body.tv-mode #app {
  max-width: 1500px;
  padding-bottom: 60px;
}

/* A laptop shared on Zoom is wide but seen small: scale everything up. */
@media (min-width: 1000px) {
  body.tv-mode #app {
    zoom: 1.25;
  }
}

.tv-link-btn {
  width: 100%;
  margin-top: 8px;
}

.tv-lobby {
  text-align: center;
  padding-top: 2vh;
}

.tv-title {
  font-size: clamp(30px, 5vw, 60px);
  margin: 0 0 3vh;
}

.tv-lobby-grid {
  display: flex;
  gap: 5vw;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3vh;
}

.tv-qr {
  width: min(40vh, 340px);
  aspect-ratio: 1;
  background: #fff;
  border-radius: 20px;
  padding: 12px;
  box-sizing: border-box;
  animation: tv-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.tv-qr .qr-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.tv-sub {
  color: var(--ink-soft);
  font-size: clamp(15px, 1.8vw, 22px);
  margin: 6px 0;
}

.tv-code-label {
  margin-top: 3vh;
}

.tv-code {
  font-size: clamp(60px, 10vw, 160px);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
}

.tv-names {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 1.5vh;
}

.tv-names span {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: clamp(15px, 1.7vw, 22px);
  animation: tv-pop 0.35s ease both;
}

.tv-names span.off {
  opacity: 0.45;
}

.tv-teams {
  text-align: left;
  max-width: 900px;
  margin: 0 auto;
}

.tv-corner {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 50;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  pointer-events: none;
}

.tv-corner strong {
  letter-spacing: 2px;
}

.tv-round-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .tv-round-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tv-landing-card {
  max-width: 420px;
  margin: 0 auto;
}

.tv-go {
  display: flex;
  margin-top: 10px;
  text-decoration: none;
}

@keyframes tv-pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
}

/* The screen has room for bigger boards. */
body.tv-mode .rivals.big {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

body.tv-mode .rivals.big .mini-row {
  grid-template-columns: repeat(var(--len, 5), 30px);
  gap: 4px;
}

body.tv-mode .rivals.big .mini {
  width: 30px;
  height: 30px;
  border-radius: 5px;
}

body.tv-mode .rivals.big .mini-board {
  gap: 4px;
}
