:root {
  --bg: #efe7d8; --ink: #24201a; --muted: #6f6556; --line: #b9ab92; --panel: #f7f1e6;
  --accent: #8c2f1b; --accent-ink: #fff8ee; --side0: #f2e8d2; --side1: #2b2622;
  --hi: #c7801a; --face: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--body); overflow: hidden; -webkit-tap-highlight-color: transparent; }
#app { height: 100%; }
.screen { height: 100%; height: 100dvh; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { min-height: 44px; padding: 8px 14px; background: transparent; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; text-align: left; touch-action: manipulation; }
button:hover { border-color: var(--ink); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--hi); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.quiet { border-color: transparent; color: var(--muted); }
button.link { border: 0; padding: 0 4px; color: var(--muted); font-size: 14px; }
small { color: inherit; opacity: .75; font-size: 13px; }

/* menu */
#menu { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.art { min-width: 0; min-height: 0; padding: 20px; display: flex; }
.art svg { flex: 1; min-width: 0; width: 100%; height: 100%; }
.front { padding: 28px 28px 14px; display: flex; flex-direction: column; gap: 16px; border-left: 1px solid var(--line); background: var(--panel); overflow: auto; }
h1 { font: 500 40px/1.05 var(--face); margin: 0 0 6px; letter-spacing: -.01em; }
.lede { margin: 0; color: var(--muted); }
#front-body { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack button { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
.note { margin: 0; padding: 8px 10px; border-left: 3px solid var(--accent); font-size: 14px; }
.levels { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.levels button { width: 100%; display: flex; justify-content: space-between; align-items: baseline; }
.seg { display: flex; gap: 0; }
.seg button { flex: 1; text-align: center; border-radius: 0; margin-left: -1px; }
.seg button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.rules { overflow: auto; font-size: 15px; }
.rules p { margin: 0 0 10px; }
.code { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.code span { display: flex; gap: 8px; }
.code input { flex: 1; min-width: 0; min-height: 44px; padding: 0 10px; background: transparent; border: 1px solid var(--line); border-radius: 3px; font-size: 18px; letter-spacing: .12em; color: var(--ink); }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.tools { display: flex; align-items: center; gap: 6px; }
sg-exit, sg-fullscreen { --sg-exit-bg: transparent; --sg-exit-color: var(--ink); --sg-exit-size: 44px; --sg-exit-radius: 3px; --sg-exit-border: 1px solid var(--line); --sg-fullscreen-bg: transparent; --sg-fullscreen-color: var(--ink); --sg-fullscreen-size: 44px; --sg-fullscreen-radius: 3px; --sg-fullscreen-border: 1px solid var(--line); }

/* table */
#play { display: grid; grid-template-columns: minmax(0, 1fr) 280px; grid-template-rows: auto auto 1fr auto auto; grid-template-areas: "stage top" "stage status" "stage acts" "stage you" "stage ."; column-gap: 0; }
#stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; padding: 12px; display: flex; }
#board { flex: 1; min-width: 0; width: 100%; height: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.strip { display: grid; grid-template-columns: 18px minmax(0, auto) minmax(0, 1fr) auto; column-gap: 8px; align-items: center; min-height: 52px; padding: 8px 14px; background: var(--panel); border-left: 1px solid var(--line); }
#top { grid-area: top; border-bottom: 1px solid var(--line); }
#you { grid-area: you; border-top: 1px solid var(--line); }
.strip b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strip em { font-style: normal; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tally { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.to-move { grid-column: 1 / -1; font-style: normal; font-size: 12px; letter-spacing: .04em; color: var(--accent); }
.mark { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--ink); }
.mark[data-side="0"] { background: var(--side0); }
.mark[data-side="1"] { background: var(--side1); }
#status { grid-area: status; margin: 0; padding: 12px 14px; min-height: 48px; font-family: var(--face); font-size: 18px; background: var(--panel); border-left: 1px solid var(--line); }
#acts { grid-area: acts; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 2px 14px 14px; background: var(--panel); border-left: 1px solid var(--line); }
#act-btns { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; }
#act-btns button { flex: 1 1 auto; text-align: center; }
#choice { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; background: var(--panel); border: 1px solid var(--ink); border-radius: 3px; }

/* sheet */
#sheet { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: color-mix(in srgb, var(--ink) 45%, transparent); z-index: 5; }
.card { width: min(380px, 100%); max-height: 100%; overflow: auto; padding: 22px; background: var(--panel); border: 1px solid var(--ink); border-radius: 3px; }
.card h2 { font: 500 28px/1.1 var(--face); margin: 0 0 8px; }
.card p { margin: 0 0 10px; }
.delta { font-variant-numeric: tabular-nums; color: var(--muted); min-height: 1.4em; }
#lb { margin: 0 0 14px; padding: 0 0 0 26px; font-size: 15px; }
#lb:empty { display: none; }
#lb li { padding: 3px 0; border-bottom: 1px solid var(--line); }
#lb li > * { display: inline-block; }
#lb li b { float: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.room-code { font: 500 40px/1 var(--face); letter-spacing: .12em; text-align: center; }
#n-link { width: 100%; min-height: 44px; padding: 0 10px; margin-bottom: 10px; background: transparent; border: 1px solid var(--line); border-radius: 3px; font-size: 13px; color: var(--muted); }

/* board primitives */
[data-spot] { cursor: pointer; }
.hit { fill: transparent; }
.spot-dot { fill: var(--hi); opacity: .85; pointer-events: none; }
.spot-ring { fill: none; stroke: var(--hi); pointer-events: none; }
.last-mark { fill: var(--hi); opacity: .22; pointer-events: none; }
.hint-mark { fill: none; stroke: var(--accent); stroke-dasharray: 4 3; pointer-events: none; }
.pc { transform-box: fill-box; transform-origin: center; }

@media (max-aspect-ratio: 1/1), (max-width: 720px) {
  #menu { grid-template-columns: 1fr; grid-template-rows: minmax(0, 38%) minmax(0, 1fr); }
  .art { padding: 12px 16px 6px; }
  .front { padding: 14px 16px 8px; gap: 10px; border-left: 0; border-top: 1px solid var(--line); }
  h1 { font-size: 32px; }
  #play { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto auto auto; grid-template-areas: "top" "stage" "you" "status" "acts"; }
  #stage { padding: 4px 6px; }
  .strip, #status, #acts { border-left: 0; }
  .strip { min-height: 40px; padding: 4px 12px; grid-template-columns: 16px auto minmax(0, 1fr) auto auto; }
  .to-move { grid-column: auto; }
  #status { min-height: 38px; padding: 6px 12px; font-size: 16px; }
  #acts { padding: 0 12px calc(10px + env(safe-area-inset-bottom)); flex-wrap: nowrap; }
  #act-btns { flex-wrap: nowrap; }
  #act-btns button { padding: 6px 8px; flex: 1 1 0; min-width: 0; }
}
@media (max-height: 460px) and (min-aspect-ratio: 1/1) {
  .strip { min-height: 40px; padding: 4px 12px; }
  #status { min-height: 34px; padding: 6px 12px; font-size: 15px; }
  #act-btns button { min-height: 40px; }
  .art { display: none; }
  #menu { grid-template-columns: 1fr; }
  .front { border-left: 0; flex-direction: row; flex-wrap: wrap; padding: 12px 16px; }
  .front header { flex: 0 0 40%; }
  #front-body { flex: 1 1 50%; }
  .foot { flex: 1 0 100%; }
}

/* catalog cover */
body.cover #menu { display: block; }
body.cover .front, body.cover #play, body.cover #sheet { display: none; }
body.cover .art { position: fixed; inset: 0; padding: 0; }
