:root {
  --field: #0f2a1d;
  --field-2: #174a32;
  --accent: #1f9d55;
  --gold: #e8b923;
  --ink: #15202b;
  --muted: #5d6b78;
  --line: #dde3e8;
  --bg: #f3f5f2;
  --card: #fff;
  --mine: #d9f2e3;
  --danger: #c0392b;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--field-2); }
h1 { font-size: 1.45rem; margin: .2rem 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  background: var(--field); color: #fff; padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top));
}
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: .5rem; }
.ball { width: 22px; height: 14px; background: #8b4513; border-radius: 50%; position: relative; display: inline-block; }
.ball::after { content: ""; position: absolute; left: 6px; right: 6px; top: 6px; height: 2px; background: #fff; }
main { max-width: 640px; margin: 0 auto; padding: .9rem .75rem 3rem; }

.card { display: block; background: var(--card); border-radius: var(--radius); padding: 1rem; margin: 0 0 .9rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); color: inherit; text-decoration: none; }
.pool-link:active { background: #f7faf8; }
.foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 0 0 2rem; }
.hero { text-align: center; padding: 2.5rem 1rem; }
.hero h1 { font-size: 2rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hint { display: block; color: var(--muted); font-size: .8rem; font-weight: normal; margin-top: .2rem; }
td .hint, .score-label .hint { display: block; }
.center { text-align: center; }
.pre.recipe { white-space: pre; font-size: .72rem; }
.nowrap { white-space: nowrap; }
pre { white-space: pre-wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.stack { display: grid; gap: .6rem; max-width: 320px; margin: 1.2rem auto; }
.stack-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.tag, .pill { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 99px; background: #e9edf0; color: var(--muted); }
.pill.open { background: var(--mine); color: var(--field-2); }
.pill.done { background: #fff3cc; color: #7a5b00; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* forms */
.form { display: grid; gap: .8rem; }
label { display: grid; gap: .25rem; font-size: .9rem; font-weight: 600; }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: normal; }
label.check input { margin-top: .25rem; width: 1.1rem; height: 1.1rem; }
input, select, textarea {
  font: inherit; font-weight: normal; width: 100%; padding: .65rem .7rem; border: 1px solid #c6ced5; border-radius: 9px; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin: 0; display: grid; gap: .7rem; min-width: 0; }
fieldset[disabled] { opacity: .6; }
legend { font-weight: 700; padding: 0 .3rem; }
.two, .three, .four { display: grid; gap: .6rem; }
.two { grid-template-columns: 1fr 1fr; }
.three { grid-template-columns: 1fr 1fr 2fr; }
.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
.payout-sum.bad { color: var(--danger); }
.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: .4rem; min-height: 44px; padding: .55rem 1.1rem;
  border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--field-2); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.danger { background: var(--danger); }
.btn.small { min-height: 36px; padding: .35rem .8rem; font-size: .88rem; }
.btn[disabled] { opacity: .6; }
.copy-row { display: flex; gap: .5rem; margin-bottom: .4rem; }
.copy-row input { font-size: .85rem; }

.flash { padding: .7rem .9rem; border-radius: 10px; background: #e7f6ec; color: #135c32; margin: 0 0 .9rem; font-size: .92rem; }
.flash.error { background: #fdecea; color: #8e2a1e; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* pool header */
.pool-head { margin-bottom: .6rem; }
.pool-head .status { font-size: .88rem; color: var(--muted); margin-bottom: .5rem; }
.live { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem; background: var(--field); color: #fff; padding: .55rem .8rem; border-radius: 10px; margin-bottom: .6rem; }
.live strong { font-size: 1.2rem; }
.live .muted { color: #b9d3c4; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4d4d; align-self: center; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: .5rem; }
.tabs button { flex: 1; font: inherit; font-size: .82rem; font-weight: 700; padding: .45rem .3rem; border: 1px solid var(--line); background: #fff; border-radius: 8px; color: var(--muted); }
.tabs-label { align-self: center; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; padding-right: .2rem; }
.tabs button.active { background: var(--field); color: #fff; border-color: var(--field); }

/* grid */
.grid-wrap { background: var(--card); border-radius: var(--radius); padding: .6rem .5rem .4rem; margin-bottom: .9rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.team-across { text-align: center; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--field-2); margin: 0 0 .3rem 1.4rem; }
.grid-row { display: flex; align-items: stretch; gap: .2rem; }
.team-down { width: 1.2rem; display: flex; align-items: center; justify-content: center; }
.team-down span { writing-mode: vertical-rl; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--field-2); white-space: nowrap; }
.grid { flex: 1; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 2px; }
.grid > * { aspect-ratio: 1; min-width: 0; }
.hd { display: flex; align-items: center; justify-content: center; background: var(--field); color: var(--gold); font-weight: 800; font-size: clamp(.8rem, 3.4vw, 1.05rem); border-radius: 4px; }
.corner { background: transparent; }
.cell {
  border: 0; padding: 0; margin: 0; border-radius: 4px; font: inherit; font-size: clamp(.6rem, 2.7vw, .85rem); font-weight: 700;
  background: #eef1ee; color: var(--ink); cursor: pointer; overflow: hidden; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.cell.free { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.cell.free:hover { background: #f1faf4; }
.cell.taken { background: #e3e8e5; }
.cell.mine { background: var(--mine); box-shadow: inset 0 0 0 2px var(--accent); color: var(--field-2); }
.cell.win { background: var(--gold); color: #3d2e00; box-shadow: inset 0 0 0 2px #b38900; }
.cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* bottom sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 20; }
.sheet[hidden] { display: none; }
.sheet-body { width: 100%; max-width: 640px; margin: 0 auto; background: #fff; border-radius: 16px 16px 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
.sheet-title { font-weight: 800; font-size: 1.1rem; }
.sheet-text { margin: .3rem 0 .9rem; color: var(--muted); }
.sheet-actions { display: grid; gap: .5rem; }

/* tables & misc */
table.payouts { width: 100%; border-collapse: collapse; font-size: .9rem; }
.payouts th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: .3rem .3rem; }
.payouts td { padding: .5rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.payouts .num { text-align: right; }
.payouts tr.won td { background: #fffbe8; }
.payouts tr.rolled td, .payouts tr.unclaimed td { color: var(--muted); }
code.hash { display: block; font-size: .75rem; word-break: break-all; background: #f1f3f4; padding: .4rem .5rem; border-radius: 6px; }
pre.recipe { white-space: pre; font-size: .72rem; }
.nowrap { white-space: nowrap; }
pre { white-space: pre-wrap; word-break: break-word; background: #f6f7f8; padding: .6rem; border-radius: 8px; overflow-x: auto; }
dl.kv dt { font-weight: 700; font-size: .85rem; margin-top: .6rem; }
dl.kv dd { margin: .2rem 0 0; }
textarea.mono { font-size: .78rem; }
.checks { list-style: none; padding: 0; }
.checks li { padding: .3rem 0; }
.pass { color: #137a3a; font-weight: 600; }
.fail { color: var(--danger); font-weight: 600; }
ol.log { padding-left: 1.4rem; margin: 0; }
ol.log li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
details summary { cursor: pointer; }
.score-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: .4rem; align-items: center; margin-bottom: .5rem; }
.score-row label { font-weight: normal; }
.score-label { font-weight: 700; font-size: .9rem; }
