/* Connect Four — tokens from /assets/base.css */

:root {
  --cols: 7;
  --rows: 6;
  --slot: 52px;
  --slot-gap: 6px;
  --red: #ff5d7a;
  --yellow: #ffc94a;
  --board-bg: rgba(60, 80, 180, 0.18);
  --slot-bg: rgba(0, 0, 0, 0.35);
  --win-glow: 0 0 12px 2px;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app {
  width: 100%;
  max-width: 600px;
  padding: 0 16px;
  position: relative;
}

/* Header */
.top {
  text-align: center;
  padding: 28px 0 4px;
}
.top h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Screens */
.screen { margin-bottom: 24px; }
.hidden { display: none !important; }

/* Mode select */
.mode-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 0;
  margin: 0;
  overflow: clip;
}
.mode-sub {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 15px;
}
.mode-buttons {
  display: flex;
  gap: 14px;
}
.mode-btn {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { opacity: 0.9; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--surface-hover); }

/* Options panels */
.ai-options, .local-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
  animation: pop 0.3s ease-out;
}
.option-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.option-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  min-width: 60px;
}
.option-pills { display: flex; gap: 6px; }
.btn.pill {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: var(--radius-pill);
}
.btn.pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Toggle switches */
.toggles-row {
  display: flex;
  gap: 18px;
  justify-content: center;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--slot-bg);
  border-radius: 10px;
  transition: background 0.2s;
  display: inline-block;
  flex-shrink: 0;
}
.toggle-track input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  margin: 0;
  z-index: 1;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
  pointer-events: none;
}
.toggle-track input:checked ~ .toggle-thumb {
  transform: translateX(16px);
  background: var(--accent);
}
.toggle-track:has(input:checked) {
  background: rgba(138, 124, 255, 0.25);
}

/* Phase labels */
.phase-label {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
}
.game-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

/* Move label - kept in the DOM for screen readers, hidden visually
   (the score bar + result banner already surface this info). */
.move-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Turn indicator colors */
.phase-label.red   { color: var(--red); }
.phase-label.yellow { color: var(--yellow); }

/* Score bar */
.score-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
}
.score-player {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.score-disc {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.score-disc.red    { background: var(--red); }
.score-disc.yellow { background: var(--yellow); }
.score-val {
  font-size: 20px;
  font-weight: 800;
}
.score-sep {
  color: var(--muted);
  font-size: 16px;
}
.streak-badge {
  font-size: 12px;
  color: var(--muted);
}

/* Timer bar */
.timer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.timer-track {
  width: 160px;
  height: 6px;
  background: var(--slot-bg);
  border-radius: 3px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1s linear;
}
.timer-fill.urgent {
  background: var(--red);
}
.timer-text {
  font-size: 14px;
  font-weight: 700;
  min-width: 28px;
}

/* Board */
.board-area {
  display: flex;
  justify-content: center;
}
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--slot));
  grid-template-rows: repeat(var(--rows), var(--slot));
  gap: var(--slot-gap);
  padding: 12px;
  background: var(--board-bg);
  border-radius: 12px;
  border: 1px solid var(--line);
  touch-action: none;
  transition: transform 0.1s;
}

/* Slot */
.slot {
  width: var(--slot);
  height: var(--slot);
  border-radius: 50%;
  background: var(--slot-bg);
  transition: background 0.15s, transform 0.12s, box-shadow 0.2s;
  position: relative;
}

/* Default cursor everywhere on the field; hitboxes tile edge-to-edge */
.board, .board .slot { cursor: default; }
.slot::after {
  content: "";
  position: absolute;
  inset: calc(var(--slot-gap) / -2 - 1px);
}
.slot:hover:not(.red):not(.yellow) {
  background: rgba(255, 255, 255, 0.08);
}

/* Column hover highlight */
.slot.col-highlight {
  background: rgba(255, 255, 255, 0.06);
}

/* Filled slots */
.slot.red { background: var(--red); }
.slot.yellow { background: var(--yellow); }

/* Drop animation */
@keyframes drop {
  0%   { transform: translateY(calc(-1 * (var(--drop-rows, 1) * (var(--slot) + var(--slot-gap))))); opacity: 0.7; }
  60%  { transform: translateY(4px); opacity: 1; }
  80%  { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}
.slot.drop-anim {
  animation: drop 0.35s ease-out;
}

/* Win highlight */
.slot.win {
  box-shadow: var(--win-glow) currentColor;
  z-index: 1;
}
.slot.win.red   { box-shadow: var(--win-glow) var(--red); }
.slot.win.yellow { box-shadow: var(--win-glow) var(--yellow); }

/* Column hover preview — ghost disc */
.slot.preview-red {
  background: rgba(255, 93, 122, 0.3);
  border: 2px dashed var(--red);
}
.slot.preview-yellow {
  background: rgba(255, 201, 74, 0.3);
  border: 2px dashed var(--yellow);
}

/* The landing cell grows - that's where the disc will go */
.slot.preview-red,
.slot.preview-yellow {
  transform: scale(1.14);
}

/* Bomb mode */
.slot.bombable {
  animation: bomb-pulse 0.6s ease-in-out infinite;
}
@keyframes bomb-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.5); }
}

.bomb-btn {
  padding: 6px 16px;
  font-size: 13px;
  margin-top: 8px;
}

/* Disabled board */
.board.disabled .slot {
  pointer-events: none;
  cursor: default;
}

/* Board shake on draw */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-4px); }
  30%, 70% { transform: translateX(4px); }
}
.board.shake {
  animation: shake 0.5s ease-in-out;
}

/* Game actions - always reserves its space so showing it never shifts the board */
.game-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  min-height: 42px;
}

.game-actions.invisible {
  visibility: hidden;
  pointer-events: none;
}

@keyframes pop {
  0%   { opacity: 0; transform: scale(0.7) translateY(10px); }
  60%  { transform: scale(1.05) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Game over overlay text */
.result-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}
.result-title.red   { color: var(--red); }
.result-title.yellow { color: var(--yellow); }
.result-sub {
  font-size: 14px;
  color: var(--muted);
}
.result-sub.streak {
  margin-top: 4px;
  font-weight: 600;
}

/* Confetti canvas */
.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Mobile */
@media (max-width: 520px) {
  :root { --slot: 40px; --slot-gap: 4px; }
  .mode-btn { padding: 12px 24px; font-size: 15px; }
  .option-group { flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 380px) {
  :root { --slot: 34px; --slot-gap: 3px; }
}


/* ==========================================================================
   MENU PANEL - site-standard centered menu
   ========================================================================== */

.c4-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.c4-bg-item {
  position: absolute;
  opacity: 0.06;
  color: var(--muted);
}
.c4-bg-item svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
}

/* Hide the page header + gear while on the menu */
body.on-menu .top { display: none; }
body.on-menu #btnOpenSettings { display: none; }

.menu-panel {
  width: 100%;
  max-width: 460px;
  background: linear-gradient(160deg, #141826, #101321);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 44px 36px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  box-shadow: var(--shadow-soft);
  position: relative;
  z-index: 1;
  animation: menu-entrance 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes menu-entrance {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  margin: 0;
}
.menu-title .accent { color: var(--accent); }

.menu-form {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.menu-step { display: flex; flex-direction: column; gap: 16px; }

.menu-step:not(.hidden) > * {
  animation: menu-field-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.menu-step:not(.hidden) > *:nth-child(1) { animation-delay: 0.06s; }
.menu-step:not(.hidden) > *:nth-child(2) { animation-delay: 0.12s; }
.menu-step:not(.hidden) > *:nth-child(3) { animation-delay: 0.18s; }
.menu-step:not(.hidden) > *:nth-child(4) { animation-delay: 0.24s; }
.menu-step:not(.hidden) > *:nth-child(5) { animation-delay: 0.3s; }
.menu-step:not(.hidden) > *:nth-child(6) { animation-delay: 0.36s; }
.menu-step:not(.hidden) > *:nth-child(7) { animation-delay: 0.42s; }

@keyframes menu-field-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-row-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#diffRow.collapsed { display: none; }

.menu-start-btn {
  width: 100%;
  justify-content: center;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  gap: 10px;
  margin-top: 4px;
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 22px rgba(138, 124, 255, 0.45);
}
.menu-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(138, 124, 255, 0.7);
}
.menu-start-btn .icon { width: 20px; height: 20px; }

.menu-stats[hidden] { display: none; }

.menu-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.menu-stats .icon {
  width: 16px;
  height: 16px;
  opacity: 0.5;
  stroke: currentColor;
  fill: none;
}

/* ==========================================================================
   TURN INDICATOR - text-free: the active player is a glowing coloured disc.
   The chip text is kept for screen readers only (.visually-hidden behaviour).
   ========================================================================== */

.game-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.game-header .move-label { margin: 0; }

/* The chip is now just its dot - no pill, no text. */
.turn-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

/* Keep the turn text in the DOM (live region) but visually hidden. */
.turn-chip #turnChipText {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The disc colour alone signals whose turn it is. */
.turn-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04),
              0 4px 14px rgba(0, 0, 0, 0.5);
}

.turn-chip[data-turn="red"]    { color: var(--red); }
.turn-chip[data-turn="yellow"] { color: var(--yellow); }
.turn-chip[data-turn="none"] .turn-dot { display: none; }

.turn-chip[data-turn="red"] .turn-dot    { animation: chip-pulse-red 1.5s ease infinite; }
.turn-chip[data-turn="yellow"] .turn-dot { animation: chip-pulse-yellow 1.5s ease infinite; }

@keyframes chip-pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 93, 122, 0.55), 0 4px 14px rgba(0, 0, 0, 0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 93, 122, 0), 0 4px 14px rgba(0, 0, 0, 0.5); }
}
@keyframes chip-pulse-yellow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 201, 74, 0.55), 0 4px 14px rgba(0, 0, 0, 0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 201, 74, 0), 0 4px 14px rgba(0, 0, 0, 0.5); }
}

/* Active side glows in the two-player score bar */
.score-player { transition: opacity 0.25s ease; }
.score-bar[data-active="red"] .score-player:first-child,
.score-bar[data-active="yellow"] .score-player:last-child {
  opacity: 1;
}
.score-bar[data-active="red"] .score-player:last-child,
.score-bar[data-active="yellow"] .score-player:first-child {
  opacity: 0.4;
}
.score-bar[data-active="red"] .score-player:first-child .score-disc {
  box-shadow: 0 0 0 3px rgba(255, 93, 122, 0.18), 0 0 12px rgba(255, 93, 122, 0.6);
}
.score-bar[data-active="yellow"] .score-player:last-child .score-disc {
  box-shadow: 0 0 0 3px rgba(255, 201, 74, 0.18), 0 0 12px rgba(255, 201, 74, 0.6);
}

/* ==========================================================================
   IN-GAME SETTINGS OVERLAY
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.hidden { display: none !important; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 12, 0.7);
  backdrop-filter: blur(4px);
  animation: overlay-fade 0.2s ease;
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-dialog {
  position: relative;
  background: linear-gradient(160deg, #141826, #101321);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  animation: overlay-pop 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes overlay-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.settings-dialog {
  width: 100%;
  max-width: 340px;
  padding: 26px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  text-align: center;
}

.settings-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.settings-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.settings-exit {
  width: 100%;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}

/* Center the game screen vertically */
#gameScreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - 140px);
  margin-bottom: 0;
}

/* Bomb row reserves its space so the button appearing never shifts the board */
.bomb-row {
  text-align: center;
  min-height: 40px;
  margin-top: 10px;
}


/* Series mode: target note + match-point glow on the score */
.score-sep {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.score-val.match-point {
  animation: score-mp-pulse 1.4s ease-in-out infinite;
}

@keyframes score-mp-pulse {
  0%, 100% { text-shadow: 0 0 0 rgba(255, 209, 102, 0); }
  50%      { text-shadow: 0 0 16px rgba(255, 209, 102, 0.8); }
}


/* ==========================================================================
   POWER-UPS - collectible on the field, stored in inventories
   ========================================================================== */

/* Power-up sitting in a board cell */
.slot.has-power svg {
  width: 66%;
  height: 66%;
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
  stroke-width: 2.4;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.8));
  animation: power-float 2.4s ease-in-out infinite;
}
.slot.power-bomb   { color: var(--red); }
.slot.power-lock   { color: #6ec9ff; }
.slot.power-double { color: var(--yellow); }

.slot.has-power {
  background: rgba(63, 220, 130, 0.16);
  box-shadow: inset 0 0 0 1.5px rgba(63, 220, 130, 0.5),
              0 0 12px rgba(63, 220, 130, 0.3);
  animation: power-cell-glow 2s ease-in-out infinite;
}

@keyframes power-cell-glow {
  0%, 100% { box-shadow: inset 0 0 0 1.5px rgba(63, 220, 130, 0.5), 0 0 8px rgba(63, 220, 130, 0.2); }
  50%      { box-shadow: inset 0 0 0 1.5px rgba(63, 220, 130, 0.75), 0 0 18px rgba(63, 220, 130, 0.45); }
}

.slot.power-spawn svg { animation: power-spawn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both, power-float 2.4s ease-in-out 0.5s infinite; }

@keyframes power-spawn {
  from { opacity: 0; transform: scale(0.2) rotate(-30deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes power-float {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.9; }
  50%      { transform: translateY(-3px) scale(1.07); opacity: 1; }
}


/* Aiming states: everything that is NOT a target fades back */
.board.aiming-bomb .slot:not(.bombable),
.board.aiming-lock .slot:not(.lockable):not(.lock-hover) {
  opacity: 0.3;
  transition: opacity 0.2s ease;
}

.slot.bombable {
  opacity: 1;
  box-shadow: inset 0 0 0 2px var(--red), 0 0 12px rgba(255, 93, 122, 0.4);
  animation: aim-pulse 1.1s ease infinite;
}

@keyframes aim-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
.slot.bombable:hover {
  transform: scale(1.12);
  box-shadow: inset 0 0 0 3px var(--red), 0 0 20px rgba(255, 93, 122, 0.7);
}

.slot.lockable {
  opacity: 1;
  box-shadow: inset 0 0 0 1.5px rgba(110, 201, 255, 0.45);
}

.slot.lock-hover {
  opacity: 1;
  background: rgba(110, 201, 255, 0.2);
  box-shadow: inset 0 0 0 2px #6ec9ff;
}



/* Locked column */
.slot.locked {
  background: rgba(110, 201, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(110, 201, 255, 0.35);
}
.slot.locked svg {
  width: 45%;
  height: 45%;
  position: absolute;
  inset: 0;
  margin: auto;
  color: #6ec9ff;
  opacity: 0.8;
  pointer-events: none;
}

/* Bombed disc blows up */
.slot.bombed {
  animation: bomb-out 0.3s ease-in both;
}

@keyframes bomb-out {
  0%   { transform: scale(1); filter: brightness(1); }
  40%  { transform: scale(1.25); filter: brightness(2); }
  100% { transform: scale(0); filter: brightness(3); opacity: 0; }
}


/* Result banner - floats over the board, the field never moves */
.board-area { position: relative; }

.result-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 20;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(8, 9, 16, 0.82) 30%, rgba(8, 9, 16, 0.4) 70%, transparent 100%);
  border-radius: 12px;
  animation: banner-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes banner-in {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

.result-banner .result-title { text-shadow: 0 2px 20px rgba(0, 0, 0, 0.9); }
.result-banner .result-sub { text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9); }

/* Winning discs: cascade pop + steady pulse */
.slot.win {
  animation: win-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
             win-pulse 1.4s ease-in-out 0.45s infinite;
}

@keyframes win-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.35); filter: brightness(1.8); }
  100% { transform: scale(1); }
}

@keyframes win-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.45); }
}


/* Power-up effect bits */
.burst-ring {
  position: fixed;
  z-index: 10002;
  width: 14px;
  height: 14px;
  border: 3px solid var(--red);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: burst-ring-out 0.5s ease-out both;
}

@keyframes burst-ring-out {
  from { width: 14px; height: 14px; opacity: 1; }
  to   { width: 110px; height: 110px; opacity: 0; }
}

.burst-p {
  position: fixed;
  z-index: 10002;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.slot.lock-flash {
  animation: lock-flash 0.55s ease-out;
}

@keyframes lock-flash {
  0%   { background: rgba(110, 201, 255, 0.55); box-shadow: 0 0 18px rgba(110, 201, 255, 0.7); }
  100% { background: rgba(110, 201, 255, 0.08); box-shadow: none; }
}

.pop-text {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 25;
  pointer-events: none;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
  animation: pop-text-float 1.05s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes pop-text-float {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  35%  { transform: translate(-50%, -55%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -110%); }
}


/* Timer bar keeps its space when the clock stops (game end) */
.timer-bar.invisible { visibility: hidden; }


/* ==========================================================================
   ONLINE MODE - create/join room UI in the menu panel
   ========================================================================== */

.menu-form .collapsed { display: none !important; }

#modePills { flex-wrap: wrap; justify-content: flex-end; }

.online-box {
  width: 100%;
}

.online-setup {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.online-btn {
  width: 100%;
  justify-content: center;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  gap: 8px;
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 18px rgba(138, 124, 255, 0.35);
}
.online-btn:disabled { opacity: 0.6; cursor: default; }
.online-btn .icon { width: 18px; height: 18px; }

.online-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.online-divider::before,
.online-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.online-join {
  display: flex;
  gap: 8px;
}
.online-join input {
  flex: 1;
  min-width: 0;
  background: var(--slot-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 14px;
  transition: border-color 0.2s;
}
.online-join input::placeholder {
  color: var(--muted);
  opacity: 0.5;
  letter-spacing: 0.2em;
}
.online-join input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(138, 124, 255, 0.25);
}

.online-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.online-status.error { color: var(--red); }
.online-status[hidden] { display: none; }

/* Waiting-for-opponent state */
.online-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.online-wait.hidden { display: none !important; }
.online-setup.hidden { display: none !important; }

.online-wait-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.online-code {
  margin: 0;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-indent: 0.25em; /* visually re-center despite trailing letter-spacing */
  color: var(--accent);
  text-shadow: 0 0 26px rgba(138, 124, 255, 0.55);
  cursor: pointer;
  user-select: all;
}

.online-wait-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  animation: wait-pulse 1.6s ease-in-out infinite;
}

@keyframes wait-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}


/* Stone disc - neutral blocker, belongs to nobody */
.slot.stone {
  background: radial-gradient(circle at 36% 30%, #6a6f80, #4a4e5c 55%, #34374222 100%), #3c4050;
  box-shadow: inset 0 4px 8px rgba(255, 255, 255, 0.12),
              inset 0 -5px 9px rgba(0, 0, 0, 0.45);
}
.slot.stone::before {
  content: "";
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
}

/* Online overlay dialog (create/join + host config step) */
.online-dialog { gap: 18px; }

.online-close-btn {
  width: 100%;
  justify-content: center;
}

.online-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.online-config.hidden { display: none !important; }
.online-config-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}


/* ==========================================================================
   STEPPED MENU - Local/Online choice cards + Local setup (2026-06-05)
   ========================================================================== */
.menu-choices { display: flex; gap: 12px; width: 100%; }
.choice-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 12px 16px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 12px);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.choice-card:hover {
  background: var(--surface-hover, rgba(255,255,255,0.09));
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(138, 124, 255, 0.18);
}
.choice-icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.choice-label { font-size: 15px; font-weight: 700; letter-spacing: 0.03em; }
.choice-desc { font-size: 12px; color: var(--muted); }

.step-back {
  align-self: flex-start;
  background: none; border: none;
  color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 2px 4px; margin-bottom: -4px;
  transition: color 0.15s ease;
}
.step-back:hover { color: var(--text); }
