:root {
  color-scheme: dark;
  --bg: #11100f;
  --surface: #191816;
  --surface-2: #22201d;
  --surface-3: #2a2824;
  --line: #393631;
  --ink: #f3eee4;
  --muted: #a8a197;
  --gold: #d7ba7d;
  --gold-strong: #efd18d;
  --red: #d87663;
  --green: #78b894;
  --blue: #7caac8;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% -5%, rgba(215, 186, 125, 0.11), transparent 30rem),
    radial-gradient(circle at 95% 15%, rgba(120, 184, 148, 0.06), transparent 24rem),
    var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; }
button, select, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) clamp(16px, 4vw, 36px) max(32px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(215, 186, 125, .45);
  border-radius: 13px;
  background: linear-gradient(145deg, #29251e, #171513);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 24px;
}
.brand h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 22px; letter-spacing: .02em; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .13em; text-transform: uppercase; }

.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: 12px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 10px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 7vw, 46px); font-weight: 500; line-height: 1.05; }
h3 { margin-bottom: 14px; font-size: 17px; }
.muted { color: var(--muted); }
.lede { max-width: 620px; color: var(--muted); font-size: 16px; line-height: 1.55; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(25, 24, 22, .94);
  box-shadow: var(--shadow);
}

.setup-layout { display: grid; grid-template-columns: .9fr 1.1fr; gap: 24px; align-items: start; }
.setup-intro { padding: 32px 8px 0; }
.setup-card { padding: clamp(18px, 4vw, 30px); }
.step-row { display: flex; gap: 8px; margin-bottom: 24px; }
.step-dot { width: 31px; height: 4px; border-radius: 99px; background: var(--line); }
.step-dot.active { background: var(--gold); }

.field { display: grid; gap: 8px; margin-bottom: 17px; }
.field > span, .field-label { color: #d4cec4; font-size: 13px; font-weight: 650; }
.field small { color: var(--muted); line-height: 1.4; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--surface-2);
  color: var(--ink);
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(215, 186, 125, .12); }

.player-row { display: grid; grid-template-columns: 1fr 88px; gap: 10px; }
.player-row + .player-row { margin-top: 10px; }
.player-row input[type="number"] { text-align: center; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice {
  position: relative;
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--gold); background: rgba(215, 186, 125, .1); }
.choice input { width: 17px; min-height: 17px; accent-color: var(--gold); }
.choice span { font-size: 13px; }
.choice-group + .choice-group { margin-top: 18px; }
.choice-group h4 { margin: 0 0 9px; color: var(--muted); font-size: 11px; letter-spacing: .11em; text-transform: uppercase; }

.btn {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--gold);
  color: #1d1912;
  cursor: pointer;
  font-weight: 750;
}
.btn:hover { background: var(--gold-strong); }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn.secondary { border-color: var(--line); background: var(--surface-2); color: var(--ink); }
.btn.ghost { min-height: 40px; padding: 0 12px; border-color: var(--line); background: transparent; color: var(--muted); }
.btn.danger { color: var(--red); }
.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }
.actions .btn:last-child { margin-left: auto; }
.error { margin: 12px 0 0; color: #ed9b8b; font-size: 13px; }

.dashboard-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dashboard-head h2 { margin: 0; font-size: clamp(28px, 5vw, 38px); }
.status-pill { padding: 8px 11px; border: 1px solid rgba(120,184,148,.32); border-radius: 999px; color: var(--green); background: rgba(120,184,148,.08); font-size: 12px; white-space: nowrap; }

.tabs {
  position: sticky;
  z-index: 10;
  top: max(0px, env(safe-area-inset-top));
  display: flex;
  gap: 5px;
  margin: 0 -6px 20px;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 16, 15, .91);
  backdrop-filter: blur(16px);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { min-height: 39px; padding: 0 15px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--surface-3); color: var(--ink); }
.tab-badge { display: inline-grid; min-width: 18px; height: 18px; margin-left: 6px; place-items: center; border-radius: 99px; background: rgba(215,186,125,.16); color: var(--gold); font-size: 10px; }

.overview-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; }
.hero-card { position: relative; min-height: 262px; padding: clamp(21px, 4vw, 30px); overflow: hidden; }
.hero-card::after { position: absolute; right: -70px; bottom: -110px; width: 270px; height: 270px; border: 1px solid rgba(215,186,125,.13); border-radius: 50%; content: ""; }
.hero-top { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 16px; }
.confidence { display: grid; flex: 0 0 76px; height: 76px; place-items: center; border: 6px solid var(--line); border-top-color: var(--gold); border-radius: 50%; font-family: Georgia, serif; font-size: 19px; }
.solution { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 22px; }
.solution-item { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(17,16,15,.55); }
.solution-item small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.solution-item strong { font-size: 14px; }
.callout { margin-top: 16px; padding: 12px 14px; border-left: 3px solid var(--gold); border-radius: 4px 10px 10px 4px; background: rgba(215,186,125,.08); color: #ded6c8; font-size: 13px; line-height: 1.45; }
.callout.ready { border-color: var(--green); background: rgba(120,184,148,.09); }

.next-card { padding: 22px; }
.next-triple { display: grid; gap: 8px; margin: 16px 0; }
.next-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.next-line span { color: var(--muted); font-size: 12px; }
.next-line strong { text-align: right; font-size: 14px; }
.compact-field { margin-top: 15px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.stat { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(25,24,22,.7); }
.stat strong { display: block; margin-bottom: 4px; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.stat span { color: var(--muted); font-size: 11px; }

.form-card { max-width: 780px; margin: 0 auto; padding: clamp(18px, 4vw, 30px); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.response-hint { margin: -5px 0 17px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: start; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.turn-number { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--gold); font-family: Georgia, serif; }
.history-item p { margin: 0 0 5px; line-height: 1.45; }
.history-item small { color: var(--muted); line-height: 1.4; }
.empty { padding: 44px 22px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }

.matrix-card { overflow: hidden; }
.matrix-scroll { overflow-x: auto; }
.matrix { width: 100%; min-width: 700px; border-collapse: collapse; }
.matrix th, .matrix td { height: 44px; padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; font-size: 12px; }
.matrix th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-weight: 650; }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; z-index: 1; width: 180px; background: var(--surface); text-align: left; }
.matrix th:first-child { z-index: 3; background: var(--surface-2); }
.matrix .group-row td { height: 34px; background: #151412; color: var(--gold); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.mark { display: inline-grid; min-width: 27px; height: 27px; padding: 0 5px; place-items: center; border-radius: 8px; }
.mark.yes { background: rgba(120,184,148,.13); color: var(--green); }
.mark.no { color: #5f5a54; }
.mark.maybe { color: var(--muted); font-size: 10px; }
.mark.envelope { background: rgba(215,186,125,.14); color: var(--gold-strong); font-weight: 750; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px 16px; color: var(--muted); font-size: 11px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { padding: 22px; }
.settings-list { display: grid; gap: 11px; }
.settings-row { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.settings-row span { color: var(--muted); }
.danger-zone { border-color: rgba(216,118,99,.25); }

.toast { position: fixed; z-index: 50; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 36px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: #292622; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 760px) {
  .shell { padding-left: 14px; padding-right: 14px; }
  .topbar { margin-bottom: 20px; }
  .brand small { display: none; }
  .setup-layout, .overview-grid, .settings-grid { grid-template-columns: 1fr; }
  .setup-intro { padding: 8px 2px 0; }
  .setup-intro .lede { margin-bottom: 6px; }
  .dashboard-head { align-items: center; }
  .solution { grid-template-columns: 1fr; }
  .hero-card { min-height: 0; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 13px 10px; }
  .stat strong { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .history-item { grid-template-columns: 34px 1fr; }
  .history-item .btn { grid-column: 2; justify-self: start; }
}

@media (max-width: 430px) {
  .topbar .btn { min-height: 40px; padding: 0 11px; font-size: 12px; }
  .choice-grid { grid-template-columns: 1fr; }
  .setup-card { padding: 18px 15px; }
  .hero-top { align-items: flex-start; }
  .confidence { flex-basis: 66px; height: 66px; font-size: 17px; }
  .stats { overflow-x: auto; }
  .stat { min-width: 105px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; } }
