/* POCKET METROPOLIS */
:root {
  --bg: #0f1a2b; --panel: rgba(14, 22, 34, .93); --panel2: rgba(24, 35, 52, .96); --line: rgba(255, 255, 255, .09); --line2: rgba(255, 255, 255, .16);
  --text: #e9eef5; --mut: #8fa0b5; --gold: #ffb43a; --gold2: #f08a1c; --red: #e8574f; --green: #46c98b; --blue: #4aa8ff; --warn: #f0a53a; --purple: #a98aea;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --display: "Nunito", ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
body { -webkit-touch-callout: none; }
.hidden { display: none !important; }
svg { display: block; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(5, 10, 22, .45) 100%); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line2); font-weight: 600; transition: transform .08s, background .15s, border-color .15s; }
.btn:hover { background: rgba(255, 255, 255, .14); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #f6cf6a, #d9a52e); color: #2a1d05; border-color: #f6d780; text-shadow: 0 1px 0 rgba(255, 255, 255, .3); box-shadow: 0 4px 18px rgba(217, 165, 46, .35); }
.btn.primary:hover { background: linear-gradient(180deg, #fbd978, #e4b13a); }
.btn.ghost { background: rgba(255, 255, 255, .04); }
.btn.big { padding: 14px 26px; font-size: 17px; letter-spacing: .06em; text-transform: uppercase; min-width: 240px; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: rgba(232, 87, 79, .18); border-color: rgba(232, 87, 79, .5); color: #ffb3ae; }
.btn:disabled { opacity: .45; pointer-events: none; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: background .15s, transform .08s; }
.iconbtn:hover { background: var(--panel2); }
.iconbtn:active { transform: scale(.93); }
.iconbtn.on { background: var(--gold); color: #2a1d05; border-color: #f6d780; }
.iconbtn svg { width: 22px; height: 22px; }

/* ---------- main menu (left-aligned list over the live city, like a tycoon game) ---------- */
.screen { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; }
#scr-main { justify-content: flex-start; align-items: stretch; }
.menu-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8, 14, 28, .94) 0%, rgba(8, 14, 28, .78) 28%, rgba(8, 14, 28, .25) 58%, rgba(8, 14, 28, 0) 80%), linear-gradient(0deg, rgba(8, 14, 28, .55), transparent 28%); pointer-events: none; }
.menu-left { position: relative; width: min(470px, 100%); padding: calc(34px + var(--sat)) 30px 40px calc(34px + var(--sal)); display: flex; flex-direction: column; justify-content: center; animation: slidein .7s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes slidein { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
.logo { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.logo-mark { width: 74px; flex: none; filter: drop-shadow(0 6px 14px rgba(240, 138, 28, .45)); }
.title { margin: 0; font-family: var(--display); font-weight: 900; line-height: .95; letter-spacing: .01em; font-size: clamp(34px, 6.4vw, 58px); color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, .35), 0 8px 26px rgba(0, 0, 0, .5); }
.title span { display: block; }
.title span:nth-child(2) { color: var(--gold); font-size: .72em; letter-spacing: .05em; }
.tag { margin: 6px 0 28px; color: #b8c6da; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.menu-list { display: flex; flex-direction: column; gap: 7px; max-width: 340px; }
.mi { position: relative; text-align: left; padding: 15px 22px 15px 24px; border-radius: 6px; background: rgba(22, 34, 54, .82); border: 1px solid rgba(255, 255, 255, .09); font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: .02em; color: #e8eef6; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .15s, transform .12s, padding .12s; overflow: hidden; }
.mi .mi-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--gold); transform: scaleY(0); transform-origin: center; transition: transform .15s; }
.mi:hover, .mi:focus-visible { background: rgba(40, 58, 88, .92); padding-left: 30px; outline: none; }
.mi:hover .mi-bar, .mi:focus-visible .mi-bar { transform: scaleY(1); }
.mi:active { transform: scale(.985); }
.mi#btn-play, .mi#btn-continue { background: rgba(255, 180, 58, .94); color: #2a1a05; border-color: rgba(255, 220, 140, .6); }
.mi#btn-continue:not(.hidden) + #btn-play { background: rgba(22, 34, 54, .82); color: #e8eef6; border-color: rgba(255, 255, 255, .09); }
.mi#btn-play:hover, .mi#btn-continue:hover { background: #ffc35c; }
.mi#btn-continue:not(.hidden) + #btn-play:hover { background: rgba(40, 58, 88, .92); }
.mi#btn-play .mi-bar, .mi#btn-continue .mi-bar { background: #2a1a05; }
.mi#btn-continue:not(.hidden) + #btn-play .mi-bar { background: var(--gold); }
.menu-foot { position: absolute; bottom: calc(14px + var(--sab)); left: calc(34px + var(--sal)); right: 14px; color: #8fa0b5; font-size: 12px; letter-spacing: .03em; opacity: .85; }
.laurel { width: 74px; margin: 0 auto 6px; }
@media (max-width: 760px) {
  .menu-shade { background: linear-gradient(0deg, rgba(8, 14, 28, .95) 0%, rgba(8, 14, 28, .78) 55%, rgba(8, 14, 28, .1) 100%); }
  #scr-main { align-items: flex-end; }
  .menu-left { width: 100%; padding: 20px 20px calc(54px + var(--sab)); justify-content: flex-end; }
  .menu-list { max-width: none; }
  .logo-mark { width: 56px; } .tag { margin-bottom: 16px; }
  .menu-foot { left: 20px; }
}
/* ---------- world setup ---------- */
#scr-world { background: linear-gradient(180deg, rgba(6, 11, 22, .86), rgba(6, 11, 22, .93)); align-items: stretch; justify-content: center; padding: calc(14px + var(--sat)) calc(14px + var(--sar)) calc(14px + var(--sab)) calc(14px + var(--sal)); overflow: hidden; }
.ws { display: grid; grid-template-columns: minmax(280px, 440px) minmax(320px, 560px); grid-template-rows: minmax(0, 1fr); gap: 18px; max-width: 1060px; width: 100%; margin: auto; height: 100%; max-height: 800px; justify-content: center; }
.ws-left { overflow-y: auto; scrollbar-width: none; }
.ws > * { min-width: 0; }
.seg { min-width: 0; } .seg button { min-width: 0; padding-left: 2px; padding-right: 2px; }
.ws-left { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.ws-head { font-family: var(--display); font-weight: 800; letter-spacing: .1em; font-size: 22px; margin: 0; }
.ws-head small { display: block; font-family: system-ui; font-weight: 500; letter-spacing: .02em; color: var(--mut); font-size: 13px; margin-top: 2px; }
.prev-wrap { position: relative; background: #0a1220; border: 1px solid var(--line2); border-radius: 14px; padding: 10px; aspect-ratio: 1; max-height: 56vh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prev-wrap canvas { width: 100%; height: 100%; image-rendering: pixelated; border-radius: 8px; object-fit: contain; }
.prev-wrap .busy { position: absolute; inset: 0; background: rgba(8, 14, 26, .55); display: flex; align-items: center; justify-content: center; color: var(--gold); font-weight: 700; letter-spacing: .15em; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.prev-wrap.busy .busy { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--mut); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.wstats { font-size: 12.5px; color: var(--mut); display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wstats div { background: rgba(255, 255, 255, .05); border-radius: 8px; padding: 6px 8px; }
.wstats b { display: block; color: var(--text); font-size: 15px; }
.ws-right { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; overflow: hidden; }
.ws-scroll { overflow-y: auto; padding: 14px 16px 6px; flex: 1; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.ws-actions { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel2); }
.ws-actions .btn { flex: 1; }
.ws-actions .btn.primary { flex: 2; }
.sec { margin: 0 0 16px; }
.sec h3 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sec h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.row label { flex: 0 0 118px; font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 7px; }
.row .ctl { flex: 1; min-width: 0; }
.row .val { flex: 0 0 38px; text-align: right; color: var(--mut); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
input[type=text] { width: 100%; background: rgba(255, 255, 255, .07); border: 1px solid var(--line2); color: var(--text); padding: 9px 11px; border-radius: 9px; font: inherit; user-select: text; -webkit-user-select: text; }
input[type=text]:focus { outline: 2px solid rgba(242, 193, 78, .5); }
input[type=range] { width: 100%; accent-color: var(--gold); height: 28px; margin: 0; touch-action: pan-y; }
.seg { display: flex; background: rgba(255, 255, 255, .06); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { flex: 1; padding: 7px 4px; border-radius: 7px; font-size: 12.5px; color: var(--mut); font-weight: 600; transition: background .12s, color .12s; white-space: nowrap; }
.seg button.on { background: var(--gold); color: #2a1d05; }
.seg button:not(.on):hover { background: rgba(255, 255, 255, .08); color: var(--text); }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.types button { text-align: left; padding: 8px 10px; background: rgba(255, 255, 255, .05); border: 1px solid transparent; border-radius: 10px; }
.types button b { display: block; font-size: 13px; }
.types button span { font-size: 11px; color: var(--mut); line-height: 1.2; display: block; }
.types button.on { border-color: var(--gold); background: rgba(242, 193, 78, .12); }
.seedrow { display: flex; gap: 8px; min-width: 0; }
.seedrow input { min-width: 0; flex: 1; }
.seedrow .btn { flex: none; }
.seedrow .btn { padding: 0 12px; }
.toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; background: rgba(255, 255, 255, .05); border-radius: 10px; text-align: left; }
.toggle .sw { width: 38px; height: 22px; border-radius: 11px; background: rgba(255, 255, 255, .15); position: relative; flex: none; transition: background .15s; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.on .sw { background: var(--green); }
.toggle.on .sw::after { transform: translateX(16px); }
.toggle small { display: block; color: var(--mut); font-size: 11.5px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
.glass { background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#topbar { position: absolute; top: 0; left: 0; right: 0; padding: calc(8px + var(--sat)) calc(8px + var(--sar)) 0 calc(8px + var(--sal)); display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.tb { display: flex; align-items: center; gap: 9px; padding: 6px 12px 6px 10px; border-radius: var(--r); min-height: 48px; text-align: left; }
button.tb:hover { background: var(--panel2); border-color: var(--line2); }
.tb .ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; }
.tb .ic svg { width: 18px; height: 18px; }
.tb .lab { font-size: 10.5px; letter-spacing: .12em; color: var(--mut); text-transform: uppercase; font-weight: 700; line-height: 1; }
.tb .num { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tb .sub { font-size: 11.5px; color: var(--mut); font-variant-numeric: tabular-nums; line-height: 1.1; }
.pos { color: var(--green) !important; } .neg { color: var(--red) !important; } .warn { color: var(--warn) !important; }
#tb-citizen { display: flex; gap: 4px; padding: 5px 6px; border-radius: var(--r); align-items: stretch; }
.chip { display: flex; align-items: center; gap: 7px; padding: 3px 9px 3px 6px; border-radius: 9px; text-align: left; min-width: 0; }
.chip:hover { background: rgba(255, 255, 255, .08); }
.chip .ring { width: 32px; height: 32px; flex: none; position: relative; }
.chip .ring svg { width: 32px; height: 32px; }
.chip .ring .ic2 { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.chip .ring .ic2 svg { width: 15px; height: 15px; }
.chip .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.chip .l { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--mut); font-weight: 700; line-height: 1; }
.chip.alert { background: rgba(232, 87, 79, .16); }
.chip.alert .v { color: #ff9a93; }
.chip.alert.s2 { background: rgba(240, 165, 58, .16); } .chip.alert.s2 .v { color: #ffc57a; }
#tb-time { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: var(--r); }
#tb-time .date { font-weight: 700; font-size: 14px; line-height: 1.1; }
#tb-time .clock { font-size: 11px; color: var(--mut); display: flex; align-items: center; gap: 5px; }
.speed { display: flex; background: rgba(255, 255, 255, .06); border-radius: 9px; padding: 2px; }
.speed button { width: 34px; height: 34px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--mut); }
.speed button svg { width: 16px; height: 16px; }
.speed button.on { background: var(--gold); color: #2a1d05; }
.rci { display: flex; gap: 3px; align-items: flex-end; height: 34px; padding: 0 4px; }
.rci div { width: 9px; height: 100%; background: rgba(255, 255, 255, .08); border-radius: 3px; position: relative; overflow: hidden; }
.rci i { position: absolute; left: 0; right: 0; bottom: 50%; background: currentColor; transition: height .4s, bottom .4s; }
.rci .r { color: #46c98b; } .rci .c { color: #4aa8ff; } .rci .i { color: #e8b84a; }
.rci b { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255, 255, 255, .35); }

#advisor { position: absolute; left: 50%; transform: translateX(-50%); top: calc(66px + var(--sat)); max-width: min(520px, calc(100vw - 24px)); display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px; font-size: 13px; text-align: left; border-color: rgba(242, 193, 78, .35); }
#advisor b { color: var(--gold); letter-spacing: .08em; font-size: 10.5px; text-transform: uppercase; flex: none; }
#advisor span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#advisor .x { width: 20px; height: 20px; flex: none; opacity: .6; }

#toasts { position: absolute; left: calc(10px + var(--sal)); top: calc(118px + var(--sat)); display: flex; flex-direction: column; gap: 6px; width: min(340px, calc(100vw - 80px)); pointer-events: none !important; }
.toast { pointer-events: auto; padding: 8px 12px 8px 10px; border-radius: 10px; font-size: 13px; display: flex; gap: 9px; align-items: flex-start; animation: tin .3s ease both; border-left: 3px solid var(--blue); }
.toast.good { border-left-color: var(--green); } .toast.bad { border-left-color: var(--red); } .toast.warn { border-left-color: var(--warn); }
.toast.out { animation: tout .4s ease both; }
@keyframes tin { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes tout { to { opacity: 0; transform: translateX(-16px); } }

#side { position: absolute; right: calc(8px + var(--sar)); top: 50%; transform: translateY(-58%); display: flex; flex-direction: column; gap: 8px; }
#minimap { position: absolute; left: calc(8px + var(--sal)); bottom: calc(var(--bh, 150px) + 8px); width: 168px; height: 168px; border-radius: 12px; overflow: hidden; padding: 5px; }
#minimap canvas { width: 100%; height: 100%; border-radius: 8px; display: block; touch-action: none; }

#toolinfo { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bh, 150px) + 8px); width: min(560px, calc(100vw - 16px)); border-radius: 12px; padding: 9px 12px; display: flex; gap: 12px; align-items: center; }
#toolinfo .ti-main { flex: 1; min-width: 0; }
#toolinfo b { font-size: 14px; }
#toolinfo .d { color: var(--mut); font-size: 12.5px; line-height: 1.3; margin-top: 2px; }
#toolinfo .meta { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
#toolinfo .meta span { color: var(--mut); } #toolinfo .meta em { font-style: normal; color: var(--text); font-weight: 600; }
#confirm { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--bh, 150px) + 84px); display: flex; gap: 10px; }
#confirm .btn { padding: 12px 22px; font-size: 15px; box-shadow: 0 6px 22px rgba(0, 0, 0, .5); }
#cost-tip { position: absolute; transform: translate(-50%, -140%); padding: 4px 9px; border-radius: 8px; background: rgba(10, 16, 28, .92); border: 1px solid var(--line2); font-weight: 700; font-size: 13px; pointer-events: none !important; white-space: nowrap; }

#bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 calc(8px + var(--sar)) calc(6px + var(--sab)) calc(8px + var(--sal)); }
#build { border-radius: 16px 16px 12px 12px; overflow: hidden; }
#cats { display: flex; gap: 2px; padding: 5px 5px 0; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; border-bottom: 1px solid var(--line); }
#cats::-webkit-scrollbar, #items::-webkit-scrollbar { display: none; }
#cats button { flex: 1 0 auto; min-width: 58px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 10px 7px; border-radius: 10px 10px 0 0; color: var(--mut); font-size: 11px; font-weight: 600; letter-spacing: .02em; position: relative; }
#cats button svg { width: 22px; height: 22px; }
#cats button.on { color: var(--gold); background: rgba(242, 193, 78, .1); }
#cats button.on::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: 0; height: 3px; border-radius: 2px 2px 0 0; background: var(--gold); }
#cats .collapse { flex: 0 0 38px; min-width: 38px; padding: 0; justify-content: center; }
#items { display: flex; gap: 7px; padding: 9px 9px 10px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
.card { flex: 0 0 auto; width: 92px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid transparent; padding: 5px 4px 6px; text-align: center; position: relative; transition: background .12s, border-color .12s, transform .08s; }
.card:hover { background: rgba(255, 255, 255, .1); }
.card:active { transform: scale(.96); }
.card.on { border-color: var(--gold); background: rgba(242, 193, 78, .14); }
.card canvas { width: 64px; height: 56px; display: block; margin: 0 auto; }
.card .n { font-size: 11.5px; font-weight: 600; line-height: 1.15; height: 27px; display: flex; align-items: center; justify-content: center; }
.card .p { font-size: 11px; color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 700; }
.card.locked { opacity: .5; }
.card.locked .p { color: var(--mut); }
.card.poor .p { color: var(--red); }
.card .lock { position: absolute; top: 4px; right: 4px; width: 16px; height: 16px; color: var(--mut); }
#bottom.min #items, #bottom.min #cats button:not(.collapse) { display: none; }
#bottom.min #cats { border-bottom: 0; padding-bottom: 5px; }

/* ---------- sheets (panels) ---------- */
#modal-root { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(4, 8, 16, .55); pointer-events: auto; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(720px, calc(100vw - 20px)); max-height: min(86vh, 760px); display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; pointer-events: auto; animation: pop .22s cubic-bezier(.2, .9, .3, 1) both; background: var(--panel2); border: 1px solid var(--line2); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
.sheet.narrow { width: min(460px, calc(100vw - 20px)); }
.sh-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.sh-head h2 { margin: 0; font-family: var(--display); font-size: 18px; letter-spacing: .08em; flex: 1; font-weight: 800; }
.sh-tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.sh-tabs button { padding: 8px 14px; border-radius: 9px 9px 0 0; color: var(--mut); font-weight: 600; position: relative; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.sh-tabs button.on { color: var(--gold); background: rgba(242, 193, 78, .1); }
.sh-tabs button.on::after { content: ""; position: absolute; left: 10%; right: 10%; bottom: 0; height: 3px; background: var(--gold); border-radius: 2px 2px 0 0; }
.sh-tabs .badge { background: var(--red); color: #fff; font-size: 10.5px; border-radius: 9px; padding: 1px 6px; font-weight: 700; }
.sh-body { padding: 16px 18px 20px; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.box { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.box h4 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--mut); font-weight: 700; display: flex; align-items: center; gap: 7px; }
.box h4 svg { width: 15px; height: 15px; }
.big-n { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.kv span:first-child { color: var(--mut); }
.bar { height: 8px; border-radius: 5px; background: rgba(255, 255, 255, .1); overflow: hidden; margin: 5px 0 3px; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 5px; background: var(--green); transition: width .3s; }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--red); } .bar.blue > i { background: var(--blue); }
.bar2 { display: flex; align-items: center; gap: 10px; font-size: 12.5px; margin: 5px 0; }
.bar2 .nm { flex: 0 0 96px; color: var(--mut); }
.bar2 .tr { flex: 1; height: 8px; background: rgba(255, 255, 255, .08); border-radius: 4px; position: relative; }
.bar2 .tr i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.bar2 .tr::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255, 255, 255, .3); }
.bar2 .vv { flex: 0 0 46px; text-align: right; font-variant-numeric: tabular-nums; }
.prob { display: flex; gap: 12px; padding: 11px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); margin-bottom: 8px; align-items: flex-start; }
.prob .sv { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex: none; background: var(--blue); }
.prob.s2 .sv { background: var(--warn); } .prob.s3 .sv { background: var(--red); box-shadow: 0 0 10px var(--red); }
.prob .tx { flex: 1; } .prob .tx b { display: block; font-size: 14px; } .prob .tx span { color: var(--mut); font-size: 12.5px; }
.empty { text-align: center; padding: 30px 10px; color: var(--mut); }
.empty svg { width: 46px; height: 46px; margin: 0 auto 10px; color: var(--green); }
.slider-row { display: grid; grid-template-columns: 110px 1fr 50px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.slider-row .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
table.led { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.led td { padding: 4px 0; border-bottom: 1px solid var(--line); } table.led td:last-child { text-align: right; }
table.led tr.t td { font-weight: 800; border-bottom: 0; padding-top: 8px; }
.layers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layers button { padding: 12px 6px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid transparent; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.layers button svg { width: 24px; height: 24px; }
.layers button.on { border-color: var(--gold); background: rgba(242, 193, 78, .14); color: var(--gold); }
.goal { display: flex; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04); margin-bottom: 7px; align-items: flex-start; }
.goal .ck { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line2); flex: none; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.goal.done .ck { background: var(--green); border-color: var(--green); color: #05230f; }
.goal.done { opacity: .6; } .goal.cur { border: 1px solid rgba(242, 193, 78, .45); background: rgba(242, 193, 78, .08); }
.goal .ck svg { width: 13px; height: 13px; }
.goal b { display: block; } .goal span { color: var(--mut); font-size: 12.5px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: rgba(255, 255, 255, .1); }
.pill.ok { background: rgba(70, 201, 139, .2); color: #7de7b2; } .pill.bad { background: rgba(232, 87, 79, .22); color: #ff9d97; } .pill.warn { background: rgba(240, 165, 58, .22); color: #ffc57a; }
.help h3 { margin: 18px 0 6px; font-family: var(--display); letter-spacing: .06em; color: var(--gold); font-size: 16px; }
.help h3:first-child { margin-top: 0; }
.help p, .help li { color: #c8d3e0; font-size: 13.5px; line-height: 1.5; margin: 0 0 6px; }
.help ul { padding-left: 18px; margin: 0 0 6px; }
.keys kbd { background: rgba(255, 255, 255, .12); border-radius: 5px; padding: 1px 6px; font-family: inherit; font-size: 12px; border: 1px solid var(--line2); }
.hero { text-align: center; padding: 10px 6px 4px; }
.hero h2 { font-family: var(--display); font-size: 26px; margin: 8px 0 4px; letter-spacing: .08em; color: var(--gold); }
.hero p { color: #c8d3e0; margin: 0 auto 14px; max-width: 420px; }
.hero .laurel { width: 90px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btnrow .btn { flex: 1; min-width: 120px; }
.list-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 14px; border-radius: 12px; background: rgba(255, 255, 255, .06); margin-bottom: 8px; font-weight: 600; font-size: 15px; }
.list-btn:hover { background: rgba(255, 255, 255, .11); }
.list-btn svg { width: 22px; height: 22px; color: var(--gold); }
.list-btn small { display: block; color: var(--mut); font-weight: 400; font-size: 12px; }

#loading { position: fixed; inset: 0; z-index: 60; background: radial-gradient(ellipse at 50% 40%, #12202f, #070c15); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
#loading .t { font-family: var(--display); letter-spacing: .2em; color: var(--gold); font-weight: 800; }
#loading .sp { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .12); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#fps { position: fixed; right: 8px; bottom: 4px; z-index: 5; font-size: 11px; color: rgba(255, 255, 255, .6); pointer-events: none; }

/* ---------- tech tree, garage, misc additions ---------- */
.iconbtn { position: relative; }
.iconbtn:disabled { opacity: .38; pointer-events: none; }
.dot-badge { position: absolute; top: 5px; right: 5px; width: 11px; height: 11px; border-radius: 50%; background: var(--gold); border: 2px solid var(--panel); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.3); } }
.card.locked .p { color: #b9a3f0; }
.sheet.wide { width: min(1040px, calc(100vw - 20px)); max-height: min(92vh, 840px); }
.tdetail { display: flex; gap: 16px; align-items: flex-start; padding: 12px 14px; margin-bottom: 12px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 12px; }
.td-main { flex: 1; min-width: 0; }
.td-main h3 { margin: 0 0 4px; font-family: var(--display); font-size: 19px; font-weight: 800; }
.td-main p { margin: 0 0 8px; color: #c8d3e0; font-size: 13px; }
.rqs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.rq { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: rgba(255, 255, 255, .08); font-weight: 700; }
.rq.ok { background: rgba(70, 201, 139, .2); color: #7de7b2; } .rq.no { background: rgba(232, 87, 79, .2); color: #ff9d97; }
.unl { font-size: 12.5px; color: var(--mut); }
.td-act { flex: none; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; min-width: 150px; }
.td-act small { color: var(--mut); font-size: 11.5px; text-align: right; max-width: 180px; }
.tree-wrap { overflow: auto; border-radius: 12px; background: rgba(0, 0, 0, .2); border: 1px solid var(--line); max-height: 50vh; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.tree { position: relative; }
.tr-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.tr-lines path { fill: none; stroke: rgba(255, 255, 255, .18); stroke-width: 2; }
.tr-lines path.on { stroke: var(--green); stroke-width: 2.6; }
.tr-row { position: absolute; left: 10px; width: 92px; display: flex; align-items: center; height: 76px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.tnode { position: absolute; border-radius: 12px; padding: 9px 30px 9px 12px; text-align: left; background: rgba(40, 56, 84, .92); border: 2px solid rgba(255, 255, 255, .1); display: flex; flex-direction: column; gap: 3px; justify-content: center; overflow: hidden; transition: transform .1s, border-color .15s; }
.tnode:hover { transform: translateY(-2px); }
.tnode b { font-size: 13.5px; line-height: 1.15; } .tnode span { font-size: 11.5px; color: var(--mut); line-height: 1.2; }
.tnode.locked { opacity: .5; } .tnode.pop, .tnode.cash { opacity: .88; }
.tnode.ready { border-color: var(--gold); background: rgba(255, 180, 58, .16); animation: glow 1.6s ease-in-out infinite; }
.tnode.done { border-color: rgba(70, 201, 139, .7); background: rgba(70, 201, 139, .15); }
.tnode.sel { box-shadow: 0 0 0 3px rgba(255, 255, 255, .4); }
.tnode i { position: absolute; right: 8px; top: 8px; width: 18px; height: 18px; color: var(--green); }
.tnode i.rd { color: var(--gold); }
@keyframes glow { 50% { box-shadow: 0 0 14px rgba(255, 180, 58, .55); } }
.trow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow canvas { width: 76px; height: 48px; flex: none; }
.trow > div { flex: 1; min-width: 0; }
.trow b { display: block; font-size: 13.5px; } .trow span { display: block; color: var(--mut); font-size: 12px; line-height: 1.3; }
.trow .bar { margin: 4px 0 0; }
/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .ws { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 10px; overflow-y: auto; margin: 0; align-content: start; max-height: none; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
  .ws-left { overflow: visible; }
  #scr-world { align-items: flex-start; }
  .ws-left { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .ws-left > .ws-head { flex: 1 1 100%; }
  .prev-wrap { flex: 0 0 min(46vw, 260px); max-height: none; padding: 6px; }
  .ws-left .side-info { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 8px; }
  .ws-right { overflow: visible; background: none; border: 0; }
  .ws-scroll { overflow: visible; padding: 0 2px; }
  .ws-actions { position: sticky; bottom: 0; border-radius: 14px; border: 1px solid var(--line2); }
  .wstats { grid-template-columns: repeat(2, 1fr); }
  #prev-mode { flex-wrap: wrap; } #prev-mode button { flex: 1 0 44%; }
}
@media (max-width: 720px) {
  .tb { padding: 5px 9px 5px 7px; min-height: 44px; gap: 7px; }
  .tb .ic { width: 26px; height: 26px; } .tb .num { font-size: 16px; }
  #tb-citizen { order: 5; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
  #tb-citizen .chip { flex: 1 0 auto; }
  #tb-time { margin-left: auto; padding-left: 8px; }
  #tb-time .clock, .rci { display: none; }
  #advisor { top: calc(112px + var(--sat)); font-size: 12px; padding: 6px 12px; }
  #toasts { top: calc(150px + var(--sat)); }
  .speed button { width: 28px; height: 32px; }
  #tb-menu { padding: 0 9px; } #topbar { gap: 6px; }
  #tb-time { padding: 4px; } #tb-time .date { display: none; }
  .toast { font-size: 12px; padding: 6px 10px; }
  #side { top: calc(178px + var(--sat)); transform: none; gap: 6px; display: grid; grid-template-columns: repeat(2, 40px); }
  #toolinfo .d { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .iconbtn { width: 40px; height: 40px; }
  #minimap { width: 128px; height: 128px; }
  .card { width: 82px; } .card canvas { width: 56px; height: 50px; }
  #cats button { min-width: 52px; padding: 5px 7px 6px; font-size: 10.5px; }
  .sheet { top: auto; bottom: 0; left: 0; transform: none; width: 100vw !important; max-height: 88vh; border-radius: 18px 18px 0 0; animation: slide .25s cubic-bezier(.2, .9, .3, 1) both; padding-bottom: var(--sab); }
  @keyframes slide { from { transform: translateY(40px); opacity: 0; } }
  .grid2 { grid-template-columns: 1fr; } .grid3 { grid-template-columns: 1fr 1fr; }
  .tdetail { flex-direction: column; } .td-act { align-items: stretch; min-width: 0; width: 100%; } .td-act small { text-align: left; max-width: none; }
  .tree-wrap { max-height: 46vh; } .sheet.wide { width: 100vw !important; }
  .types { grid-template-columns: 1fr 1fr; }
  .row label { flex-basis: 96px; font-size: 12.5px; }
  .layers { grid-template-columns: repeat(3, 1fr); }
  .slider-row { grid-template-columns: 86px 1fr 46px; }
  .btn.big { min-width: 220px; }
}
@media (max-width: 420px) {
  #tb-cash .ic, #tb-pop .ic { display: none; } .tb { padding: 5px 10px; }
  #tb-menu { padding: 0 10px; } .speed button { width: 24px; height: 30px; } .speed button svg { width: 14px; height: 14px; } #topbar { gap: 5px; }
  .tb .num { font-size: 15px; } .tb .lab { font-size: 9.5px; letter-spacing: .08em; }
  .chip { padding: 3px 5px 3px 3px; gap: 5px; } .chip .ring, .chip .ring svg { width: 26px; height: 26px; } .chip .ring .ic2 svg { width: 12px; height: 12px; } .chip .v { font-size: 13px; } .chip .l { font-size: 9px; letter-spacing: .06em; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #minimap { display: none; }
  #toasts { top: calc(64px + var(--sat)); width: min(300px, 40vw); }
  #advisor { display: none; }
  #topbar { padding-top: calc(5px + var(--sat)); }
  .tb { min-height: 42px; padding-top: 3px; padding-bottom: 3px; }
  #toolinfo { padding: 6px 10px; bottom: calc(var(--bh, 120px) + 4px); }
  #toolinfo .d { display: none; }
  #cats button span { display: none; }
  #cats button { min-width: 44px; padding: 5px 10px; flex-direction: row; }
  #cats button svg { width: 19px; height: 19px; }
  #items { padding: 6px 8px 8px; gap: 6px; }
  .card { width: 70px; padding: 3px 3px 4px; } .card canvas { width: 48px; height: 40px; } .card .n { height: 22px; font-size: 10px; }
  #side { top: calc(60px + var(--sat)); transform: none; display: grid; grid-template-columns: repeat(2, 38px); gap: 6px; }
  .iconbtn { width: 38px; height: 38px; } .iconbtn svg { width: 19px; height: 19px; }
  #tb-time .clock { display: none; }
  .sheet { max-height: 94vh; width: min(720px, calc(100vw - 20px)) !important; left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); border-radius: 16px; }
}
/* ---------- military & attack planning ---------- */
.cityic { width: 38px; height: 38px; flex: none; border-radius: 10px; background: rgba(255,255,255,.08); display: grid; place-items: center; color: var(--gold); }
.cityic svg { width: 20px; height: 20px; }
#alert { position: absolute; left: 50%; transform: translateX(-50%); top: calc(108px + var(--sat)); max-width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 12px; background: rgba(60, 14, 12, .92); border: 1px solid rgba(232, 87, 79, .7); color: #ffd9d5; font-size: 13px; cursor: pointer; z-index: 6; box-shadow: 0 6px 24px rgba(0,0,0,.45); }
#alert.urgent { animation: alertpulse .9s ease-in-out infinite; }
#alert b { color: #ff6b61; letter-spacing: .1em; font-size: 11px; flex: none; }
#alert span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes alertpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,87,79,.6), 0 6px 24px rgba(0,0,0,.45); } 50% { box-shadow: 0 0 0 7px rgba(232,87,79,0), 0 6px 24px rgba(0,0,0,.45); } }
#alert.hidden { display: none; }
#advisor { z-index: 5; }
body.attacking #bottom, body.attacking #side, body.attacking #toolinfo, body.attacking #inspector, body.attacking #alert, body.attacking #advisor, body.attacking #tb-citizen { display: none !important; }
#atk { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(8px + var(--sab)); width: min(760px, calc(100vw - 16px)); border-radius: 14px; padding: 10px 12px; z-index: 7; }
#atk .atk-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#atk .atk-head b { font-size: 16px; color: var(--red); display: block; }
#atk .atk-head span { color: var(--mut); font-size: 12.5px; }
#atk .atk-hint { font-size: 13px; margin: 6px 0; color: var(--text); }
#atk .atk-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.atk-card { flex: none; width: 132px; border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; text-align: center; }
.atk-card canvas { width: 64px; height: 38px; }
.atk-card b { font-size: 12.5px; } .atk-card span { font-size: 11px; color: var(--mut); }
.atk-card.sel { border-color: var(--gold); background: rgba(242,193,78,.12); }
.atk-card.aimed { box-shadow: inset 0 0 0 1px rgba(125,231,178,.5); }
.atk-card .stp { display: flex; align-items: center; gap: 4px; margin: 3px 0; }
.atk-card .stp button { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.1); font-size: 17px; font-weight: 800; }
.atk-card .stp i { font-style: normal; font-size: 12px; min-width: 40px; font-variant-numeric: tabular-nums; }
.atk-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 12.5px; color: var(--mut); }
.badge { background: var(--red); color: #fff; font-size: 10.5px; border-radius: 9px; padding: 1px 6px; font-weight: 700; margin-left: 4px; }
@media (max-width: 720px) { #alert { top: calc(154px + var(--sat)); font-size: 12px; } #atk { padding: 8px; } .atk-card { width: 118px; } }

/* ---------- inspector ---------- */
#inspector { position: absolute; right: calc(62px + var(--sar)); top: calc(80px + var(--sat)); width: min(300px, calc(100vw - 80px)); max-height: calc(100vh - var(--bh, 150px) - 110px); overflow-y: auto; border-radius: 14px; padding: 12px 14px; z-index: 4; font-size: 13px; scrollbar-width: thin; }
#inspector .btnrow { margin-top: 8px; } #inspector .btnrow .btn { min-width: 0; }
@media (max-width: 720px) { #inspector { right: calc(58px + var(--sar)); left: calc(8px + var(--sal)); width: auto; top: auto; bottom: calc(var(--bh, 150px) + 8px); max-height: 38vh; } }

.trow > .cityic { flex: none; }
.trow span.pill { display: inline-block; font-size: 11px; line-height: 1.4; }
