:root {
  --bg: #1b1f3a; --bg2: #262b52; --card: #2d335f; --ink: #f3f1ff; --muted: #a9adcf;
  --accent: #ffd166; --accent2: #06d6a0; --danger: #ef476f; --pill: #3a4178;
  --radius: 10px; --font: ui-rounded, "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; }
.hud { padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--bg2); }
.hud-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.name { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.weather { font-size: 24px; }
.stats { margin-top: 6px; justify-content: flex-start; flex-wrap: wrap; }
.pill { background: var(--pill); border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 700; }
.xpbar { position: relative; margin-top: 8px; height: 14px; background: #141733; border-radius: 7px; overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .6s ease; }
.xp-text { position: absolute; inset: 0; font-size: 10px; font-weight: 800; text-align: center; line-height: 14px; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
main { flex: 1; overflow-y: auto; padding: 12px 16px 90px; }
.tab { display: none; }
.tab.active { display: block; }
.stage { position: relative; width: 100%; max-width: 528px; margin: 0 auto; aspect-ratio: 1; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; border-radius: var(--radius); background: #6fb7ff; touch-action: manipulation; }
.toast { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(20,22,50,.9); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; pointer-events: none; white-space: nowrap; }
.actions { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.btn { background: var(--accent); color: #1b1f3a; border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 800; font-size: 15px; min-height: 44px; cursor: pointer; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: var(--pill); color: var(--ink); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.danger { background: var(--danger); color: #fff; }
.place-bar { background: var(--card); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.kinds { display: flex; gap: 6px; }
.kinds button { width: 36px; height: 36px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.kinds button.sel { border-color: var(--accent); }
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p { margin: 0 0 8px; font-size: 14px; }
.muted { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.06); font-size: 14px; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: 12px; display: block; }
.list.small li { font-size: 12px; padding: 5px 0; }
.list .ico { font-size: 20px; width: 28px; text-align: center; }
.rules { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.45; }
.rules li { margin-bottom: 4px; }
.branches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.branches button { background: var(--pill); border: 2px solid transparent; border-radius: var(--radius); padding: 10px 4px; color: var(--ink); font-weight: 800; cursor: pointer; }
.branches button canvas { width: 48px; height: 48px; display: block; margin: 0 auto 4px; background: transparent; border-radius: 0; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg2); border-top: 1px solid rgba(255,255,255,.08); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 6px; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button span { font-size: 11px; font-weight: 700; }
.tabs button.active { color: var(--accent); }
dialog { background: var(--card); color: var(--ink); border: 0; border-radius: var(--radius); padding: 16px; width: min(90vw, 320px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog input { width: 100%; font: inherit; font-size: 16px; padding: 10px; border-radius: 8px; border: 0; margin: 8px 0 12px; }
.row { display: flex; gap: 8px; justify-content: flex-end; }
.locked { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.locked p { max-width: 100%; }
.badge { font-size: 11px; background: var(--pill); border-radius: 6px; padding: 2px 6px; }
.badge.ok { background: var(--accent2); color: #0f1230; }
.badge.no { background: var(--danger); color: #fff; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #eef1ff; --bg2: #ffffff; --card: #ffffff; --ink: #1b1f3a; --muted: #5b618a; --pill: #e3e7ff; }
}
