:root { --ink: #eef1f8; --muted: #9aa3b8; --bg: rgba(16, 19, 28, 0.94); --bg2: #1a2030; --line: #2c3548; --mint: #3ee6a0; --violet: #8a6cff; --gold: #ffc94a; --red: #ff5a6a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #10131c; color: var(--ink); font: 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; display: block; }
button { font: inherit; font-weight: 700; color: var(--ink); background: var(--bg2); border: 2px solid var(--line); border-bottom-width: 4px; padding: 8px 14px; border-radius: 8px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--mint); }
button:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: #17a673; border-color: #0d6e4c; color: #fff; }
button.violet { background: var(--violet); border-color: #5a42b8; color: #fff; }
button.danger { background: #4a1820; border-color: #7a2a34; }
button.big { font-size: 18px; padding: 12px 24px; }
button.icon { padding: 4px 10px; font-size: 18px; }
button.sm { padding: 4px 10px; font-size: 12px; border-bottom-width: 3px; }
.screen { position: fixed; z-index: 20; }
[hidden] { display: none !important; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.good { color: var(--mint); } .bad { color: var(--red); } .gold { color: var(--gold); }

/* title */
.title { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 20px; background: radial-gradient(ellipse at center, rgba(16, 19, 28, 0.1), rgba(16, 19, 28, 0.8) 75%); }
.logo { font: 900 clamp(48px, 12vw, 104px)/0.88 Impact, "Arial Black", sans-serif; letter-spacing: 0.02em; text-shadow: 4px 4px 0 var(--violet), 8px 8px 0 #000; }
.logo small { display: block; font-size: 0.22em; letter-spacing: 0.35em; color: var(--mint); text-shadow: 2px 2px 0 #000; }
.logo em { display: block; font: italic 700 0.18em Georgia, serif; color: var(--gold); margin-top: 12px; text-shadow: 2px 2px 0 #000; letter-spacing: 0.02em; }
.title p { margin: 0; font-weight: 700; text-shadow: 1px 1px 0 #000; }
.col { display: flex; flex-direction: column; gap: 8px; min-width: 250px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; } .row.center { justify-content: center; }

/* setup wizard */
.setup { inset: 0; display: flex; flex-direction: column; background: rgba(16, 19, 28, 0.9); }
.setup header, #sheet header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 2px solid var(--line); }
.setup header > div { flex: 1; display: flex; flex-direction: column; }
.setup header b { font-size: 19px; }
#setup-body { flex: 1; overflow-y: auto; padding: 14px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.wrap { max-width: 980px; margin: 0 auto; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-weight: 700; }
.field input { font: 700 18px system-ui, sans-serif; padding: 10px; background: var(--bg2); color: var(--ink); border: 2px solid var(--line); border-radius: 8px; user-select: text; max-width: 360px; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.choice { text-align: left; display: flex; flex-direction: column; gap: 4px; font-weight: 400; padding: 10px 12px; }
.choice b { font-size: 15px; }
.choice.on { border-color: var(--mint); background: #163a30; }
.choice .flag { width: 30px; height: 20px; border-radius: 3px; box-shadow: 0 0 0 1px #0006; float: right; }
.kv { display: grid; grid-template-columns: auto auto; gap: 0 10px; font-size: 12px; color: var(--muted); }
.kv span:nth-child(even) { color: var(--ink); text-align: right; font-weight: 700; }
.hint { background: var(--bg2); border-left: 4px solid var(--violet); padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; color: #cfd5e4; }
.logo-edit { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; }
.logo-edit canvas { width: 200px; height: 200px; image-rendering: pixelated; background: #0b0e15; border-radius: 12px; border: 2px solid var(--line); }
.opt-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.opt-row button.on { border-color: var(--mint); background: #163a30; }
@media (max-width: 640px) { .logo-edit { grid-template-columns: 1fr; } .logo-edit canvas { width: 150px; height: 150px; margin: 0 auto; } }

/* hud */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: linear-gradient(#10131cee, #10131c99); }
#hud-logo { width: 38px; height: 38px; image-rendering: pixelated; border-radius: 8px; }
.co { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.co b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat small { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat b { font-size: 16px; }
.stat.cash b { color: var(--mint); }
.stat.cash.neg b { color: var(--red); animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.speed { display: flex; gap: 2px; }
.speed button { padding: 4px 7px; font-size: 11px; border-bottom-width: 3px; letter-spacing: -2px; }
.speed button.on { background: var(--violet); border-color: #5a42b8; }
#unicorn-bar { position: fixed; z-index: 10; top: calc(max(8px, env(safe-area-inset-top)) + 46px); left: 10px; right: 10px; height: 14px; background: #0009; border-radius: 7px; overflow: hidden; }
#unicorn-fill { height: 100%; background: linear-gradient(90deg, var(--violet), #ff6ad5, var(--gold)); width: 0; transition: width 0.4s; }
#unicorn-text { position: absolute; inset: 0; font-size: 10px; font-weight: 700; text-align: center; line-height: 14px; text-shadow: 1px 1px 0 #000; }
@media (max-width: 720px) { .stat.wide { display: none; } .co small { font-size: 11px; } }
@media (max-width: 420px) { .speed button[data-sp="3"] { display: none; } #hud-logo { width: 30px; height: 30px; } }

.tabs { position: fixed; z-index: 16; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; padding: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); background: linear-gradient(#10131c00, #10131cee 40%); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 8px; min-width: 62px; position: relative; }
.tabs button i { font-style: normal; font-size: 18px; }
.tabs button.on { background: var(--violet); border-color: #5a42b8; }
.tabs button .dot { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; }
@media (max-width: 520px) { .tabs { gap: 2px; padding-left: 2px; padding-right: 2px; } .tabs button { min-width: 0; flex: 1; padding: 5px 2px; font-size: 9.5px; } }

#toasts { position: fixed; z-index: 11; left: 10px; top: calc(max(8px, env(safe-area-inset-top)) + 68px); display: flex; flex-direction: column; gap: 4px; max-width: min(380px, 70vw); pointer-events: none; }
.toast { background: var(--bg); border-left: 4px solid var(--line); padding: 6px 10px; border-radius: 6px; font-size: 12.5px; animation: tin 0.25s ease-out; }
.toast.good { border-left-color: var(--mint); color: var(--ink); } .toast.bad { border-left-color: var(--red); color: var(--ink); }
.toast.out { opacity: 0; transition: opacity 0.5s; }
@keyframes tin { from { transform: translateX(-20px); opacity: 0; } }

#floats { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.float { position: absolute; font-weight: 800; font-size: 13px; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; transform: translate(-50%, -100%); animation: up 1.6s ease-out forwards; white-space: nowrap; }
@keyframes up { to { transform: translate(-50%, -260%); opacity: 0; } }

/* bottom sheet */
#sheet { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; max-height: 62vh; max-height: 62dvh; display: flex; flex-direction: column; background: var(--bg); border-top: 2px solid var(--line); border-radius: 14px 14px 0 0; animation: sup 0.2s ease-out; max-width: 860px; margin: 0 auto; }
@keyframes sup { from { transform: translateY(30px); opacity: 0; } }
#sheet header { border-radius: 14px 14px 0 0; padding-top: 10px; }
#sheet header b { font-size: 17px; }
#sheet header small { flex: 1; }
#sheet-body { overflow-y: auto; padding: 10px 14px; padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 76px)); }
#sheet-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 14px 0 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg2); border: 2px solid var(--line); border-radius: 10px; margin-bottom: 6px; }
.item > .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .ico { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 18px; flex: none; }
.item.sel { border-color: var(--mint); }
.item.off { opacity: 0.55; }
.pill { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #2c3548; color: #cfd5e4; margin-right: 4px; font-weight: 700; }
.pill.skill { background: #3a2f6a; }
.bar { height: 7px; background: #0b0e15; border-radius: 4px; overflow: hidden; }
.bar div { height: 100%; background: var(--mint); }
.bar.v div { background: var(--violet); }
.bar.r div { background: var(--red); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.box { background: var(--bg2); border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.box small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.box b { font-size: 17px; }
input[type=range] { width: 100%; accent-color: var(--violet); }
canvas.chart { width: 100%; height: 130px; background: var(--bg2); border-radius: 10px; border: 2px solid var(--line); }
.log div { padding: 3px 0; border-bottom: 1px solid #ffffff10; font-size: 12.5px; }
.log div small { margin-right: 6px; }

/* modal */
#modal { inset: 0; display: grid; place-items: center; background: rgba(8, 10, 16, 0.55); padding: 16px; z-index: 30; }
.card { background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 18px; max-width: 460px; width: 100%; box-shadow: 0 10px 40px #0008; animation: pop 0.2s ease-out; max-height: 90vh; overflow-y: auto; }
.card h2 { margin: 0 0 8px; font-size: 21px; }
.card p { margin: 0 0 12px; color: #cfd5e4; }
.card .col { min-width: 0; }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } }
.big-emoji { font-size: 54px; text-align: center; line-height: 1; margin-bottom: 8px; }

#ios-install { position: fixed; z-index: 40; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; padding: 12px 40px 12px 14px; background: var(--bg); border: 2px solid var(--violet); border-radius: 10px; }
#ios-install button { position: absolute; top: 6px; right: 6px; padding: 2px 8px; }
.ios-share { display: inline-block; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; font-size: 11px; }
.co small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .topbar { gap: 6px; } .co b { font-size: 14px; } .stat b { font-size: 14px; } .speed button { padding: 4px 6px; } }
