﻿:root {
  --bg: #0d131c;
  --panel: rgba(18, 26, 38, 0.94);
  --panel-2: #1b2636;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8eef7;
  --muted: #8fa0b8;
  --accent: #ffd166;
  --accent-2: #5ec2ff;
  --good: #69f0ae;
  --bad: #ff6b6b;
  --radius: 12px;
  font-family: Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: 'Space Grotesk', Inter, sans-serif; margin: 0; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- scrolling pages (home, loading, guide, privacy) ---------- */
html:has(body.page) { overflow-y: auto; height: auto; }
body.page { overflow: visible; height: auto; min-height: 100vh; background:
  radial-gradient(1200px 600px at 20% -10%, rgba(94,194,255,.18), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(255,209,102,.14), transparent 60%), var(--bg) fixed; }
a { color: var(--accent-2); }
a.btn { display: inline-block; text-decoration: none; color: var(--text); text-align: center; }
a.btn.primary { color: #1a1300; }
.site-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; max-width: 980px; margin: 0 auto; flex-wrap: wrap; }
.nav-brand { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--text); text-decoration: none; font-size: 17px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--panel-2); }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 24px; }
.intro-text p { color: var(--muted); line-height: 1.6; margin: 0 0 10px; }
.intro-text p:last-child { margin: 0; }

.content { max-width: 780px; margin: 0 auto; padding: 16px 16px 32px; line-height: 1.65; }
.content h1 { font-size: clamp(28px, 6vw, 40px); margin: 8px 0 12px; }
.content h2 { font-size: 22px; margin: 32px 0 10px; }
.content h3 { font-size: 17px; margin: 20px 0 8px; }
.content .lead { font-size: 18px; color: var(--muted); }
.content ul { padding-left: 20px; }
.content li { margin: 4px 0; }
.content table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; display: block; overflow-x: auto; }
.content th, .content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.content th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

.loading-wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 32px; display: flex; flex-direction: column; gap: 20px; align-items: center; }
.big-btn { margin-top: 18px; width: 100%; padding: 14px; font-size: 17px; }
.small-note { font-size: 12px; margin: 12px 0 0; }

/* ---------- ad slots ---------- */
.ad-wrap { width: 100%; max-width: 760px; margin: 0 auto; text-align: center; }
.ad-wrap.ad-on { min-height: 120px; padding: 8px 0; }
.ad-wrap:has(ins[data-ad-status="unfilled"]) { display: none; }   /* no ad available → no empty box */
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad-panel { margin-top: 16px; border-top: 1px solid var(--line); }
.home-link { text-decoration: none; font-size: 20px; }

/* ---------- buttons ---------- */
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 600; transition: background .15s, transform .05s; }
.btn:hover { background: #24324a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #ffb703, #ffd166); color: #1a1300; border: 0; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.icon { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; font-size: 18px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- start ---------- */
#start-screen { overflow-y: auto; background:
  radial-gradient(1200px 600px at 20% -10%, rgba(94,194,255,.18), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(255,209,102,.14), transparent 60%), var(--bg); }
.start-wrap { max-width: 720px; margin: 0 auto; padding: 48px 16px 32px; display: flex; flex-direction: column; gap: 20px; }
.brand { text-align: center; }
.logo { font-size: 56px; }
.brand h1 { font-size: clamp(34px, 7vw, 52px); letter-spacing: -0.02em; background: linear-gradient(90deg, #fff, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); font-size: 18px; margin: 8px 0 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.card h3 { margin-bottom: 12px; }
#search-form { display: flex; gap: 8px; }
#search-input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: #0f1824; outline: none; font-size: 16px; }
#search-input:focus { border-color: var(--accent-2); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { background: #142033; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.result { text-align: left; padding: 10px 12px; border-radius: 10px; background: #142033; border: 1px solid var(--line); cursor: pointer; }
.result:hover { border-color: var(--accent); }
.result b { display: block; }
.result small { color: var(--muted); }
.size-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.size-row select { flex: 1; padding: 8px; border-radius: 8px; background: #0f1824; border: 1px solid var(--line); }
.save-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: #142033; margin-bottom: 6px; }
.save-item .grow { flex: 1; min-width: 0; }
.save-item small { color: var(--muted); display: block; }
.row-btns { display: flex; gap: 8px; margin-top: 8px; }
.credits { color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- loading ---------- */
#loading-screen { display: none; place-items: center; background: var(--bg); padding: 16px; }
#loading-screen.active { display: grid; }
.loading-card { width: min(520px, 100%); }
#load-steps { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 10px; }
#load-steps li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
#load-steps li .st { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #3a4a62; flex: none; display: grid; place-items: center; font-size: 12px; }
#load-steps li.active { color: var(--text); }
#load-steps li.active .st { border-color: var(--accent-2); border-top-color: transparent; animation: spin .8s linear infinite; }
#load-steps li.done { color: var(--text); }
#load-steps li.done .st { background: var(--good); border-color: var(--good); }
#load-steps li.done .st::after { content: '✓'; color: #003; font-weight: 800; }
#load-steps li.warn .st { background: var(--accent); border-color: var(--accent); }
#load-steps li em { color: var(--muted); font-style: normal; font-size: 13px; margin-left: auto; text-align: right; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- game layout ---------- */
#game-screen { background: var(--bg); }
#map { position: absolute; inset: 56px 0 0 0; }
#map canvas { display: block; touch-action: none; }
#topbar { position: absolute; top: 0; left: 0; right: 0; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; }
.city-title { min-width: 0; }
#city-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
#era-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
#resources { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; justify-content: center; }
#resources::-webkit-scrollbar { display: none; }
.res { display: flex; align-items: center; gap: 6px; background: #121c2a; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; white-space: nowrap; flex: none; }
.res .ic { font-size: 16px; }
.res .v { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; }
.res .r { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.res .r.neg { color: var(--bad); }
.res .r.pos { color: var(--good); }
.res.warn { border-color: var(--bad); }
.top-actions { display: flex; gap: 6px; }

#panel { position: absolute; top: 68px; right: 12px; bottom: 12px; width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; z-index: 4; backdrop-filter: blur(8px); }
#panel-toggle { display: none; }
.tabs { display: flex; padding: 6px; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--panel-2); color: var(--text); }
.tab-body { flex: 1; overflow-y: auto; padding: 12px; }

.cat-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 6px; }
.cat-title:first-child { margin-top: 0; }
.bcard { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: #142033; border: 1px solid transparent; cursor: pointer; margin-bottom: 6px; width: 100%; text-align: left; }
.bcard:hover { border-color: #33476a; }
.bcard.sel { border-color: var(--accent); background: #2a2a1c; }
.bcard.locked { opacity: .45; cursor: not-allowed; }
.bcard .bi { font-size: 26px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; flex: none; }
.bcard .bn { font-weight: 700; font-size: 14px; }
.bcard .bd { font-size: 12px; color: var(--muted); }
.bcard .bc { font-size: 12px; margin-left: auto; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bcard .bc .no { color: var(--bad); }
.size2 { font-size: 10px; background: #33476a; padding: 1px 5px; border-radius: 4px; margin-left: 4px; }

.era-col { margin-bottom: 14px; }
.era-col h4 { margin: 0 0 6px; font-size: 13px; }
.tech { padding: 10px; border-radius: 10px; background: #142033; margin-bottom: 6px; border: 1px solid var(--line); }
.tech .tn { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }
.tech .tu { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tech .tr { font-size: 12px; color: var(--muted); }
.tech.done { border-color: rgba(105,240,174,.4); background: #12261f; }
.tech.locked { opacity: .5; }
.tech.ready { border-color: var(--accent); }
.tech button { margin-top: 8px; width: 100%; }
.progress { height: 6px; background: #0c131d; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--good)); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { background: #142033; border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.bonus { display: flex; gap: 10px; padding: 8px; background: #142033; border-radius: 10px; margin-bottom: 6px; }
.bonus .bi { font-size: 22px; }
.bonus b { font-size: 13px; }
.bonus div div { font-size: 12px; color: var(--muted); }
.future-banner { background: linear-gradient(135deg, #1d3557, #2b2d42); border: 1px solid #3c5a8a; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.future-banner .quote { font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 700; }
.future-banner .big { font-size: 26px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 4px 0; }
.bar-row .lab { width: 74px; color: var(--muted); }
.bar-row .bar { flex: 1; height: 8px; background: #0c131d; border-radius: 4px; overflow: hidden; }
.bar-row .bar > div { height: 100%; }
.bar-row .pc { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

#map-controls { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; align-items: center; z-index: 3; background: var(--panel); padding: 6px; border-radius: 12px; border: 1px solid var(--line); }
.seg { display: flex; background: #0f1824; border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 9px; cursor: pointer; font-size: 16px; opacity: .55; }
.seg button.active { opacity: 1; background: #24324a; }
#overlay-op { width: 80px; accent-color: var(--accent); }

#tool-bar { position: absolute; left: 12px; top: 68px; display: flex; gap: 6px; align-items: center; z-index: 3; flex-wrap: wrap; max-width: calc(100% - 380px); }
.tool { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.tool.active { border-color: var(--accent); color: var(--accent); }
#tool-hint { font-size: 13px; background: rgba(0,0,0,.55); padding: 6px 10px; border-radius: 8px; }
#tool-hint:empty { display: none; }

#hover-tip { position: absolute; z-index: 2; pointer-events: none; max-width: 260px; background: rgba(15,22,33,.92); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.45; box-shadow: 0 6px 18px rgba(0,0,0,.4); backdrop-filter: blur(4px); }
#hover-tip .t { font-weight: 700; font-size: 13px; }
#hover-tip .place { color: var(--text); }
#hover-tip .muted { color: var(--muted); }
#hover-tip .why { color: var(--bad); }
@media (hover: none) { #hover-tip { display: none !important; } }
#tile-info { position: absolute; left: 12px; bottom: 68px; width: min(320px, calc(100% - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; z-index: 3; font-size: 13px; }
#tile-info h4 { margin: 0 0 4px; font-size: 15px; }
#tile-info .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 18px; }
#tile-info .kv { display: flex; justify-content: space-between; color: var(--muted); }
#tile-info .kv b { color: var(--text); }
#tile-info .btn { margin-top: 8px; width: 100%; }
.warn-text { color: var(--bad); }

.attribution { position: absolute; right: 364px; bottom: 4px; font-size: 10px; color: rgba(255,255,255,.75); text-shadow: 0 1px 2px #000; z-index: 2; text-align: right; }

/* ---------- modal & toasts ---------- */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(460px, 100%); max-height: 90vh; overflow-y: auto; }
.modal-box h2 { margin-bottom: 8px; }
.modal-box .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.modal-box .btns .btn { flex: 1; }
.gain-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
#toasts { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; align-items: center; }
.toast { background: rgba(20, 30, 45, .96); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; font-size: 14px; animation: tin .2s ease-out; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.bad { border-color: var(--bad); }
.toast.good { border-color: var(--good); }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  #topbar { height: auto; flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  #resources { order: 3; flex-basis: 100%; justify-content: flex-start; }
  #map { top: 96px; }
  #city-name { max-width: 55vw; }
  .top-actions .lbl { display: none; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 42vh; border-radius: 16px 16px 0 0; }
  #panel.collapsed { height: 46px; }
  #panel.collapsed .tab-body { display: none; }
  #panel-toggle { display: block; position: absolute; right: 12px; bottom: calc(42vh + 8px); z-index: 4; }
  #panel.collapsed + #panel-toggle { bottom: 54px; }
  #tool-bar { top: 104px; max-width: calc(100% - 24px); }
  #map-controls { bottom: auto; top: 148px; left: auto; right: 12px; flex-direction: column; }
  #overlay-op { width: 36px; writing-mode: vertical-lr; direction: rtl; height: 70px; }
  .seg { flex-direction: column; }
  #tile-info { bottom: calc(42vh + 8px); }
  .attribution { right: 8px; bottom: calc(42vh + 2px); }
  #toasts { top: 100px; }
}
