/* SogoTable game-screen styles, extracted from styles.css. Linked right after
   it in index.html so the cascade order is byte-identical to the old single
   file. Covers per-game boards (Battleship, Boxes, Quoridor, Super Tic Tac
   Toe), the win overlay/confetti, the 10,000 dice/lobby/standings, and the
   game-options + bug-report controls with their game-screen media queries. */

.battleship-panel {
  display: grid;
  gap: 10px;
}

.battleship-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.battleship-toolbar.segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.battleship-toolbar button,
.battleship-ship {
  min-height: 36px;
  padding: 4px 6px;
  font-size: 0.8rem;
}

.battleship-toolbar .selected,
.battleship-ship.selected {
  border-color: var(--accent);
  background: #e8f3ef;
}

.battleship-toolbar .active-mode {
  border-color: #16a34a;
  background: #dcfce7;
  color: #14532d;
}

.battleship-toolbar .selected.active-mode {
  box-shadow: inset 0 -3px 0 #16a34a;
}

.battleship-ship.placed {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.battleship-ship-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.battleship-board-title {
  font-weight: 900;
  color: var(--muted);
}

.battleship-grid {
  display: grid;
  grid-template-columns: repeat(var(--battle-size), minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.battle-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: clamp(0.65rem, 3.5vw, 1rem);
  font-weight: 900;
  line-height: 1;
}

.battle-cell.ship {
  background: #d1fae5;
  border-color: #34d399;
  color: #065f46;
}

.battle-cell.ship.selected-ship {
  background: var(--battle-owner-soft, #d1fae5);
  border-color: var(--battle-owner-color, #1f7a5f);
  color: var(--battle-owner-color, #1f7a5f);
  box-shadow: inset 0 0 0 2px var(--battle-owner-glow, rgba(31, 122, 95, 0.42));
}

.battle-cell.hit {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
  position: relative;
}

.battle-cell.hit.damaged-hit {
  background: var(--battle-reveal-soft, #d1fae5);
  border-color: var(--battle-reveal-color, #1f7a5f);
  color: var(--battle-reveal-color, #1f7a5f);
}

.battle-cell.hit.sunk-hit {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
  box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.24);
}

.battle-cell.miss {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0369a1;
  position: relative;
}

.battle-cell.battle-result-reveal {
  z-index: 2;
  transform: scale(1.08);
  background: var(--battle-reveal-soft, #d1fae5);
  border-color: var(--battle-reveal-color, #1f7a5f);
  outline: 3px solid var(--battle-reveal-color, #1f7a5f);
  outline-offset: 2px;
}

.battle-cell.battle-radar-scan {
  border-color: #facc15;
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.46), 0 0 0 1px rgba(250, 204, 21, 0.18);
  animation: battle-radar-sweep 1s ease-in-out both;
}

.battle-cell.battle-radar-target {
  box-shadow: inset 0 0 0 2px #facc15, 0 0 0 3px rgba(250, 204, 21, 0.28);
}

.battle-cell.battle-attack-lock {
  position: relative;
  z-index: 3;
  border-color: #facc15;
  box-shadow: inset 0 0 0 2px #facc15, 0 0 0 3px rgba(250, 204, 21, 0.22), 0 0 22px rgba(250, 204, 21, 0.36);
  overflow: visible;
}

.battle-cell.battle-attack-lock::before {
  content: "";
  position: absolute;
  inset: -260%;
  border: 5px solid rgba(250, 204, 21, 0.9);
  border-radius: 999px;
  box-shadow: 0 0 0 10px rgba(250, 204, 21, 0.12), 0 0 28px rgba(250, 204, 21, 0.62);
  pointer-events: none;
  animation: battle-attack-lock-collapse 1s cubic-bezier(0.12, 0.82, 0.24, 1) both;
}

.battle-cell.battle-attack-lock::after {
  content: "";
  position: absolute;
  inset: -34%;
  border: 2px solid rgba(250, 204, 21, 0.85);
  border-radius: 999px;
  pointer-events: none;
  animation: battle-attack-lock-pulse 0.24s ease-in-out 4 both;
}

.battle-cell.reveal-hit {
  animation: battle-hit-pop 1s ease-out both;
  box-shadow: 0 0 0 4px var(--battle-reveal-glow, rgba(31, 122, 95, 0.42)), 0 0 20px var(--battle-reveal-glow, rgba(31, 122, 95, 0.42));
}

.battle-cell.reveal-hit::after {
  content: "";
  position: absolute;
  inset: -8px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: radial-gradient(circle, var(--battle-reveal-glow, rgba(31, 122, 95, 0.42)), rgba(255, 255, 255, 0.68) 44%, rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}

.battle-cell.reveal-miss {
  animation: battle-miss-splash 1s ease-out both;
  box-shadow: 0 0 0 4px var(--battle-reveal-glow, rgba(31, 122, 95, 0.42)), 0 0 16px var(--battle-reveal-glow, rgba(31, 122, 95, 0.42));
}

.battle-cell.reveal-miss::after {
  content: "";
  position: absolute;
  width: 70%;
  height: 70%;
  border: 2px solid rgba(14, 116, 144, 0.55);
  border-radius: 999px;
  pointer-events: none;
  animation: battle-splash-ring 1s ease-out both;
}

@keyframes battle-hit-pop {
  0% { transform: scale(0.9); }
  22% { transform: scale(1.18); }
  100% { transform: scale(1.02); }
}

@keyframes battle-miss-splash {
  0% { transform: scale(0.94); }
  30% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes battle-splash-ring {
  0% { opacity: 0.95; transform: scale(0.25); }
  100% { opacity: 0; transform: scale(1.55); }
}

@keyframes battle-radar-sweep {
  0% { filter: brightness(1); }
  45% { filter: brightness(1.12); }
  100% { filter: brightness(1); }
}

@keyframes battle-attack-lock-collapse {
  0% {
    opacity: 0;
    transform: scale(1.15);
  }

  12% {
    opacity: 1;
  }

  70% {
    opacity: 1;
    transform: scale(0.33);
  }

  100% {
    opacity: 0.95;
    transform: scale(0.18);
  }
}

@keyframes battle-attack-lock-pulse {
  0% {
    opacity: 0.2;
    transform: scale(0.82);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }

  100% {
    opacity: 0.42;
    transform: scale(0.9);
  }
}

.boxes-room-table {
  display: grid;
  gap: 14px;
}

.boxes-room-score-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.boxes-room-score {
  --player-color: var(--accent);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
}

.boxes-room-score.active {
  border-color: var(--player-color);
  background: color-mix(in srgb, var(--player-color) 12%, #fff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--player-color) 18%, transparent);
}

.boxes-room-score .avatar {
  width: 30px;
  height: 30px;
}

.boxes-room-score strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boxes-room-score b {
  font-size: 1.1rem;
}

.boxes-room-grid {
  display: grid;
  grid-template-columns: repeat(var(--boxes-grid-cols), minmax(0, auto));
  grid-template-rows: repeat(var(--boxes-grid-rows), auto);
  justify-content: center;
  align-items: center;
  overflow-x: auto;
  padding: 8px 0;
  touch-action: manipulation;
}

.boxes-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ink);
  z-index: 2;
}

.boxes-edge {
  --owner-color: var(--accent);
  display: block;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 999px;
  background: #e7e5e4;
  padding: 0;
}

.boxes-edge-horizontal {
  width: clamp(42px, 13vw, 82px);
  height: 6px;
  margin: 0 -1px;
}

.boxes-edge-vertical {
  width: 6px;
  height: clamp(42px, 13vw, 82px);
  margin: -1px 0;
}

.boxes-edge:not(:disabled):hover,
.boxes-edge:not(:disabled):focus-visible {
  background: color-mix(in srgb, var(--turn-color, var(--accent)) 55%, #fff);
  outline: 2px solid var(--turn-color, var(--accent));
  outline-offset: 2px;
}

.boxes-edge.claimed {
  background: var(--owner-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--owner-color) 18%, transparent);
}

.boxes-edge.last-move,
.boxes-edge.pending {
  outline: 3px solid color-mix(in srgb, var(--owner-color) 45%, #fff);
  outline-offset: 3px;
}

.boxes-cell {
  --owner-color: var(--accent);
  display: grid;
  place-items: center;
  width: clamp(42px, 13vw, 82px);
  height: clamp(42px, 13vw, 82px);
  border-radius: 8px;
  background: #fff;
}

.boxes-cell.owned {
  background: color-mix(in srgb, var(--owner-color) 18%, #fff);
}

.boxes-cell.danger {
  background: #fef3c7;
}

.boxes-cell span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: transparent;
  color: #111827;
  font-size: clamp(1.35rem, 6vw, 2.2rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.macro-board.quoridor-room-board {
  display: block;
  width: 100%;
  aspect-ratio: auto;
  padding: 10px;
  border: 3px solid var(--turn-color, var(--line));
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 0 0 4px var(--turn-glow, rgba(31, 122, 95, 0.16));
}

.quoridor-table {
  display: grid;
  gap: 10px;
}

.quoridor-score-row,
.quoridor-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quoridor-toolbar {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quoridor-toolbar button {
  min-height: 36px;
  padding: 4px 6px;
  font-size: 0.82rem;
}

.quoridor-toolbar .selected {
  border-color: var(--turn-color, var(--accent));
  background: var(--turn-soft, #e8f3ef);
  color: var(--turn-text, var(--accent-strong));
  box-shadow: inset 0 -3px 0 var(--turn-color, var(--accent));
}

.quoridor-score {
  --player-color: var(--accent);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 900;
}

.quoridor-score.active {
  border-color: var(--player-color);
  background: color-mix(in srgb, var(--player-color) 12%, #fff);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--player-color) 18%, transparent);
}

.quoridor-score .avatar {
  width: 30px;
  height: 30px;
}

.quoridor-score strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quoridor-score b::after {
  content: " walls";
  font-size: 0.72rem;
  color: var(--muted);
}

.quoridor-board {
  --q-board-size: min(100%, 440px);
  --q-gap: clamp(3px, 1vw, 5px);
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr) var(--q-gap)) minmax(0, 1fr);
  grid-template-rows: repeat(8, minmax(0, 1fr) var(--q-gap)) minmax(0, 1fr);
  gap: 0;
  justify-content: center;
  align-items: stretch;
  width: var(--q-board-size);
  aspect-ratio: 1;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  margin-inline: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.quoridor-cell {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #111827;
  font-size: clamp(0.95rem, 4vw, 1.65rem);
  font-weight: 900;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.quoridor-cell.occupied {
  border-color: var(--pawn-color, var(--accent));
  background: color-mix(in srgb, var(--pawn-color, var(--accent)) 16%, #fff);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pawn-color, var(--accent)) 28%, transparent);
}

.quoridor-cell.legal {
  border-color: var(--quoridor-active-color, var(--accent));
  background: color-mix(in srgb, var(--quoridor-active-color, var(--accent)) 14%, #fff);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--quoridor-active-color, var(--accent)) 32%, transparent);
}

.quoridor-cell.own-pawn-control {
  cursor: pointer;
}

/* Goal-row tint: a faint wash of the player's colour on the far edge they are
   racing toward. Subtler than the occupied/legal cues so it reads as ambient
   context, not an actionable cell. */
.quoridor-cell.goal {
  background: color-mix(in srgb, var(--goal-color, var(--accent)) 12%, #f8fafc);
  border-color: color-mix(in srgb, var(--goal-color, var(--accent)) 38%, #cbd5e1);
}

.quoridor-wall {
  z-index: 2;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.quoridor-wall-h {
  height: var(--q-gap);
  align-self: center;
}

.quoridor-wall-v {
  width: var(--q-gap);
  justify-self: center;
}

.quoridor-wall.placed {
  background: #334155;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.18);
}

.quoridor-wall.temporary {
  background: #facc15;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.36);
}

.quoridor-wall-dot {
  z-index: 4;
  position: relative;
  display: grid;
  place-items: center;
  place-self: center;
  width: clamp(32px, 10vw, 42px);
  height: clamp(32px, 10vw, 42px);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.quoridor-wall-dot::after {
  content: "";
  z-index: 2;
  width: clamp(3px, 0.8vw, 4px);
  height: clamp(3px, 0.8vw, 4px);
  border: 1px solid #475569;
  border-radius: 999px;
  background: #fff;
}

.quoridor-wall-hold-progress {
  position: absolute;
  left: 50%;
  bottom: 4px;
  z-index: 1;
  width: clamp(5px, 1.4vw, 7px);
  height: calc(100% - 8px);
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.86);
  transform: translateX(-50%) scaleY(0);
  transform-origin: bottom center;
  pointer-events: none;
}

.quoridor-wall-dot.holding .quoridor-wall-hold-progress {
  animation: quoridor-wall-hold-fill 1s linear forwards;
}

@keyframes quoridor-wall-hold-fill {
  from {
    transform: translateX(-50%) scaleY(0);
  }
  to {
    transform: translateX(-50%) scaleY(1);
  }
}

.quoridor-wall-dot:disabled {
  opacity: 1;
  cursor: default;
}

.quoridor-wall-dot:not(:disabled):hover,
.quoridor-wall-dot:not(:disabled):focus-visible {
  outline: 2px solid var(--quoridor-active-color, var(--accent));
  outline-offset: -6px;
}

.quoridor-wall-dot:not(:disabled):hover::after,
.quoridor-wall-dot:not(:disabled):focus-visible::after {
  border-color: var(--quoridor-active-color, var(--accent));
  background: var(--quoridor-active-color, var(--accent));
}

.quoridor-wall-dot.selected::after {
  border-color: #facc15;
  background: #facc15;
}

.small-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  border: 2px solid #8a94a8;
  border-radius: 8px;
  background: #eef2f8;
  opacity: 0.48;
}

.small-board.legal {
  border-color: var(--turn-color, var(--accent));
  background: var(--turn-soft, #e6f3ef);
  opacity: 1;
  box-shadow: 0 0 0 2px var(--turn-glow, rgba(31, 122, 95, 0.16));
}

.small-board.flash {
  animation: active-board-flash 0.25s ease-out;
}

.small-board.done {
  opacity: 0.72;
  animation: none;
}

.small-board.macro-win-cell {
  opacity: 1;
}

.cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border-radius: 5px;
  border: 1px solid #c5ccda;
  background: #fff;
  font-size: clamp(14px, 5vw, 28px);
  font-weight: 900;
  line-height: 1;
  padding: 0;
  touch-action: manipulation;
}

.turn-status small {
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.82;
}

.cell.x {
  color: var(--x);
}

.cell.o {
  color: var(--o);
}

.cell.small-win-cell {
  border-color: #f59e0b;
  box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.36);
}

.cell.pending {
  opacity: 0.72;
  box-shadow: inset 0 0 0 2px var(--turn-color, var(--accent));
}

.cell.pickup {
  font-size: clamp(14px, 4.6vw, 24px);
  background: #fff9db;
  border-color: #f4c542;
}

.cell.pickup.treasureChest {
  background: #f4ecff;
  border-color: #b98cff;
}

.macro-win-line {
  position: absolute;
  z-index: 5;
  border-radius: 999px;
  background: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

.macro-win-line.row-0,
.macro-win-line.row-1,
.macro-win-line.row-2 {
  left: 2%;
  width: 96%;
  height: 6px;
}

.macro-win-line.row-0 {
  top: 16.666%;
}

.macro-win-line.row-1 {
  top: 50%;
}

.macro-win-line.row-2 {
  top: 83.333%;
}

.macro-win-line.col-0,
.macro-win-line.col-1,
.macro-win-line.col-2 {
  top: 2%;
  width: 6px;
  height: 96%;
}

.macro-win-line.col-0 {
  left: 16.666%;
}

.macro-win-line.col-1 {
  left: 50%;
}

.macro-win-line.col-2 {
  left: 83.333%;
}

.macro-win-line.diag-down,
.macro-win-line.diag-up {
  left: -16%;
  top: 50%;
  width: 132%;
  height: 6px;
  transform-origin: center;
}

.macro-win-line.diag-down {
  transform: rotate(45deg);
}

.macro-win-line.diag-up {
  transform: rotate(-45deg);
}

.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 51, 0.58);
  overflow: hidden;
}

.win-overlay.hidden {
  display: none;
}

.win-card {
  position: relative;
  z-index: 30;
  width: min(100%, 360px);
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 24px 18px 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(23, 32, 51, 0.32);
  text-align: center;
}

.win-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e8f3ef;
  color: #fff;
  font-size: 42px;
  font-weight: 950;
  line-height: 1;
}

.win-card h3 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -24px;
  width: 9px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall 1.9s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    translate: 0 0;
  }

  100% {
    opacity: 0.9;
    translate: 0 110vh;
    rotate: 280deg;
  }
}

.board-winner {
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  font-size: clamp(36px, 18vw, 82px);
  font-weight: 950;
  pointer-events: none;
}

.board-winner.x {
  color: var(--x);
}

.board-winner.o {
  color: var(--o);
}

.board-winner.d {
  color: var(--muted);
}

.ten-thousand-table {
  align-self: center;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: none;
  gap: 10px;
  width: min(100%, 620px);
  aspect-ratio: auto;
  padding: 0 0 18px;
}

/* Collapse the player-switch row when it has no buttons (e.g. 10,000) so the
   board sits higher. */
#gamePlayerSwitch:empty {
  display: none;
}

.ten-thousand-scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ten-thousand-scoreboard > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.ten-thousand-scoreboard strong {
  font-size: 22px;
  line-height: 1;
}

.ten-thousand-dice {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 14px;
  justify-items: center;
  overflow: hidden;
  padding: 8px 0;
  perspective: 900px;
}

.ten-thousand-die {
  width: clamp(74px, 24vw, 112px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 700px;
  cursor: pointer;
  position: relative;
  transition: top 200ms ease;
}

.ten-thousand-die:disabled {
  cursor: default;
}

.die-cube {
  --die-size: clamp(70px, 22vw, 104px);
  --die-depth: calc(var(--die-size) / 2);
  position: relative;
  display: block;
  width: var(--die-size);
  height: var(--die-size);
  transform-style: preserve-3d;
  transition: transform 360ms ease, filter 180ms ease;
}

.die-cube.rolling {
  animation: dice-tumble 900ms cubic-bezier(.2, .8, .25, 1);
}

/* Lift the whole die on the button so the cube keeps its face rotation
   (.die-face-N); overriding the cube transform here snapped every die to the
   front face, which is the 1. */
.ten-thousand-die.selected,
.ten-thousand-die.scored {
  top: -8px;
}

.ten-thousand-die.pending {
  top: -10px;
}

/* NB: never put `filter` on .die-cube — it has transform-style: preserve-3d,
   and filter forces a flattening context that collapses the rotated faces, so
   any die not showing the 1-face (no rotation) disappears when selected.
   Selection is conveyed by the lift, border, and face colour instead. */

/* Live selection feedback: green = this die scores in the current selection,
   red = selected but it can't score yet (e.g. one or two of a kind). */
.ten-thousand-die.select-score .die-face {
  border-color: #5cc492;
  background: linear-gradient(145deg, #e9fbf0, #bfeccf);
}

.ten-thousand-die.select-bust .die-face {
  border-color: #e08585;
  background: linear-gradient(145deg, #fdecec, #f6c9c9);
}

.ten-thousand-die.select-bust.pending .die-face,
.ten-thousand-die.farkled .die-face {
  border-color: #d45a5a;
  background: linear-gradient(145deg, #f7d0d0, #ef8f8f);
  color: #7f1d1d;
  box-shadow: inset 0 0 0 1px rgba(127, 29, 29, 0.12);
}

/* A die that was actually part of a scoring play on a declared farkle: yellow,
   to show the player the move they didn't take. */
.ten-thousand-die.tt-missed .die-face {
  border-color: #eab308;
  background: linear-gradient(145deg, #fef9c3, #fde047);
  color: #713f12;
  box-shadow: inset 0 0 0 1px rgba(113, 63, 18, 0.18);
}

/* Five distinct dice kept to press for a six-die straight: yellow — not scoring
   on their own (not green), but a deliberate all-or-nothing bet, not an invalid
   keep (not red). */
.ten-thousand-die.select-straight .die-face {
  border-color: #eab308;
  background: linear-gradient(145deg, #fef9c3, #fde047);
  color: #713f12;
  box-shadow: inset 0 0 0 1px rgba(113, 63, 18, 0.18);
}

.ten-thousand-die.selected .die-face,
.ten-thousand-die.scored .die-face {
  border-color: #8ad3ad;
  background: linear-gradient(145deg, #eef9f3, #d2ecdc);
}

.die-face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 7%;
  padding: 17%;
  border: 2px solid #d7dde5;
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff, #e9eef5);
  box-shadow: inset -6px -7px 12px rgba(15, 23, 42, 0.08), inset 4px 5px 10px rgba(255, 255, 255, 0.95);
  backface-visibility: hidden;
}

.die-face .pip {
  border-radius: 999px;
  background: #172033;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.face-1 { transform: rotateY(0deg) translateZ(var(--die-depth)); }
.face-2 { transform: rotateY(180deg) translateZ(var(--die-depth)); }
.face-3 { transform: rotateY(90deg) translateZ(var(--die-depth)); }
.face-4 { transform: rotateY(-90deg) translateZ(var(--die-depth)); }
.face-5 { transform: rotateX(90deg) translateZ(var(--die-depth)); }
.face-6 { transform: rotateX(-90deg) translateZ(var(--die-depth)); }

.die-face-1 { transform: rotateX(0deg) rotateY(0deg); }
.die-face-2 { transform: rotateX(0deg) rotateY(180deg); }
.die-face-3 { transform: rotateX(0deg) rotateY(-90deg); }
.die-face-4 { transform: rotateX(0deg) rotateY(90deg); }
.die-face-5 { transform: rotateX(-90deg) rotateY(0deg); }
.die-face-6 { transform: rotateX(90deg) rotateY(0deg); }

.ten-thousand-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ten-thousand-actions .tt-action {
  min-width: 0;
  padding-inline: 8px;
  background: #bbf7d0;
  border-color: #86efac;
  color: #14532d;
  opacity: 1;
}

.ten-thousand-actions .tt-action:disabled {
  cursor: not-allowed;
  background: #fef9c3;
  border-color: #fde68a;
  color: #92400e;
  opacity: 1;
}

.ten-thousand-actions .tt-action:not(:disabled):hover,
.ten-thousand-actions .tt-action:not(:disabled):focus-visible {
  filter: brightness(0.96);
}

/* The Red X: after rolling, the first slot becomes "declare a farkle yourself".
   It is red and enabled only while a fresh roll is on the table. */
.ten-thousand-actions .tt-farkle-x:not(:disabled) {
  background: #fecaca;
  border-color: #f87171;
  color: #7f1d1d;
}

/* The farkle acknowledge button is the only control in its row — span the full
   width so its "You Farkled!" label sits centered. It is a red, display-only
   banner shown for a beat before the bust auto-acknowledges. */
.ten-thousand-actions .tt-ack {
  grid-column: 1 / -1;
  background: #fecaca;
  border-color: #f87171;
  color: #7f1d1d;
  opacity: 1;
  cursor: default;
}

/* When the start-roll is the only choice, it spans the whole action row. */
.ten-thousand-actions .tt-action.tt-wide {
  grid-column: 1 / -1;
}

/* Word mode (Game Options): shrink the label to a single non-wrapping line so
   the three buttons still fit on the narrowest phones. */
.ten-thousand-actions.tt-words .tt-action {
  font-size: clamp(0.72rem, 3.4vw, 0.95rem);
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: -0.01em;
  padding-inline: 4px;
}

/* Game Options modal */
.game-options {
  display: grid;
  gap: 12px;
  padding: 4px 2px 2px;
}

.game-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.game-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* The volume row is a slider, not a checkbox: let it stretch and keep the level
   readout pinned to the right. */
.game-option-volume,
.game-option-volume label {
  cursor: default;
}

.game-option-volume input[type="range"] {
  flex: 1 1 auto;
  width: auto;
  height: auto;
  min-width: 0;
  cursor: pointer;
}

.game-option-value {
  flex: 0 0 auto;
  min-width: 72px;
  text-align: right;
  font-weight: 700;
  color: #334155;
}

.bug-report {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}

.bug-report-label {
  font-weight: 700;
}

.bug-report textarea {
  width: 100%;
  resize: vertical;
  min-height: 80px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
}

.bug-report-status {
  margin: 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.passcode-input {
  width: 100%;
  margin: 14px 0;
  padding: 12px 14px;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 0.3em;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
}

.ten-thousand-tray .tt-opening-hint {
  margin-top: 8px;
  color: #92400e;
  background: #fef9c3;
  border-color: #fde68a;
}

.ten-thousand-tray .tt-waiting {
  margin-top: 8px;
}

.ten-thousand-message {
  min-height: 24px;
  margin: 0;
  padding: 10px 12px;
  color: var(--muted);
  text-align: center;
  border: 1px solid #d7dde5;
  border-radius: 12px;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Lobby */
.ten-thousand-lobby {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
}

.ten-thousand-lobby h3 {
  margin: 0;
  text-align: center;
}

.tt-lobby-roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tt-lobby-player {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--turn-soft, #eef2f7);
}

.tt-lobby-player-no {
  font-weight: 700;
  color: var(--muted);
}

.tt-lobby-player-body {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.tt-lobby-player-body strong,
.tt-lobby-player-body span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-lobby-player-body span {
  font-size: 0.85em;
  color: var(--muted);
}

.tt-lobby-empty {
  list-style: none;
  padding: 8px 10px;
  color: var(--muted);
  text-align: center;
}

.tt-lobby-opening {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 700;
  color: #334155;
}

.tt-lobby-opening select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-weight: 700;
  color: #111827;
  min-width: 96px;
}

.tt-lobby-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tt-lobby-actions .primary {
  grid-column: 1 / -1;
}

/* Round bar */
.ten-thousand-roundbar {
  text-align: center;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--turn-soft, #e6f3ef);
  margin-bottom: 4px;
}

.ten-thousand-tray {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Standings table */
.ten-thousand-standings {
  margin-top: 12px;
  width: 100%;
}

.ten-thousand-standings table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.ten-thousand-standings th,
.ten-thousand-standings td {
  padding: 2px 10px;
  line-height: 1.25;
  text-align: left;
}

.ten-thousand-standings th {
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid #d7dde5;
}

.ten-thousand-standings td:last-child,
.ten-thousand-standings th:last-child {
  text-align: right;
}

.ten-thousand-standings th:nth-child(2),
.ten-thousand-standings td:nth-child(2),
.ten-thousand-standings th:nth-child(3),
.ten-thousand-standings td:nth-child(3) {
  text-align: center;
}

.ten-thousand-standings tr.is-resolved td {
  color: var(--muted);
}

.ten-thousand-standings tr.is-farkle td:nth-child(2) {
  color: #d24040;
  font-weight: 600;
}

.tt-standing-player {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 42px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.tt-standing-player-icon {
  font-size: 1.15em;
  line-height: 1;
}

.tt-standing-player-name {
  display: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-standing-player.is-expanded .tt-standing-player-name {
  display: inline;
}

.tt-standing-status {
  text-align: center;
  white-space: nowrap;
}

.tt-status-good {
  color: #15803d;
}

.tt-status-bad {
  color: #dc2626;
}

.tt-status-wait,
.tt-status-done {
  color: var(--muted);
}

.tt-status-inline,
.tt-standing-turn {
  font-size: 0.78em;
  color: var(--muted);
  margin-left: 0.2rem;
}

@keyframes dice-tumble {
  0% {
    transform: translateY(-10px) rotateX(360deg) rotateY(270deg) rotateZ(40deg) scale(0.96);
  }

  70% {
    transform: translateY(2px) rotateX(54deg) rotateY(92deg) rotateZ(8deg) scale(1.02);
  }
}

@keyframes active-board-flash {
  0% {
    border-color: var(--turn-color, #1f7a5f);
    background: var(--turn-soft-strong, #e6f3ef);
    box-shadow: 0 0 0 4px var(--turn-glow, rgba(31, 122, 95, 0.35));
  }

  100% {
    border-color: var(--turn-color, var(--accent));
    background: var(--turn-soft, #e6f3ef);
    box-shadow: 0 0 0 2px var(--turn-glow, rgba(31, 122, 95, 0.16));
  }
}

@keyframes waiting-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 2px var(--turn-glow, rgba(31, 122, 95, 0.22));
  }

  50% {
    box-shadow: 0 0 0 5px var(--turn-glow, rgba(31, 122, 95, 0.48));
  }
}

@media (min-width: 600px) {
  .app {
    padding-top: 28px;
  }

  .macro-board {
    max-width: 640px;
    width: 95%;
    align-self: center;
  }
}

@media (max-width: 430px) {
  .app {
    padding: 10px;
  }

  .boxes-room-score-row {
    grid-template-columns: 1fr;
  }

  #intro {
    min-height: calc(100dvh - 20px);
    border-radius: 14px;
  }

  .intro-art {
    border-width: 3px;
    border-radius: 22px;
  }

  .player-create-row {
    grid-template-columns: minmax(0, 1fr) 58px;
  }

  .player-create-row > div {
    grid-column: 1 / -1;
  }

  .section-action,
  .section-action button {
    width: 100%;
  }

  .room-summary-card {
    grid-template-columns: minmax(0, 1fr) minmax(74px, auto) auto auto;
    gap: 6px;
    padding: 8px;
  }

  .room-summary-card button {
    justify-self: center;
    min-width: 74px;
    min-height: 32px;
    padding: 0 8px;
    font-size: 12px;
  }

  .room-summary-card .room-super-close {
    min-width: 32px;
    padding: 0 7px;
  }

  .room-summary-players {
    justify-content: flex-end;
  }

  .room-summary-players .avatar {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .notice {
    grid-template-columns: 1fr;
  }

  .notice button {
    width: 100%;
  }

  .ten-thousand-scoreboard {
    gap: 6px;
  }

  .ten-thousand-scoreboard > div {
    padding: 8px 4px;
  }

  /* Keep the 6 dice 3-across / 2-down and the actions 4-across on phones too,
     matching larger screens — shrink the dice to fit rather than reflowing. */
  .ten-thousand-dice {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .ten-thousand-die {
    width: clamp(56px, 26vw, 104px);
  }

  .die-cube {
    --die-size: clamp(54px, 24vw, 96px);
  }

  .ten-thousand-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .ten-thousand-actions .tt-action {
    padding-inline: 4px;
  }
}
