:root {
  color-scheme: dark;
  --bg: #070b17;
  --panel: rgba(8, 14, 29, .88);
  --panel-strong: rgba(7, 12, 25, .96);
  --line: rgba(70, 219, 255, .24);
  --cyan: #42dcff;
  --cyan-soft: #9beeff;
  --magenta: #ff51c7;
  --violet: #c79aff;
  --text: #e8f4ff;
  --muted: #8295ad;
  --green: #6cf2c2;
  --danger: #ff667f;
  --shadow: 0 16px 48px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { font-family: 'Rajdhani', sans-serif; -webkit-font-smoothing: antialiased; user-select: none; }
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
#map { position: fixed; inset: 0; z-index: 0; background: #0d1827; }
.map-vignette { position: fixed; inset: 0; z-index: 300; pointer-events: none; box-shadow: inset 0 0 110px rgba(2, 7, 18, .36); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

.hud-top { position: fixed; z-index: 650; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 13px 8px 10px; pointer-events: auto; }
.brand-emblem { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(66, 220, 255, .62); border-radius: 10px; color: var(--cyan); font-size: 25px; line-height: 1; text-shadow: 0 0 12px rgba(66, 220, 255, .6); }
.brand-copy h1 { margin: 0; font-family: 'Orbitron', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: .16em; line-height: 1.2; }
.brand-copy p { margin: 3px 0 0; color: #92a9bf; font-family: 'Share Tech Mono', monospace; font-size: 8px; letter-spacing: .11em; white-space: nowrap; }
.header-actions { display: flex; gap: 7px; pointer-events: auto; }
.icon-btn { min-width: 42px; height: 44px; padding: 0 10px; color: var(--cyan-soft); border: 1px solid var(--line); font-family: 'Orbitron', sans-serif; font-size: 11px; font-weight: 700; cursor: pointer; }
.icon-btn:active, .secondary-btn:active { transform: translateY(1px); }

.gps-chip { position: fixed; z-index: 650; top: 76px; right: 12px; display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 6px 10px; color: #a6bacf; font-family: 'Share Tech Mono', monospace; font-size: 9px; letter-spacing: .04em; pointer-events: none; }
.gps-indicator { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #d4a64b; box-shadow: 0 0 9px currentColor; }
.gps-chip--ok { color: var(--green); border-color: rgba(108, 242, 194, .28); }
.gps-chip--ok .gps-indicator { background: var(--green); }
.gps-chip--warn { color: #ffd27c; border-color: rgba(255, 210, 124, .3); }
.gps-chip--warn .gps-indicator { background: #ffd27c; }
.gps-chip--off { color: #ff8795; border-color: rgba(255, 102, 127, .3); }
.gps-chip--off .gps-indicator { background: var(--danger); }
.gps-chip--search .gps-indicator { animation: pulse 1.5s infinite; }

.resource-bar { position: fixed; z-index: 650; top: 76px; left: 12px; display: flex; gap: 0; padding: 6px 4px; pointer-events: none; }
.resource-item { min-width: 43px; display: flex; justify-content: center; align-items: center; gap: 5px; padding: 0 7px; color: #d8e8f5; font-family: 'Share Tech Mono', monospace; font-size: 11px; border-right: 1px solid rgba(109, 156, 190, .16); }
.resource-item:last-child { border-right: 0; }
.resource-symbol { font-size: 13px; color: var(--cyan); }
.resource-symbol--food { color: #86e4b5; }
.resource-symbol--coins { color: #f0ce78; }
.resource-symbol--materials { color: #bba9ff; }
.resource-symbol--stone { color: #c0d0df; }

.map-hint { position: fixed; z-index: 650; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); padding: 7px 11px; color: rgba(186, 221, 239, .78); font-family: 'Share Tech Mono', monospace; font-size: 9px; letter-spacing: .055em; text-align: center; pointer-events: none; }

.player-location-icon { background: transparent; border: 0; }
.player-location { position: relative; width: 32px; height: 32px; display: grid; place-items: center; }
.player-location__halo { position: absolute; width: 30px; height: 30px; border: 1px solid rgba(60, 229, 255, .68); border-radius: 50%; box-shadow: 0 0 15px rgba(50, 213, 255, .38); animation: halo 2s ease-out infinite; }
.player-location__dot { position: relative; width: 10px; height: 10px; border: 2px solid white; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px #28dfff, 0 0 24px rgba(40, 223, 255, .8); }
.hex-number-icon { background: transparent; border: 0; }
.hex-number-wrap { display: flex; justify-content: center; align-items: center; width: 34px; height: 20px; gap: 2px; font-family: 'Share Tech Mono', monospace; font-size: 12px; font-weight: 700; text-shadow: 0 1px 4px #030913, 0 0 5px #030913; }
.hex-number--player { color: #61ecff; }
.hex-number--cpu { color: #ff72d3; }
.hex-number__dot { color: rgba(240, 244, 255, .75); font-size: 10px; }
.leaflet-container { font-family: 'Rajdhani', sans-serif; background: #101c2c; }
.leaflet-control-zoom { border: 1px solid rgba(66, 220, 255, .22) !important; border-radius: 9px !important; overflow: hidden; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { width: 32px !important; height: 32px !important; line-height: 32px !important; background: rgba(8, 14, 29, .88) !important; color: #bdefff !important; border: 0 !important; }
.leaflet-control-zoom a + a { border-top: 1px solid rgba(66, 220, 255, .16) !important; }
.leaflet-control-scale-line { background: rgba(8, 14, 29, .7) !important; color: #e7f2fb !important; border-color: #b7e5f7 !important; text-shadow: none !important; }
.leaflet-top.leaflet-right { top: 112px; }
.leaflet-control-attribution { background: rgba(7, 12, 25, .72) !important; color: #a8b7c8 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #7bdcf1 !important; }

.hex-panel { position: fixed; z-index: 900; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(430px, calc(100vw - 20px)); max-height: min(65vh, 560px); overflow-y: auto; padding: 14px 15px 13px; background: rgba(6, 12, 26, .96); border-color: rgba(64, 217, 255, .34); }
.hex-panel-head, .modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.section-kicker { margin: 0 0 3px; color: #68dff8; font-family: 'Share Tech Mono', monospace; font-size: 8px; letter-spacing: .16em; }
.hex-panel h2, .modal-heading h2 { margin: 0; font-family: 'Orbitron', sans-serif; font-size: 15px; letter-spacing: .08em; font-weight: 600; }
.hex-id { margin: 4px 0 0; color: #72869e; font-family: 'Share Tech Mono', monospace; font-size: 8px; }
.close-btn { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; margin: -3px -4px 0 0; border: 1px solid rgba(130, 156, 181, .25); border-radius: 8px; background: rgba(255, 255, 255, .035); color: #c4d5e3; font-size: 22px; line-height: 1; cursor: pointer; }
.hex-owner { display: inline-block; margin: 12px 0 9px; padding: 4px 8px; border: 1px solid rgba(118, 143, 166, .25); border-radius: 5px; font-family: 'Share Tech Mono', monospace; font-size: 9px; letter-spacing: .08em; }
.hex-owner--player { color: var(--cyan); border-color: rgba(66, 220, 255, .35); }
.hex-owner--cpu { color: var(--magenta); border-color: rgba(255, 81, 199, .35); }
.hex-owner--contested { color: #d2a7ff; border-color: rgba(210, 167, 255, .4); }
.hex-owner--neutral { color: #9aadc0; }
.influence-row { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 7px; margin-bottom: 10px; }
.influence-stat { min-width: 0; padding: 7px 8px 6px; border: 1px solid rgba(66, 220, 255, .12); border-radius: 7px; background: rgba(45, 90, 120, .08); }
.influence-stat small { display: block; color: #8da2b8; font-family: 'Share Tech Mono', monospace; font-size: 7px; letter-spacing: .06em; }
.influence-stat strong { display: block; margin-top: 3px; color: var(--cyan); font-family: 'Orbitron', sans-serif; font-size: 16px; }
.influence-stat--cpu strong { color: var(--magenta); }
.influence-stat:last-child strong { color: #d4e7f4; font-family: 'Rajdhani', sans-serif; font-size: 13px; }
.hex-detail-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(110, 145, 173, .12); font-size: 12px; }
.hex-detail-line > span { color: #93a6ba; }
.hex-detail-line > strong { color: #d9e9f4; text-align: right; font-weight: 600; }
.terrain-edit-row { display: flex; flex-direction: column; gap: 3px; padding: 7px 0; }
.terrain-edit-row select, .cpu-settings-row select { min-width: 0; padding: 7px 9px; border: 1px solid rgba(74, 197, 226, .25); border-radius: 6px; background: #0e1b2d; color: #d9edf8; font-size: 12px; }
.terrain-edit-row small { color: #70859c; font-family: 'Share Tech Mono', monospace; font-size: 8px; }
.hex-production-line strong { max-width: 65%; font-size: 10px; }
.hex-footnote { margin: 7px 0 0; color: #a5b7c8; font-size: 11px; }
.hex-rule-note { margin: 9px 0 0; padding-top: 8px; border-top: 1px solid rgba(66, 220, 255, .14); color: #6f849b; font-size: 10px; line-height: 1.3; }

.modal-backdrop { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 6, 15, .72); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
.hidden { display: none !important; }
.stats-card { width: min(540px, 100%); max-height: min(90vh, 820px); overflow-y: auto; padding: 17px; background: var(--panel-strong); border-color: rgba(66, 220, 255, .32); }
.modal-heading { align-items: center; padding-bottom: 12px; border-bottom: 1px solid rgba(66, 220, 255, .14); }
.modal-heading h2 { font-size: 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 13px; }
.stat-tile { min-width: 0; padding: 9px 10px; border: 1px solid rgba(66, 220, 255, .14); border-radius: 8px; background: rgba(25, 55, 77, .12); }
.stat-tile small { display: block; color: #8ca4b9; font-family: 'Share Tech Mono', monospace; font-size: 7px; letter-spacing: .06em; }
.stat-tile strong { display: block; margin-top: 4px; color: #dff6ff; font-family: 'Orbitron', sans-serif; font-size: 19px; }
.stat-tile--cpu strong { color: var(--magenta); }
.stat-tile--disputed strong { color: #d2a7ff; }
.stats-section { margin-top: 16px; padding-top: 13px; border-top: 1px solid rgba(110, 145, 173, .14); }
.stats-section h3 { margin: 0; color: #a6c1d3; font-family: 'Orbitron', sans-serif; font-size: 10px; letter-spacing: .1em; font-weight: 600; }
.stats-section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.stats-section-heading small { color: #86a0b5; font-size: 10px; }
.inventory-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.inventory-item { padding: 7px 5px; border: 1px solid rgba(110, 145, 173, .13); border-radius: 6px; background: rgba(255, 255, 255, .02); text-align: center; }
.inventory-item span { display: block; color: #9cb0c1; font-size: 9px; }
.inventory-item strong { display: block; margin-top: 4px; color: #e1f4ff; font-family: 'Share Tech Mono', monospace; font-size: 13px; }
.cpu-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 9px var(--magenta); }
.cpu-settings-row, .cpu-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; color: #9eb1c2; font-size: 12px; }
.cpu-settings-row select { flex: 1; max-width: 270px; }
.cpu-meta-row strong { color: #d8eafa; font-size: 12px; }
.cpu-last-action { margin: 8px 0 3px; color: var(--magenta); font-size: 13px; font-weight: 600; }
.cpu-next-action { margin: 0 0 8px; color: #788da2; font-size: 10px; }
.cpu-log { display: flex; flex-direction: column; gap: 5px; }
.cpu-log-entry { display: flex; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: 5px; background: rgba(255, 81, 199, .045); color: #b9c8d5; font-size: 10px; }
.cpu-log-entry time { flex: 0 0 auto; color: #77899b; font-family: 'Share Tech Mono', monospace; font-size: 8px; }
.empty-log { margin: 0; color: #788da2; font-size: 11px; }
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 8px; }
.secondary-btn, .danger-btn { min-height: 36px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-family: 'Orbitron', sans-serif; font-size: 9px; letter-spacing: .05em; }
.secondary-btn { border: 1px solid rgba(66, 220, 255, .3); background: rgba(66, 220, 255, .055); color: #abedff; }
.danger-btn { width: 100%; border: 1px solid rgba(255, 102, 127, .28); background: rgba(255, 102, 127, .06); color: #ff8fa0; }
.local-save-note { margin: 9px 0 0; color: #71859a; font-size: 10px; line-height: 1.35; }

.toasts { position: fixed; z-index: 1400; top: 120px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 7px; width: min(420px, calc(100vw - 30px)); pointer-events: none; }
.toast { max-width: 100%; padding: 9px 13px; border: 1px solid rgba(66, 220, 255, .3); border-radius: 8px; background: rgba(5, 14, 28, .94); box-shadow: var(--shadow); color: #d7f7ff; font-family: 'Share Tech Mono', monospace; font-size: 10px; line-height: 1.35; text-align: center; opacity: 0; transform: translateY(-5px); transition: opacity .18s ease, transform .18s ease; }
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--warn { border-color: rgba(255, 199, 105, .38); color: #ffe1a5; }
.toast--info { border-color: rgba(185, 158, 255, .3); color: #e3d7ff; }

@keyframes pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes halo { 0% { transform: scale(.7); opacity: .95; } 100% { transform: scale(1.25); opacity: .05; } }

@media (max-width: 600px) {
  .hud-top { top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; }
  .brand { gap: 7px; padding: 6px 9px 6px 7px; border-radius: 10px; }
  .brand-emblem { width: 29px; height: 29px; font-size: 21px; }
  .brand-copy h1 { font-size: 13px; }
  .brand-copy p { font-size: 6.5px; letter-spacing: .08em; }
  .header-actions { gap: 5px; }
  .icon-btn { min-width: 36px; height: 38px; padding: 0 7px; border-radius: 9px; font-size: 9px; }
  .gps-chip { top: 88px; right: 8px; min-height: 24px; padding: 5px 8px; font-size: 8px; }
  .leaflet-top.leaflet-right { top: 122px; }
  .resource-bar { top: 54px; left: 8px; padding: 5px 2px; border-radius: 9px; }
  .resource-item { min-width: 34px; gap: 3px; padding: 0 5px; font-size: 10px; }
  .resource-symbol { font-size: 11px; }
  .map-hint { bottom: max(9px, env(safe-area-inset-bottom)); padding: 6px 8px; font-size: 7.5px; }
  .hex-panel { bottom: max(9px, env(safe-area-inset-bottom)); width: calc(100vw - 14px); max-height: 61vh; padding: 12px; border-radius: 11px; }
  .hex-panel h2 { font-size: 13px; }
  .influence-stat { padding: 6px; }
  .influence-stat small { font-size: 6px; }
  .influence-stat strong { font-size: 14px; }
  .influence-stat:last-child strong { font-size: 11px; }
  .hex-detail-line { font-size: 11px; }
  .hex-production-line strong { font-size: 9px; }
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .stats-card { max-height: 91vh; padding: 13px; border-radius: 13px 13px 9px 9px; }
  .stats-grid { gap: 6px; }
  .stat-tile { padding: 7px; }
  .stat-tile small { font-size: 6px; }
  .stat-tile strong { font-size: 16px; }
  .inventory-grid { gap: 4px; }
  .inventory-item { padding: 6px 2px; }
  .inventory-item span { font-size: 8px; }
  .inventory-item strong { font-size: 11px; }
  .cpu-settings-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .cpu-settings-row select { width: 100%; max-width: none; }
  .toasts { top: 92px; }
}

@media (max-width: 370px) {
  .brand-copy p { letter-spacing: .045em; }
  .icon-btn { min-width: 32px; }
  .resource-item { min-width: 30px; padding: 0 4px; }
  .influence-row { grid-template-columns: 1fr 1fr 1.25fr; gap: 5px; }
}
