:root {
  --bg: #e9f3fb; --fg: #13283a; --muted: #5b7187; --card: #ffffff; --line: #cfe0ee;
  --accent: #1f7ae0; --accent-fg: #ffffff; --good: #1a9e5c; --warn: #d9822b; --bad: #d64545;
  --ice: #bfe3f7; --ice2: #a9d7f0; --snow: #f7fbff; --snow2: #dbe9f3; --shadow: 0 10px 30px rgba(19, 40, 58, .12);
}
:root[data-theme="dark"], :root:not([data-theme="light"]).sys-dark {
  --bg: #0d1a26; --fg: #e8f1f8; --muted: #93a8bb; --card: #142636; --line: #244057;
  --accent: #5aa9ff; --accent-fg: #06192b; --ice: #7fb6d8; --ice2: #6aa6cc; --snow: #e6f0f7; --snow2: #c3d4e2; --shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 560px; margin: 0 auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 100%; }
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
header h1 { font-size: 18px; margin: 0; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row.right { justify-content: flex-end; }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat.par b { color: var(--accent); }
.stat.over b { color: var(--warn); }
.board { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; }
canvas { display: block; width: 100%; height: auto; max-width: 100%; border-radius: 10px; touch-action: none; image-rendering: pixelated; }
.pad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 54px); gap: 6px; justify-content: center; margin-top: 4px; }
.pad button { border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 12px; font-size: 22px; cursor: pointer; }
.pad button:active { background: var(--line); }
.pad .u { grid-column: 2; grid-row: 1; } .pad .l { grid-column: 1; grid-row: 2; } .pad .d { grid-column: 2; grid-row: 2; } .pad .r { grid-column: 3; grid-row: 2; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 12px; padding: 10px 14px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-size: 16px; padding: 12px 22px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }
.tiny { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.overlay { position: absolute; inset: 0; border-radius: 16px; display: none; align-items: center; justify-content: center; padding: 12px; background: rgba(10, 25, 40, .72); backdrop-filter: blur(3px); z-index: 5; }
.overlay.show { display: flex; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: 100%; max-width: 360px; max-height: 100%; overflow: auto; text-align: center; box-shadow: var(--shadow); }
.box h2 { margin: 0 0 6px; font-size: 21px; }
.box p { margin: 6px 0; color: var(--muted); font-size: 14px; }
.stars { font-size: 30px; letter-spacing: 4px; margin: 4px 0; color: #f5b73a; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; font-size: 12px; margin: 8px 0 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.lg-rock { background: #7c8794; } .lg-water { background: #2566a8; } .lg-snow { background: #f7fbff; } .lg-goal { background: #f5b73a; }
.field { text-align: left; margin: 8px 0; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
input[type=text] { width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); font: inherit; outline: none; }
input:focus { border-color: var(--accent); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 10px; }
.mode { border: 2px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 12px; padding: 10px 8px; cursor: pointer; text-align: center; }
.mode b { display: block; font-size: 14px; }
.mode small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.mode.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.msg { display: none; margin: 8px 0; padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.msg.show { display: block; }
.msg.err { background: rgba(214, 69, 69, .12); color: var(--bad); }
.msg.ok { background: rgba(26, 158, 92, .12); color: var(--good); }
.score-line { font-size: 15px; }
.score-line b { font-variant-numeric: tabular-nums; }
.score-line span { color: var(--accent); font-weight: 700; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.tab { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 6px 14px; font-weight: 700; cursor: pointer; font-size: 13px; }
.tab.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.boardlist { list-style: none; margin: 0; padding: 0; text-align: left; max-height: 300px; overflow: auto; }
.boardlist li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.boardlist .rk { width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; }
.boardlist .nm { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boardlist .lv { color: var(--muted); font-size: 12px; }
.boardlist .tt { font-variant-numeric: tabular-nums; font-weight: 700; }
.boardlist li.me { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 8px; }
.boardlist .empty { color: var(--muted); justify-content: center; }
footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: auto; }
footer a { color: var(--muted); }
@media (max-width: 400px) { .hud { gap: 4px; } .stat b { font-size: 17px; } .pad { grid-template-columns: repeat(3, 58px); } .box { padding: 14px; } header h1 { font-size: 16px; } }
