:root {
  --bg: #14161a; --panel: #1c1f25; --line: #2c313a; --text: #e8e6e3; --muted: #9aa1ab;
  --accent: #ff5a1f; --accent2: #ffb000; --input: #262a32;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { display: flex; height: 100vh; }
#panel { width: 430px; flex: 0 0 430px; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 18px 28px; }
#map { flex: 1; min-height: 300px; }
/* ⚠️ 26px пречупваше „СИМУЛАТОР НА ЯДРЕН УДАР" на два реда в панела
   (430 px минус подложката). 23px го събира, а разредката пада на .2px,
   за да остане запас при по-тесни панели. */
.brand h1 { margin: 0; font-size: 23px; letter-spacing: .2px; color: var(--accent); text-transform: uppercase; }
.brand p { margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.step { border-top: 1px solid var(--line); padding: 12px 0 6px; }
/* ⚠️ nowrap пази самото заглавие цяло: при дълго име на цел („Пловдив,
   68-а бригада…") текстът „Избери цел" се чупеше на две. Пренася се
   само надписът с мястото. */
.step h2 { font-size: 15px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
/* ⚠️ САМО първият span е кръгчето с номера. Без „> span:first-child"
   правилото хващаше и надписа с избраното място и го свиваше до кръгче
   от 22 px, та текстът излизаше отрязан. */
.step h2 > span:first-child { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #111; font-size: 13px; }
input, select, button { font: inherit; color: var(--text); }
input[type=search], input[type=number], select { background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
select { width: 100%; margin-top: 6px; }
/* ⚠️ Атрибутът hidden е само display:none от браузъра и ВСЯКО правило с
   display го надвива — заради .row по-долу полетата за ръчен вятър си
   стояха на екрана, макар кодът да ги беше скрил. Това го заковава. */
[hidden] { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row select { width: auto; margin: 0; flex: 1; }
#kt { width: 120px; }
#hob { width: 90px; padding: 4px 6px; }
#windSpd, #windDir { width: 72px; padding: 4px 6px; }
.search { display: flex; gap: 6px; }
.search input { flex: 1; min-width: 0; }
button { background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.big { width: 100%; margin-top: 14px; padding: 12px; font-size: 18px; font-weight: 700; background: var(--accent); color: #111; border: 0; text-transform: uppercase; letter-spacing: 1px; }
button.big:hover { background: #ff7a45; }
button.link { background: none; border: 0; color: var(--accent2); padding: 6px 0; text-decoration: underline; }
.qres { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; max-height: 220px; overflow: auto; }
.qres li { padding: 7px 9px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 14px; }
.qres li:hover { background: var(--input); }
.qres li.muted, .muted { color: var(--muted); cursor: default; }
.hint, .small { color: var(--muted); font-size: 13px; margin: 6px 0; }
/* Надписът живее в заглавието на стъпка 1 и се избутва вдясно. */
.place { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--accent2);
  text-align: right; line-height: 1.2; white-space: normal; min-width: 0; }
.placelbl { font-weight: 400; color: var(--muted); }
label.radio, label.check { display: block; margin: 6px 0; cursor: pointer; }
.indent { margin-left: 24px; }
#falloutOpts label { display: inline-block; margin: 4px 8px 4px 0; }
#falloutOpts select { margin-top: 4px; }
#results { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 6px; }
#results h2 { font-size: 18px; margin: 8px 0 4px; }
.lead { margin: 0 0 10px; color: var(--muted); }
.cas { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.cas div.ok b { color: #4cd07d; }
.subhead { margin: 12px 0 6px; font-size: 14px; color: var(--text); }
.fallcas b { color: #b57edc !important; }
.radcas b { color: #2ecc71 !important; }
.cas div { background: var(--input); border-radius: 8px; padding: 10px; text-align: center; }
.cas b { display: block; font-size: 22px; color: var(--accent); }
.cas span { color: var(--muted); font-size: 13px; }
.legend { list-style: none; padding: 0; margin: 12px 0; }
.legend li { display: flex; gap: 10px; margin: 0 0 10px; }
.legend i { flex: 0 0 14px; height: 14px; border-radius: 50%; margin-top: 3px; border: 1px solid rgba(255,255,255,.3); }
.legend p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.legend small { color: var(--muted); }
.banner { display: block; margin: 16px 0 6px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.banner[hidden] { display: none; }
.banner img { display: block; width: 100%; height: auto; transition: transform .2s; }
.banner:hover img { transform: scale(1.02); }
.methodlink { margin: 14px 0 4px; font-size: 14px; }
.methodlink a { color: var(--accent2); }
.foot { margin-top: 22px; font-size: 12px; color: var(--muted); }
.foot a { color: var(--accent2); }
.toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); background: #b02a00; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 9999; box-shadow: 0 4px 18px rgba(0,0,0,.4); }
/* Празното гнездо не заема място на широк екран. */
#mapSlot:empty, .maphere:empty { display: none; }
/* Докато няма избрано място, редът не се показва изобщо. */
.place:has(#placeName:empty) { display: none; }

/* ⚠️ Измерено: при 23px заглавието се събира на ред до 375px ширина, но на
   320px (стари и малки телефони) се пречупва. Там пада на 19px. */
@media (max-width: 360px) {
  .brand h1 { font-size: 19px; }
  .brand h1 .h1q { font-size: 17px; }
}

@media (max-width: 760px) {
  /* ⚠️ Беше column-reverse, за да излиза картата отгоре. Сега картата се
     мести в #mapSlot под резултатите, затова редът е нормален: първо
     настройките, после картата. */
  #app { flex-direction: column; height: auto; }
  #panel { width: 100%; flex: none; border-right: 0; padding: 14px 16px 24px; }
  #map { height: 55vh; flex: none; }
  #mapSlot, .maphere { margin: 12px 0 16px; }
  #mapSlot #map, .maphere #map { width: 100%; height: 60vh; min-height: 280px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
}

table.area { width: 100%; border-collapse: collapse; font-size: 13px; margin: 4px 0 8px; }
table.area th, table.area td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: right; }
table.area th:first-child, table.area td:first-child { text-align: left; }
table.area th { color: var(--muted); font-weight: 600; }
table.area tr.tot td { font-weight: 700; color: #b57edc; }

.cond { margin: 6px 0 2px; }
.cond label { display: flex; align-items: center; gap: 6px; flex: 1; }
.cond select { margin: 0; }
.totcas { grid-template-columns: repeat(4, 1fr) !important; }
.totcas b { font-size: 18px !important; }
.fire { color: #ffb38a; }

/* по-сбити полета с числа */
.cas { gap: 6px !important; }
.cas div { padding: 7px 6px !important; border-radius: 6px !important; }
.cas b { font-size: 19px !important; line-height: 1.15; }
.cas span { font-size: 12px !important; }
.totcas b { font-size: 16px !important; }
.subhead { margin: 10px 0 5px !important; font-size: 13.5px !important; font-weight: 600; }
.subhead.first { margin-top: 4px !important; }
.totcas div:first-child b { color: var(--text) !important; }

.falltip { white-space: normal; width: 260px; }
.falltip .tipnote { display: block; margin-top: 3px; }

.unitslink { background: none; border: 0; padding: 2px 0; color: var(--accent2); text-decoration: underline; font-size: 13px; cursor: pointer; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { position: relative; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px 22px; }
.modal-box h2 { margin: 0 30px 12px 0; font-size: 20px; color: var(--accent); }
.modal-box h3 { font-size: 15px; margin: 14px 0 6px; }
.modal-box ul { padding-left: 20px; margin: 0; }
.modal-box li { margin: 3px 0; font-size: 14px; }
.modal-close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
table.units { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.units th, table.units td { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; vertical-align: top; }
table.units th { color: var(--muted); }

/* Стъпка 4 е акордеон: заглавието ѝ е бутонът.
   Редът нарочно изглежда като падащите менюта наоколо — рамка, фон и
   стрелка — за да личи, че се натиска. */
.stepacc > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; }
.stepacc > summary:hover { border-color: var(--accent2); }
.stepacc > summary::-webkit-details-marker { display: none; }
.stepacc > summary h2 { margin: 0; flex: 1; }
/* ⚠️ Шевронът е НАЧЕРТАН с рамки, не е знакът „▾" от шрифта: той излизаше
   дребен като точица и не се четеше като стрелка. */
.stepacc > summary::after { content: ''; width: 9px; height: 9px; margin: -4px 3px 0 0;
  border-right: 2px solid var(--accent2); border-bottom: 2px solid var(--accent2);
  transform: rotate(45deg); transition: transform .15s; }
.stepacc[open] > summary::after { transform: rotate(225deg); margin: 3px 3px 0 0; }
.stepacc[open] > summary { margin-bottom: 10px; }
.stepacc > summary:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
#settingsSummary { margin: 2px 0 4px; }

/* превключватели като на телефон */
.nowcheck { margin: 4px 0 8px; }
#switches { display: grid; gap: 8px; margin: 4px 0 10px; }
#switches.off { opacity: .4; pointer-events: none; }
.sw { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.sw .opt { font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }
.sw .opt:first-child { text-align: right; }
.sw .opt.on { color: var(--text); font-weight: 600; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; inset: 0; background: var(--accent); border-radius: 28px; cursor: pointer; transition: background .2s; }
.slider::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + .slider { background: #4a6fa5; }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent2); outline-offset: 2px; }

.printbtn { background: var(--input); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 8px 16px; font-weight: 600; cursor: pointer; margin: 8px 0 4px; }
.printbtn:hover { border-color: var(--accent); }
@media print {
  @page { margin: 12mm; }
  html, body { background: #fff !important; color: #000 !important; height: auto; }
  #app { display: block; height: auto; }
  #map, .step, #detonate, #clear, .banner, .foot, .noprint, .modal, .leaflet-control-container { display: none !important; }
  #panel { width: auto; flex: none; overflow: visible; background: #fff; border: 0; padding: 0; }
  .brand h1 { color: #000; }
  .brand p, .lead, .small, .legend p, .legend small, .subhead, .legend b { color: #222 !important; }
  .cas div { background: #f2f2f2 !important; border: 1px solid #ccc; }
  .cas b { color: #000 !important; }
  .cas span { color: #333 !important; }
  table.area th, table.area td { color: #000 !important; border-color: #bbb; }
  table.area tr.tot td { color: #000 !important; }
  .legend i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #results { display: block !important; border: 0; }
}

/* цветове по колони: загинали – червено, ранени и облъчени – оранжево, дясната колона – зелено */
#results .cas div:nth-child(1) b { color: #ff4d4d !important; }
#results .cas div:nth-child(2) b { color: #ff9f1c !important; }
#results .cas div:nth-child(3) b { color: #4cd07d !important; }
@media print {
  #results .cas div:nth-child(1) b, #results .cas div:nth-child(2) b, #results .cas div:nth-child(3) b { color: #000 !important; }
}
/* радиоактивната следа: загинали и болни в лилаво, живеещите в следата в синьо */
#results .cas.fallcas div:nth-child(1) b, #results .cas.fallcas div:nth-child(2) b { color: #b57edc !important; }
#results .cas.fallcas div:nth-child(3) b { color: #5aa9ff !important; }

/* бутоните „Принтирай“ и „Нов тест“ */
/* ⚠️ align-items: center. Без него flex разтяга бутоните на цялата
   височина на реда, а „Принтирай" има собствен margin и остава
   по-нисък — измерено 43 px срещу 55 px. Еднакъв margin + center. */
.printwrap { text-align: center; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.printbtn, .newbtn { margin: 8px 0 4px !important; background: #ffd400 !important; color: #111 !important; border: 0 !important; border-radius: 8px; padding: 10px 22px !important; font-weight: 700; font-size: 16px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.35); display: inline-flex; align-items: center; gap: 8px; }
.printbtn:hover, .newbtn:hover { background: #ffe24d !important; }
.printbtn svg, .newbtn svg { fill: #111; flex: 0 0 auto; }

/* област за печат: на екрана е извън полезрението */
#printArea { position: absolute; left: -30000px; top: 0; width: 1047px; background: #fff; color: #111; }
#printArea[hidden] { display: none; }
#pmapSlot #map, #pmapSlot .leaflet-container { width: 1047px !important; height: 642px !important; }
.pcredits { font-size: 11px; color: #444; margin: 4px 0 0; }
#ptitle { font-size: 18px; font-weight: 700; margin: 0 0 8px; color: #111; }
.pdatapage { display: flex; gap: 6mm; }
.pleft { flex: 2; min-width: 0; align-self: flex-start; }
.pright { flex: 1; border: 1px dashed #bbb; border-radius: 4px; min-height: 170mm; }
#pdata h2 { font-size: 16px; margin: 0 0 4px; color: #111; }
#pdata .lead, #pdata .small, #pdata .subhead, #pdata .legend p, #pdata .legend small, #pdata .legend b, #pdata table.area td, #pdata table.area th { color: #222 !important; }
#pdata .small { font-size: 10.5px; margin: 3px 0; }
#pdata .subhead { font-size: 12px !important; margin: 6px 0 3px !important; }
#pdata .cas { gap: 4px !important; }
#pdata .cas div { background: #f3f3f3 !important; border: 1px solid #ddd; padding: 4px !important; }
#pdata .cas span { color: #333 !important; font-size: 10px !important; }
#pdata .cas b { font-size: 15px !important; }
#pdata .cas div:nth-child(1) b { color: #c62828 !important; }
#pdata .cas div:nth-child(2) b { color: #e07b00 !important; }
#pdata .cas div:nth-child(3) b { color: #2e7d32 !important; }
#pdata .cas.fallcas div:nth-child(1) b, #pdata .cas.fallcas div:nth-child(2) b { color: #7b3fa8 !important; }
#pdata .cas.fallcas div:nth-child(3) b { color: #1565c0 !important; }
#pdata .legend { columns: 2; column-gap: 6mm; margin: 6px 0; }
#pdata .legend li { break-inside: avoid; margin-bottom: 4px; font-size: 10.5px; }
#pdata .legend p { font-size: 9.5px; }
#pdata table.area { font-size: 10px; }
#pdata .fire { color: #a33 !important; }

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body.printing #app, body.printing .modal { display: none !important; }
  body.printing #printArea { position: static; left: auto; width: auto; display: block !important; }
  .ppage { break-after: page; page-break-after: always; }
  .ppage:last-child { break-after: auto; page-break-after: auto; }
  #pmapSlot .leaflet-control-zoom { display: none; }
  #printArea * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media print {
  body.printing #pmapSlot #map { display: block !important; }
  body.printing #pmapSlot .leaflet-control-container { display: block !important; }
  body.printing #pmapSlot .leaflet-control-zoom { display: none !important; }
}

.printbtn svg, .newbtn svg { fill: #111; }

.pright { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 6mm; }
.pqr { text-align: center; }
.pqr img { width: 38mm; height: 38mm; display: block; margin: 0 auto 2mm; image-rendering: pixelated; }
.pqr span { font-size: 10px; color: #333; }

.pqrs { display: flex; gap: 5mm; justify-content: center; width: 100%; }
.pqrs .pqr img { width: 30mm; height: 30mm; }
.pqrs .pqr span { font-size: 9px; line-height: 1.3; display: block; }

.pqrs .pqr b { display: block; font-size: 11px; margin-bottom: 2mm; color: #111; }

/* дясната колона за печат: снимка отгоре, заглавие и текст, QR кодовете най-долу */
.pright { justify-content: flex-start !important; height: 190mm; min-height: 0 !important; padding: 0 !important; border: 0 !important; }
.pbook { width: 100%; height: auto; display: block; border-radius: 2mm; }
.padtitle { font-size: 15pt; font-weight: 700; margin: 4mm 0 2mm; color: #111; text-align: left; width: 100%; }
.padtext { font-size: 10pt; line-height: 1.35; color: #222; width: 100%; }
.pqrs { margin-top: auto; }

.methodlink .credits { color: var(--muted); font-size: 12px; }

.padtitle { margin: 0 !important; padding-bottom: 3mm; display: flex; align-items: flex-end; box-sizing: border-box; font-size: 13pt !important; line-height: 1.2; letter-spacing: .3px; }

.padtext { margin-top: 3mm; text-align: justify; hyphens: auto; }
.padtext p { margin: 0 0 2mm; }

.padtext .padcall { font-weight: 600; text-align: left; }

/* свита разбивка по причина */
details.breakdown { margin: 6px 0 4px; }
details.breakdown > summary { cursor: pointer; list-style: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 0; }
details.breakdown > summary::-webkit-details-marker { display: none; }
details.breakdown > summary::before { content: '▸'; display: inline-block; margin-right: 6px; transition: transform .15s; }
details.breakdown[open] > summary::before { transform: rotate(90deg); }
details.breakdown[open] { border-left: 2px solid var(--line); padding-left: 8px; }
#pdata details.breakdown > summary { color: #333 !important; font-size: 11px; }
#pdata details.breakdown > summary::before { content: none; }

/* вариант Б: подчертан общ сбор */
.subhead small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.cas.mini b { font-size: 17px !important; }
.totalbox { margin: 14px 0 8px; padding: 12px 14px 10px; border: 2px solid var(--accent); border-radius: 10px; background: rgba(255,90,31,.08); }
.tb-title { text-transform: uppercase; letter-spacing: .08em; font-weight: 800; font-size: 13px; color: var(--accent); margin-bottom: 6px; }
.tb-nums { display: flex; gap: 10px; }
.tb-nums > div { flex: 1; display: flex; flex-direction: column; }
.tb-nums b { font-size: 32px; line-height: 1.1; font-weight: 800; }
.tb-dead b { color: #ff4d4d; } .tb-inj b { color: #ff9f1c; }
.tb-nums span { font-size: 14px; font-weight: 600; }
.tb-nums small { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.tb-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 10px 0 6px; background: #4cd07d; }
.tb-bar i { display: block; height: 100%; } .tb-bar .d { background: #ff4d4d; } .tb-bar .j { background: #ff9f1c; } .tb-bar .a { flex: 1; background: #4cd07d; }
.tb-pop { margin: 0; font-size: 12.5px; color: var(--muted); } .tb-pop b { color: #4cd07d; }
#pdata .totalbox { background: #fff4ef !important; border-color: #e0531c !important; }
#pdata .tb-title { color: #c0410f !important; }
#pdata .tb-dead b { color: #c62828 !important; } #pdata .tb-inj b { color: #e07b00 !important; }
#pdata .tb-nums span, #pdata .tb-pop, #pdata .tb-nums small, #pdata .subhead small { color: #333 !important; }
#pdata .tb-pop b { color: #2e7d32 !important; }
#pdata .tb-bar, #pdata .tb-bar i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

.tb-row2 { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.12); }
.tb-aff b { color: #4aa3ff; } .tb-alive b { color: #4cd07d; }
.tb-pop { color: #4cd07d !important; font-weight: 600; }
#pdata .tb-aff b { color: #1565c0 !important; } #pdata .tb-alive b { color: #2e7d32 !important; }
#pdata .tb-row2 { border-top-color: #e6c8bb; } #pdata .tb-pop { color: #2e7d32 !important; }

/* „в зоната на облъчване“ в синьо, като хората в следата */
#results .cas.radcas div:nth-child(3) b { color: #5aa9ff !important; }
#pdata .cas.radcas div:nth-child(3) b { color: #1565c0 !important; }
.brand h1 .h1q { display: block; font-size: 20px; letter-spacing: 0; margin-top: 2px; color: var(--text); }
.brand p.brandmore { margin-top: -6px; font-size: 13px; line-height: 1.45; }

/* „За симулатора“, въпроси и автор */
.about { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.about h2 { font-size: 17px; color: var(--text); margin: 0 0 8px; }
.about h3 { font-size: 14px; color: var(--text); margin: 14px 0 4px; }
.about p { margin: 0 0 6px; }
.about a { color: var(--accent2); }
.about .author { margin-top: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); }
.about .author b { color: var(--text); }
.nojs { padding: 16px; background: #3a2410; color: #fff; margin: 0; }
.about .faqlinks { padding-left: 18px; margin: 4px 0 8px; } .about .faqlinks li { margin-bottom: 3px; }
