:root {
  --ink: #f3e9d2; --muted: #b9ab8c; --paper: #e9dcc0; --bg: rgba(22, 18, 13, 0.88); --line: rgba(233, 220, 192, 0.18);
  --de: #d9483b; --us: #4a8fe7; --uk: #c9a24a; --gold: #d8ad55; --foot: 112px;
  --title: "Special Elite", "Courier New", monospace; --body: "Source Sans 3", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a241b; color: var(--ink); font: 15px/1.45 var(--body); }
button, select { font: inherit; color: inherit; }
kbd { font: 11px var(--body); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: rgba(255,255,255,.06); }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

#map, #fx { position: fixed; top: 0; left: 0; width: 100%; height: calc(100% - var(--foot)); }
#fx { pointer-events: none; overflow: hidden; z-index: 2; }
/* vignette for a war-room feel */
#fx::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(30, 20, 10, .45)); }

/* HUD */
#hud { position: fixed; z-index: 5; top: 12px; left: 12px; right: 392px; display: flex; gap: 14px; align-items: center; pointer-events: none; }
#hud > * { pointer-events: auto; }
.brand, .clock, .weather { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; backdrop-filter: blur(4px); }
.brand h1 { margin: 0; font: 22px/1.1 var(--title); letter-spacing: .5px; }
.stamp { display: inline-block; font: 11px var(--title); letter-spacing: 2px; color: var(--de); border: 1.5px solid var(--de); padding: 0 6px; transform: rotate(-1.5deg); }
.clock #date { font: 22px/1.1 var(--title); color: var(--gold); min-width: 290px; }
.clock #day { font-size: 13px; color: var(--muted); }
.weather { font-size: 14px; max-width: 260px; }
.weather b { font-size: 20px; margin-right: 6px; vertical-align: middle; }
.ghost { background: rgba(22,18,13,.7); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.ghost:hover { border-color: var(--gold); }
#btn-sources { margin-left: auto; }

/* Side panel */
#panel { position: fixed; z-index: 5; top: 12px; right: 12px; bottom: calc(var(--foot) + 40px); width: 368px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; scrollbar-width: thin; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; backdrop-filter: blur(4px); position: relative; }
.card h2 { margin: 2px 0 6px; font: 21px/1.15 var(--title); color: var(--paper); }
.card h3 { margin: 2px 0 6px; font: 18px/1.2 var(--title); }
.card p { margin: 0; }
.kicker { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); }
.card.event { border-left: 4px solid var(--gold); animation: pop .35s ease-out; }
.card.event.attack { border-left-color: var(--de); }
.card.event.defense, .card.event.relief { border-left-color: var(--us); }
.card.event.atrocity { border-left-color: #7d7d7d; }
.card.event.air { border-left-color: #8fd0ff; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.primary { background: var(--gold); color: #1b140b; border: 0; border-radius: 8px; padding: 7px 14px; font-weight: 700; cursor: pointer; }
.primary:hover { filter: brightness(1.1); }
#btn-continue { margin-top: 10px; }
.close { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }
.bars { display: grid; gap: 3px; }
.bar { height: 14px; border-radius: 3px; font-size: 11px; line-height: 14px; padding-left: 6px; white-space: nowrap; transition: width .3s; min-width: 2px; color: #fff; text-shadow: 0 1px 1px #000; }
.bar.al { background: var(--us); } .bar.de { background: var(--de); }
.bar-key { display: flex; gap: 14px; font-size: 12px; margin-top: 6px; } .bar-key .al { color: var(--us); } .bar-key .de { color: var(--de); }
#log { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; }
#log li { padding: 3px 0; border-top: 1px solid var(--line); cursor: pointer; }
#log li:hover { color: var(--gold); }
#log li b { color: var(--muted); font-weight: 600; margin-right: 6px; }

/* Legend */
#legend { position: fixed; z-index: 4; left: 12px; bottom: calc(var(--foot) + 12px); margin-left: 52px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 13px; max-width: 260px; }
#legend summary { cursor: pointer; font: 14px var(--title); color: var(--gold); }
#legend ul { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 3px; }
.sw { display: inline-block; width: 22px; height: 12px; margin-right: 8px; vertical-align: middle; border-radius: 2px; }
.sw.de-area { background: rgba(217, 72, 59, .45); border: 2px solid #8e1b12; }
.sw.ring { border-radius: 50%; width: 14px; height: 14px; margin: 0 12px 0 4px; }
.sw.ring.us { background: rgba(74, 143, 231, .35); border: 2px dashed var(--us); }
.sw.ring.de { background: rgba(217, 72, 59, .35); border: 2px dashed var(--de); }
.sw.line { height: 0; border-top: 2.5px dashed #2d2216; border-radius: 0; }
.sw.line.start { border-top-color: #e9dcc0; }
.sw.line.hwm { border-top: 2.5px dotted #ff7a5c; }
.sw.meuse { height: 4px; background: #5fb6ff; box-shadow: 0 0 6px #5fb6ff; }
.mini { display: inline-block; width: 16px; height: 11px; border: 1.5px solid #111; margin: 0 4px 0 2px; vertical-align: middle; }
.mini.us { background: var(--us); } .mini.uk { background: var(--uk); } .mini.de { background: var(--de); }

/* Controls & timeline */
#controls { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: var(--foot); background: #17130e; border-top: 1px solid var(--line); padding: 8px 16px 10px; display: grid; grid-template-rows: auto 1fr; gap: 6px; }
.buttons { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.buttons button:not(.primary) { background: #2a231a; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; cursor: pointer; }
#btn-play { min-width: 52px; font-size: 16px; }
.sel select { background: #2a231a; border: 1px solid var(--line); border-radius: 6px; margin-left: 4px; }
.tog { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; color: var(--muted); }
.tog input { accent-color: var(--gold); }
#timeline { position: relative; cursor: pointer; touch-action: none; outline: none; border-radius: 6px; }
#timeline:focus-visible { box-shadow: 0 0 0 2px var(--gold); }
#chapters { position: absolute; left: 0; right: 0; top: 0; height: 18px; }
.chap { position: absolute; top: 0; height: 18px; font-size: 11px; line-height: 18px; padding-left: 6px; overflow: hidden; white-space: nowrap; color: #e9dcc0cc; border-left: 1px solid #000; }
.chap:nth-child(odd) { background: #2b241b; } .chap:nth-child(even) { background: #352c20; }
.chap.on { background: #5a4520; color: #fff; }
#ticks { position: absolute; left: 0; right: 0; top: 20px; bottom: 0; }
.tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid #ffffff14; font-size: 10px; color: var(--muted); padding: 22px 0 0 3px; white-space: nowrap; }
.tick.major { border-left-color: #ffffff33; color: var(--ink); }
#marks { position: absolute; left: 0; right: 0; top: 24px; height: 18px; }
.mk { position: absolute; width: 11px; height: 11px; transform: translateX(-50%) rotate(45deg); top: 3px; background: var(--gold); border: 1px solid #000; cursor: pointer; padding: 0; }
.mk.attack { background: var(--de); } .mk.defense, .mk.relief { background: var(--us); } .mk.atrocity { background: #8a8a8a; } .mk.air { background: #8fd0ff; } .mk.note { background: #c9b48a; }
.mk:not(.key) { width: 7px; height: 7px; top: 5px; opacity: .8; }
.mk:hover { transform: translateX(-50%) rotate(45deg) scale(1.5); }
#progress { position: absolute; left: 0; top: 20px; bottom: 0; background: linear-gradient(90deg, transparent, rgba(216,173,85,.18)); pointer-events: none; }
#head { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--gold); box-shadow: 0 0 8px var(--gold); pointer-events: none; }

/* Map overlay: units, pings, aircraft */
.unit { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; align-items: center; transition: opacity .2s; }
.unit svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.unit span { font: 600 10.5px/1.1 var(--body); color: #1d140a; background: rgba(243,233,210,.85); padding: 0 3px; border-radius: 3px; margin-top: 1px; white-space: nowrap; }
.unit:hover { z-index: 10; } .unit:hover svg { transform: scale(1.25); }
.unit.sel span { background: var(--gold); }
.ping { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid var(--gold); animation: ping 1.6s ease-out infinite; }
.ping.attack { border-color: var(--de); } .ping.defense, .ping.relief { border-color: var(--us); } .ping.air { border-color: #8fd0ff; } .ping.atrocity { border-color: #444; }
@keyframes ping { from { transform: scale(.6); opacity: 1; } to { transform: scale(3.2); opacity: 0; } }
.plane { position: absolute; font-size: 18px; color: #1a2b44; text-shadow: 0 0 3px #fff; transform: translate(-50%, -50%); }
.chute { position: absolute; font-size: 15px; animation: fall 2.6s linear infinite; }
@keyframes fall { from { transform: translateY(-40px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(18px); opacity: 0; } }
.pocket-label, .map-tag { position: absolute; transform: translate(-50%, -50%); font: 12px var(--title); color: #fff; background: rgba(20,15,10,.75); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(10, 8, 5, .6); backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.sheet { position: relative; max-width: 620px; max-height: 88vh; overflow-y: auto; background: #efe3c8; color: #22180c; border-radius: 6px; padding: 28px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.6); background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(80,50,20,.06) 27px 28px); }
.sheet.wide { max-width: 820px; }
.sheet h2 { font: 34px/1.1 var(--title); margin: 10px 0 12px; }
.sheet h3 { font: 19px var(--title); margin: 18px 0 6px; }
.sheet a { color: #8a3b12; }
.sheet .muted { color: #6d5a3d; }
.sheet .lede { font-size: 17px; }
.sheet .close { color: #6d5a3d; }
.actions { display: flex; gap: 12px; margin: 18px 0 10px; flex-wrap: wrap; }
.big { font-size: 18px; padding: 10px 20px; }
.sheet .ghost { background: transparent; color: #22180c; border-color: #22180c55; }

@media (max-width: 900px) {
  :root { --foot: 120px; }
  #hud { right: 12px; flex-wrap: wrap; } .weather, #legend { display: none; }
  #panel { top: auto; bottom: calc(var(--foot) + 8px); left: 8px; right: 8px; width: auto; max-height: 38vh; }
  .card.forces, .card.log { display: none; }
  .clock #date { min-width: 0; font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .ping, .chute, .card.event { animation: none; }
}
#fx.far .unit span { display: none; }
#fx.far .unit:hover span, #fx.far .unit.sel span { display: block; }
