/* ============================================================
   style.css — Juvva Game · Premium Dark Theme
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Inter:wght@400;500;600;700;800&display=swap");

/* --- Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  overflow-x: hidden;
}

/* --- Design Tokens --- */
:root {
  /* Board dimensions — JS path-overlay depends on exact values */
  --app-width: 596px;
  --grid-line: 2px;

  /* Backgrounds */
  --bg-body: #0f0c08;
  --bg-surface-1: #1a1410;
  --bg-surface-2: #231c14;
  --bg-surface-3: #2e2418;
  --bg-elevated: #382e20;

  /* Board */
  --board-grid: #4a3a28;
  --board-cell-field: #faf4eb;
  --board-cell-bridge: #f2e8d4;
  --board-cell-squad: #e8dbc2;
  --board-cell-command: #ddd0b5;
  --board-cell-throne: #fdf6e8;

  /* Gold accent */
  --gold: #d4a843;
  --gold-light: #f0d78c;
  --gold-dark: #a17d2e;

  /* Players */
  --p0: #ef4444;
  --p0-bg: #fecaca;
  --p1: #3b82f6;
  --p1-bg: #bfdbfe;
  --p2: #22c55e;
  --p2-bg: #bbf7d0;
  --p3: #eab308;
  --p3-bg: #fef08a;

  /* Text */
  --text-light: #f5ebe0;
  --text-light-secondary: #c4b49a;
  --text-light-muted: #8a7a66;
  --text-dark: #1a1410;
  --text-dark-secondary: #4a3c2e;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.1);
  --border-gold: rgba(212, 168, 67, 0.35);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 6px;
  --space-md: 8px;
  --space-lg: 12px;
  --space-xl: 16px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 999px;

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
}

/* --- Base --- */
body {
  background: var(--bg-body);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(42, 32, 18, 0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(42, 32, 18, 0.3) 0%, transparent 60%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-light);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: sticky;
  top: var(--space-md);
  z-index: 100;
  width: min(var(--app-width), 96vw);
  margin: var(--space-lg) auto;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: rgba(20, 16, 10, 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-light-muted) transparent;
}

/* Hamburger button: hidden on desktop */
.btn-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}
.btn-hamburger:hover {
  background: var(--bg-elevated);
}
.hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform 0.25s, opacity 0.25s;
}
/* Animate to X when open */
.btn-hamburger.active .hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.btn-hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
}
.btn-hamburger.active .hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Menu icon row: inline on desktop, row on mobile */
.menu-icon-row {
  display: contents;
}

/* Logo */
.juvva-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.12), rgba(212, 168, 67, 0.04));
  color: var(--gold-light);
  padding: 4px 10px 4px 4px;
}

.juvva-logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  font-family: "Cinzel", serif;
  background: linear-gradient(145deg, var(--gold), var(--gold-dark));
  color: #1a1410;
}

.juvva-logo-text {
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 14px;
  font-family: "Cinzel", serif;
}

/* ============================================================
   PILLS & ROOM CONTROLS
   ============================================================ */
.room-pill {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light-secondary);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.room-pill-round {
  border-color: var(--border-gold);
  color: var(--gold-light);
  background: rgba(212, 168, 67, 0.06);
}

.cloud-status-row .room-pill-round {
  border: none;
  background: transparent;
  color: var(--text-light-muted);
}

.room-pill-role {
  border-color: var(--border-medium);
  color: var(--text-light-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.room-input {
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  padding: 0 10px;
  min-width: 100px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: border-color var(--transition-fast);
}

.room-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.18);
}

.room-input::placeholder {
  color: var(--text-light-muted);
}

#btn-room-leave {
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

#btn-room-leave:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.45);
}

/* ============================================================
   CLOUD STATUS
   ============================================================ */
.cloud-status-row {
  width: min(var(--app-width), 96vw);
  margin: 0 auto var(--space-md) auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-xs) var(--space-md);
  background: rgba(20, 16, 10, 0.5);
}

.cloud-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light-muted);
  flex: 1;
  min-width: 0;
}

.cloud-status-row:has(.cloud-status[data-state="ok"]) {
  border-color: rgba(34, 197, 94, 0.25);
}

.cloud-status[data-state="ok"] {
  color: #86efac;
}

.cloud-status-row:has(.cloud-status[data-state="error"]) {
  border-color: rgba(239, 68, 68, 0.25);
}

.cloud-status[data-state="error"] {
  color: #fca5a5;
}

.cloud-status-row:has(.cloud-status[data-state="warn"]) {
  border-color: rgba(234, 179, 8, 0.25);
}

.cloud-status[data-state="warn"] {
  color: #fde047;
}

/* ============================================================
   GAME CONTAINER & ZONES
   ============================================================ */
.game-container {
  width: min(var(--app-width), 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.turn-zone {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(20, 16, 10, 0.35);
  padding: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.turn-zone-board {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  border: none;
  background: transparent;
}

.turn-zone-you {
  border: none;
  background: transparent;
}

.turn-zone-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light-muted);
}

.turn-zone-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.turn-zone-meta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-light-muted);
}

/* ============================================================
   BOARD GRID
   ============================================================ */
#game-board {
  display: grid;
  grid-template-columns: repeat(9, 64px);
  grid-template-rows: repeat(9, 64px);
  touch-action: manipulation;
  gap: var(--grid-line);
  background:
    /* Mortar/grout texture between stones */
    repeating-linear-gradient(
      90deg,
      transparent 0px, transparent 3px,
      rgba(0, 0, 0, 0.04) 3px, rgba(0, 0, 0, 0.04) 4px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0px, transparent 3px,
      rgba(0, 0, 0, 0.03) 3px, rgba(0, 0, 0, 0.03) 4px
    ),
    var(--board-grid);
  padding: var(--grid-line);
  border-radius: var(--radius-lg);
  border: 5px solid #5a4832;
  border-top-color: #6d5c42;
  border-left-color: #64533a;
  border-bottom-color: #4a3a28;
  border-right-color: #503f2c;
  overflow: hidden;
  box-shadow:
    /* Outer frame bevel — carved stone frame */
    inset 0 2px 0 rgba(255, 220, 160, 0.14),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    inset 2px 0 0 rgba(255, 220, 160, 0.1),
    inset -2px 0 0 rgba(0, 0, 0, 0.25),
    /* Depth shadows */
    0 10px 40px rgba(0, 0, 0, 0.5),
    0 3px 10px rgba(0, 0, 0, 0.35),
    0 0 70px rgba(0, 0, 0, 0.3),
    /* Subtle ground shadow for floating effect */
    0 20px 60px rgba(0, 0, 0, 0.2);
  transform-origin: center center;
  position: relative;
  margin: 0 auto;
}

#game-board::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--grid-line) solid var(--board-grid);
  border-radius: inherit;
  pointer-events: none;
  z-index: 15;
}

.pov-top #game-board {
  transform: rotate(180deg);
}

.pov-top .cell {
  transform: rotate(180deg);
}

/* ============================================================
   CELLS & LAYERS — 3D Stepped Amphitheater Effect
   Each concentric ring appears as a physical tier.
   Light source: top-left. Outer = highest, inner = lowest.
   ============================================================ */
.cell {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: filter var(--transition-fast), box-shadow 0.15s ease;
  overflow: visible;
  touch-action: manipulation;
}

.cell:hover {
  filter: brightness(0.96) contrast(1.04);
}

.inner-locked-dim {
  opacity: 0.58;
}

/* --- FIELD (outermost ring) — Highest step --- */
.layer-field {
  background:
    /* Stone grain — fine diagonal striations */
    repeating-linear-gradient(
      115deg,
      transparent 0px, transparent 4px,
      rgba(140, 120, 90, 0.045) 4px, rgba(140, 120, 90, 0.045) 5px
    ),
    repeating-linear-gradient(
      55deg,
      transparent 0px, transparent 7px,
      rgba(100, 80, 55, 0.03) 7px, rgba(100, 80, 55, 0.03) 8px
    ),
    /* Surface wear — light hits & polishes upper-left */
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.42) 0%, transparent 62%),
    /* Base sandstone */
    linear-gradient(155deg, #fefaf3 0%, #f4ebdb 55%, #ede2cf 100%);
  color: var(--text-dark);
  box-shadow:
    /* Top lit edge — bright stone face */
    inset 0 3px 1px rgba(255, 255, 255, 0.9),
    /* Left lit edge */
    inset 3px 0 1px rgba(255, 255, 255, 0.55),
    /* Bottom step face — visible stone edge */
    inset 0 -3px 1px rgba(80, 62, 40, 0.3),
    /* Right step face */
    inset -3px 0 1px rgba(80, 62, 40, 0.18),
    /* Inner depth — worn stone cavity */
    inset 0 0 10px rgba(140, 115, 80, 0.06);
}

/* --- BRIDGE (2nd ring) — Second step down --- */
.layer-bridge {
  background:
    repeating-linear-gradient(
      118deg,
      transparent 0px, transparent 4px,
      rgba(130, 110, 80, 0.05) 4px, rgba(130, 110, 80, 0.05) 5px
    ),
    repeating-linear-gradient(
      50deg,
      transparent 0px, transparent 6px,
      rgba(100, 80, 55, 0.035) 6px, rgba(100, 80, 55, 0.035) 7px
    ),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.34) 0%, transparent 60%),
    linear-gradient(155deg, #f7f0e0 0%, #ede3ce 55%, #e2d5bc 100%);
  color: var(--text-dark);
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.75),
    inset 3px 0 1px rgba(255, 255, 255, 0.42),
    inset 0 -3px 1px rgba(78, 60, 38, 0.32),
    inset -3px 0 1px rgba(78, 60, 38, 0.2),
    inset 0 0 10px rgba(130, 105, 72, 0.08);
}

/* --- SQUAD (3rd ring) — Third step down --- */
.layer-squad {
  background:
    repeating-linear-gradient(
      120deg,
      transparent 0px, transparent 3px,
      rgba(120, 100, 70, 0.055) 3px, rgba(120, 100, 70, 0.055) 4px
    ),
    repeating-linear-gradient(
      48deg,
      transparent 0px, transparent 6px,
      rgba(90, 70, 45, 0.04) 6px, rgba(90, 70, 45, 0.04) 7px
    ),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.28) 0%, transparent 58%),
    linear-gradient(155deg, #f0e7d2 0%, #e2d6bb 55%, #d6c8ac 100%);
  color: var(--text-dark);
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.6),
    inset 3px 0 1px rgba(255, 255, 255, 0.32),
    inset 0 -3px 1px rgba(75, 58, 35, 0.35),
    inset -3px 0 1px rgba(75, 58, 35, 0.22),
    inset 0 0 10px rgba(120, 95, 62, 0.1);
}

/* --- COMMAND (4th ring) — Fourth step down --- */
.layer-command {
  background:
    repeating-linear-gradient(
      122deg,
      transparent 0px, transparent 3px,
      rgba(110, 90, 60, 0.06) 3px, rgba(110, 90, 60, 0.06) 4px
    ),
    repeating-linear-gradient(
      45deg,
      transparent 0px, transparent 5px,
      rgba(85, 65, 40, 0.045) 5px, rgba(85, 65, 40, 0.045) 6px
    ),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.22) 0%, transparent 55%),
    linear-gradient(155deg, #e8dcc4 0%, #d9ccb2 55%, #cdc0a2 100%);
  color: var(--text-dark);
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.45),
    inset 3px 0 1px rgba(255, 255, 255, 0.22),
    inset 0 -3px 1px rgba(70, 55, 32, 0.38),
    inset -3px 0 1px rgba(70, 55, 32, 0.24),
    inset 0 0 10px rgba(110, 88, 55, 0.12);
}

/* --- THRONE (center) — Sunken golden center --- */
.layer-throne {
  background:
    repeating-linear-gradient(
      110deg,
      transparent 0px, transparent 5px,
      rgba(180, 150, 80, 0.04) 5px, rgba(180, 150, 80, 0.04) 6px
    ),
    radial-gradient(circle at 38% 32%, rgba(255, 248, 220, 0.55) 0%, transparent 55%),
    linear-gradient(155deg, #fdf6e8 0%, #f5e8cc 55%, #ecdbb2 100%);
  color: var(--text-dark);
  box-shadow:
    inset 0 3px 1px rgba(255, 240, 180, 0.45),
    inset 3px 0 1px rgba(255, 240, 180, 0.25),
    inset 0 -3px 1px rgba(120, 80, 20, 0.3),
    inset -3px 0 1px rgba(120, 80, 20, 0.18),
    inset 0 0 14px rgba(212, 168, 67, 0.15);
}

/* Outer edge cells get an extra "drop" shadow on their outer face */
.layer-field-outer-edge { border: none; }
.layer-bridge-outer-edge { border: none; }
.layer-squad-outer-edge { border: none; }
.layer-command-outer-edge { border: none; }

/* ============================================================
   SHIELD SQUARES — Etched cross pattern on 3D surface
   ============================================================ */
.shield::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Double-line etched cross for a carved/engraved look */
  background:
    linear-gradient(
      45deg,
      transparent calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 1.5px),
      transparent calc(50% + 1.5px)
    ),
    linear-gradient(
      -45deg,
      transparent calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 1.5px),
      transparent calc(50% + 1.5px)
    );
  pointer-events: none;
  z-index: 2;
  opacity: 0.75;
}

.shield {
  /* Keep a subtle stone bevel even on shield cells */
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.5),
    inset 2px 0 1px rgba(255, 255, 255, 0.25),
    inset 0 -2px 1px rgba(80, 62, 40, 0.18),
    inset -2px 0 1px rgba(80, 62, 40, 0.1);
}

.shield::after {
  content: none;
}

.throne.shield::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Golden etched cross on throne */
  background:
    linear-gradient(
      0deg,
      transparent calc(50% - 1.5px),
      rgba(161, 98, 7, 0.18) calc(50% - 1.5px),
      rgba(161, 98, 7, 0.18) calc(50% - 0.5px),
      rgba(255, 240, 180, 0.2) calc(50% - 0.5px),
      rgba(255, 240, 180, 0.2) calc(50% + 0.5px),
      rgba(161, 98, 7, 0.18) calc(50% + 0.5px),
      rgba(161, 98, 7, 0.18) calc(50% + 1.5px),
      transparent calc(50% + 1.5px)
    ),
    linear-gradient(
      90deg,
      transparent calc(50% - 1.5px),
      rgba(161, 98, 7, 0.18) calc(50% - 1.5px),
      rgba(161, 98, 7, 0.18) calc(50% - 0.5px),
      rgba(255, 240, 180, 0.2) calc(50% - 0.5px),
      rgba(255, 240, 180, 0.2) calc(50% + 0.5px),
      rgba(161, 98, 7, 0.18) calc(50% + 0.5px),
      rgba(161, 98, 7, 0.18) calc(50% + 1.5px),
      transparent calc(50% + 1.5px)
    );
  pointer-events: none;
  z-index: 3;
  opacity: 0.8;
}

/* Keep shield accent neutral for all player shields — etched style */
.shield.base-p0::before,
.shield.formation-p0::before,
.shield.base-p1::before,
.shield.formation-p1::before,
.shield.base-p2::before,
.shield.formation-p2::before,
.shield.base-p3::before,
.shield.formation-p3::before {
  background:
    linear-gradient(
      45deg,
      transparent calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 1.5px),
      transparent calc(50% + 1.5px)
    ),
    linear-gradient(
      -45deg,
      transparent calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 1.5px),
      rgba(74, 58, 40, 0.2) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% - 0.5px),
      rgba(255, 255, 255, 0.15) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 0.5px),
      rgba(74, 58, 40, 0.2) calc(50% + 1.5px),
      transparent calc(50% + 1.5px)
    );
}

.shield-safe-label {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dark-secondary);
  background: rgba(255, 255, 255, 0.82);
  padding: 1px 4px;
  border-radius: 3px;
  z-index: 4;
  pointer-events: none;
}

/* ============================================================
   THRONE
   ============================================================ */
.throne {
  background:
    repeating-linear-gradient(
      110deg,
      transparent 0px, transparent 5px,
      rgba(180, 150, 80, 0.05) 5px, rgba(180, 150, 80, 0.05) 6px
    ),
    radial-gradient(circle at 36% 30%, rgba(255, 248, 210, 0.65) 0%, transparent 50%),
    linear-gradient(155deg, #fdf6e8 0%, #f5e8cc 55%, #ecdbb2 100%) !important;
  border: none !important;
  box-shadow:
    inset 0 0 20px rgba(212, 168, 67, 0.25),
    inset 0 3px 1px rgba(255, 240, 180, 0.5),
    inset 3px 0 1px rgba(255, 240, 180, 0.28),
    inset 0 -3px 1px rgba(120, 80, 20, 0.28),
    inset -3px 0 1px rgba(120, 80, 20, 0.16);
}

/* ============================================================
   PLAYER BASE SQUARES — 3D beveled with player colors
   ============================================================ */
.base-p0 {
  background:
    repeating-linear-gradient(115deg, transparent 0px, transparent 4px, rgba(180, 80, 80, 0.04) 4px, rgba(180, 80, 80, 0.04) 5px),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.35) 0%, transparent 60%),
    linear-gradient(155deg, #fee6e6 0%, #fccaca 55%, #f5b5b5 100%) !important;
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.75),
    inset 3px 0 1px rgba(255, 255, 255, 0.42),
    inset 0 -3px 1px rgba(180, 50, 50, 0.2),
    inset -3px 0 1px rgba(180, 50, 50, 0.12);
}

.base-p1 {
  background:
    repeating-linear-gradient(115deg, transparent 0px, transparent 4px, rgba(50, 80, 180, 0.04) 4px, rgba(50, 80, 180, 0.04) 5px),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.35) 0%, transparent 60%),
    linear-gradient(155deg, #e8f0fe 0%, #bfdbfe 55%, #a5c8f7 100%) !important;
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.75),
    inset 3px 0 1px rgba(255, 255, 255, 0.42),
    inset 0 -3px 1px rgba(30, 70, 160, 0.18),
    inset -3px 0 1px rgba(30, 70, 160, 0.1);
}

.base-p2 {
  background:
    repeating-linear-gradient(115deg, transparent 0px, transparent 4px, rgba(40, 140, 70, 0.04) 4px, rgba(40, 140, 70, 0.04) 5px),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.35) 0%, transparent 60%),
    linear-gradient(155deg, #e4fbe9 0%, #bbf7d0 55%, #a0edb8 100%) !important;
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.75),
    inset 3px 0 1px rgba(255, 255, 255, 0.42),
    inset 0 -3px 1px rgba(20, 120, 50, 0.18),
    inset -3px 0 1px rgba(20, 120, 50, 0.1);
}

.base-p3 {
  background:
    repeating-linear-gradient(115deg, transparent 0px, transparent 4px, rgba(180, 150, 30, 0.04) 4px, rgba(180, 150, 30, 0.04) 5px),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.35) 0%, transparent 60%),
    linear-gradient(155deg, #fef9e0 0%, #fef08a 55%, #fde34e 100%) !important;
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.8),
    inset 3px 0 1px rgba(255, 255, 255, 0.48),
    inset 0 -3px 1px rgba(160, 120, 10, 0.18),
    inset -3px 0 1px rgba(160, 120, 10, 0.1);
}

.current-turn-base {
  box-shadow:
    inset 0 0 0 2px var(--gold),
    0 0 12px rgba(212, 168, 67, 0.4),
    0 0 24px rgba(212, 168, 67, 0.15) !important;
}

.base-current-clickable {
  cursor: pointer;
}

/* ============================================================
   FORMATION & GATE SQUARES
   ============================================================ */
.formation-p0,
.formation-p1,
.formation-p2,
.formation-p3 {
  background:
    repeating-linear-gradient(118deg, transparent 0px, transparent 4px, rgba(130, 110, 80, 0.05) 4px, rgba(130, 110, 80, 0.05) 5px),
    radial-gradient(ellipse at 36% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 58%),
    linear-gradient(155deg, #f5ecd6 0%, #ede3cc 55%, #e0d3b4 100%) !important;
  border: none !important;
  box-shadow:
    inset 0 3px 1px rgba(255, 255, 255, 0.55),
    inset 3px 0 1px rgba(255, 255, 255, 0.28),
    inset 0 -3px 1px rgba(90, 72, 50, 0.28),
    inset -3px 0 1px rgba(90, 72, 50, 0.16),
    inset 0 0 8px rgba(130, 105, 72, 0.06);
}

.gate {
  position: relative;
}

.gate::before {
  content: "▸";
  position: absolute;
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: rgba(74, 58, 40, 0.5);
}

.gate-entry-art { box-shadow: none; }
.gate-entry { position: relative; }
.gate-entry-p0 { box-shadow: none; }
.gate-entry-p2 { box-shadow: none; }
.gate-entry-current { filter: saturate(1.15); }

.gate-entry-marker {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dark-secondary);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(74, 58, 40, 0.25);
  border-radius: 3px;
  padding: 0 3px;
  z-index: 10;
}

.formation-marker {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dark-secondary);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(74, 58, 40, 0.25);
  border-radius: 3px;
  padding: 0 3px;
  z-index: 10;
  pointer-events: none;
}

/* ============================================================
   MOVE HIGHLIGHTING
   ============================================================ */
.possible-move {
  box-shadow:
    inset 0 0 0 999px rgba(34, 197, 94, 0.07),
    inset 0 0 0 2px rgba(34, 197, 94, 0.55);
}

.possible-move.move-cell-clickable {
  cursor: pointer;
}

.capture-target-cell {
  box-shadow:
    inset 0 0 0 999px rgba(239, 68, 68, 0.12),
    inset 0 0 0 2px rgba(239, 68, 68, 0.65);
}

.capture-target-cell.capture-target-clickable {
  cursor: pointer;
}

.capture-source-cell {
  box-shadow:
    inset 0 0 0 999px rgba(34, 197, 94, 0.1),
    inset 0 0 0 2px rgba(22, 163, 74, 0.7);
}

.capture-source-cell-alt {
  box-shadow:
    inset 0 0 0 999px rgba(34, 197, 94, 0.05),
    inset 0 0 0 2px rgba(22, 163, 74, 0.35);
}

.capture-source-clickable {
  cursor: pointer;
}

.capture-flash {
  animation: capturePulse 0.9s ease;
}

.opponent-selected-cell {
  box-shadow:
    inset 0 0 0 999px rgba(59, 130, 246, 0.08),
    inset 0 0 0 2px rgba(59, 130, 246, 0.55);
}

/* ============================================================
   MOVE HINTS & POPOVERS
   ============================================================ */
.move-hint {
  font-size: 11px;
  font-weight: 700;
  color: #166534;
  background: rgba(220, 252, 231, 0.94);
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  z-index: 11;
  cursor: pointer;
  pointer-events: auto;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.move-hint-wrap {
  position: absolute;
  right: 3px;
  top: 3px;
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  max-width: none;
  justify-content: flex-end;
  z-index: 24;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.possible-move:hover .move-hint-wrap,
.possible-move.move-hints-open .move-hint-wrap {
  opacity: 1;
  pointer-events: auto;
}

.move-hint:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.move-hint-capture {
  color: #991b1b;
  border-color: #fca5a5;
  background: rgba(254, 226, 226, 0.94);
}

.move-hint-more {
  font-weight: 800;
}

.move-options-popover {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: max-content;
  padding: 6px;
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 247, 0.98);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}

.pov-top .move-options-popover {
  transform: translate(-50%, -50%) rotate(180deg);
}

.move-popover-close {
  align-self: flex-end;
  appearance: none;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #6b7280;
  border-radius: 4px;
  width: 18px;
  height: 18px;
  line-height: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.move-popover-close:hover,
.move-popover-close:focus-visible {
  border-color: #86efac;
  color: #166534;
}

.move-popover-option {
  appearance: none;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  background: rgba(220, 252, 231, 0.98);
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  padding: 3px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.move-popover-option:hover,
.move-popover-option:focus-visible {
  background: rgba(187, 247, 208, 0.98);
  border-color: #22c55e;
  color: #14532d;
}

.move-popover-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.move-popover-option-capture {
  color: #991b1b;
  border-color: #fca5a5;
  background: rgba(254, 226, 226, 0.98);
}

.move-popover-option-capture:hover,
.move-popover-option-capture:focus-visible {
  background: rgba(254, 202, 202, 0.98);
  border-color: #ef4444;
  color: #7f1d1d;
}

/* Multi-move hover */
.possible-move-multi:hover .move-hint {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.possible-move-multi:hover .move-hint.move-hint-capture {
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.18);
}

.possible-move-multi .move-hint:hover,
.possible-move-multi .move-hint:focus-visible {
  background: rgba(187, 247, 208, 0.98);
  border-color: #22c55e;
  color: #14532d;
  box-shadow: 0 3px 8px rgba(34, 197, 94, 0.22);
  filter: none;
  transform: translateY(-1px) scale(1.02);
}

.possible-move-multi .move-hint.move-hint-capture:hover,
.possible-move-multi .move-hint.move-hint-capture:focus-visible {
  background: rgba(254, 202, 202, 0.98);
  border-color: #ef4444;
  color: #7f1d1d;
  box-shadow: 0 3px 8px rgba(239, 68, 68, 0.22);
}

/* ============================================================
   PATH OVERLAY
   ============================================================ */
.path-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.path-overlay-line {
  fill: none;
  stroke: rgba(74, 58, 40, 0.45);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.5;
  filter: none;
}

.path-overlay-line-capture {
  stroke: rgba(239, 68, 68, 0.65);
  opacity: 0.6;
}

/* ============================================================
   DEBUG LABELS
   ============================================================ */
.cell-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(74, 58, 40, 0.45);
  background: rgba(255, 255, 255, 0.5);
  border-radius: 3px;
  padding: 0 3px;
  position: absolute;
  top: 3px;
  left: 3px;
  pointer-events: none;
  z-index: 8;
}

.cell-coord {
  font-size: 7px;
  color: rgba(74, 58, 40, 0.35);
  position: absolute;
  bottom: 2px;
  right: 3px;
  pointer-events: none;
  z-index: 7;
}

/* ============================================================
   PIECE STACKS
   ============================================================ */
.piece-stack {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  display: grid;
  gap: 2px;
  width: 52px;
  align-items: center;
  justify-content: center;
}

.piece-stack-base {
  width: 50px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  justify-items: center;
  align-items: center;
}

.piece-stack-formation {
  width: 24px;
  height: 28px;
  display: grid;
  grid-template-columns: repeat(2, 11px);
  grid-template-rows: repeat(2, 13px);
  gap: 2px;
  justify-content: center;
  align-content: center;
  justify-items: center;
  align-items: center;
}

.piece-stack-formation .piece-chip {
  justify-self: center;
  align-self: center;
}

.piece-stack-n1 { width: 14px; grid-template-columns: 1fr; }
.piece-stack-n2 { width: 30px; grid-template-columns: repeat(2, 1fr); }
.piece-stack-n3 { width: 30px; grid-template-columns: repeat(2, 1fr); }
.piece-stack-n3 .piece-chip:nth-child(3) { grid-column: 1 / span 2; justify-self: center; }
.piece-stack-n4 { width: 30px; grid-template-columns: repeat(2, 1fr); }

/* Solo soldiers on the board (not base, not formation, not in a piece) get 2x size */
.piece-stack-n1 > .piece-chip-soldier { transform: scale(2); }
.piece-stack-n2 > .piece-chip-soldier { transform: scale(1.6); }
.piece-stack-n3 > .piece-chip-soldier { transform: scale(1.4); }
.piece-stack-n5 { width: 44px; grid-template-columns: repeat(3, 1fr); }
.piece-stack-n5 .piece-chip:nth-child(4) { grid-column: 1; }
.piece-stack-n5 .piece-chip:nth-child(5) { grid-column: 3; }
.piece-stack-n6 { width: 44px; grid-template-columns: repeat(3, 1fr); }
.piece-stack-n7plus { width: 56px; grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   PIECE CHIPS
   ============================================================ */
.piece-chip {
  min-width: 11px;
  width: 11px;
  height: 13px;
  border-radius: 6px 6px 50% 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  color: transparent;
  font-size: 0;
  line-height: 0;
  text-align: center;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  position: relative;
}

.piece-chip::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: inherit;
  border: 1.5px solid rgba(0, 0, 0, 0.16);
}

.piece-chip::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 2px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.3);
}

.piece-chip-unit {
  width: 14px;
  min-width: 14px;
  height: 11px;
  border-radius: 4px;
}

.piece-chip-squad {
  width: 16px;
  min-width: 16px;
  height: 14px;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Player colors */
.chip-p0 { background: var(--p0); color: var(--p0); }
.chip-p1 { background: var(--p1); color: var(--p1); }
.chip-p2 { background: var(--p2); color: var(--p2); }
.chip-p3 { background: var(--p3); color: var(--p3); }

.piece-chip-selectable {
  cursor: pointer;
  animation: pieceBreath 2.4s ease-in-out infinite;
}

/* Expand touch target: entire cell is tappable when it contains your pieces */
.cell-has-selectable {
  cursor: pointer;
}

.piece-chip-selected {
  outline: 2px solid #22c55e;
  outline-offset: 1px;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.45), 0 1px 3px rgba(0, 0, 0, 0.28);
  animation: none;
}

.piece-chip-capture-active {
  outline-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.45), 0 1px 3px rgba(0, 0, 0, 0.28);
}

.piece-chip-opponent-selected {
  outline-color: #3b82f6;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.35), 0 1px 3px rgba(0, 0, 0, 0.28);
}

.piece-chip-locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.piece-chip-lock {
  position: absolute;
  right: -5px;
  top: -6px;
  font-size: 8px;
  line-height: 1;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.piece-chip-squad-cluster {
  width: 11px;
  min-width: 11px;
  height: 13px;
  border-radius: 6px 6px 50% 50%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0;
  align-items: center;
  justify-items: center;
  padding: 1px;
}

.piece-chip-squad-cluster::before,
.piece-chip-squad-cluster::after {
  content: none;
}

.piece-chip-squad-dot {
  width: 3px;
  height: 4px;
  border-radius: 3px 3px 50% 50%;
  background: currentColor;
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: none;
}

/* ============================================================
   SQUAD CART
   ============================================================ */
.squad-cart {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  padding: 3px;
  border: 1.5px solid rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25), inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
  cursor: pointer;
  width: 30px;
  min-width: 30px;
  height: 32px;
  justify-items: center;
  align-items: center;
  z-index: 10;
}

.squad-cart .piece-chip {
  width: 10px;
  min-width: 10px;
  height: 12px;
  border-radius: 5px 5px 50% 50%;
  justify-self: center;
  align-self: center;
}

.squad-cart .piece-chip::before {
  width: 5px;
  height: 5px;
  top: -2px;
}

.squad-cart .piece-chip::after {
  width: 6px;
  bottom: 1px;
}

.squad-cart-selected {
  outline: 2px solid #22c55e;
  outline-offset: 1px;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* ============================================================
   LAST MOVE BADGE
   ============================================================ */
.last-move-badge {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #991b1b;
  background: rgba(254, 226, 226, 0.94);
  border: 1px solid #fca5a5;
  border-radius: 4px;
  padding: 0 4px;
  z-index: 12;
  pointer-events: none;
}

/* ============================================================
   FORMATION PROGRESS
   ============================================================ */
.formation-progress-indicator {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 28px;
  display: grid;
  grid-template-columns: repeat(2, 11px);
  grid-template-rows: repeat(2, 13px);
  gap: 2px;
  justify-content: center;
  align-content: center;
  z-index: 8;
  pointer-events: none;
}

.formation-progress-slot {
  width: 11px;
  height: 13px;
  border-radius: 6px 6px 50% 50%;
  border: 1px solid rgba(74, 58, 40, 0.3);
  background: rgba(120, 111, 99, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.formation-progress-slot.filled {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.formation-progress-p0 .formation-progress-slot.filled { background: rgba(239, 68, 68, 0.55); border-color: rgba(185, 28, 28, 0.5); }
.formation-progress-p1 .formation-progress-slot.filled { background: rgba(59, 130, 246, 0.55); border-color: rgba(29, 78, 216, 0.5); }
.formation-progress-p2 .formation-progress-slot.filled { background: rgba(34, 197, 94, 0.55); border-color: rgba(21, 128, 61, 0.5); }
.formation-progress-p3 .formation-progress-slot.filled { background: rgba(234, 179, 8, 0.6); border-color: rgba(161, 98, 7, 0.5); }

.formation-cart {
  position: absolute;
  left: 50%;
  top: 5px;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  padding: 1px 3px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.16);
  z-index: 10;
}

.formation-cart-slot {
  width: 8px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(74, 58, 40, 0.3);
}

.formation-cart-slot.filled {
  background: rgba(253, 224, 71, 0.88);
  border-color: rgba(161, 98, 7, 0.5);
}

/* ============================================================
   THROW AREA
   ============================================================ */
.throw-tab-bar {
  display: none;
}

.dual-throw-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm) var(--space-lg);
}

.throw-tray {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  background: rgba(20, 16, 10, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all var(--transition-normal);
}

.throw-tray .turn-zone-title,
.throw-tray .turn-zone-meta {
  color: var(--text-light-muted);
  letter-spacing: 0.06em;
}

.throw-tray-active {
  border-color: var(--border-gold);
  box-shadow:
    0 0 20px rgba(212, 168, 67, 0.08),
    inset 0 0 0 1px rgba(212, 168, 67, 0.12);
}

.throw-tray-active .turn-zone-meta {
  color: var(--gold-light);
}

/* Throw mat */
.throw-mat {
  position: relative;
  width: 100%;
  background: radial-gradient(ellipse at 50% 40%, #2a1e0e 0%, #160e04 100%);
  border: 1px solid rgba(212, 168, 67, 0.08);
  border-radius: var(--radius-md);
  padding: 32px 10px;
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.3),
    inset 0 0 40px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.throw-mat-muted::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: rgba(12, 8, 3, 0.5);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.28);
  z-index: 2;
  pointer-events: none;
}

.throw-mat-muted .coin-tray {
  opacity: 0.3;
  filter: saturate(0.45) brightness(0.8);
}

/* Sync overlay */
.throw-sync-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(7, 5, 2, 0.6);
  color: var(--gold-light);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* Turn banners inside throw mat */
.throw-turn-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  pointer-events: none;
  padding: 3px 12px;
  border: 1px solid rgba(212, 168, 67, 0.45);
  border-radius: var(--radius-full);
  background: rgba(12, 8, 3, 0.72);
  color: var(--gold-light);
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: 800;
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  animation: turnBannerGlow 1.2s ease-in-out infinite alternate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.throw-turn-banner .throw-turn-label {
  display: block;
  font-size: 9px;
  line-height: 1;
  font-weight: 600;
  opacity: 0.7;
  letter-spacing: 0.18em;
}
.throw-turn-banner .throw-turn-title {
  display: block;
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
}

.throw-turn-banner .throw-turn-sub {
  display: block;
  font-size: 10px;
  line-height: 1;
  opacity: 0.85;
  letter-spacing: 0.1em;
}

.throw-turn-banner-compact {
  min-width: 118px;
  padding: 8px;
  text-align: center;
}

.throw-turn-banner-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 160px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  animation: quickTurnPulse 540ms ease-out infinite alternate;
}

.throw-turn-banner-center .throw-turn-title {
  display: block;
  line-height: 0.9;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-align: center;
  white-space: pre-line;
  font-family: "Cinzel", serif;
  color: var(--gold-light);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.6),
    0 0 24px rgba(240, 215, 140, 0.3),
    0 0 48px rgba(240, 215, 140, 0.12);
}

.throw-turn-banner-center .throw-turn-sub {
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-align: center;
  color: var(--gold-light);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  opacity: 0.9;
}

/* Throw actions */
.throw-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  position: relative;
}

.opponent-action-status {
  min-width: 158px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-light-muted);
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ============================================================
   THROW VALUES
   ============================================================ */
.throw-values {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--text-light-muted) transparent;
  padding-bottom: 2px;
}

.throw-values.power-celebrate {
  padding-top: 4px;
  padding-bottom: 6px;
  overflow-y: visible;
}

.throw-values-outside {
  margin-top: var(--space-lg);
  min-height: 32px;
  overflow-x: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

#top-throw-values .throw-value-btn {
  cursor: default;
}

.throw-tray .throw-value-fill-empty,
.throw-tray .throw-slot-btn.slot-empty {
  border-color: var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

/* Coin tray */
.coin-tray {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.coin-tray,
.throw-values {
  align-self: center;
}

.throw-tray .coin-tray {
  grid-column: auto;
  grid-row: auto;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  min-height: 176px;
  padding: 2px;
}

/* ============================================================
   SHELL STYLING
   ============================================================ */
.shell-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 38px;
}

.shell-shadow {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 10px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

.shell-wrap {
  width: 34px;
  height: 42px;
  position: relative;
  transform-origin: center bottom;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}

.shell-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(-8deg);
}

.shell-hidden {
  opacity: 0.18;
}

.shell-slot:has(.shell-hidden) .shell-shadow {
  opacity: 0;
}

.shell-wrap.throwing {
  animation: throw 0.62s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.shell-wrap.landed-open {
  animation: openFlash 0.8s ease-out forwards;
}

.shell-wrap.landed-closed {
  animation: shellLandClosed 0.36s ease-out;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  appearance: none;
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light-secondary);
  font-weight: 600;
  font-size: 12px;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  touch-action: manipulation;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-light);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-title {
  padding: 6px 14px;
  border-color: var(--border-gold);
  background: rgba(212, 168, 67, 0.08);
  color: var(--gold-light);
}

.btn-title:hover {
  background: rgba(212, 168, 67, 0.16);
  border-color: var(--gold);
}

.btn-help {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  font-weight: 800;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light-muted);
}

.btn-help:hover {
  color: var(--gold-light);
  border-color: var(--border-gold);
}

/* Throw button */
.btn-throw {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-lg);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.btn-throw-icon {
  font-size: 24px;
  line-height: 1;
}

.throw-btn-lite {
  margin-top: 0;
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  width: auto;
  min-width: 158px;
  height: 44px;
  padding: 0 28px;
  border-radius: var(--radius-full);
  flex-direction: row;
  gap: 0;
  text-transform: uppercase;
}

.throw-btn-lite .btn-throw-icon {
  display: none;
}

.throw-tray .throw-btn-lite {
  border: 2px solid #d4a843;
  background:
    linear-gradient(180deg,
      #f0d868 0%,
      #e4be42 25%,
      #d4a843 50%,
      #e4be42 75%,
      #f0d868 100%);
  color: #3a2a0a;
  box-shadow:
    0 3px 16px rgba(0, 0, 0, 0.35),
    0 0 28px rgba(212, 168, 67, 0.18),
    inset 0 1px 0 rgba(255, 248, 200, 0.6),
    inset 0 -1px 0 rgba(160, 120, 30, 0.2);
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(255, 240, 180, 0.5);
}

.throw-tray .throw-btn-lite:hover {
  filter: brightness(1.08);
  box-shadow:
    0 4px 18px rgba(0, 0, 0, 0.45),
    0 0 32px rgba(212, 168, 67, 0.2),
    inset 0 1px 0 rgba(255, 248, 224, 0.4);
}

.throw-tray .throw-btn-lite:active {
  transform: translateY(1px) scale(0.99);
}

.throw-tray .throw-btn-lite.throw-btn-live {
  animation: throwBtnGlow 1s ease-in-out infinite alternate;
}

.throw-tray .throw-btn-lite.throw-btn-busy {
  background: linear-gradient(180deg, #b38928 0%, #8f6a1c 100%);
}

.throw-tray .throw-btn-lite:disabled {
  border-color: var(--border-medium);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-light-muted);
  box-shadow: none;
  animation: none;
}

.throw-tray .throw-btn-lite.throw-btn-move-state:disabled,
.throw-tray .throw-btn-lite.throw-btn-move-state {
  opacity: 1 !important;
  cursor: default;
  transform: none;
  border: 2px solid #d4a843 !important;
  background: transparent !important;
  color: #e4be42 !important;
  box-shadow:
    0 0 12px rgba(212, 168, 67, 0.15),
    inset 0 0 0 rgba(0, 0, 0, 0) !important;
  animation: none;
  min-width: 158px;
  height: 44px;
  padding: 0 28px;
  filter: none;
  font-weight: 800;
  text-shadow: none;
  letter-spacing: 0.5px;
}

.throw-tray .throw-btn-lite.throw-btn-move-state:hover,
.throw-tray .throw-btn-lite.throw-btn-move-state:active,
.throw-tray .throw-btn-lite.throw-btn-move-state:disabled:hover,
.throw-tray .throw-btn-lite.throw-btn-move-state:disabled:active {
  filter: none;
  transform: none;
  border-color: #e4be42;
  background: rgba(212, 168, 67, 0.1) !important;
  box-shadow: 0 0 16px rgba(212, 168, 67, 0.2);
}

.throw-pop {
  animation: throwButtonPop 220ms ease;
}

/* Power badge */
.power-badge {
  display: none;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #1a1410;
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 14px rgba(212, 168, 67, 0.45);
  position: absolute;
  right: 0;
  top: -10px;
}

.power-badge.visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: powerBadgeFloat 0.9s ease;
}

/* ============================================================
   THROW VALUE BUTTONS
   ============================================================ */
.throw-value-btn {
  appearance: none;
  border: 1px solid rgba(212, 168, 67, 0.3);
  background: rgba(212, 168, 67, 0.1);
  color: var(--gold-light);
  border-radius: var(--radius-sm);
  min-width: 38px;
  height: 30px;
  padding: 0 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  touch-action: manipulation;
  text-align: center;
  transition: all var(--transition-fast);
}

.throw-value-btn:hover:not(:disabled) {
  background: rgba(212, 168, 67, 0.18);
  border-color: rgba(212, 168, 67, 0.45);
  color: var(--gold-light);
}

.throw-value-capture {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

.throw-value-capture:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.45);
}

.throw-value-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.throw-value-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.throw-value-fill-empty {
  border-style: dashed;
  border-color: var(--border-subtle);
  background: transparent;
  opacity: 0.3;
  cursor: default;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  color: var(--text-light-muted);
}

.throw-slot-btn {
  min-width: 44px;
}

.throw-slot-btn.slot-unused {
  opacity: 0.9;
  border-color: var(--border-gold);
  background: rgba(212, 168, 67, 0.06);
  color: var(--gold-light);
}

.throw-slot-btn.slot-used {
  opacity: 0.35;
  text-decoration: line-through;
}

.throw-slot-btn.slot-empty {
  opacity: 0.3;
  border-style: dashed;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.throw-value-empty {
  font-size: 12px;
  color: var(--text-light-muted);
}

/* Throw token rows */
.throw-token-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: max-content;
}

.throw-token {
  border-radius: var(--radius-full);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
}

.throw-token.empty {
  border-style: dashed;
  color: var(--text-light-muted);
  background: transparent;
  border-color: var(--border-subtle);
}

.throw-token.unused {
  background: rgba(212, 168, 67, 0.08);
  border-color: var(--border-gold);
  color: var(--gold-light);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.throw-token.used {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border-subtle);
  color: var(--text-light-muted);
  text-decoration: line-through;
  opacity: 0.4;
}

/* Throw option rows */
.throw-option-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.throw-option-row-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
  width: 100%;
  padding-bottom: 2px;
}

.throw-option-row-fill {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--throw-fill-count, 4), minmax(0, 1fr));
  gap: 8px;
}

.throw-option-row-fill .throw-value-btn {
  width: 100%;
  min-width: 0;
}

.throw-option-row-scroll-ten {
  flex-wrap: nowrap;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.throw-option-row-scroll-ten .throw-value-btn {
  flex: 0 0 calc((100% - (9 * 8px)) / 10);
  min-width: calc((100% - (9 * 8px)) / 10);
}

.power-celebrate .throw-option-row {
  animation: powerPulse 0.45s ease 0s 3;
}

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */
h1 {
  text-align: center;
  margin-bottom: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--gold-light);
  font-family: "Cinzel", serif;
}

.title-row {
  width: 100%;
  max-width: var(--app-width);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.controls-throw-corner {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-content: center;
  align-items: stretch;
  position: relative;
  flex-wrap: nowrap;
}

.throw-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  grid-template-rows: 1fr 1fr;
  gap: 6px 10px;
  align-items: center;
  min-height: 96px;
}

.status-row {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xl);
  font-size: 13px;
  color: var(--text-light-secondary);
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 12px;
  color: var(--text-light-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  border: 1px solid var(--border-medium);
}

.move-options-panel {
  min-height: 0;
}

.turn-banner {
  width: 100%;
  max-width: var(--app-width);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-xs) var(--space-md);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-light-secondary);
}

.turn-banner-bottom {
  box-shadow: inset 0 -2px 0 rgba(239, 68, 68, 0.35);
}

.turn-banner-top {
  box-shadow: inset 0 2px 0 rgba(34, 197, 94, 0.35);
}

.turn-banner-power {
  animation: powerPulse 0.45s ease 0s 3;
}

/* ============================================================
   HUD
   ============================================================ */
.hud {
  width: 100%;
  max-width: var(--app-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.hud-top {
  margin-bottom: 4px;
}

.status-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  min-width: 0;
  color: var(--text-light-secondary);
  font-size: 12px;
}

.selected-piece-card {
  min-height: 20px;
  font-size: 12px;
  color: var(--text-light-muted);
}

.move-options-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding: 4px 0;
}

.move-summary-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--border-gold);
  background: rgba(212, 168, 67, 0.12);
  color: var(--gold-light);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.move-summary-chip:hover:not(:disabled) {
  background: rgba(212, 168, 67, 0.28);
  transform: translateY(-1px);
}
.move-summary-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.move-summary-capture {
  border-color: #fca5a5;
  background: rgba(254, 226, 226, 0.15);
  color: #fca5a5;
}
.move-summary-capture:hover:not(:disabled) {
  background: rgba(254, 226, 226, 0.3);
}

[data-theme="light"] .move-summary-chip {
  background: rgba(160, 120, 20, 0.15);
  color: #5c4306;
  border-color: #b8942e;
}
[data-theme="light"] .move-summary-chip:hover:not(:disabled) {
  background: rgba(160, 120, 20, 0.28);
}
[data-theme="light"] .move-summary-capture {
  border-color: #f87171;
  background: rgba(254, 226, 226, 0.4);
  color: #991b1b;
}
[data-theme="light"] .move-summary-capture:hover:not(:disabled) {
  background: rgba(254, 226, 226, 0.6);
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-area {
  width: 100%;
  max-width: var(--app-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid;
  box-shadow: var(--shadow-md);
}

.toast-info {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-medium);
  color: var(--text-light-secondary);
}

.toast-success {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.toast-warning {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.25);
  color: #fde047;
}

.toast-persistent {
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.toast-power {
  background: linear-gradient(180deg, rgba(212, 168, 67, 0.12), rgba(161, 98, 7, 0.06));
  border-color: rgba(212, 168, 67, 0.35);
  color: var(--gold-light);
  position: relative;
  overflow: hidden;
}

.toast-power::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 4px;
  font-size: 14px;
}

/* --- Squad / Unit Capture Celebrations --- */
.toast-capture-squad {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18) 0%, rgba(220, 38, 38, 0.12) 50%, rgba(239, 68, 68, 0.18) 100%);
  border: 2px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  font-size: 18px;
  font-weight: 800;
  font-family: "Cinzel", serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  box-shadow:
    0 4px 32px rgba(239, 68, 68, 0.25),
    0 0 60px rgba(239, 68, 68, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: squadKillPulse 0.6s ease-out;
}

.toast-capture-unit {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.15) 0%, rgba(234, 88, 12, 0.1) 100%);
  border: 2px solid rgba(251, 146, 60, 0.45);
  color: #fdba74;
  font-size: 15px;
  font-weight: 700;
  font-family: "Cinzel", serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  box-shadow:
    0 4px 24px rgba(251, 146, 60, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: squadKillPulse 0.5s ease-out;
}

@keyframes squadKillPulse {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   MODAL (Help)
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(680px, 96vw);
  max-height: 84vh;
  overflow: auto;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  scrollbar-width: thin;
  scrollbar-color: var(--text-light-muted) transparent;
}

.modal-header {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(20, 16, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-header h2 {
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-light);
}

.btn-help-close {
  border-color: var(--border-medium);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light-secondary);
}

.modal-body {
  padding: var(--space-xl) var(--space-xl) 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--text-light-secondary);
  line-height: 1.6;
}

.modal-body p {
  margin: 4px 0;
  line-height: 1.5;
}

.modal-body ul {
  margin: 6px 0 8px 18px;
  padding: 0;
  line-height: 1.5;
}

.modal-body li {
  margin: 3px 0;
}

.modal-body details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color var(--transition-fast);
}

.modal-body details[open] {
  border-color: var(--border-medium);
}

.modal-body summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-light);
}

.modal-body strong {
  color: var(--text-light);
}

/* Victory modal */
.modal-victory {
  text-align: center;
  max-width: 420px;
}
.modal-victory .modal-header {
  justify-content: center;
  border-bottom: 2px solid rgba(212, 168, 67, 0.3);
}
.modal-victory #victory-title {
  font-family: "Cinzel", serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.victory-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 16px;
}
.victory-message {
  font-size: 14px;
  color: var(--text-light-secondary);
  margin: 0;
}
.victory-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.victory-stage-chip {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light-secondary);
}
.victory-stage-chip.victory-stage-done {
  background: rgba(212, 168, 67, 0.15);
  border-color: rgba(212, 168, 67, 0.4);
  color: var(--gold-light);
}
.btn-victory-new-game {
  background: linear-gradient(180deg, #f0d868 0%, #e4be42 25%, #d4a843 50%, #e4be42 75%, #f0d868 100%);
  border: 2px solid #d4a843;
  color: #3a2a0a;
  font-weight: 800;
  font-size: 14px;
  padding: 8px 32px;
  border-radius: 6px;
  text-shadow: 0 1px 0 rgba(255, 240, 180, 0.5);
  cursor: pointer;
}
.btn-victory-new-game:hover {
  filter: brightness(1.08);
}

/* Temp formation rally point */
.temp-formation {
  box-shadow:
    0 0 0 2px rgba(212, 168, 67, 0.5),
    0 0 8px rgba(212, 168, 67, 0.25),
    inset 0 0 6px rgba(212, 168, 67, 0.1) !important;
  animation: rallyPulse 1.5s ease-in-out infinite;
}
@keyframes rallyPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.5), 0 0 8px rgba(212, 168, 67, 0.25), inset 0 0 6px rgba(212, 168, 67, 0.1); }
  50% { box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.7), 0 0 14px rgba(212, 168, 67, 0.4), inset 0 0 8px rgba(212, 168, 67, 0.15); }
}
.temp-formation-marker {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 5;
}

.rule-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rule-chip {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-light-secondary);
}

.quick-example {
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
  color: var(--text-light-secondary);
}

.help-tabs {
  display: flex;
  gap: 8px;
}

.help-tab {
  appearance: none;
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-light-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.help-tab.active {
  background: rgba(212, 168, 67, 0.1);
  border-color: var(--border-gold);
  color: var(--gold-light);
}

.help-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
}

.help-pane h3 {
  margin: 6px 0;
  color: var(--text-light);
  font-family: "Cinzel", serif;
}

/* ============================================================
   DEBUG PANEL
   ============================================================ */
.log-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-light-muted);
  max-height: 120px;
  overflow: auto;
  line-height: 1.45;
}

#debug-log-panel {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes capturePulse {
  0% { box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0.08); }
  30% { box-shadow: inset 0 0 0 999px rgba(239, 68, 68, 0.3); }
  100% { box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0.04); }
}

@keyframes throw {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  15% { transform: translateY(-26px) rotate(-24deg) scale(1.18); }
  40% { transform: translateY(-16px) rotate(16deg) scale(1.1); }
  70% { transform: translateY(-4px) rotate(-6deg) scale(1.02); }
  86% { transform: translateY(2px) rotate(2deg) scale(0.98); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes openFlash {
  0% { filter: drop-shadow(0 0 16px rgba(212, 168, 67, 0.9)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6)); }
  100% { filter: brightness(1); }
}

@keyframes shellLandClosed {
  0% { filter: brightness(0.82); }
  100% { filter: brightness(1); }
}

@keyframes throwButtonPop {
  0% { transform: scale(1); }
  40% { transform: scale(0.92); }
  100% { transform: scale(1); }
}

@keyframes powerBadgeFloat {
  0% { transform: translateY(6px); opacity: 0; }
  30% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-2px); opacity: 1; }
}

@keyframes powerPulse {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.02); filter: brightness(1.15); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes turnBannerGlow {
  0% { opacity: 0.78; box-shadow: 0 0 0 rgba(212, 168, 67, 0); }
  100% { opacity: 1; box-shadow: 0 0 18px rgba(212, 168, 67, 0.18); }
}

@keyframes throwBtnGlow {
  0% {
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.4), 0 0 24px rgba(212, 168, 67, 0.12), inset 0 1px 0 rgba(255, 248, 224, 0.35);
  }
  100% {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45), 0 0 36px rgba(212, 168, 67, 0.3), inset 0 1px 0 rgba(255, 248, 224, 0.4);
  }
}

@keyframes quickTurnPulse {
  0% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(1.04); opacity: 1; }
}

@keyframes throwMatPulse {
  0% { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 0 40px rgba(0, 0, 0, 0.3); }
  45% { box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4), inset 0 0 54px rgba(212, 168, 67, 0.1); }
  100% { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 0 40px rgba(0, 0, 0, 0.3); }
}

@keyframes throwTrayKick {
  0% { transform: translateX(0) scale(1); }
  22% { transform: translateX(-2px) scale(0.985); }
  45% { transform: translateX(3px) scale(1.01); }
  68% { transform: translateX(-1px) scale(0.995); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes pieceBreath {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15) drop-shadow(0 0 3px rgba(255, 255, 255, 0.3)); }
}

/* Occupied cell — pressed/sunken under the weight of the piece.
   Inverted bevel: top/left get shadow (pressed edge), bottom/right get highlight (lip). */
.cell:has(.piece-stack) {
  box-shadow:
    inset 0 2px 1px rgba(60, 45, 28, 0.14),
    inset 2px 0 1px rgba(60, 45, 28, 0.07),
    inset 0 -1px 1px rgba(255, 255, 255, 0.28),
    inset -1px 0 1px rgba(255, 255, 255, 0.14),
    inset 0 0 6px rgba(80, 60, 35, 0.07) !important;
  filter: brightness(0.985);
}

.throw-mat.throwing-now {
  animation: throwMatPulse 0.6s ease-out;
}

.coin-tray.throwing-now {
  animation: throwTrayKick 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */
.btn-sound {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-sound-off {
  opacity: 0.45;
}
.btn-theme {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   LIGHT THEME
   ============================================================ */

/* --- Variable overrides --- */
[data-theme="light"] {
  --bg-body: #f5f0e8;
  --bg-surface-1: #ede6d9;
  --bg-surface-2: #f8f3ec;
  --bg-surface-3: #faf7f2;
  --bg-elevated: #ffffff;

  --board-grid: #c4b49a;

  --gold: #c49a30;
  --gold-light: #a88425;
  --gold-dark: #7d6118;

  --text-light: #1a1410;
  --text-light-secondary: #4a3c2e;
  --text-light-muted: #8a7a66;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-gold: rgba(196, 154, 48, 0.35);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* --- Body --- */
[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(212, 190, 150, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(212, 190, 150, 0.12) 0%, transparent 60%);
}

/* --- Scrollbar --- */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.14); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.24); }

/* --- Header --- */
[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-lg), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .btn-hamburger {
  border-color: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .btn-hamburger:hover {
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .hamburger-line {
  background: #1a1410;
}

[data-theme="light"] .juvva-logo {
  color: var(--gold-dark);
}

/* --- Controls & Pills --- */
[data-theme="light"] .room-pill {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .room-input {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] #btn-room-leave {
  color: #dc2626;
}

[data-theme="light"] #btn-room-leave:hover {
  background: rgba(239, 68, 68, 0.06);
}

/* --- Cloud Status --- */
[data-theme="light"] .cloud-status-row {
  background: rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .cloud-status[data-state="ok"] { color: #16a34a; }
[data-theme="light"] .cloud-status[data-state="error"] { color: #dc2626; }
[data-theme="light"] .cloud-status[data-state="warn"] { color: #ca8a04; }

/* --- Turn Zone --- */
[data-theme="light"] .turn-zone {
  background: rgba(255, 255, 255, 0.35);
}

/* --- Buttons --- */
[data-theme="light"] .btn:not(.throw-btn-lite) {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .btn:hover:not(.throw-btn-lite) {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .btn-title {
  background: rgba(196, 154, 48, 0.08);
}

[data-theme="light"] .btn-title:hover {
  background: rgba(196, 154, 48, 0.14);
}

[data-theme="light"] .throw-tray .throw-btn-lite.throw-btn-move-state:disabled,
[data-theme="light"] .throw-tray .throw-btn-lite.throw-btn-move-state {
  color: #b08a20 !important;
  border-color: #c49a30 !important;
  background: transparent !important;
  box-shadow: 0 0 8px rgba(180, 140, 40, 0.12) !important;
}

/* --- Board --- */
[data-theme="light"] #game-board {
  border-color: #b0a088;
  border-top-color: #c0b098;
  border-left-color: #b8a890;
  border-bottom-color: #a09078;
  border-right-color: #a89880;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 0 rgba(0, 0, 0, 0.08),
    inset 2px 0 0 rgba(255, 255, 255, 0.4),
    inset -2px 0 0 rgba(0, 0, 0, 0.05),
    0 10px 40px rgba(0, 0, 0, 0.12),
    0 3px 10px rgba(0, 0, 0, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.06);
}

/* --- Throw Tab Bar --- */
[data-theme="light"] .throw-tab {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-dark-muted);
  border-color: var(--border-medium);
}
[data-theme="light"] .throw-tab-active {
  background: rgba(196, 154, 48, 0.12);
  border-color: var(--border-gold);
  color: var(--gold-dark);
}

/* --- Throw Tray --- */
[data-theme="light"] .throw-tray {
  background: rgba(255, 255, 255, 0.65);
}

[data-theme="light"] .throw-tray-active {
  box-shadow:
    0 0 20px rgba(196, 154, 48, 0.06),
    inset 0 0 0 1px rgba(196, 154, 48, 0.1);
}

/* --- Throw Mat --- */
[data-theme="light"] .throw-mat {
  background: radial-gradient(ellipse at 50% 40%, #efe5d0 0%, #e2d6be 100%);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.06),
    inset 0 0 40px rgba(0, 0, 0, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .throw-mat-muted::after {
  background: rgba(245, 238, 226, 0.55);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.03);
}

/* --- Sync Overlay --- */
[data-theme="light"] .throw-sync-overlay {
  background: rgba(245, 238, 226, 0.8);
  color: var(--gold-dark);
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.6);
}

/* --- Turn Banners --- */
[data-theme="light"] .throw-turn-banner {
  background: transparent;
  color: var(--gold-dark);
  text-shadow: none;
}

[data-theme="light"] .throw-turn-banner-compact {
  background: rgba(255, 255, 255, 0.88);
  color: var(--gold-dark);
}

[data-theme="light"] .throw-turn-banner-compact .throw-turn-title {
  color: var(--gold-dark);
  text-shadow: none;
}

[data-theme="light"] .throw-turn-banner-center .throw-turn-title {
  color: var(--gold-dark);
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.8),
    0 0 24px rgba(196, 154, 48, 0.15);
}

[data-theme="light"] .throw-turn-banner-center .throw-turn-sub {
  color: var(--gold);
  text-shadow: none;
}

/* --- Opponent Action Status --- */
[data-theme="light"] .opponent-action-status {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-light-secondary);
}

/* Throw button gold is identical in both themes — no light-mode overrides needed */

/* --- Throw Values --- */
[data-theme="light"] .throw-value-btn {
  background: rgba(140, 100, 20, 0.18);
  border-color: rgba(140, 100, 20, 0.45);
  color: #4a3808;
}
[data-theme="light"] .throw-value-btn:disabled {
  opacity: 0.7;
}

[data-theme="light"] .throw-value-btn:hover:not(:disabled) {
  background: rgba(140, 100, 20, 0.28);
  border-color: rgba(140, 100, 20, 0.6);
  color: #3a2a04;
}

[data-theme="light"] .throw-value-capture {
  color: #dc2626;
}

[data-theme="light"] .throw-value-capture:hover:not(:disabled) {
  color: #b91c1c;
}

[data-theme="light"] .throw-value-fill-empty,
[data-theme="light"] .throw-tray .throw-value-fill-empty,
[data-theme="light"] .throw-tray .throw-slot-btn.slot-empty {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(140, 100, 20, 0.25);
  color: #8a7a50;
  opacity: 0.5;
}

[data-theme="light"] .throw-slot-btn.slot-unused {
  background: rgba(140, 100, 20, 0.15);
  border-color: rgba(140, 100, 20, 0.4);
  color: #4a3808;
}

/* --- Throw Tokens --- */
[data-theme="light"] .throw-token.unused {
  background: rgba(196, 154, 48, 0.08);
  color: var(--gold-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .throw-token.used {
  background: rgba(0, 0, 0, 0.02);
}

/* --- Shell --- */
[data-theme="light"] .shell-shadow {
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.12) 0%, transparent 100%);
}

[data-theme="light"] .shell-wrap {
  filter: brightness(0.6) saturate(1.8) contrast(1.3) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12));
}

[data-theme="light"] .shell-hidden {
  opacity: 0.12;
}

/* --- Power Badge --- */
[data-theme="light"] .power-badge {
  background: linear-gradient(180deg, #f0d078 0%, #dab040 100%);
  border-color: #dab040;
  color: #4a3510;
  box-shadow: 0 2px 14px rgba(218, 176, 64, 0.45);
}

/* --- Status & HUD --- */
[data-theme="light"] .status-pill {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .turn-banner {
  background: rgba(0, 0, 0, 0.03);
}

/* --- Toasts --- */
[data-theme="light"] .toast-info {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .toast-success {
  background: rgba(34, 197, 94, 0.08);
  color: #166534;
}

[data-theme="light"] .toast-warning {
  background: rgba(234, 179, 8, 0.08);
  color: #92400e;
}

[data-theme="light"] .toast-power {
  background: linear-gradient(180deg, rgba(196, 154, 48, 0.1), rgba(161, 98, 7, 0.04));
  color: var(--gold-dark);
}

[data-theme="light"] .toast-capture-squad {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.12) 0%, rgba(185, 28, 28, 0.08) 100%);
  border-color: rgba(220, 38, 38, 0.4);
  color: #991b1b;
}

[data-theme="light"] .toast-capture-unit {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.1) 0%, rgba(194, 65, 12, 0.06) 100%);
  border-color: rgba(234, 88, 12, 0.35);
  color: #9a3412;
}

/* --- Modal --- */
[data-theme="light"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .modal {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .modal-header {
  background: rgba(255, 255, 255, 0.92);
}

[data-theme="light"] .modal-body details {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .rule-chip {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .quick-example {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .help-tab {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .help-tab.active {
  background: rgba(196, 154, 48, 0.1);
}

[data-theme="light"] .help-tab:hover:not(.active) {
  background: rgba(0, 0, 0, 0.05);
}

/* --- Debug Panel --- */
[data-theme="light"] .log-box {
  background: rgba(0, 0, 0, 0.04);
}

/* ============================================================
   AUTH & MY GAMES
   ============================================================ */

/* Auth header controls */
.btn-auth {
  border-color: rgba(212, 168, 67, 0.3);
  color: var(--gold-light);
}
.btn-auth:hover {
  background: rgba(212, 168, 67, 0.1);
  border-color: rgba(212, 168, 67, 0.5);
}
.btn-rejoin {
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  font-weight: 700;
  font-size: 12px;
}
.btn-rejoin:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.6);
}

.room-pill-user {
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
  background: rgba(34, 197, 94, 0.08);
  font-weight: 700;
}

/* Auth modal */
.modal-auth {
  max-width: 380px;
  width: 90vw;
}
.auth-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-tabs {
  display: flex;
  gap: 8px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-input {
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
  font-weight: 500;
  font-size: 14px;
  transition: border-color var(--transition-fast);
}
.auth-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.18);
}
.auth-input::placeholder {
  color: var(--text-light-muted);
}
.btn-auth-submit {
  height: 40px;
  background: linear-gradient(180deg, #f0d868 0%, #e4be42 25%, #d4a843 50%, #e4be42 75%, #f0d868 100%);
  border: 2px solid #d4a843;
  color: #3a2a0a;
  font-weight: 800;
  font-size: 14px;
  border-radius: 6px;
  text-shadow: 0 1px 0 rgba(255, 240, 180, 0.5);
  cursor: pointer;
  transition: filter var(--transition-fast);
}
.btn-auth-submit:hover {
  filter: brightness(1.08);
}
.btn-auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-error {
  color: #fca5a5;
  font-size: 13px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* My Games modal */
.modal-mygames {
  max-width: 520px;
  width: 92vw;
}
.mygames-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mygames-tabs {
  display: flex;
  gap: 8px;
}
.mygames-list,
.mygames-invites {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mygames-loading,
.mygames-empty {
  text-align: center;
  color: var(--text-light-muted);
  font-size: 13px;
  padding: 24px 0;
}

/* Game row */
.mygames-game-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  transition: background var(--transition-fast);
}
.mygames-game-row:hover {
  background: rgba(255, 255, 255, 0.06);
}
.mygames-game-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.mygames-game-code {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--gold-light);
  letter-spacing: 0.08em;
}
.mygames-game-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-light-muted);
}
.mygames-status {
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mygames-status-waiting {
  background: rgba(234, 179, 8, 0.12);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.25);
}
.mygames-status-active,
.mygames-status-full {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.mygames-status-playing {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.mygames-status-left {
  background: rgba(249, 115, 22, 0.12);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.25);
}
.mygames-status-seed,
.mygames-status-unknown {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light-muted);
  border: 1px solid var(--border-medium);
}
.mygames-game-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-mygames-join {
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
  font-weight: 700;
  font-size: 12px;
}
.btn-mygames-join:hover {
  background: rgba(34, 197, 94, 0.12);
}

/* Invite input row */
.invite-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.invite-username-input {
  height: 30px;
  width: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
  font-weight: 500;
  font-size: 12px;
  transition: border-color var(--transition-fast);
}
.invite-username-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.18);
}
.invite-username-input::placeholder {
  color: var(--text-light-muted);
}
.btn-invite-send {
  border-color: rgba(212, 168, 67, 0.3);
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
}
.btn-invite-send:hover {
  background: rgba(212, 168, 67, 0.1);
}

/* Invite badge */
.invite-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
#btn-my-games {
  position: relative;
}

/* Invite row */
.mygames-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}
.mygames-invite-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.mygames-invite-from,
.mygames-invite-to {
  color: var(--gold-light);
  font-weight: 700;
}
.mygames-invite-game {
  color: var(--text-light-muted);
  font-size: 12px;
}
.mygames-invite-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-invite-accept {
  border-color: rgba(34, 197, 94, 0.35);
  color: #86efac;
  font-weight: 700;
  font-size: 12px;
}
.btn-invite-accept:hover {
  background: rgba(34, 197, 94, 0.12);
}
.btn-invite-decline {
  border-color: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-size: 12px;
}
.btn-invite-decline:hover {
  background: rgba(239, 68, 68, 0.08);
}
.mygames-invite-status {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mygames-invite-status-pending {
  color: #fde047;
}
.mygames-invite-status-accepted {
  color: #86efac;
}
.mygames-invite-status-declined {
  color: #fca5a5;
}

.mygames-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  margin: 0;
}

/* Light theme overrides for auth */
[data-theme="light"] .auth-input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--text-dark);
}
[data-theme="light"] .auth-input::placeholder {
  color: var(--text-dark-muted);
}
[data-theme="light"] .auth-error {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.15);
}
[data-theme="light"] .room-pill-user {
  border-color: rgba(22, 163, 74, 0.3);
  color: #166534;
  background: rgba(22, 163, 74, 0.08);
}
[data-theme="light"] .mygames-game-row {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .mygames-game-row:hover {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .mygames-game-code {
  color: var(--gold-dark);
}
[data-theme="light"] .invite-username-input {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--text-dark);
}
[data-theme="light"] .mygames-invite-from,
[data-theme="light"] .mygames-invite-to {
  color: var(--gold-dark);
}
[data-theme="light"] .mygames-status-waiting {
  background: rgba(234, 179, 8, 0.1);
  color: #a16207;
  border-color: rgba(234, 179, 8, 0.2);
}
[data-theme="light"] .mygames-status-active,
[data-theme="light"] .mygames-status-full {
  background: rgba(22, 163, 74, 0.08);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.2);
}
[data-theme="light"] .mygames-status-playing {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.2);
}
[data-theme="light"] .mygames-status-left {
  background: rgba(234, 88, 12, 0.08);
  color: #c2410c;
  border-color: rgba(234, 88, 12, 0.2);
}
[data-theme="light"] .btn-rejoin {
  border-color: rgba(37, 99, 235, 0.3);
  color: #1d4ed8;
}
[data-theme="light"] .btn-mygames-join {
  border-color: rgba(22, 163, 74, 0.3);
  color: #166534;
}
[data-theme="light"] .btn-invite-accept {
  border-color: rgba(22, 163, 74, 0.3);
  color: #166534;
}
[data-theme="light"] .btn-invite-decline {
  border-color: rgba(220, 38, 38, 0.2);
  color: #dc2626;
}
[data-theme="light"] .mygames-invite-status-pending { color: #a16207; }
[data-theme="light"] .mygames-invite-status-accepted { color: #166534; }
[data-theme="light"] .mygames-invite-status-declined { color: #dc2626; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet portrait and below: keep throw trays side-by-side, just tighten */
@media (max-width: 760px) {
  .game-container {
    gap: 8px;
  }
}

/* Mobile: board scaling, header reorganization, touch targets */
@media (max-width: 620px) {
  /* Body: don't vertically center on mobile — content overflows viewport */
  body {
    justify-content: flex-start;
    overflow-x: hidden;
  }

  /* Tighten game container gap */
  .game-container {
    gap: 8px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Board: scale via JS-set --board-scale variable (see ui.js)
     Compensate ALL 4 sides — transform: scale() doesn't shrink layout box,
     so negative margins collapse the 606px box to match visual size */
  #zone-board {
    width: 100%;
    max-width: 100vw;
  }
  #game-board {
    transform: scale(var(--board-scale, 1));
    margin: calc(606px * (var(--board-scale, 1) - 1) / 2);
  }
  /* Combine rotation + scale for Player 2 POV */
  .pov-top #game-board {
    transform: rotate(180deg) scale(var(--board-scale, 1));
  }

  /* Counter board scale on text badges to keep them readable */
  .move-hint-wrap {
    transform: scale(calc(1 / var(--board-scale, 1)));
    transform-origin: top right;
  }
  .last-move-badge {
    transform: translateX(-50%) scale(calc(1 / var(--board-scale, 1)));
    transform-origin: bottom center;
  }

  /* Header: hamburger menu on mobile */
  .app-header {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }
  .app-header-left {
    flex: 1;
    justify-content: space-between;
  }
  .btn-hamburger {
    display: flex;
  }
  .app-header-right {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
    gap: 6px;
    padding-top: 10px;
    margin-top: 4px;
    border-top: 1px solid var(--border-medium);
  }
  .app-header-right.menu-open {
    display: flex;
  }
  /* Menu items: full-width stacked on mobile */
  .app-header-right .btn,
  .app-header-right .room-input {
    width: 100%;
    text-align: center;
    justify-content: center;
    border-radius: 8px;
  }
  .app-header-right .room-pill {
    text-align: center;
    align-self: center;
  }
  /* Icon buttons row: side-by-side at bottom */
  .menu-icon-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding-top: 6px;
    border-top: 1px solid var(--border-medium);
    margin-top: 2px;
  }
  .menu-icon-row .btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 10px;
    font-size: 18px;
    flex: 0 0 44px;
  }

  /* Larger touch targets (minimum ~36px height) */
  .btn {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
  }
  .btn-help,
  .btn-theme,
  .btn-sound {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  /* Room controls */
  .room-input {
    min-width: 80px;
    height: 36px;
    font-size: 13px;
  }

  /* Pill readability */
  .room-pill {
    font-size: 12px;
    padding: 6px 10px;
  }

  /* Text sizes for readability */
  .turn-zone-title,
  .turn-zone-meta {
    font-size: 10px;
  }
  .cloud-status {
    font-size: 12px;
  }
  .cloud-status-row {
    padding: 6px 10px;
  }

  /* --- Tab bar: visible on mobile --- */
  .throw-tab-bar {
    display: flex;
    width: 100%;
  }
  .throw-tab {
    flex: 1;
    padding: 8px 0;
    background: rgba(20, 16, 10, 0.6);
    border: 1px solid var(--border-subtle);
    color: var(--text-light-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .throw-tab:first-child {
    border-radius: 8px 0 0 8px;
  }
  .throw-tab:last-child {
    border-radius: 0 8px 8px 0;
  }
  .throw-tab-active {
    background: rgba(212, 168, 67, 0.15);
    border-color: var(--border-gold);
    color: var(--gold-light);
  }
  .throw-tray-tab-hidden {
    display: none !important;
  }

  /* --- Dual throw grid: single column with tabs --- */
  .dual-throw-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  /* --- Throw tray: full width with tabs --- */
  .throw-tray {
    padding: 4px;
    border-radius: 8px;
  }
  .turn-zone-header {
    padding: 0 4px;
  }
  .throw-mat {
    padding: 0;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .throw-tray .coin-tray {
    width: 200px;
    height: 200px;
    min-height: 0;
    padding: 8px;
    gap: 4px;
    place-items: center;
    place-content: center;
    box-sizing: border-box;
  }
  .shell-slot {
    height: auto;
  }
  .shell-wrap {
    width: 28px;
    height: 36px;
  }
  .shell-shadow {
    width: 32px;
    height: 7px;
  }
  /* Throw values: 5 per row, wrap to 2 lines on mobile */
  .throw-values {
    white-space: normal;
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 3px;
    min-height: 0;
  }
  .throw-values .throw-value-btn,
  .throw-values .throw-value-fill-empty {
    flex: 0 0 calc((100% - 12px) / 5);
    min-width: 0;
    box-sizing: border-box;
  }
  .throw-values-outside {
    margin-top: 10px;
    min-height: 0;
    padding-left: 2px;
    padding-right: 2px;
  }
  .turn-zone-header {
    margin-bottom: 2px;
  }

  /* Throw button: full width on mobile */
  .throw-actions {
    margin-top: 12px;
    gap: 3px;
  }
  .throw-btn-lite {
    min-width: 0;
    width: 100%;
    height: 40px;
    padding: 0 14px;
    font-size: 0.72rem;
  }

  /* Throw value reveal: bigger on mobile */
  .throw-btn-lite.throw-btn-reveal {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
  }

  /* Turn banners: fill throw-mat area on mobile */
  .throw-turn-banner {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    animation: none;
  }
  .throw-turn-banner-compact .throw-turn-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    opacity: 0.6;
    margin-bottom: 2px;
  }
  .throw-turn-banner-compact .throw-turn-title {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.12em;
    font-family: "Cinzel", serif;
    color: var(--gold-light);
    text-shadow:
      0 2px 0 rgba(0, 0, 0, 0.5),
      0 0 20px rgba(240, 215, 140, 0.25);
  }
  .throw-turn-banner-compact .throw-turn-sub {
    margin-top: 3px;
    font-size: 10px;
    letter-spacing: 0.12em;
    opacity: 0.85;
  }
  .throw-turn-banner-center .throw-turn-title {
    font-size: 26px;
  }
  .throw-turn-banner-center .throw-turn-sub {
    font-size: 10px;
    margin-top: 2px;
  }
  /* Light theme: keep banners transparent on mobile */
  [data-theme="light"] .throw-turn-banner,
  [data-theme="light"] .throw-turn-banner-compact {
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  [data-theme="light"] .throw-turn-banner-compact .throw-turn-title {
    color: var(--gold-dark);
    text-shadow:
      0 2px 0 rgba(255, 255, 255, 0.7),
      0 0 20px rgba(196, 154, 48, 0.15);
  }

  /* Opponent action status on mobile */
  .opponent-action-status {
    min-width: 0;
    height: 30px;
    padding: 0 10px;
    font-size: 0.65rem;
  }

  /* Both trays use same full-width layout with tabs */

  /* Throw value chips: smaller for mobile */
  .throw-value-btn {
    min-width: 30px;
    height: 26px;
    padding: 0 6px;
    font-size: 11px;
  }
  .throw-value-fill-empty {
    font-size: 10px;
    min-width: 24px;
    height: 26px;
    padding: 0 4px;
  }

  /* Modal: readable text */
  .modal-body {
    font-size: 15px;
    padding: 14px;
  }
  .modal-header {
    padding: 10px 14px;
  }

  /* Auth modal */
  .auth-input {
    height: 44px;
    font-size: 15px;
  }
  .btn-auth-submit {
    height: 44px;
    font-size: 15px;
  }

  /* My Games modal */
  .mygames-game-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .mygames-game-actions {
    width: 100%;
  }
  .btn-mygames-join {
    flex: 1;
    min-height: 36px;
  }
  .invite-input-row {
    flex: 1;
  }
}

/* Small mobile: hide non-essential, tighter layout */
@media (max-width: 420px) {
  .game-container {
    gap: 6px;
  }

  /* Hide debug controls on small screens */
  #btn-debug-toggle,
  #joined-role-badge,
  #btn-fix-formations {
    display: none !important;
  }

  /* Tighter header */
  .app-header {
    padding: 6px 8px;
  }
  .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .room-input {
    min-width: 70px;
  }
  .juvva-logo-text {
    font-size: 12px;
  }

  /* Move hints: counter-scaled so bump up size */
  .move-hint {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
  }
  .move-hint-wrap {
    gap: 2px;
    right: 1px;
    top: 1px;
  }

  /* Throw panel: slightly tighter for 420px (still full-width tabs) */
  .throw-mat {
    height: 170px;
  }
  .throw-tray .coin-tray {
    width: 170px;
    height: 170px;
    padding: 6px;
    gap: 3px;
  }
  .shell-wrap {
    width: 24px;
    height: 32px;
  }
  .shell-shadow {
    width: 28px;
    height: 6px;
  }
  .throw-btn-lite {
    height: 34px;
    font-size: 0.6rem;
    padding: 0 6px;
  }
  .throw-actions {
    margin-top: 16px;
  }
  .throw-values-outside {
    margin-top: 8px;
    min-height: 0;
    font-size: 10px;
  }

  /* YOUR TURN banner: even smaller */
  .throw-turn-banner-center .throw-turn-title {
    font-size: 15px;
  }
  .throw-turn-banner-center .throw-turn-sub {
    font-size: 8px;
  }

  /* Opponent action status: slightly smaller at 420px */
  .opponent-action-status {
    height: 24px;
    font-size: 0.58rem;
  }
  /* Throw value reveal: bigger at 420px */
  .throw-btn-lite.throw-btn-reveal {
    font-size: 1rem;
  }

  /* Compact cloud status */
  .cloud-status-row {
    font-size: 11px;
    padding: 4px 8px;
    gap: 6px;
  }
}

/* Very small mobile (iPhone SE, 320px) */
@media (max-width: 360px) {
  .game-container {
    gap: 3px;
  }
  .app-header-right {
    gap: 4px;
  }
  .btn {
    padding: 5px 8px;
    font-size: 11px;
    min-height: 32px;
  }
  .room-pill {
    font-size: 10px;
    padding: 4px 8px;
  }
  .room-input {
    min-width: 60px;
    font-size: 11px;
  }
  /* Throw panel: tighter for 360px (still full-width tabs) */
  .throw-mat {
    height: 140px;
  }
  .throw-tray .coin-tray {
    width: 140px;
    height: 140px;
    padding: 4px;
    gap: 2px;
  }
  .shell-wrap {
    width: 20px;
    height: 26px;
  }
  .shell-shadow {
    width: 24px;
    height: 5px;
  }
  .throw-btn-lite {
    height: 30px;
    font-size: 0.55rem;
    padding: 0 4px;
  }
  /* Both trays use same full-width layout with tabs at 360px */
  .throw-turn-banner-center .throw-turn-title {
    font-size: 13px;
  }
  .throw-turn-banner-center .throw-turn-sub {
    font-size: 7px;
  }
  /* Throw value reveal at 360px */
  .throw-btn-lite.throw-btn-reveal {
    font-size: 0.9rem;
  }
  .opponent-action-status {
    height: 20px;
    font-size: 0.5rem;
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}
