/* Pike Poker Lab: "Felt & gold". Single deliberate dark look: poker-table green, gold trim, ivory card faces.
   Layout: one phone-width column (max 560px) with a fixed bottom tab bar. */
:root {
  --felt: #0d3527; --felt-hi: #15513b; --felt-lo: #0a2c20;
  --card: #0a2b20; --card-2: #0f3a2b; --line: #23503f; --chip: #134434;
  --fg: #f1ead8; --dim: #a9bfae; --gold: #d9b25f; --gold-deep: #8a7038; --on-gold: #1d1606;
  --good: #8fe0a9; --bad: #ff9b8a; --warn: #f2cf7a; --close: #6b5a2e;
  --face: #fbf7ec; --ink: #16181c; --red: #c2252f;
  --s1: #d9b25f; --s2: #8fe0a9; --s3: #ff9b8a; --s4: #8cc8ff; --s5: #d3a6ff;
  --f-display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --f-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--fg); font-family: var(--f-body); font-size: 15px; line-height: 1.45;
  background: var(--felt-lo) radial-gradient(120% 60% at 50% 0%, var(--felt-hi) 0%, var(--felt) 55%, var(--felt-lo) 100%) fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.app { max-width: 560px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.view { display: grid; gap: 14px; }

/* Top bar */
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 40px; }
.brand { font-family: var(--f-display); font-size: 1.45rem; letter-spacing: .01em; line-height: 1.1; }
.brand i { font-style: normal; color: var(--gold); }
.page-title { font-family: var(--f-display); font-size: 1.6rem; margin: 0; line-height: 1.15; font-weight: 400; text-wrap: balance; }
.sub { color: var(--dim); font-size: .85rem; margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); text-decoration: none; font-size: .9rem; background: none; border: 0; padding: 6px 0; cursor: pointer; }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: var(--dim); text-decoration: none; }
.iconbtn svg { width: 20px; height: 20px; }

/* Cards (panels) */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; box-shadow: inset 0 0 0 1px rgba(217,178,95,.06); min-width: 0; }
.panel.hero { border-color: var(--gold-deep); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); }
.link { color: var(--gold); font-size: .82rem; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; }
.big { font-family: var(--f-display); font-size: 2.4rem; line-height: 1; color: var(--gold); }
.big.neg { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stat b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.stat span { font-size: .7rem; color: var(--dim); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 12px; display: grid; gap: 4px; text-align: left; cursor: pointer; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--gold); }
.tile strong { font-family: var(--f-display); font-weight: 400; font-size: 1.15rem; }
.tile small { color: var(--dim); font-size: .76rem; }

/* Buttons */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--fg); min-height: 46px; transition: transform .1s, border-color .15s, background .15s; }
.btn:hover { border-color: var(--gold); }
.btn:active { transform: scale(.98); }
.btn.gold { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.btn.danger { color: var(--bad); border-color: rgba(255,155,138,.4); }
.btn.small { min-height: 36px; padding: 7px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-btns.three { grid-template-columns: 1fr 1fr 1fr; }

/* Segmented control */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--dim); font-size: .82rem; cursor: pointer; }
.seg button.on { background: var(--chip); color: var(--fg); border-color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .74rem; padding: 3px 9px; border-radius: 99px; background: var(--chip); color: var(--fg); }
.pill { font-size: .7rem; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.pill.good { color: var(--good); } .pill.bad { color: var(--bad); } .pill.warn { color: var(--warn); } .pill.gold { color: var(--gold); } .pill.dim { color: var(--dim); }
.up { color: var(--good); } .down { color: var(--bad); } .muted { color: var(--dim); }

/* Playing cards */
.hand { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pc { width: 50px; height: 70px; border-radius: 7px; background: var(--face); color: var(--ink); display: inline-grid; place-items: center; align-content: center; font-weight: 700; font-size: 1.15rem; line-height: 1.05; text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.35); border: 1px solid var(--gold); flex: none; }
.pc.red { color: var(--red); }
.pc.sm { width: 34px; height: 48px; font-size: .85rem; border-radius: 5px; }
.pc.empty { background: transparent; border: 1px dashed var(--line); color: var(--dim); box-shadow: none; font-weight: 400; }
.pc.hl { outline: 2px solid var(--good); outline-offset: 1px; }
.board-gap { width: 6px; }
.vs { font-size: .8rem; color: var(--dim); }

/* Lists */
.rows { display: grid; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; }
.rows > .item:first-child { border-top: 0; padding-top: 2px; }
.item .t { font-size: .92rem; min-width: 0; overflow-wrap: anywhere; }
.item .m { font-size: .72rem; color: var(--dim); grid-column: 1; }
.item .r { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 22px 12px; display: grid; gap: 10px; justify-items: center; color: var(--dim); }
.empty-state strong { color: var(--fg); font-family: var(--f-display); font-weight: 400; font-size: 1.2rem; }

/* Forms */
form.panel { gap: 12px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: .78rem; color: var(--dim); }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--felt-lo); color: var(--fg); min-height: 44px; }
.field textarea { min-height: 70px; resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); outline: none; }
.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.section-h { font-family: var(--f-display); font-weight: 400; font-size: 1.1rem; margin: 6px 0 0; }
.hint { font-size: .76rem; color: var(--dim); margin: 0; }
.cardslot { display: flex; gap: 6px; flex-wrap: wrap; }
.cardslot button { background: none; border: 0; padding: 0; cursor: pointer; }

/* Trainer */
.scenario { font-size: .95rem; }
.feedback { padding: 10px 12px; border-radius: 9px; background: var(--chip); font-size: .9rem; display: grid; gap: 4px; }
.feedback b.ok { color: var(--good); } .feedback b.no { color: var(--bad); } .feedback b.close { color: var(--warn); }
.answers { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.answers .btn.right { border-color: var(--good); color: var(--good); }
.answers .btn.wrong { border-color: var(--bad); color: var(--bad); }
.progress { height: 6px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); transition: width .3s; }

/* 13x13 range grid */
.range { display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; width: 100%; }
.range button { aspect-ratio: 1; min-width: 0; border: 0; padding: 0; border-radius: 3px; font-size: clamp(.46rem, 2.1vw, .68rem); font-weight: 700; background: var(--felt-lo); color: var(--dim); cursor: pointer; line-height: 1; }
.range button.in { background: var(--gold); color: var(--on-gold); }
.range button.mid { background: var(--close); color: var(--fg); }
.range button.me { outline: 2px solid var(--fg); outline-offset: 1px; position: relative; z-index: 1; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .74rem; color: var(--dim); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
input[type=range] { width: 100%; accent-color: var(--gold); }

/* Charts */
svg.chart { width: 100%; display: block; overflow: visible; }
svg.chart text { fill: var(--dim); font-size: 10px; font-family: var(--f-body); }
.keys { display: flex; flex-wrap: wrap; gap: 10px; font-size: .75rem; color: var(--dim); }
.keys i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }

/* Tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
th { text-align: left; font-weight: 500; color: var(--dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: 6px 6px 6px 0; }
td { padding: 8px 6px 8px 0; border-top: 1px solid var(--line); }
td.n, th.n { text-align: right; }

/* Bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(10,43,32,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.tabs nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabs a { padding: 9px 2px 11px; font-size: .68rem; text-align: center; color: var(--dim); text-decoration: none; display: grid; gap: 3px; justify-items: center; }
.tabs a svg { width: 21px; height: 21px; }
.tabs a.on { color: var(--gold); }

/* Sheet (confirm / card picker) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: grid; align-items: end; justify-items: center; }
.sheet { width: 100%; max-width: 560px; background: var(--card-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 12px; max-height: 88vh; overflow-y: auto; }
.sheet h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.25rem; }
.picker { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.picker button { aspect-ratio: 5 / 7; min-width: 0; border-radius: 4px; border: 1px solid var(--gold-deep); background: var(--face); color: var(--ink); font-weight: 700; font-size: clamp(.55rem, 2.6vw, .8rem); padding: 0; cursor: pointer; line-height: 1.05; }
.picker button.red { color: var(--red); }
.picker button[disabled] { opacity: .18; cursor: default; }
.picker button.sel { outline: 2px solid var(--good); }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--face); color: var(--ink); padding: 10px 16px; border-radius: 99px; font-weight: 700; font-size: .88rem; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: calc(100% - 32px); text-align: center; }
.notice { font-size: .74rem; color: var(--dim); text-align: center; padding: 4px 8px; }
.loading { color: var(--dim); text-align: center; padding: 30px 0; }

@media (max-width: 380px) { .stats.four { grid-template-columns: repeat(2, 1fr); } .fields3 { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
