:root { --ink: #101a36; --gold: #ffc53d; --cream: #fff8ea; --teal: #2bb0a0; --r: 18px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--ink);
  font: 500 15px/1.45 Montserrat, "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-tap-highlight-color: transparent; }
canvas#city { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; cursor: grab; display: block; }
canvas#city:active { cursor: grabbing; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: 10px 14px; background: #fff; color: var(--ink); font-weight: 700; }
.primary { background: var(--gold); color: var(--ink); font-weight: 800; }
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 12px; padding: 10px 14px; background: #fff; color: var(--ink); font-weight: 700; }
[hidden] { display: none !important; }

.top { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 5; }
.brand { pointer-events: auto; display: flex; gap: 8px; align-items: center; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.star { width: 12px; height: 12px; background: var(--gold); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.pop { pointer-events: auto; background: #fff; border-radius: 14px; padding: 4px 12px; text-align: right; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.pop small { display: block; font-size: 9px; letter-spacing: .12em; opacity: .6; font-weight: 800; }
.pop b { font-size: 18px; font-weight: 900; }
.sample { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: #c0392b; color: #fff; font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 8px; z-index: 5; }

.ctl { position: fixed; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.ctl button { width: 44px; height: 44px; padding: 0; font-size: 20px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.ctl button.on { background: var(--teal); color: #fff; }
.ctl .build { height: auto; padding: 8px 0 6px; background: var(--gold); display: flex; flex-direction: column; align-items: center; font-size: 10px; font-weight: 900; }
.build svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.search { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 50px); left: 10px; display: flex; gap: 6px; z-index: 6; width: min(360px, calc(100vw - 76px)); }
.search input, .wcard input { flex: 1; min-width: 0; border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; background: #fff; outline: none; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.search input:focus, .wcard input:focus { border-color: var(--gold); }
.sugg { position: absolute; top: 100%; left: 0; right: 0; margin: 6px 0 0; padding: 4px; list-style: none; background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 10; text-align: left; }
.sugg li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 700; display: flex; justify-content: space-between; }
.sugg li:hover { background: #fff3cf; }
.sugg small { opacity: .5; }

.welcome { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, rgba(16,26,54,.15), rgba(16,26,54,.65)); z-index: 8; }
.wcard { width: min(440px, 100%); background: var(--cream); border-radius: 24px; padding: 26px 22px 20px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: up .5s ease both; }
.kicker { display: inline-block; background: var(--ink); color: var(--gold); font-weight: 900; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; }
.wcard h1 { font-size: 28px; line-height: 1.1; margin: 12px 0 8px; font-weight: 900; }
.wcard p { margin: 0 0 16px; opacity: .8; }
#wform { display: flex; gap: 6px; position: relative; }
.wbuild { margin-top: 10px; width: 100%; background: transparent; border: 2px dashed #d9b45a; }
.link { background: none; text-decoration: underline; opacity: .7; margin-top: 8px; }
.wpop { margin-top: 8px; font-size: 13px; opacity: .7; }

.sheet { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(420px, calc(100vw - 20px)); background: var(--cream); border-radius: 22px; padding: 18px 18px 14px; z-index: 7; box-shadow: 0 16px 50px rgba(0,0,0,.35); animation: up .3s ease both; max-height: 75vh; overflow: auto; }
.sheet h2, .mcard h2 { margin: 8px 0 4px; font-size: 22px; font-weight: 900; word-break: break-all; }
.sheet .addr { margin: 4px 0 12px; opacity: .8; }
.sheet .tag { display: inline-block; background: var(--teal); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 9px; border-radius: 8px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.row > * { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.x { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 20px; background: rgba(16,26,54,.08); }

.shop label { display: block; margin: 10px 0 4px; font-weight: 700; font-size: 13px; }
.shop label input:not([type=range]) { display: block; width: 100%; margin-top: 4px; border: 2px solid #eadfc6; border-radius: 10px; padding: 9px 10px; background: #fff; outline: none; }
.shop input[type=range] { width: 100%; accent-color: var(--ink); }
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.kinds button { border: 2px solid #eadfc6; font-size: 13px; }
.kinds button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.colors { display: flex; gap: 8px; margin: 10px 0 0; }
.colors button { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #ccc; }
.colors button.on { box-shadow: 0 0 0 3px var(--ink); }
.price { margin: 12px 0 8px; font-weight: 900; }
.wide { width: 100%; }
.note { font-size: 12px; opacity: .65; margin: 8px 0 0; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(16,26,54,.55); z-index: 9; padding: 16px; }
.mcard { position: relative; width: min(420px, 100%); background: var(--cream); border-radius: 22px; padding: 22px 18px 18px; max-height: 92vh; overflow: auto; animation: up .3s ease both; }
#vform label { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 10px 12px; margin: 6px 0; font-weight: 700; }
#vform input#vother { flex: 1; border: 0; border-bottom: 2px solid #eadfc6; outline: none; background: transparent; }
#vform .primary { width: 100%; margin-top: 8px; }
.msg { margin-top: 12px; }
.bar { position: relative; display: flex; justify-content: space-between; background: #fff; border-radius: 10px; padding: 8px 10px; margin: 5px 0; overflow: hidden; font-weight: 700; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,197,61,.45); z-index: 0; }
.bar span, .bar b { position: relative; z-index: 1; }
.story img { width: 100%; border-radius: 14px; display: block; margin-top: 28px; }

.toast { position: fixed; left: 50%; top: 110px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; z-index: 20; max-width: calc(100vw - 30px); text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.fatal { position: fixed; inset: auto 10px 10px; background: #c0392b; color: #fff; padding: 12px; border-radius: 12px; z-index: 30; }
body.intro .ctl, body.intro .search { opacity: 0; pointer-events: none; }
@keyframes up { from { transform: translate(var(--tx, 0), 20px); opacity: 0; } to { transform: translate(var(--tx, 0), 0); opacity: 1; } }
.sheet { --tx: -50%; }
@media (max-width: 520px) { .wcard h1 { font-size: 24px; } .ctl { top: auto; bottom: 200px; transform: none; } }

/* paid upgrades */
.sheet .tag.gold { background: linear-gradient(90deg, #e0b23a, #f6d77a); color: #4a3200; }
.knote { font-size: 13px; opacity: .8; margin: 4px 0 8px; }
.pay { white-space: pre-line; background: rgba(224,178,58,.15); border: 1px solid #e0b23a; border-radius: 12px; padding: 10px 12px; font-weight: 700; margin: 8px 0; user-select: all; }
.stars { display: block; margin-top: 10px; text-align: center; padding: 12px; border-radius: 14px; background: #229ED9; color: #fff; font-weight: 800; text-decoration: none; }
