:root {
  --bg: #101820; --panel: rgba(18, 26, 34, 0.96); --line: #2c3a47; --text: #e8eef3; --muted: #93a4b3;
  --accent: #ffd34d; --good: #5fd38d; --bad: #ff6a5a; --btn: #243444; --btn2: #2f465b;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; overscroll-behavior: none; }
canvas#map { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
button { font: inherit; color: var(--text); background: var(--btn); border: 1px solid var(--line); border-radius: 9px;
  min-height: 40px; padding: 0 12px; cursor: pointer; }
button:active { background: var(--btn2); }
button:disabled { opacity: 0.45; }
button.primary { background: #3b6f3f; border-color: #4f8f54; }
button.danger { background: #7a2f2a; border-color: #9c3f37; }
button.icon { min-width: 40px; padding: 0; font-size: 18px; }

#top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; background: linear-gradient(var(--panel), rgba(18,26,34,0.85)); border-bottom: 1px solid var(--line); z-index: 5; }
#flag { width: 22px; height: 16px; border-radius: 3px; border: 1px solid #000; flex: none; }
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.stat b { font-size: 15px; white-space: nowrap; }
.stat small { color: var(--muted); font-size: 11px; white-space: nowrap; }
#date { font-weight: 600; font-size: 13px; white-space: nowrap; }
.money b::after { content: " mld"; font-size: 11px; color: var(--muted); font-weight: 400; }
#speed { margin-left: auto; display: flex; gap: 3px; }
#speed button { min-width: 40px; min-height: 40px; padding: 0 6px; font-size: 13px; }
#speed button.on { background: var(--accent); color: #222; border-color: var(--accent); font-weight: 700; }

#hint { position: fixed; top: calc(env(safe-area-inset-top) + 62px); left: 50%; transform: translateX(-50%); z-index: 4;
  background: rgba(0,0,0,0.75); padding: 6px 12px; border-radius: 20px; font-size: 13px; pointer-events: none; display: none; max-width: 92vw; text-align: center; }
#ticker { position: fixed; left: 8px; bottom: calc(env(safe-area-inset-bottom) + 8px); z-index: 3; max-width: min(70vw, 420px);
  font-size: 12px; color: #dfe7ee; text-shadow: 0 1px 2px #000; cursor: pointer; }
#ticker div { background: rgba(0,0,0,0.5); padding: 3px 8px; border-radius: 8px; margin-top: 3px; }
#toasts { position: fixed; top: calc(env(safe-area-inset-top) + 100px); left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: rgba(10,14,18,0.94); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 8px 12px; border-radius: 10px; animation: in .2s; }
.toast.click { pointer-events: auto; cursor: pointer; }
.toast.bad { border-left-color: var(--bad); } .toast.good { border-left-color: var(--good); }
@keyframes in { from { opacity: 0; transform: translateY(-6px); } }

#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; max-height: 50vh; overflow-y: auto; padding: 4px 14px calc(env(safe-area-inset-bottom) + 14px);
  box-shadow: 0 -6px 24px rgba(0,0,0,0.4); }
#sheet.compact { max-height: 38vh; }
#sheet.compact .unit { padding: 4px 10px; }
#sheet.compact .unit .st { font-size: 11px; }
#sheet.compact h2 { font-size: 16px; margin-bottom: 2px; }
#sheet.compact .row { margin-top: 6px !important; }
#sheet.compact .row button { min-height: 36px; }
@media (min-width: 760px) { #sheet { left: auto; right: 12px; bottom: 12px; width: 400px; border-radius: 16px; max-height: calc(100vh - 90px); border: 1px solid var(--line); } }
.hidden { display: none !important; }
.grip { width: 40px; height: 4px; background: #3c4c5a; border-radius: 2px; margin: 6px auto 8px; }
h2 { margin: 2px 0 6px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
h3 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid #000; flex: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > button { flex: 1 1 auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.good { color: var(--good); } .bad { color: var(--bad); }
.units { display: grid; grid-template-columns: 1fr; gap: 8px; }
.unit { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; background: #1b2834; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.unit .nm { font-weight: 600; }
.unit .st { color: var(--muted); font-size: 12px; grid-column: 1; }
.unit button { grid-row: 1 / span 2; grid-column: 2; min-width: 96px; }
.stepper { display: flex; align-items: center; gap: 6px; grid-row: 1 / span 2; grid-column: 2; }
.stepper button { min-width: 40px; padding: 0; font-size: 18px; }
.stepper b { min-width: 46px; text-align: center; font-size: 15px; }
.bar { height: 6px; background: #2a3846; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--good); }
.rel { display: inline-block; padding: 1px 7px; border-radius: 10px; font-weight: 700; font-size: 12px; }
.list { display: flex; flex-direction: column; gap: 4px; }
.list .it { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; background: #1b2834; border-radius: 8px; border: 1px solid var(--line); align-items: center; }
.list .it.click { cursor: pointer; }
.list .it.sel { border-color: var(--accent); }
.log .it { font-size: 12px; }
.note { font-size: 12px; background: #1e2d3a; border-radius: 8px; padding: 6px 9px; margin: 3px 0; }
.side { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
select, input[type=range] { width: 100%; }
select { background: var(--btn); color: var(--text); border: 1px solid var(--line); border-radius: 8px; min-height: 38px; padding: 0 8px; font: inherit; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-body { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: min(460px, 100%); max-height: 86vh; overflow-y: auto; }
#modal-body h1 { margin: 0 0 4px; font-size: 24px; }
.countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; max-height: 40vh; overflow-y: auto; margin: 8px 0; }
.countries button { display: flex; gap: 8px; align-items: center; justify-content: flex-start; text-align: left; font-size: 13px; }
.countries button.sel, [data-al].sel { border-color: var(--accent); background: #3a3a22; }
@media (max-width: 420px) {
  .stat.men, #flag, .stat small { display: none; }
  #top { gap: 7px; padding-left: 6px; padding-right: 6px; }
  #date { font-size: 12px; }
  .stat b { font-size: 14px; }
  .money b::after { content: ""; }
  .money b::before { content: "💰"; font-size: 11px; margin-right: 2px; }
  .regs b::before { content: "🏳"; font-size: 11px; margin-right: 2px; }
  #speed { gap: 2px; }
  #speed button { min-width: 36px; padding: 0 4px; }
}

button.close { position: sticky; top: 0; float: right; min-height: 36px; min-width: 36px; margin: -2px -4px 0 8px; z-index: 2; background: #2a3a4a; }
#modal-body button.close { position: relative; }
#ticker div { font-size: 11px; }
