:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel2: #1b2030;
  --line: #262c3b;
  --text: #e6e9f0;
  --dim: #8a93a8;
  --p1: #38d9f5;
  --p2: #ff5f7a;
  --gold: #e8c547;
  --danger: #ff4d4d;
  --ok: #59e39a;
  --purple: #b48cff;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.35;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overscroll-behavior: none;
}
#app { max-width: 520px; margin: 0 auto; padding: 8px 12px 24px; }
button {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; transform: none; }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: 13px; }
.p1 { color: var(--p1); } .p2 { color: var(--p2); }
.dim { color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- Menu ---------- */
.title { font-size: 44px; font-weight: 800; letter-spacing: 0.32em; margin: 28px 0 0; text-align: center; }
.subtitle { text-align: center; color: var(--dim); margin: 4px 0 24px; letter-spacing: 0.08em; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.section h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice { text-align: left; padding: 10px; }
.choice b { display: block; }
.choice span { font-size: 12px; color: var(--dim); }
.choice.on { border-color: var(--text); background: #262d40; }
.choice.on.c1 { border-color: var(--p1); } .choice.on.c2 { border-color: var(--p2); }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; border: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--dim); transition: left .15s; }
.switch.on { background: #3a4a66; } .switch.on::after { left: 21px; background: var(--text); }

/* ---------- Game ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.score { font-weight: 800; font-size: 22px; min-width: 64px; }
.score small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .06em; color: var(--dim); }
.score.right { text-align: right; }
.round { text-align: center; color: var(--dim); font-size: 13px; }
.round b { color: var(--text); font-size: 15px; display: block; }
.turnbar { display: flex; align-items: center; justify-content: space-between; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
.turnbar .who { font-weight: 700; }
.pips { display: inline-flex; gap: 4px; vertical-align: middle; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--gold); }
.pip.on { background: var(--gold); }
.board-wrap { position: relative; }
svg.board { width: 100%; height: auto; display: block; border-radius: 10px; touch-action: manipulation; user-select: none; }
.prompt { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 8px 2px; }
.prompt .msg { flex: 1; font-size: 14px; }
.info { font-size: 13px; color: var(--dim); }
.info b { color: var(--text); }
.actions { display: flex; gap: 8px; margin: 4px 0 10px; }
.actions .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { font-size: 13px; padding: 6px 10px; border-radius: 999px; }
.chip.on { border-color: var(--gold); color: var(--gold); }

.track { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.slot { background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; padding: 6px 8px; min-height: 48px; font-size: 12px; }
.slot .lbl { color: var(--dim); font-size: 11px; letter-spacing: .06em; }
.slot div { line-height: 1.3; }

.hand { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; position: relative; min-height: 104px; display: flex; flex-direction: column; gap: 4px; }
.card.ready { border-color: #3b4560; }
.card.playable { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,197,71,.25) inset; }
.card.active { background: #2a2a1c; border-color: var(--gold); }
.card.out { opacity: 0.45; }
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.card .name { font-weight: 700; font-size: 14px; }
.card .cost { font-size: 12px; color: var(--gold); white-space: nowrap; }
.card .text { font-size: 12px; color: #c4cad8; flex: 1; }
.card .foot { font-size: 11px; color: var(--dim); display: flex; justify-content: space-between; gap: 6px; }
.tag { font-size: 10px; letter-spacing: .08em; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--dim); }
.tag.react { color: var(--purple); border-color: #4b3d73; }
.tag.equip { color: var(--ok); border-color: #2c5a44; }
.tag.set { color: var(--gold); border-color: #5c5124; }

.opp { margin-top: 12px; }
.opp .hand .card { min-height: 0; }
.log { font-size: 12px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; margin-bottom: 8px; max-height: 96px; overflow: hidden; }
.log.open { max-height: 280px; overflow-y: auto; }
.log div { padding: 1px 0; }
.log .lp1 { color: #9be9f9; } .log .lp2 { color: #ffb0bd; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,6,10,.82); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.overlay.solid { background: var(--bg); }
.overlay.bottom { align-items: flex-end; background: rgba(5,6,10,.35); }
.overlay.bottom .modal { max-height: 52vh; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; }
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal p { margin: 6px 0; }
.modal .btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.modal .opt { text-align: left; }
.modal .opt b { display: block; }
.modal .opt span { font-size: 12px; color: var(--dim); }
.cover h2 { font-size: 26px; text-align: center; }
.cover p { text-align: center; color: var(--dim); }

.rules { line-height: 1.5; }
.rules h2 { margin-top: 18px; }
.rules h3 { margin: 14px 0 4px; }
.rules ul { padding-left: 20px; margin: 4px 0; }
.rules table { border-collapse: collapse; width: 100%; font-size: 13px; }
.rules td, .rules th { border-bottom: 1px solid var(--line); padding: 4px; text-align: left; vertical-align: top; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; z-index: 20; font-size: 14px; pointer-events: none; max-width: 90vw; text-align: center; }
