/* THE KING'S FEVER — wireframe. Greyscale on purpose: layout first, look second.
   A skin (skins/<name>.css, loaded with ?style=<name>) only has to redefine the
   tokens below and may add art. */

:root {
  --bg: #efefec;
  --panel: #ffffff;
  --ink: #1b1b1b;
  --dim: #7a7a76;
  --line: #cfcfca;
  --card: #ffffff;
  --card-ink: #1b1b1b;
  --go: #1b1b1b;
  --go-ink: #ffffff;
  --warn: #a8660a;
  --up: #1b1b1b;
  --down: #7a7a76;
  --rise: #1b1b1b;
  --fall: #1b1b1b;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: var(--font);
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

#app { height: 100dvh; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; position: relative; }

/* Bars reach the window edges. */
.top, .dock, .court {
  background: var(--panel);
  box-shadow: 0 0 0 100vmax var(--panel);
  clip-path: inset(0 -100vmax);
}

.label { font-size: 13px; color: var(--dim); }

/* ---- buttons ---- */
.seg { display: flex; }
.seg button, .calls button, .stepper button, .chip, .toggle {
  min-height: 44px; padding: 0 14px; background: transparent; border: 1.5px solid var(--ink); border-radius: var(--radius); font-weight: 600;
}
.seg button { flex: 1; border-radius: 0; margin-left: -1.5px; }
.seg button:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.seg button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.seg button[aria-pressed="true"], .calls button[aria-pressed="true"], .toggle[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.go {
  min-height: 52px; width: 100%; border: 0; border-radius: var(--radius); background: var(--go); color: var(--go-ink);
  font-size: 18px; font-weight: 700; letter-spacing: 0.02em;
}
.go.warn { background: var(--warn); color: #fff; }
.plain { background: none; border: 0; min-height: 44px; padding: 0 10px; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }

/* ---- home / over ---- */
.home { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 16px; padding: calc(16px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); }
.over { justify-content: center; }
/* Key art stands on the wordmark: it fills what the controls leave. */
.art { flex: 1; min-height: 90px; margin: calc(-16px - env(safe-area-inset-top)) -20px 0; display: grid; place-items: center; border-bottom: 1.5px dashed var(--line); color: var(--dim); font-size: 14px; }
.wordmark, .home h1 { font-family: var(--display); font-size: clamp(34px, 9vw, 60px); line-height: 1; margin: 0; letter-spacing: 0.01em; }
.wordmark img { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; }
.lede { margin: 0; color: var(--dim); font-size: 16px; line-height: 1.45; }
.field { display: grid; gap: 6px; }
.final { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.final li { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 18px; }
.final li.win { font-weight: 700; }

/* ---- game ---- */
.top { display: flex; align-items: center; gap: 14px; padding: calc(env(safe-area-inset-top) + 4px) 8px 4px 16px; border-bottom: 1px solid var(--line); }
.stat { font-size: 14px; font-weight: 600; white-space: nowrap; }
@media (max-width: 380px) { .top { gap: 8px; } .top .plain { padding: 0 6px; } }
.spacer { flex: 1; }

/* One row up to four physicians, two rows of three for five or six. */
.court { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); border-bottom: 1px solid var(--line); }
.seat { padding: 8px 12px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: -1px; display: grid; gap: 2px; }
.seat.me { background: var(--bg); }
.who { display: flex; gap: 6px; align-items: baseline; }
.name { font-weight: 700; font-size: 14px; }
.lvl { font-size: 11px; color: var(--dim); }
.standing { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1.1; }
.pips { display: flex; gap: 4px; }
.pip { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink); }
.pip.on { background: var(--ink); }
.line { font-size: 12px; color: var(--dim); min-height: 16px; }
.seat.up .line { color: var(--up); font-weight: 700; }
.seat.down .line { color: var(--down); font-weight: 700; }
.seat.out { opacity: 0.45; }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 16px; }
.cards { display: flex; align-items: center; gap: clamp(12px, 5vw, 28px); }
.cards figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
figcaption { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.card {
  width: clamp(84px, 26vw, 132px); aspect-ratio: 5 / 7; display: grid; place-items: center;
  background: var(--card); color: var(--card-ink); border: 2px solid var(--card-ink); border-radius: 8px;
  font-family: var(--display); font-size: clamp(40px, 13vw, 68px); font-weight: 700;
}
.card.blank { border-style: dashed; color: var(--dim); border-color: var(--line); background: transparent; }
.card.tie { border-style: dashed; }
.card.rise { box-shadow: inset 0 -8px 0 var(--rise); }
.card.fall { box-shadow: inset 0 8px 0 var(--fall); }
.vs { font-size: 28px; color: var(--dim); }
.verdict { margin: 0; text-align: center; font-size: 16px; font-weight: 600; min-height: 1.4em; }

.dock { border-top: 1px solid var(--line); padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.chartline { display: grid; gap: 2px; }
.fever { width: 100%; height: 44px; display: block; }
.fever polyline { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.fever .mid { stroke: var(--line); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.fever circle { fill: var(--ink); }
.count { font-size: 12px; color: var(--dim); }
.calls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calls button { min-height: 52px; font-size: 18px; }
.calls [data-v="rise"][aria-pressed="true"] { background: var(--rise); border-color: var(--rise); }
.calls [data-v="fall"][aria-pressed="true"] { background: var(--fall); border-color: var(--fall); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; }
.stepper button { width: 44px; padding: 0; font-size: 20px; }
.stepper output { min-width: 48px; text-align: center; font-family: var(--display); font-size: 24px; font-weight: 700; }
.toggle { margin-left: auto; }
.hint { margin: 0; font-size: 14px; }
.hint.warn { color: var(--warn); font-weight: 600; }
.status { margin: 0; font-size: 15px; min-height: 22px; }
.status b { font-family: var(--display); font-size: 20px; margin-right: 4px; }

.links { display: flex; justify-content: center; flex-wrap: wrap; }

/* ---- the deck chart ---- */
.deck { margin: 4px 0 16px; display: grid; gap: 6px; }
.bars { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; align-items: end; }
.bars .col { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.bars i { display: block; width: 100%; background: var(--ink); border-radius: 2px 2px 0 0; }
.bars .n { font-size: 11px; font-weight: 700; line-height: 1; }
.bars .v { font-size: 11px; color: var(--dim); line-height: 1; }
.deck figcaption { text-align: center; text-transform: none; letter-spacing: 0; }
.credits { padding-left: 18px; margin: 0 0 12px; display: grid; gap: 4px; line-height: 1.4; }
.sheet h3 { margin: 12px 0 6px; font-size: 15px; }
.sheet ul { padding-left: 20px; margin: 0 0 16px; display: grid; gap: 8px; line-height: 1.4; }
.sheet a { color: inherit; }

/* ---- rules sheet ---- */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-body { background: var(--panel); color: var(--ink); width: 100%; max-width: 720px; max-height: 90dvh; overflow: auto; padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet h2 { margin: 0 0 8px; font-family: var(--display); }
.sheet ol { padding-left: 20px; margin: 0 0 16px; display: grid; gap: 8px; line-height: 1.4; }

@media (max-height: 700px) {
  .standing { font-size: 22px; }
  .card { width: clamp(70px, 20vw, 104px); font-size: clamp(34px, 10vw, 52px); }
  .calls button, .go { min-height: 46px; }
  .fever { height: 32px; }
}
