/* MBH Dharma Twin. Layout: a card table. Draw pile + active card on the left (sticky on phones), the two camps'
   character boxes on the right. Camp = colour + K/P letter; suit = colour + symbol, consistent everywhere. */
:root {
  --table: #e4e8e2; --table-2: #d8ddd5; --surface: #fdfdfb; --ink: #1b211e; --muted: #56615a; --line: #c3cac1;
  --k: #7a1f2b; --k-soft: #f2e4e6; --k-line: #d9b3b9;
  --p: #1d3a7a; --p-soft: #e3e8f4; --p-line: #b1bfdd;
  --hearts: #b8302a; --diamonds: #8f6200; --clubs: #2b7230; --spades: #1d5aa3;
  --good: #22702a; --good-soft: #e1f0e0; --warn: #9a5200; --warn-soft: #f8ead6; --bad: #a3261e;
  --gold: #a87a10; --focus: #b5850f; --on-fill: #ffffff;
  --shadow: 0 1px 2px rgb(20 30 25 / 0.12), 0 6px 18px rgb(20 30 25 / 0.08);
  --font-display: "Rozha One", "Georgia", serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --table: #111613; --table-2: #171e1a; --surface: #1e2622; --ink: #edf1ec; --muted: #a2ada5; --line: #36413b;
    --k: #a33a4a; --k-soft: #2b1c20; --k-line: #6a3540; --p: #3a5cb0; --p-soft: #1a2234; --p-line: #3b4f80;
    --hearts: #ff8172; --diamonds: #e6b84c; --clubs: #74c87a; --spades: #86b6ff;
    --good: #7fd086; --good-soft: #1c2e1e; --warn: #f0b060; --warn-soft: #33270f; --bad: #ff8a80;
    --gold: #e0b44c; --focus: #f0c75a; --on-fill: #ffffff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 22px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --table: #111613; --table-2: #171e1a; --surface: #1e2622; --ink: #edf1ec; --muted: #a2ada5; --line: #36413b;
  --k: #a33a4a; --k-soft: #2b1c20; --k-line: #6a3540; --p: #3a5cb0; --p-soft: #1a2234; --p-line: #3b4f80;
  --hearts: #ff8172; --diamonds: #e6b84c; --clubs: #74c87a; --spades: #86b6ff;
  --good: #7fd086; --good-soft: #1c2e1e; --warn: #f0b060; --warn-soft: #33270f; --bad: #ff8a80;
  --gold: #e0b44c; --focus: #f0c75a; --on-fill: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 22px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--table); color: var(--ink);
  font: 16px/1.5 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 32px;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
.wrap { max-width: 1180px; margin: 0 auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Suit and camp tokens used everywhere */
.s-hearts { --suit: var(--hearts); } .s-diamonds { --suit: var(--diamonds); }
.s-clubs { --suit: var(--clubs); } .s-spades { --suit: var(--spades); }
.c-kaurava { --camp: var(--k); --camp-soft: var(--k-soft); --camp-line: var(--k-line); }
.c-pandava { --camp: var(--p); --camp-soft: var(--p-soft); --camp-line: var(--p-line); }
.suit { color: var(--suit); }
.marker {
  display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 6px;
  background: var(--camp); color: var(--on-fill); font-weight: 700; line-height: 1; flex: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 18px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700;
}
a.btn { text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--table); border-color: var(--ink); }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.pill.test { background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; }
.pill.draft { background: var(--warn-soft); color: var(--warn); }

/* ---------- Welcome ---------- */
.welcome { padding-block: 48px 24px; display: grid; gap: 28px; }
.title-block { display: grid; gap: 6px; }
.eyebrow { font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.title { font: 400 clamp(44px, 9vw, 88px)/0.95 var(--font-display); letter-spacing: -0.01em; }
.title .twin { color: var(--gold); }
.tagline { font-size: clamp(18px, 3vw, 24px); }
.count-line { color: var(--muted); font-variant-numeric: tabular-nums; }
.fan { display: flex; gap: 0; height: 120px; margin-block: 4px; }
.fan span {
  width: 74px; height: 104px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); display: grid; place-items: center; font-size: 34px; margin-right: -22px;
  transform: rotate(var(--rot)) translateY(var(--y));
}
.intro { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.intro section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.intro h2 { font: 400 22px/1.2 var(--font-display); margin-bottom: 8px; }
.intro ol, .intro ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.suit-legend { list-style: none; padding: 0 !important; }
.suit-legend li { display: flex; gap: 10px; align-items: baseline; }
.suit-legend b { font-size: 20px; width: 1.2em; text-align: center; }
.settings { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.settings label { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; cursor: pointer; }
.settings input { width: 20px; height: 20px; accent-color: var(--ink); }
.start-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---------- Header ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding-block: 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.bar .name { font: 400 26px/1 var(--font-display); }
.bar .name .twin { color: var(--gold); }
.stats { display: flex; gap: 18px; margin-left: auto; font-variant-numeric: tabular-nums; }
.stat { display: grid; line-height: 1.1; text-align: right; }
.stat b { font-size: 22px; }
.stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat.delta-up b { color: var(--good); } .stat.delta-down b { color: var(--bad); }
.bar-actions { display: flex; gap: 8px; }

/* ---------- Table layout ---------- */
.table { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
.hand { position: sticky; top: 12px; display: grid; gap: 14px; min-width: 0; }

.pile-row { display: flex; gap: 14px; align-items: center; }
.pile {
  position: relative; width: 84px; height: 116px; flex: none; border-radius: 10px; cursor: pointer; padding: 0;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow), 4px 4px 0 -1px var(--table-2), 4px 4px 0 0 var(--line);
  display: grid; place-items: center; font-weight: 700;
}
.pile::before {
  content: ""; position: absolute; inset: 7px; border-radius: 6px; border: 1.5px solid var(--gold);
  background: repeating-linear-gradient(45deg, transparent 0 6px, color-mix(in srgb, var(--gold) 16%, transparent) 6px 7px);
}
.pile span { position: relative; background: var(--surface); padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.pile[disabled] { cursor: not-allowed; opacity: 0.5; }
.pile.recovery::before { border-color: var(--warn); }
.pile-text { display: grid; gap: 2px; font-size: 14px; color: var(--muted); }
.pile-text strong { color: var(--ink); font-size: 16px; }

/* The card face: marker, suit, signature, statement. Nothing else. */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px 18px 18px; display: grid; gap: 8px; border-top: 6px solid var(--camp); position: relative;
}
.card-top { display: flex; align-items: center; justify-content: space-between; }
.card-top .suit { font-size: 30px; line-height: 1; }
.card .sig { font: 700 15px/1.3 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--suit); }
.card .stmt { font-size: 20px; line-height: 1.45; }
.card.placeholder { border: 2px dashed var(--line); border-top-width: 2px; box-shadow: none; background: transparent; color: var(--muted); min-height: 160px; place-content: center; text-align: center; }
.card.enter { animation: deal 0.35s ease-out; }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) rotate(-2deg); } to { opacity: 1; transform: none; } }

.feedback {
  min-height: 52px; border-radius: var(--r); padding: 10px 14px; border: 1px solid var(--line); background: var(--surface);
  display: flex; gap: 10px; align-items: flex-start;
}
.feedback .icon { font-weight: 700; flex: none; width: 1.4em; text-align: center; }
.feedback.good { background: var(--good-soft); border-color: var(--good); }
.feedback.good .icon { color: var(--good); }
.feedback.warn { background: var(--warn-soft); border-color: var(--warn); }
.feedback.warn .icon { color: var(--warn); }
.feedback .pts { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.correction-chip { font-size: 13px; font-weight: 700; color: var(--warn); }
.move-banner { border-radius: var(--r); padding: 10px 14px; background: var(--warn-soft); border: 1px solid var(--warn); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Camps and boxes ---------- */
.camps { display: grid; gap: 22px; min-width: 0; }
.camp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.camp-head h2 { font: 400 24px/1.1 var(--font-display); color: var(--camp); }
.camp-head p { margin: 0 0 0 auto; color: var(--muted); font-size: 14px; }
.boxes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.box {
  border-radius: 12px; border: 1.5px solid var(--camp-line); background: var(--camp-soft); padding: 10px; display: grid; gap: 8px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.box-head {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 2px; text-align: left; cursor: default;
  font-weight: 700; min-height: 36px; width: 100%; border-radius: 6px;
}
.box-head .count { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.targeting .box:not(.locked) { cursor: pointer; }
.targeting .box:not(.locked) .box-head { cursor: pointer; }
.targeting .box:not(.locked):hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--camp); }
.box.flash-good { box-shadow: 0 0 0 3px var(--good); }
.box.flash-warn { box-shadow: 0 0 0 3px var(--warn); }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.slot {
  min-height: 62px; border-radius: 8px; border: 1px dashed var(--camp-line); display: grid; place-items: center;
  font-size: 22px; color: color-mix(in srgb, var(--suit) 45%, transparent);
}
.mini {
  min-height: 62px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 6px 8px;
  text-align: left; display: grid; gap: 2px; align-content: start; cursor: pointer; font-size: 13px; line-height: 1.25; min-width: 0;
}
.mini .suit { font-size: 16px; line-height: 1; }
.mini .sig { font-weight: 700; overflow-wrap: anywhere; }
.mini.unconfirmed { border: 2px dashed var(--warn); background: var(--warn-soft); }
.mini .flag { font-size: 11px; color: var(--warn); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.targeting .mini { pointer-events: none; }
.box.locked { background: var(--surface); border-color: var(--camp); }
.box.locked .who { font: 400 20px/1.1 var(--font-display); color: var(--camp); }
.box.locked .result { font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); }
.legend b { font-size: 17px; }

/* ---------- Dialogs ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; background: var(--table); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
  width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgb(10 14 12 / 0.6); }
.dlg { padding: 22px; display: grid; gap: 16px; }
.dlg h2 { font: 400 28px/1.15 var(--font-display); }
.dlg .lede { margin: 0; color: var(--muted); }
.four { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.four .card { box-shadow: none; padding: 12px 14px; }
.four .card .stmt { font-size: 16px; }
.dim { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.names { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.names .btn { border-radius: 10px; min-height: 52px; font-size: 17px; }
.name-form { display: flex; gap: 10px; flex-wrap: wrap; }
.name-input {
  flex: 1 1 220px; min-width: 0; min-height: 52px; padding: 10px 16px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink); font: 400 20px/1.2 var(--font-body);
}
.name-input:focus-visible { border-color: var(--focus); outline: none; }
.names .btn.wrong { text-decoration: line-through; border-color: var(--bad); color: var(--bad); }
.tries { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.tries i { font-style: normal; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tries i.used { opacity: 0.4; text-decoration: line-through; }
.tries i.now { border-color: var(--ink); color: var(--ink); font-weight: 700; }
.reveal-name { font: 400 clamp(36px, 7vw, 54px)/1 var(--font-display); color: var(--camp); }
.clue-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.clue-list li { display: grid; grid-template-columns: 1.6em minmax(0, 1fr); gap: 2px 8px; }
.clue-list li > .suit { font-size: 20px; grid-row: span 2; }
.clue-list .why { color: var(--muted); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.status-msg { margin: 0; padding: 10px 14px; border-radius: var(--r); }
.status-msg.good { background: var(--good-soft); color: var(--ink); border: 1px solid var(--good); }
.status-msg.warn { background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn); }

.paused { position: fixed; inset: 0; background: var(--table); display: grid; place-items: center; z-index: 50; padding: 24px; text-align: center; }
.paused h2 { font: 400 44px/1 var(--font-display); margin-bottom: 16px; }

/* ---------- Results ---------- */
.results { padding-block: 24px; display: grid; gap: 22px; }
.big-score { font: 400 clamp(64px, 14vw, 120px)/0.9 var(--font-display); color: var(--gold); font-variant-numeric: tabular-nums; }
.result-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.panel h2 { font: 400 22px/1.2 var(--font-display); margin-bottom: 10px; }
.breakdown { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.breakdown td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.breakdown td:nth-child(2), .breakdown td:nth-child(3) { text-align: right; padding-left: 12px; }
.breakdown tfoot td { font-weight: 700; border-bottom: 0; }
.char-results { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.char-results li { display: flex; gap: 10px; align-items: center; }
.char-results .n { font-weight: 700; }
.char-results .m { margin-left: auto; color: var(--muted); font-size: 14px; }
.reflect { font-size: 19px; font-style: italic; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .table { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .hand {
    top: 0; padding-top: max(8px, env(safe-area-inset-top, 0px)); padding-bottom: 8px; z-index: 5;
    background: var(--table); margin-inline: -16px; padding-inline: 16px; border-bottom: 1px solid var(--line);
  }
  .card .stmt { font-size: 17px; }
  .card { padding: 12px 14px 14px; }
  .pile { width: 64px; height: 88px; }
  .stats { gap: 12px; } .stat b { font-size: 18px; }
  .bar .name { font-size: 22px; }
  .feedback { min-height: 0; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
