:root {
  --bg: #1a1c2c; --panel: #262b44; --panel2: #333c57; --line: #0d0e17; --ink: #f4f4f4; --mute: #94b0c2;
  --gold: #ffcd75; --green: #38b764; --lime: #a7f070; --red: #b13e53; --orange: #ef7d57; --blue: #41a6f6;
  --px: 'Press Start 2P', monospace; --tx: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); font: 15px/1.4 var(--tx); background: var(--bg); min-height: 100dvh; }
#app { max-width: 560px; margin: 0 auto; padding: 0 12px calc(84px + env(safe-area-inset-bottom)); }
.boot { text-align: center; padding: 40vh 0; font-family: var(--px); font-size: 11px; }
h1, h2, h3 { font-family: var(--px); font-weight: 400; margin: 0; line-height: 1.5; }
h2 { font-size: 13px; margin-bottom: 4px; }
h3 { font-size: 11px; margin-bottom: 10px; color: var(--gold); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
h3 small { font: 14px var(--tx); color: var(--mute); }
small { color: var(--mute); }
p { margin: 8px 0; }
canvas { image-rendering: pixelated; width: 100%; display: block; }

.logo { font-size: 26px; color: var(--gold); text-shadow: 3px 3px 0 var(--red), 6px 6px 0 var(--line); letter-spacing: 1px; text-align: center; padding: 28px 0 6px; }
.logo.sm { font-size: 14px; text-shadow: 2px 2px 0 var(--red); padding: 0; }
.tag { text-align: center; color: var(--mute); margin: 6px 0 14px; }

/* пиксельная рамка */
.card, .btn, .scenebox, .auth canvas, input, .chip, .tog, .pcard {
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line);
}
.card { background: var(--panel); padding: 14px; margin: 16px 3px; }
.auth canvas { margin: 0 3px; width: calc(100% - 6px); }
.auth .card { display: flex; flex-direction: column; gap: 12px; }

header { display: flex; justify-content: space-between; align-items: center; padding: 14px 3px 10px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.hud { display: flex; gap: 12px; align-items: center; font-family: var(--px); font-size: 10px; }
.gear { background: none; border: 0; color: var(--mute); font-size: 20px; padding: 2px 4px; cursor: pointer; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: var(--panel); border-top: 3px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
nav button { flex: 1; max-width: 112px; background: none; border: 0; color: var(--mute); font: 13px var(--tx); padding: 8px 2px 9px; cursor: pointer; position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; }
nav button span { font-size: 21px; filter: grayscale(.7); }
nav button.on { color: var(--gold); background: var(--panel2); }
nav button.on span { filter: none; }
nav .dot { position: absolute; top: 6px; right: 26%; width: 8px; height: 8px; background: var(--orange); }

.btn { display: block; width: calc(100% - 6px); margin: 14px 3px; padding: 14px 10px; border: 0; background: var(--panel2); color: var(--ink); font: 11px/1.5 var(--px); cursor: pointer; text-align: center; }
.card .btn, .sheet .btn { width: 100%; margin: 10px 0 0; }
.auth .card .btn { margin: 0; }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--green); color: #06210f; }
.btn.done { background: var(--panel); color: var(--lime); }
.btn.ghost { background: transparent; color: var(--mute); font: 16px var(--tx); padding: 10px; }
.btn.off { background: var(--panel2); color: var(--mute); }
.btn.who { display: flex; align-items: center; gap: 12px; text-align: left; font-size: 12px; }
.btn.who i { width: 18px; height: 18px; flex: none; box-shadow: 0 0 0 3px var(--line); }
.pulse { animation: pulse 1.2s steps(2) infinite; }
@keyframes pulse { 50% { background: var(--lime); } }
.link { background: none; border: 0; color: var(--blue); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

label, .lbl { display: block; font-size: 15px; color: var(--mute); }
.lbl { margin: 14px 0 8px; }
input { display: block; width: 100%; margin-top: 6px; padding: 11px 10px; background: var(--bg); color: var(--ink); border: 0; border-radius: 0; font: 18px var(--tx); min-width: 0; }
input:focus { outline: 3px solid var(--gold); outline-offset: 0; }
input:disabled { color: var(--mute); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.colors { display: flex; gap: 12px; flex-wrap: wrap; }
.sw { width: 34px; height: 34px; border: 0; padding: 0; cursor: pointer; box-shadow: 0 0 0 3px var(--line); }
.sw input { display: none; }
.sw.on, .sw:has(input:checked) { box-shadow: 0 0 0 3px var(--line), 0 0 0 6px var(--ink); }
.sw:has(input:not(:checked)) { box-shadow: 0 0 0 3px var(--line); }
.hint { color: var(--mute); font-size: 15px; margin: 8px 3px; }
.warn { color: var(--gold); background: #4a2a2f; padding: 10px; margin: 12px 3px; font-size: 15px; }
.okmsg { color: var(--lime); }

/* сцена */
.scenebox { position: relative; margin: 6px 3px 0; overflow: hidden; background: #6ec3f4; }
#labels { position: absolute; inset: 0; pointer-events: none; }
.nm { position: absolute; transform: translateX(-50%); font: 8px var(--px); color: #fff; background: rgba(13, 14, 23, .75); padding: 3px 4px; white-space: nowrap; }
.nm.me { color: var(--gold); }
.edge { position: absolute; top: 34%; font: 8px var(--px); background: rgba(13, 14, 23, .85); padding: 5px; border: 2px solid; white-space: nowrap; }
.edge.l { left: 4px; } .edge.r { right: 4px; }
.edge + .edge { top: 50%; }
.zone { position: absolute; left: 6px; top: 6px; font: 8px var(--px); background: rgba(13, 14, 23, .7); padding: 5px 6px; color: var(--gold); }

.mini { margin: 30px 12px 6px; }
.track { position: relative; height: 12px; display: flex; box-shadow: 0 0 0 3px var(--line); }
.track > b { flex: 1; }
.track > i { position: absolute; top: -3px; width: 3px; height: 18px; background: var(--line); transform: translateX(-1px); }
.track > i.ok { background: var(--gold); }
.mk { position: absolute; width: 20px; height: 20px; transform: translateX(-50%); font: 9px/20px var(--px); text-align: center; color: #fff; box-shadow: 0 0 0 2px var(--line); transition: left 2.5s steps(24); text-shadow: 1px 1px 0 #0008; }
.mk.me { box-shadow: 0 0 0 2px var(--line), 0 0 0 4px var(--gold); z-index: 1; }
.ends { display: flex; justify-content: space-between; font: 8px var(--px); color: var(--mute); margin-top: 40px; }

.quest { display: flex; gap: 12px; align-items: center; }
.quest .qe { font-size: 28px; }
.quest div { flex: 1; }
.quest small { display: block; font: 8px/1.6 var(--px); color: var(--gold); }
.quest.ok { background: #1f4d3a; }

.pcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 16px 3px; }
.pcard { background: var(--panel); padding: 12px; border-top: 6px solid var(--c); min-width: 0; }
.pcard.me { background: #2c3350; }
.phead { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 19px; }
.phead b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { font: 8px var(--px); color: var(--gold); white-space: nowrap; }
.ptitle { color: var(--mute); font-size: 14px; }
.big { font: 20px/1.4 var(--px); margin-top: 8px; }
.big small { font-size: 10px; }
.big.gold { color: var(--gold); text-align: center; margin: 6px 0 12px; }
.sub { color: var(--lime); font-size: 15px; }
.sub.up { color: var(--orange); }
.bar { position: relative; height: 20px; background: var(--bg); margin: 10px 0; box-shadow: 0 0 0 2px var(--line); }
.bar i { display: block; height: 100%; background: var(--c, var(--green)); transition: width 1s steps(12); }
.bar span { position: absolute; inset: 0; font: 8px/20px var(--px); text-align: center; text-shadow: 1px 1px 0 #000; }
.bar.thin { height: 10px; margin: 6px 0; }
.bar.hp i { background: var(--red); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; padding: 3px 0; }
.kv span { color: var(--mute); }
.kv b { font-weight: 600; text-align: right; }

.duel { display: grid; grid-template-columns: 84px 1fr 44px; gap: 10px; align-items: center; }
.duel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel b { font: 10px var(--px); text-align: right; }
.stake { font-size: 15px; margin-top: 8px; }
.stake span { color: var(--mute); }
.bossrow { display: flex; gap: 14px; align-items: center; }
.bossface { font-size: 44px; animation: bob 1s steps(2) infinite; }
.boss.dead .bossface { animation: none; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.grow { flex: 1; min-width: 0; }

/* день */
.dates, .chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 3px; }
.card .chips { margin: 10px 0 14px; }
.chip { background: var(--panel2); color: var(--ink); border: 0; font: 15px var(--tx); padding: 7px 9px; cursor: pointer; }
.chip.on { background: var(--gold); color: var(--line); }
.chip.has:not(.on) { color: var(--lime); }
.tog { display: flex; width: 100%; align-items: center; gap: 10px; background: var(--bg); color: var(--ink); border: 0; padding: 11px 10px; margin-bottom: 9px; font: 17px var(--tx); text-align: left; cursor: pointer; }
.tog .box { width: 22px; height: 22px; background: var(--panel2); flex: none; text-align: center; line-height: 22px; color: var(--line); font-weight: 700; }
.tog b { font: 9px var(--px); color: var(--mute); }
.tog.on { background: #1f4d3a; }
.tog.on .box { background: var(--lime); }
.tog.on b { color: var(--lime); }
.slip { display: grid; grid-template-columns: auto 1fr 36px; gap: 8px; align-items: center; margin-bottom: 9px; background: #4a2a2f; padding: 6px 8px; font-size: 15px; box-shadow: 0 0 0 2px var(--line); }
.slip input { margin: 0; padding: 7px; font-size: 15px; box-shadow: none; }
.x { background: none; border: 0; color: var(--orange); font-size: 17px; cursor: pointer; height: 36px; }

/* награды */
.wallet { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.wallet small { font: 8px var(--px); }
.wallet .r { flex: 1; max-width: 190px; text-align: right; }
.wallet .r b { display: block; margin-top: 4px; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 14px 3px; }
.item { margin: 0; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.item .ie { font-size: 38px; }
.item b { flex: 1; }
.item .btn { font-size: 9px; padding: 11px 4px; }
.redit { display: grid; grid-template-columns: 50px 1fr 76px 30px; gap: 8px; margin-bottom: 10px; align-items: center; }
.redit input { margin: 0; padding: 9px 7px; font-size: 16px; }

/* успехи */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 8px; text-align: center; }
.stats b { display: block; font: 12px/1.5 var(--px); overflow-wrap: anywhere; }
.stats small { font-size: 13px; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 15px; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.ach { background: var(--bg); padding: 10px 6px; text-align: center; opacity: .5; }
.ach.on { opacity: 1; background: #3a3320; box-shadow: 0 0 0 2px var(--gold); }
.ach .ae { font-size: 26px; }
.ach b { display: block; font-size: 14px; line-height: 1.2; margin: 4px 0; }
.ach small { font-size: 12px; line-height: 1.2; display: block; }

/* лента */
.postbox { display: flex; gap: 12px; align-items: stretch; }
.postbox input { margin: 0; }
.postbox .btn { width: 56px; margin: 0; padding: 0; font-size: 14px; }
.fdate { font: 8px var(--px); color: var(--mute); margin: 18px 3px 8px; }
.fitem { display: flex; gap: 10px; padding: 9px 10px; margin: 0 0 6px; background: var(--panel); border-left: 4px solid var(--green); overflow-wrap: anywhere; }
.fitem.slip { border-color: var(--red); } .fitem.buy { border-color: var(--gold); } .fitem.post { border-color: var(--blue); background: var(--panel2); } .fitem.info { border-color: var(--mute); }
.fe { font-size: 20px; }

#modal { position: fixed; inset: 0; background: rgba(13, 14, 23, .8); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden], #toast[hidden] { display: none; }
.sheet { width: 100%; max-width: 440px; max-height: 88dvh; overflow: auto; margin: 0; }
.rules p { font-size: 15px; }
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--green); color: #06210f; padding: 12px 16px; z-index: 30; max-width: 90vw; text-align: center; box-shadow: 0 0 0 3px var(--line); }
#toast.bad { background: var(--red); color: #fff; }

@media (max-width: 380px) { .row3 { gap: 8px; } .big { font-size: 16px; } .logo { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { .pulse, .bossface { animation: none; } }

.copy { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.copy code { flex: 1; min-width: 0; background: var(--bg); padding: 9px 8px; font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.rules code { background: var(--bg); padding: 1px 5px; }
