:root {
  --bg: #0b0f1a; --panel: #141a2c; --panel2: #1c2440; --line: #2c3760; --ink: #e8ecff; --dim: #8a93b8;
  --green: #3ddc84; --cyan: #35e0ff; --pink: #ff4fd8; --yellow: #ffd23f; --red: #ff5a5a; --orange: #ff9f43; --purple: #9b6bff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #05070d; color: var(--ink); overscroll-behavior: none; }
body { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, "Courier New", monospace; font-size: 14px; line-height: 1.35; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#app { position: relative; max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
canvas, img.ico, img.pix { image-rendering: pixelated; image-rendering: crisp-edges; }
.hidden { display: none !important; }
img.ico { width: 16px; height: 16px; vertical-align: -3px; }
img.ico.big { width: 32px; height: 32px; }

/* HUD */
#hud { display: flex; gap: 8px; align-items: center; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--panel); border-bottom: 2px solid var(--line); }
#hud .face { width: 40px; height: 40px; background: #221d36; border: 2px solid var(--line); }
#hud .who { flex: 1; min-width: 0; }
#hud .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud .who small { color: var(--dim); font-size: 11px; }
.xp { height: 4px; background: #0b0f1a; margin-top: 3px; }
.xp i { display: block; height: 100%; background: var(--purple); }
#hud .stats { display: grid; grid-template-columns: auto auto; gap: 2px 10px; font-size: 13px; text-align: right; }
#hud .stats span { white-space: nowrap; }
.tag { display: inline-block; padding: 1px 6px; font-size: 11px; border: 1px solid currentColor; }
.tag.cy { color: var(--cyan); } .tag.rd { color: var(--red); } .tag.gr { color: var(--green); } .tag.yl { color: var(--yellow); } .tag.pk { color: var(--pink); }

/* layout */
#main { flex: 1; overflow-y: auto; padding: 10px; -webkit-overflow-scrolling: touch; }
#nav { display: flex; background: var(--panel); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav button { flex: 1; background: none; border: 0; color: var(--dim); font: inherit; font-size: 11px; padding: 8px 0 7px; position: relative; }
#nav button img { display: block; width: 24px; height: 24px; margin: 0 auto 2px; opacity: 0.55; }
#nav button.on { color: var(--green); } #nav button.on img { opacity: 1; }
#nav .dot { position: absolute; top: 5px; right: 22%; width: 8px; height: 8px; background: var(--red); }
h2 { font-size: 15px; margin: 14px 0 6px; color: var(--cyan); text-transform: uppercase; letter-spacing: 1px; }
h2:first-child { margin-top: 0; }
p { margin: 6px 0; } .dim { color: var(--dim); } .small { font-size: 12px; }
.g { color: var(--green); } .r { color: var(--red); } .y { color: var(--yellow); } .c { color: var(--cyan); } .pk { color: var(--pink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 6px 12px; font: inherit; font-weight: bold; color: var(--ink); background: var(--panel2); border: 2px solid var(--line); box-shadow: 0 3px 0 #05070d; cursor: pointer; text-align: center; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #05070d; }
.btn.go { background: #14432b; border-color: var(--green); color: var(--green); }
.btn.bad { background: #431a1a; border-color: var(--red); color: var(--red); }
.btn.hot { background: #3a2f10; border-color: var(--yellow); color: var(--yellow); }
.btn.wide { display: flex; width: 100%; margin: 8px 0; }
.btn.sm { min-height: 32px; padding: 3px 8px; font-size: 12px; }
.btn[disabled], .btn.off { opacity: 0.4; }
.btn small { font-weight: normal; color: var(--dim); display: block; }

.card { background: var(--panel); border: 2px solid var(--line); padding: 8px 10px; margin: 8px 0; }
.card.alert { border-color: var(--red); } .card.good { border-color: var(--green); } .card.gold { border-color: var(--yellow); }
.card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .btns { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.card .btns .btn { flex: 1; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 1px 0; }
.kv span:first-child { color: var(--dim); }

/* room */
.frame { border: 2px solid var(--line); background: #000; position: relative; }
.frame canvas { display: block; width: 100%; }
.say { position: absolute; left: 6px; right: 6px; bottom: 6px; background: rgba(11,15,26,0.85); border: 1px solid var(--line); padding: 4px 8px; font-size: 12px; }
.bars { margin: 10px 0 4px; display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 20px 74px 1fr 34px; align-items: center; gap: 6px; font-size: 12px; }
.track { height: 12px; background: #05070d; border: 2px solid var(--line); }
.track i { display: block; height: 100%; }
.bar .hint { grid-column: 2 / -1; color: var(--dim); font-size: 11px; margin-top: -4px; }
.acts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.acts .btn { flex-direction: column; gap: 0; font-size: 12px; padding: 6px 2px; min-height: 52px; }

/* net graphs */
.crt { position: relative; border: 2px solid var(--line); background: #070a14; }
.crt canvas { display: block; width: 100%; }
.crt::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; background: var(--panel2); border: 2px solid var(--line); font: inherit; font-size: 12px; color: var(--ink); max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.empty { opacity: 0.35; border-style: dashed; }
.stars { color: var(--yellow); letter-spacing: 1px; } .stars i { color: var(--line); font-style: normal; }

/* run */
#run { position: absolute; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); gap: 6px; overflow-y: auto; }
.runtop { display: flex; align-items: center; gap: 8px; }
.runtop b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace { position: relative; height: 26px; border: 2px solid var(--red); background: #1a0808; }
.trace i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--red); }
.trace span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 13px; text-shadow: 1px 1px 0 #000; }
.trace.frozen { border-color: var(--cyan); } .trace.frozen i { background: var(--cyan); }
#rinfo { min-height: 86px; background: var(--panel); border: 2px solid var(--line); padding: 6px 8px; font-size: 13px; }
#rdeck { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#rdeck .btn { flex-direction: column; gap: 1px; font-size: 11px; padding: 4px 2px; min-height: 54px; }
#rdeck .btn.dead { opacity: 0.25; text-decoration: line-through; }
.lock { display: inline-block; padding: 0 5px; font-size: 11px; color: #000; font-weight: bold; margin-right: 4px; }

/* modal + toast */
#modal { position: absolute; inset: 0; z-index: 30; background: rgba(3,5,12,0.82); display: flex; align-items: center; justify-content: center; padding: 14px; }
.mbox { width: 100%; max-height: 92%; overflow-y: auto; background: var(--panel); border: 2px solid var(--cyan); padding: 12px; box-shadow: 0 6px 0 #000; }
.mbox h3 { margin: 0 0 8px; font-size: 16px; color: var(--cyan); }
.opt { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; margin: 6px 0; padding: 8px; background: var(--panel2); border: 2px solid var(--line); color: var(--ink); font: inherit; }
.opt .o1 { flex: 1; min-width: 0; } .opt small { color: var(--dim); display: block; font-size: 11px; }
.opt.on { border-color: var(--green); } .opt.off { opacity: 0.45; }
#toast { position: absolute; left: 10px; right: 10px; top: 64px; z-index: 40; pointer-events: none; display: flex; flex-direction: column; gap: 4px; align-items: center; }
#toast div { background: #000; border: 2px solid var(--yellow); color: var(--yellow); padding: 5px 10px; font-size: 13px; font-weight: bold; animation: pop 2.6s forwards; text-align: center; }
@keyframes pop { 0% { opacity: 0; transform: translateY(-6px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* create */
.create { text-align: center; padding-top: 10px; }
.create h1 { font-size: 26px; margin: 6px 0 0; color: var(--green); letter-spacing: 2px; text-shadow: 3px 3px 0 #14432b; }
.create img.pix { width: 128px; height: 128px; margin: 8px auto; display: block; background: #221d36; border: 2px solid var(--line); }
input[type=text] { width: 100%; font: inherit; font-size: 16px; padding: 10px; background: #05070d; color: var(--green); border: 2px solid var(--line); text-align: center; user-select: text; -webkit-user-select: text; }
.sw { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.sw button { width: 36px; height: 36px; border: 2px solid var(--line); }
.sw button.on { border-color: #fff; box-shadow: 0 0 0 2px #fff; }

/* shop */
#hud .stats { grid-template-columns: auto auto auto; }
#hud .stats .wide2 { grid-column: span 2; }
#nav button { font-size: 10px; }
.items { display: grid; gap: 8px; margin: 8px 0; }
.items.three { grid-template-columns: repeat(3, 1fr); } .items.two { grid-template-columns: repeat(2, 1fr); }
.item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px 8px; background: var(--panel); border: 2px solid var(--line); color: var(--ink); font: inherit; font-size: 12px; text-align: center; min-width: 0; }
.item img.pix { width: 100%; background: #10121c; }
.item.skins img.pix { width: 64px; height: 64px; }
.item b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item small { font-size: 10px; } .item .btn { width: 100%; }
.item .badge { position: absolute; top: -2px; right: -2px; background: var(--red); color: #000; font-style: normal; font-weight: bold; font-size: 10px; padding: 1px 4px; z-index: 1; }
.item.pack .ico.big { width: 40px; height: 40px; margin: 6px 0; }
s { color: var(--dim); font-weight: normal; }
.offer { display: flex; gap: 10px; align-items: center; } .offer img { width: 64px; height: 64px; background: #10121c; border: 2px solid var(--line); flex: none; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 4px 0 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; background: var(--panel2); border: 2px solid var(--line); font-size: 10px; }
.day.done { opacity: 0.35; } .day.now { border-color: var(--green); }
.pass { display: grid; gap: 4px; margin-top: 8px; }
.pr { display: grid; grid-template-columns: 22px 1fr 1fr; gap: 4px; align-items: stretch; opacity: 0.5; } .pr.open { opacity: 1; } .pr b { align-self: center; color: var(--dim); }
.pc { font: inherit; font-size: 11px; padding: 6px 4px; background: var(--panel2); border: 2px solid var(--line); color: var(--ink); }
.pc.prem { border-color: #6a5a20; } .pc.can { border-color: var(--green); color: var(--green); font-weight: bold; } .pc.got { opacity: 0.4; }

/* online */
input[type=password], input[type=number] { width: 100%; font: inherit; font-size: 16px; padding: 10px; background: #05070d; color: var(--green); border: 2px solid var(--line); text-align: center; user-select: text; -webkit-user-select: text; }
.create input { margin-top: 8px; }
.mbox input { margin: 8px 0; }
.inrow { display: flex; gap: 6px; margin-top: 8px; } .inrow input { flex: 1; min-width: 0; text-align: left; font-size: 14px; padding: 6px 8px; } .inrow .btn { flex: none; }
.chatlog { max-height: 220px; overflow-y: auto; margin-top: 6px; } .chatlog p { margin: 3px 0; word-break: break-word; user-select: text; -webkit-user-select: text; }
.rep { background: none; border: 0; color: var(--dim); font: inherit; padding: 0 4px; }
#nav button { font-size: 9px; } #nav button img { width: 22px; height: 22px; }
