/* Alias board — red board, white numbered circles, like the printed game. */

:root {
  --alias-red: #d62828;
  --alias-red-dark: #9b1c1c;
  --alias-cream: #fffaf0;
}

.page-alias {
  background: radial-gradient(circle at 50% 40%, #3b0d0d, #140606 70%);
}

.alias-app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px clamp(8px, 1.5vw, 20px);
}

/* ---------- top bar ---------- */

.alias-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.alias-teams { display: flex; gap: 8px; flex-wrap: wrap; }

.team-chip {
  display: flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.team-chip-current { border-color: var(--team); background: rgba(255, 255, 255, 0.16); }
.team-chip-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: 0;
  padding: 6px 12px 6px 6px;
  cursor: pointer;
}
.team-chip-main small { color: var(--text-muted); font-weight: 400; }
.team-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--team);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.team-chip-remove {
  font: inherit;
  color: var(--text-muted);
  background: none;
  border: 0;
  padding: 0 10px 0 4px;
  cursor: pointer;
  font-size: 1.1rem;
}
.team-chip-remove:hover { color: #fff; }

.alias-turn {
  margin-inline-start: auto;
  font-weight: 800;
  padding: 0.35em 1em;
  border-radius: 999px;
  background: var(--team);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.alias-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.3em 0.9em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}
.alias-timer.timer-running { background: var(--yellow); color: var(--card-text); font-size: 1.5rem; }
.alias-timer.timer-done { background: var(--red); color: #fff; font-size: 1.5rem; }
.code-btn.connected { border-color: #22c55e; }
.code-btn.connected::after { content: ' ●'; color: #22c55e; }
.page-alias .loading { background: rgba(20, 6, 6, 0.85); z-index: 30; }

/* ---------- board ---------- */

.alias-board-wrap { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; }
.alias-board { width: 100%; height: 100%; display: block; }

.board-surface {
  fill: url(#board-gradient);
  stroke: var(--alias-red-dark);
  stroke-width: 6;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5));
}

.board-logo {
  fill: #fff;
  font-family: 'Arial Black', var(--font);
  font-weight: 900;
  font-style: italic;
  font-size: 210px;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: -6px;
  stroke: #8f1515;
  stroke-width: 10px;
  paint-order: stroke;
  filter: drop-shadow(6px 8px 0 rgba(0, 0, 0, 0.22));
}

.cell circle { fill: var(--alias-cream); stroke: rgba(0, 0, 0, 0.12); stroke-width: 2; }
.cell text {
  fill: var(--alias-red);
  font-family: var(--font);
  font-weight: 800;
  font-size: 40px;
  text-anchor: middle;
  dominant-baseline: central;
}
/* Every 15th step: hollow ring, still numbered */
.cell-hollow circle { fill: var(--alias-red); stroke: #fff; stroke-width: 6; }
.bubble-tail { fill: var(--alias-red); stroke: #fff; stroke-width: 6; stroke-linejoin: round; }
.cell-hollow text { fill: #fff; }
/* Start: bigger, glowing */
.cell-start circle { stroke: #fde68a; stroke-width: 8; filter: drop-shadow(0 0 12px #fde68a); }
.cell-start text { font-size: 48px; }
/* Finish ✌ */
.cell-finish circle { fill: none; stroke: #fff; stroke-width: 7; }
.cell-finish .cell-emoji { fill: #fff; font-size: 80px; }

/* ---------- pawns ---------- */

.pawn { cursor: pointer; transition: transform 0.22s ease; outline: none; }
.pawn-body { stroke: #fff; stroke-width: 5; filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.45)); }
.pawn-halo { fill: none; stroke: none; }
.pawn-current .pawn-halo { stroke: #fff; stroke-width: 4; stroke-dasharray: 8 6; animation: spin 4s linear infinite; }
.pawn:hover .pawn-body, .pawn:focus-visible .pawn-body { stroke: #fde68a; }

@keyframes spin { to { stroke-dashoffset: -140; } }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- move dialog ---------- */

.move-box h2 { font-size: clamp(1.4rem, 3vw, 2rem); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 8px 0; }
.stepper-btn { font-size: 2rem; width: 64px; height: 64px; padding: 0; }
.stepper-value { font-size: 4rem; font-weight: 800; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.move-box .muted { margin: 0 0 12px; font-size: 1rem; }
.quick-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 20px; }
.quick-step {
  font: inherit;
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.5em 0;
  border-radius: 10px;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
}
.quick-step.active { background: var(--yellow); color: var(--card-text); }

@media (prefers-reduced-motion: reduce) {
  .pawn { transition: none; }
}

/* ---------- phone: card reader ---------- */

.page-alias-phone { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.alias-reader {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px;
}
.reader-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.85rem; }
.reader-bar .alias-turn { margin: 0; font-size: 0.85rem; }

/* The card: white with a red frame, like a printed Alias card */
.alias-card-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  font: inherit;
  text-align: right;
  background: var(--alias-cream);
  color: #1f1f1f;
  border: 10px solid var(--alias-red);
  border-radius: 22px;
  padding: 10px 14px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.alias-card-view:active { transform: scale(0.985); }
.card-brand {
  align-self: center;
  font-family: 'Arial Black', var(--font);
  font-weight: 900;
  font-style: italic;
  font-size: 1.4rem;
  color: var(--alias-red);
  letter-spacing: -1px;
  direction: ltr;
}
.card-words {
  flex: 1;
  list-style: none;
  counter-reset: word;
  margin: 6px 0;
  padding: 0;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
}
.card-words li {
  counter-increment: word;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.15rem, 5.4vw, 1.9rem);
  font-weight: 700;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.card-words li:last-child { border-bottom: 0; }
.card-words li::before {
  content: counter(word);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--alias-red);
  color: #fff;
  font-size: 0.8em;
  font-weight: 800;
}
.card-hint { align-self: center; font-size: 0.8rem; color: #8a8a8a; }
.card-flip { animation: card-in 0.3s ease; }
@keyframes card-in {
  from { transform: translateX(-24px) rotate(-2deg); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

.reader-timer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reader-timer .alias-timer { font-size: 2rem; padding: 0.2em 0.7em; }
.reader-timer .alias-timer.timer-running { font-size: 2.2rem; }
.reader-timer .btn { flex: 1; font-size: 1.1rem; padding: 0.9em 1em; }

/* Face-down card: only the ALIAS brand until the timer runs */
.alias-card-view { position: relative; overflow: hidden; }
.card-back {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 14px, transparent 14px 28px),
    var(--alias-red);
  color: #fff;
}
.card-back span {
  font-family: 'Arial Black', var(--font);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(3.5rem, 20vw, 6rem);
  letter-spacing: -3px;
  direction: ltr;
  text-shadow: 4px 5px 0 rgba(0, 0, 0, 0.25);
}
.card-back small { font-size: 0.95rem; opacity: 0.85; }
.alias-card-view.card-hidden { cursor: default; }
.alias-card-view.card-hidden:active { transform: none; }
.alias-card-view.card-hidden .card-back { display: flex; }
.btn-stop { background: #374151; color: #fff; }

/* Last 5 seconds: the timer glows and pulses with each beep */
.alias-timer.timer-final {
  background: #f97316;
  color: #fff;
  animation: timer-glow 1s ease-in-out infinite;
}
.alias-timer.timer-last { background: var(--red); animation-duration: 0.28s; }
@keyframes timer-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); transform: scale(1); }
  15% { box-shadow: 0 0 22px 8px rgba(251, 191, 36, 0.95), 0 0 50px 14px rgba(249, 115, 22, 0.6); transform: scale(1.08); }
}

/* Settings dialog */
.settings-box .stepper { gap: 14px; }
.settings-step { width: auto; min-width: 88px; font-size: 1rem; padding: 0 12px; }
.settings-box .btn-small { margin: 4px 0 20px; }
