/* Hearthboard Game Box — warm walnut game board container */

.game-box {
  --game-border: rgba(196, 164, 108, 0.2);
  border: 2px solid var(--game-border);
  border-radius: var(--radius-2);
  background:
    var(--texture-grain),
    linear-gradient(180deg, #2a2318 0%, #1e1b14 100%);
  box-shadow:
    0 4px 24px rgba(20, 15, 8, 0.5),
    inset 0 1px 0 rgba(255, 247, 226, 0.06);
  overflow: hidden;
}

.game-box[data-game="chain"] { --game-border: rgba(151, 196, 111, 0.3); }
.game-box[data-game="survival"] { --game-border: rgba(223, 138, 105, 0.3); }
.game-box[data-game="poll"] { --game-border: rgba(200, 217, 207, 0.3); }
.game-box[data-game="wavedefender"] { --game-border: rgba(126, 200, 227, 0.3); }
.game-box[data-game="tug"] { --game-border: rgba(226, 187, 118, 0.3); }
.game-box[data-game="emojitrain"] { --game-border: rgba(212, 165, 216, 0.3); }

/* ── Selector rail ────────────────────────────── */

.game-box__rail {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(196, 164, 108, 0.12);
  overflow-x: auto;
  scrollbar-width: none;
}

.game-box__rail::-webkit-scrollbar { display: none; }
.game-box__rail { position: relative; }

.game-box__pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: rgba(62, 52, 36, 0.35);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.game-box__pill:hover {
  background: rgba(62, 52, 36, 0.65);
  color: var(--text);
}

.game-box__pill:active {
  transform: scale(0.93);
  transition-duration: var(--dur-instant);
}

.game-box__pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-box__pill.is-active {
  background: rgba(62, 52, 36, 0.8);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Per-game active pill identity */
.game-box[data-game="chain"] .game-box__pill.is-active { border-color: #97c46f; background: rgba(151, 196, 111, 0.18); }
.game-box[data-game="survival"] .game-box__pill.is-active { border-color: #df8a69; background: rgba(223, 138, 105, 0.18); }
.game-box[data-game="poll"] .game-box__pill.is-active { border-color: #c8d9cf; background: rgba(200, 217, 207, 0.18); }
.game-box[data-game="wavedefender"] .game-box__pill.is-active { border-color: #7ec8e3; background: rgba(126, 200, 227, 0.18); }
.game-box[data-game="tug"] .game-box__pill.is-active { border-color: #e2bb76; background: rgba(226, 187, 118, 0.18); }
.game-box[data-game="emojitrain"] .game-box__pill.is-active { border-color: #d4a5d8; background: rgba(212, 165, 216, 0.18); }

.game-box__pill-emoji { font-size: 15px; line-height: 1; }

/* ── Center: playfield + log ─────────────────── */

.game-box__center {
  display: grid;
  grid-template-columns: 1fr 260px;
  min-height: 280px;
}

.game-box__playfield {
  padding: var(--space-2);
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 220px;
  transition: background 0.4s ease;
}

/* Subtle ambient tint per active game */
.game-box[data-game="chain"] .game-box__playfield { background: radial-gradient(ellipse at 30% 20%, rgba(151, 196, 111, 0.05), transparent 60%); }
.game-box[data-game="survival"] .game-box__playfield { background: radial-gradient(ellipse at 30% 20%, rgba(223, 138, 105, 0.05), transparent 60%); }
.game-box[data-game="wavedefender"] .game-box__playfield { background: radial-gradient(ellipse at 30% 20%, rgba(126, 200, 227, 0.05), transparent 60%); }
.game-box[data-game="tug"] .game-box__playfield { background: radial-gradient(ellipse at 30% 20%, rgba(226, 187, 118, 0.05), transparent 60%); }
.game-box[data-game="emojitrain"] .game-box__playfield { background: radial-gradient(ellipse at 30% 20%, rgba(212, 165, 216, 0.05), transparent 60%); }

/* Hero number glow */
.game-box__playfield .chain-number,
.game-box__playfield .game-stage__hero {
  text-shadow: 0 0 24px rgba(164, 207, 127, 0.3);
  transition: transform 0.3s ease;
}

.game-box__playfield .is-bump { animation: hero-pulse 0.3s ease; }

@keyframes hero-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ── Hearth log (chat + events) ──────────────── */

.game-box__log {
  border-left: 1px solid rgba(196, 164, 108, 0.12);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 420px;
  background: rgba(0, 0, 0, 0.1);
}

.game-box__log-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(196, 164, 108, 0.08);
  font-size: 11px;
}

.game-box__filter-chip {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(62, 52, 36, 0.3);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.game-box__filter-chip:hover { background: rgba(62, 52, 36, 0.6); color: var(--text); }
.game-box__filter-chip.is-active { background: rgba(62, 52, 36, 0.7); color: var(--text); }

.game-box__filter-chip:active {
  transform: scale(0.93);
  transition-duration: var(--dur-instant);
}

.game-box__filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-box__msg-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.6;
}

.game-box__log-feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  max-height: min(300px, 50vh);
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 164, 108, 0.2) transparent;
}

.game-box__log-feed::-webkit-scrollbar { width: 6px; }
.game-box__log-feed::-webkit-scrollbar-track { background: transparent; }
.game-box__log-feed::-webkit-scrollbar-thumb { background: rgba(196, 164, 108, 0.25); border-radius: 999px; }
.game-box__log-feed::-webkit-scrollbar-thumb:hover { background: rgba(196, 164, 108, 0.4); }

.game-box__msg {
  padding: 3px 0 3px 10px;
  font-size: 12px;
  line-height: 1.5;
  border-left: 2px solid transparent;
  color: var(--text);
}

.game-box__msg--empty { color: var(--muted); padding: 12px 0; text-align: center; border-left: none; }
.game-box__msg--chat { border-left-color: #7db862; }
.game-box__msg--self { border-left-color: var(--accent); opacity: 0.7; }
.game-box__msg--event {
  border-left-color: var(--warn); color: var(--warn);
  font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
  padding-top: 4px; padding-bottom: 4px;
  background: rgba(220, 180, 80, 0.04);
}
.game-box__msg--test { border-left-color: var(--danger); }
.game-box__msg--bot { border-left-color: #7ec8e3; }
.game-box__msg--chat strong,
.game-box__msg--self strong,
.game-box__msg--test strong { color: var(--muted); }
.game-box__badge { font-size: 10px; color: var(--danger); font-weight: 700; }

/* ── Command dock ────────────────────────────── */

.game-box__dock {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
  border-top: 1px solid rgba(196, 164, 108, 0.12);
}

.game-box__input-row {
  flex: 1;
  display: flex;
  gap: 6px;
  position: relative;
}

.game-box__input-row.is-test::before {
  content: "TEST MODE";
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--danger);
  opacity: 0.8;
}

.game-box__input-row input {
  flex: 1;
  background: rgba(62, 52, 36, 0.4);
  border: 1px solid rgba(196, 164, 108, 0.2);
  border-radius: var(--radius-1);
  padding: 8px 12px;
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.15s;
}

.game-box__input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.game-box__input-row.is-test input {
  border-color: rgba(220, 127, 92, 0.5);
}

.game-box__send {
  padding: 8px 14px;
  border-radius: var(--radius-1);
  background: rgba(164, 207, 127, 0.15);
  border: 1px solid rgba(164, 207, 127, 0.3);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.game-box__send:hover { background: rgba(164, 207, 127, 0.25); }

.game-box__send:active {
  transform: scale(0.93);
  transition-duration: var(--dur-instant);
}

.game-box__send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-box__admin-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 8px;
  border-left: 1px solid rgba(196, 164, 108, 0.1);
}

.game-box__admin-btn {
  padding: 7px 12px;
  border-radius: var(--radius-1);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: background 0.15s;
}

.game-box__admin-btn:active {
  transform: scale(0.93);
  transition-duration: var(--dur-instant);
}

.game-box__admin-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.game-box__admin-btn--stop {
  background: rgba(220, 127, 92, 0.12);
  border-color: rgba(220, 127, 92, 0.3);
  color: var(--danger);
}

.game-box__admin-btn--stop:hover { background: rgba(220, 127, 92, 0.25); }

.game-box__admin-btn--restart {
  background: rgba(164, 207, 127, 0.1);
  border-color: rgba(164, 207, 127, 0.25);
  color: var(--accent);
}

.game-box__admin-btn--restart:hover { background: rgba(164, 207, 127, 0.2); }

.game-box__admin-btn--mode {
  background: rgba(164, 207, 127, 0.1);
  border-color: rgba(164, 207, 127, 0.25);
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.5px;
  min-width: 42px;
  text-align: center;
}

.game-box__input-row.is-test .game-box__admin-btn--mode {
  background: rgba(220, 127, 92, 0.25);
  border-color: rgba(220, 127, 92, 0.6);
  color: var(--danger);
  box-shadow: 0 0 8px rgba(220, 127, 92, 0.3);
  animation: test-mode-pulse 2s ease-in-out infinite;
}

@keyframes test-mode-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(220, 127, 92, 0.3); }
  50% { box-shadow: 0 0 14px rgba(220, 127, 92, 0.5); }
}

.game-box__input-row.is-test .game-box__send {
  background: rgba(220, 127, 92, 0.12);
  border-color: rgba(220, 127, 92, 0.3);
  color: var(--danger);
}

.game-box__dock-result {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  flex-shrink: 1;
  min-width: 0;
}

/* ── Idle state (no game running) ────────────── */

.game-box__idle {
  display: grid;
  place-items: center;
  padding: var(--space-4) var(--space-3);
  min-height: 200px;
  max-width: 400px;
  margin: 0 auto;
  text-align: center;
  color: var(--muted);
  background: radial-gradient(ellipse at 50% 40%, rgba(164, 207, 127, 0.04), transparent 60%);
}

.game-box__idle strong { color: var(--text); font-size: 17px; display: block; margin-bottom: 6px; letter-spacing: 0.2px; }

.game-box__idle-clean {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: var(--space-4) var(--space-3);
  text-align: center;
  color: var(--muted);
  background: radial-gradient(ellipse at 50% 50%, rgba(196, 164, 108, 0.03), transparent 70%);
}

.game-box__idle-emoji { font-size: 36px; opacity: 0.5; animation: idle-breathe 4s ease-in-out infinite; }
@keyframes idle-breathe { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.08); opacity: 0.7; } }
.game-box__idle-clean strong { color: var(--text); font-size: 16px; letter-spacing: 0.2px; }
.game-box__idle-clean .mobile-meta { margin: 0; }

.game-box__active-label { padding: 8px 12px; }

/* ── Mobile ──────────────────────────────────── */

@media (max-width: 600px) {
  .game-box__rail {
    mask-image: linear-gradient(to right, #000 0%, #000 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 80%, transparent 100%);
  }

  .game-box__center {
    grid-template-columns: 1fr;
  }

  .game-box__log {
    border-left: none;
    border-top: 1px solid rgba(196, 164, 108, 0.12);
  }

  .game-box__log-feed {
    max-height: 220px;
  }

  .game-box__dock {
    flex-wrap: wrap;
  }

  .game-box__input-row {
    min-width: 100%;
  }

  .game-box__admin-row {
    width: 100%;
    justify-content: flex-end;
    padding-top: 4px;
    border-left: none;
    margin-left: 0;
  }
}
