:root {
  --navy: #0f1f3d; --navy2: #16305e; --panel: rgba(12, 28, 58, 0.92); --line: rgba(255,255,255,0.14);
  --gold: #ffcf4a; --gold2: #ffb300; --text: #f4f7ff; --muted: rgba(244,247,255,0.68); --green: #4cd964; --red: #ff5252; --blue: #4fc3f7;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f4f8f; color: var(--text); font-family: var(--font); font-size: 15px; }
button, input, select { font-family: inherit; font-size: inherit; }
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
.hidden { display: none !important; }

/* ---------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; padding: max(8px, env(safe-area-inset-top)) 10px 0; gap: 8px; }
.hud-left, .hud-right { display: flex; gap: 6px; pointer-events: auto; flex-wrap: wrap; }
.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: auto; }
.hud-btn { position: relative; width: 46px; height: 46px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.25); background: linear-gradient(180deg, #2d5aa6, #1b3f7e); color: #fff; cursor: pointer; display: grid; place-items: center; box-shadow: 0 3px 0 #0b2550, 0 6px 14px rgba(0,0,0,0.35); transition: transform .08s; }
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0b2550; }
.hud-btn .ico { font-size: 22px; line-height: 1; }
.hud-btn .badge, .badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font-style: normal; font-weight: 800; font-size: 12px; display: grid; place-items: center; border: 2px solid #fff; }
.gold-pill { display: flex; align-items: center; gap: 6px; padding: 6px 16px; border-radius: 999px; background: linear-gradient(180deg, #2d5aa6, #1b3f7e); border: 2px solid rgba(255,255,255,0.25); box-shadow: 0 3px 0 #0b2550, 0 6px 14px rgba(0,0,0,0.35); font-weight: 900; font-size: 22px; }
.gold-pill i { font-style: normal; font-size: 22px; } .gold-pill small { font-size: 13px; color: var(--gold); font-weight: 700; }
.sub-pill { padding: 3px 12px; border-radius: 999px; background: rgba(0,15,40,0.6); font-weight: 700; font-size: 13px; }
.sub-pill.good { background: linear-gradient(90deg, #ff9800, #ffd54a); color: #3a2000; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }
#toasts { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { padding: 8px 14px; border-radius: 12px; background: rgba(0,15,40,0.88); border: 1px solid var(--line); font-weight: 700; animation: toastIn .25s ease-out; text-align: center; }
.toast.good { border-color: var(--green); } .toast.bad { border-color: var(--red); } .toast.gold { border-color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
.tutorial { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(92vw, 460px); background: var(--panel); border: 2px solid var(--gold); border-radius: 16px; padding: 12px 14px; pointer-events: auto; }
.tutorial p { margin: 0 0 8px; font-weight: 600; }

/* ---------- Nation panel */
.panel-side { position: absolute; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: min(92vw, 340px); max-height: min(70vh, 560px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px; pointer-events: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.np-head { display: flex; gap: 10px; align-items: center; }
.np-head h3 { margin: 0; font-size: 20px; } .np-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.np-head > div { flex: 1; }
.np-forces { display: flex; gap: 6px; margin: 10px 0; }
.force { flex: 1; text-align: center; padding: 6px 4px; border-radius: 10px; background: rgba(255,255,255,0.08); font-weight: 800; }
.force small { display: block; font-weight: 600; color: var(--muted); font-size: 11px; }
.bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.12); overflow: hidden; margin: 4px 0 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #ff5252, #ffd54a 50%, #4cd964); transition: width .3s; }
.kv { display: flex; justify-content: space-between; align-items: center; margin: 4px 0; font-size: 14px; }
.kv b { font-size: 15px; }
.section { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.section h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---------- Buttons */
.btn { appearance: none; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 800; font-size: 16px; cursor: pointer; color: #2a1d00; background: linear-gradient(180deg, #ffe082, #ffb300); box-shadow: 0 3px 0 #b07a00, 0 6px 14px rgba(0,0,0,0.3); transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.05); } .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b07a00; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.5); }
.btn.primary { background: linear-gradient(180deg, #7ee88f, #2ec25a); box-shadow: 0 3px 0 #1b7a36, 0 6px 14px rgba(0,0,0,0.3); color: #04260d; }
.btn.danger { background: linear-gradient(180deg, #ff8a80, #e53935); box-shadow: 0 3px 0 #8e1b16; color: #fff; }
.btn.ghost { background: rgba(255,255,255,0.1); color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,0.35); border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.tiny { padding: 5px 9px; font-size: 13px; border-radius: 8px; box-shadow: 0 2px 0 #b07a00; }
.btn.big { font-size: 20px; padding: 16px 26px; }
.btn.ad { background: linear-gradient(180deg, #b388ff, #7c4dff); box-shadow: 0 3px 0 #4527a0; color: #fff; }
.btn.full { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row.end { justify-content: flex-end; } .row.center { justify-content: center; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,0.1); color: #fff; font-weight: 800; cursor: pointer; }

/* ---------- Overlays */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 15, 35, 0.6); backdrop-filter: blur(4px); padding: 14px; z-index: 5; }
#menu { background: transparent; backdrop-filter: none; }
.menu-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 30%, rgba(255,207,74,0.18), transparent 60%); pointer-events: none; }
.menu-card { position: relative; width: min(94vw, 460px); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 22px 22px 14px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.logo h1 { margin: 4px 0 0; font-size: clamp(34px, 7vw, 48px); letter-spacing: .02em; color: var(--gold); text-shadow: 0 3px 0 #7a4a00, 0 8px 20px rgba(0,0,0,0.5); font-weight: 900; }
.logo p { margin: 4px 0 14px; color: var(--muted); font-weight: 600; }
.menu-btns { display: flex; flex-direction: column; gap: 10px; }
.menu-btns .row { justify-content: center; }
.fine { color: var(--muted); font-size: 12px; margin: 12px 0 0; } .fine a { color: var(--gold); }
.card { width: min(96vw, 560px); max-height: min(92vh, 760px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.card.wide { width: min(96vw, 720px); }
.card h2 { margin: 0 0 12px; font-size: 24px; color: var(--gold); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; } .modal-head h2 { margin: 0; }
#modal-body { margin-top: 12px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,0.07); border: 1px solid transparent; }
.item.clickable { cursor: pointer; } .item.clickable:hover { background: rgba(255,255,255,0.12); } .item.active { border-color: var(--gold); }
.item .grow { flex: 1; min-width: 0; } .item .name { font-weight: 800; } .item .sub { color: var(--muted); font-size: 12px; }
.flag { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid #111; background: #ddd; flex: none; }
.flag.small { width: 24px; height: 24px; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 13px; }
.muted { color: var(--muted); } .good { color: var(--green); } .bad { color: var(--red); } .gold { color: var(--gold); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.07); } .stat b { display: block; font-size: 22px; } .stat small { color: var(--muted); }
input[type=search], input[type=text], select { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.08); color: #fff; min-width: 0; }
input[type=search] { flex: 1; } select option { color: #000; }
input[type=range] { width: 100%; accent-color: var(--gold); }
.choose-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 38vh; overflow: auto; margin-top: 10px; padding: 2px; }
.choose-list .item { padding: 6px 8px; }
.choose-detail { margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,0.07); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.choose-detail .flag { width: 56px; height: 56px; }
.slot-list, .mode-list { display: flex; flex-direction: column; gap: 8px; }
.slot, .mode { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.07); cursor: pointer; border: 1px solid transparent; }
.slot:hover, .mode:hover { background: rgba(255,255,255,0.12); border-color: var(--gold); }
.slot .grow, .mode .grow { flex: 1; } .slot h4, .mode h4 { margin: 0; font-size: 17px; } .slot p, .mode p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .trade-cols { grid-template-columns: 1fr; } .hud-btn { width: 40px; height: 40px; border-radius: 12px; } .hud-btn .ico { font-size: 19px; } .gold-pill { font-size: 18px; padding: 5px 12px; } .panel-side { left: 10px; right: 10px; width: auto; max-height: 52vh; } }
.news-item { padding: 8px 10px; border-left: 3px solid var(--gold); background: rgba(255,255,255,0.05); border-radius: 0 10px 10px 0; font-size: 14px; } .news-item small { color: var(--muted); display: block; font-size: 11px; }
.end-title { font-size: clamp(28px, 6vw, 42px); color: var(--gold); margin: 0; text-align: center; font-weight: 900; text-shadow: 0 3px 0 #7a4a00; }
.end-title.bad { color: var(--red); text-shadow: 0 3px 0 #6b0000; }
.center { text-align: center; }
#ad-sim { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; background: #111; color: #fff; text-align: center; }
#ad-sim strong { font-size: 48px; display: block; }
.loading { text-align: center; } .spinner { width: 48px; height: 48px; border: 5px solid rgba(255,255,255,0.2); border-top-color: var(--gold); border-radius: 50%; margin: 0 auto 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pricebar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; } .tab { flex: 1; padding: 8px; border-radius: 10px; background: rgba(255,255,255,0.08); border: 1px solid transparent; color: #fff; font-weight: 700; cursor: pointer; } .tab.active { border-color: var(--gold); color: var(--gold); }
.helpline { font-size: 13px; color: var(--muted); margin: 6px 0; }
.progress { height: 8px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--gold); }
