/* ── Tokens ───────────────────────────────────────────── */
:root {
  --bg-1: #fbf6e8;
  --bg-2: #f8e9d2;
  --ink: #1e2a39;
  --ink-muted: #4b5b6f;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #fff;
  --line: rgba(30, 42, 57, 0.12);
  --brand: #0b8f7d;
  --brand-deep: #0a5f59;
  --brand-glow: rgba(11, 143, 125, 0.18);
  --accent: #e66139;
  --accent-glow: rgba(230, 97, 57, 0.25);
  --warn: #d43f27;
  --ok: #2f9d5d;
  --ok-glow: rgba(47, 157, 93, 0.2);
  --gold: #d4a017;
  --shadow: 0 8px 32px rgba(34, 45, 62, 0.10);
  --shadow-lg: 0 16px 48px rgba(34, 45, 62, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; color: var(--ink); font-family: "Public Sans", "Segoe UI", sans-serif; }

body {
  background:
    radial-gradient(ellipse at 10% 15%, #ffe6ba 0%, transparent 40%),
    radial-gradient(ellipse at 90% 0%, #d1f2ec 0%, transparent 35%),
    radial-gradient(ellipse at 50% 100%, #fce4d6 0%, transparent 40%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

h1, h2, h3 { margin: 0; font-family: "Space Grotesk", "Segoe UI", sans-serif; letter-spacing: 0.02em; }
p { margin: 0; }
a { color: var(--brand-deep); }

/* ── Shell / Layout ───────────────────────────────────── */
.shell { width: min(960px, 96vw); margin: 0 auto; padding: 20px 0 48px; }
.index-shell { display: grid; gap: 18px; }
.game-shell { display: grid; gap: 12px; }

/* ── Topbar / HUD ─────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }

.session-badge {
  display: inline-block;
  font-family: "Space Grotesk", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--brand-deep);
  background: rgba(11, 143, 125, 0.08);
  border: 1px solid var(--brand-glow);
  border-radius: 8px;
  padding: 6px 14px;
}

.hud { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 14px;
  min-width: 72px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chip-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  font-weight: 600;
}

.chip-value {
  font-family: "Space Grotesk", monospace;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.2;
}

.chip-coin .chip-value { color: var(--gold); }
.chip-timer .chip-value { color: var(--ink); }

.chip-timer.timer-warn { border-color: var(--accent); }
.chip-timer.timer-warn .chip-value { color: var(--accent); }

.chip-timer.timer-danger {
  border-color: var(--warn);
  animation: chipPulse 0.8s ease-in-out infinite;
}
.chip-timer.timer-danger .chip-value { color: var(--warn); }

@keyframes chipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 63, 39, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(212, 63, 39, 0.25); }
}

/* ── Campaign Trail ───────────────────────────────────── */
.campaign-panel {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.campaign-trail {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 8px 8px 12px;
  min-width: min-content;
}

.trail-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  flex-shrink: 0;
  position: relative;
}

.trail-connector {
  flex: 0 0 28px;
  height: 3px;
  background: var(--line);
  margin-top: 17px;
  border-radius: 2px;
  transition: background var(--transition);
}

.trail-connector.active {
  background: var(--ok);
}

.trail-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel-solid);
  border: 3px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.trail-node.current .trail-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-glow);
  animation: trailPulse 2.5s ease-in-out infinite;
  transform: scale(1.12);
}

.trail-node.done .trail-dot {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.trail-label {
  margin-top: 5px;
  font-size: 0.68rem;
  text-align: center;
  color: var(--ink-muted);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

@keyframes trailPulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-glow); }
  50% { box-shadow: 0 0 0 8px var(--accent-glow), 0 0 20px 4px rgba(230, 97, 57, 0.12); }
}

/* ── Panels ───────────────────────────────────────────── */
.panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.panel h2 { font-size: 1.15rem; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* ── Hero (index page) ────────────────────────────────── */
.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin-top: 4px; }
.subtitle { margin-top: 8px; color: var(--ink-muted); line-height: 1.45; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; color: var(--ink-muted); }

/* ── Card grid (index page) ───────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.card-grid .panel p { margin-top: 6px; color: var(--ink-muted); }

/* ── Common ───────────────────────────────────────────── */
.hidden { display: none !important; }
.muted { color: var(--ink-muted); }
.label-sm { font-size: 0.78rem; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.stack { display: grid; gap: 10px; margin-top: 10px; }
.inline { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

.note ul { margin: 12px 0 0; padding-left: 18px; color: var(--ink-muted); line-height: 1.4; }

/* ── Badge ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(11, 143, 125, 0.10);
  color: var(--brand-deep);
}

.badge-cat {
  background: rgba(230, 97, 57, 0.10);
  color: var(--accent);
}

/* ── Inputs ───────────────────────────────────────────── */
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  box-shadow: 0 4px 14px var(--brand-glow);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 20px var(--brand-glow); }

.btn-ghost {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-lg { padding: 14px 28px; font-size: 1.05rem; margin-top: 12px; width: 100%; }

.btn-bot { border-style: dashed; }

/* ── Lobby ────────────────────────────────────────────── */
.share-area {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px;
  background: rgba(11, 143, 125, 0.04);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(11, 143, 125, 0.2);
}

.share-area img {
  width: 110px;
  height: 110px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
}

.bot-controls { margin-top: 10px; }

/* ── Mission Panel (question) ─────────────────────────── */
.mission-panel { border-left: 4px solid var(--accent); }

.mission-header { margin-bottom: 10px; }
.mission-title { font-size: 1.2rem; margin-top: 4px; }
.mission-prompt { font-size: 1.05rem; line-height: 1.55; color: var(--ink); margin-top: 4px; }
.live-info { font-size: 0.85rem; margin-top: 8px; }

/* ── Choice Grid ──────────────────────────────────────── */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-solid);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  font-size: 0.93rem;
  text-align: left;
  color: var(--ink);
  line-height: 1.35;
}

.choice-option:hover:not(:disabled) {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px var(--brand-glow);
}

.choice-option.selected {
  border-color: var(--brand);
  background: rgba(11, 143, 125, 0.05);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.choice-option:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.choice-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(30, 42, 57, 0.07);
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: all var(--transition);
}

.choice-option.selected .choice-letter {
  background: var(--brand);
  color: #fff;
}

/* ── Bet Zone ─────────────────────────────────────────── */
.bet-zone { margin-top: 16px; display: grid; gap: 8px; }
.bet-zone input[type="range"] { padding: 0; }
.bet-display { font-size: 0.95rem; }

/* ── Progress ─────────────────────────────────────────── */
.progress-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.progress-wrap {
  flex: 1;
  height: 10px;
  background: rgba(30, 42, 57, 0.07);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(120deg, var(--brand), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.submit-note { margin-top: 6px; font-size: 0.88rem; }

/* ── Player List / Squad ──────────────────────────────── */
.squad-panel { border-top: 3px solid var(--brand); }

.player-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.player-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-solid);
  align-items: center;
  font-size: 0.92rem;
}

.player-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }

.player-coins {
  font-family: "Space Grotesk", monospace;
  color: var(--gold);
}

.player-status {
  font-size: 0.78rem;
  color: var(--ink-muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(30, 42, 57, 0.05);
}

.player-status.status-done { background: var(--ok-glow); color: var(--ok); }
.player-status.status-rest { background: rgba(212, 63, 39, 0.08); color: var(--warn); }

.bot-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: rgba(30, 42, 57, 0.07);
  padding: 2px 7px;
  border-radius: 999px;
}

.host-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--brand-deep);
  background: rgba(11, 143, 125, 0.10);
  padding: 2px 7px;
  border-radius: 999px;
}

.btn-remove-bot {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}
.btn-remove-bot:hover { border-color: var(--warn); color: var(--warn); background: rgba(212, 63, 39, 0.06); }

/* ── Results ──────────────────────────────────────────── */
.result-headline { font-weight: 700; font-size: 1.05rem; margin-top: 8px; color: var(--ink); }

.result-table { margin-top: 10px; display: grid; gap: 8px; }

.result-row {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--panel-solid);
}

.result-row.result-correct { border-left-color: var(--ok); }
.result-row.result-wrong { border-left-color: var(--warn); }
.result-row.result-pause { border-left-color: var(--ink-muted); }

.result-row-header { display: flex; justify-content: space-between; align-items: center; }

.result-delta {
  font-family: "Space Grotesk", monospace;
  font-weight: 700;
  font-size: 1rem;
}
.delta-pos { color: var(--ok); }
.delta-neg { color: var(--warn); }

.result-row-details { margin-top: 4px; font-size: 0.82rem; color: var(--ink-muted); }

/* ── Ended / Ranking ──────────────────────────────────── */
.panel-ended { text-align: center; }

.winner-line {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 8px;
  color: var(--brand-deep);
}

.ranking {
  margin: 16px auto 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-width: 480px;
  text-align: left;
  counter-reset: ranking;
}

.ranking li {
  counter-increment: ranking;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-solid);
  border: 1px solid var(--line);
}

.ranking li::before {
  content: "#" counter(ranking);
  font-family: "Space Grotesk", monospace;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink-muted);
  margin-right: 12px;
}

.ranking li.rank-first { border-color: var(--gold); background: rgba(212, 160, 23, 0.06); }
.ranking li.rank-first::before { color: var(--gold); }
.ranking li.rank-second { border-color: #8e8e8e; }
.ranking li.rank-second::before { color: #8e8e8e; }
.ranking li.rank-third { border-color: #b07340; }
.ranking li.rank-third::before { color: #b07340; }

.rank-name { font-weight: 700; flex: 1; }
.rank-stats { font-size: 0.82rem; color: var(--ink-muted); white-space: nowrap; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 680px) {
  .shell { width: 100%; padding: 10px 10px 36px; }

  .topbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .hud { justify-content: center; }
  .chip { min-width: 60px; padding: 5px 10px; }
  .chip-value { font-size: 1rem; }

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

  .inline { flex-direction: column; align-items: stretch; }
  .inline .btn { width: 100%; }

  .player-list li { grid-template-columns: 1fr auto auto auto; font-size: 0.85rem; }
}

@media (max-width: 400px) {
  .trail-node { min-width: 52px; }
  .trail-dot { width: 30px; height: 30px; font-size: 0.75rem; }
  .trail-connector { flex: 0 0 16px; margin-top: 14px; }
  .trail-label { font-size: 0.6rem; max-width: 56px; }
}
