:root{
  --bg:#0B0E13;
  --panel:#141A22;
  --panel-2:#1B2330;
  --line:#28323F;
  --text:#E7ECF3;
  --muted:#8B98A9;
  --accent:#F0A63C;
  --red:#E24B4B;
  --blue:#3E8FE0;
  --smoke:#B9C4CF;
  --flash:#F2E27A;
  --molotov:#F07A35;
  --he:#7FB069;
  --safe-t:env(safe-area-inset-top,0px);
  --safe-b:env(safe-area-inset-bottom,0px);
  --font:"Segoe UI",system-ui,-apple-system,"Helvetica Neue",Arial,sans-serif;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--text);
  font-family:var(--font);
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}
h1,h2,h3{margin:0;font-weight:650;letter-spacing:-.015em}
button{font-family:inherit;color:inherit}

.screen{display:none;height:100%;flex-direction:column}
.screen.is-active{display:flex}

/* ---------- top bar ---------- */
.top{
  display:flex;align-items:center;gap:12px;
  padding:calc(var(--safe-t) + 14px) 16px 12px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg,#121924,#0D1219);
}
.top-title h1{font-size:19px}
.top-title p{margin:2px 0 0;font-size:13px;color:var(--muted)}
.top--board{gap:10px;padding-left:8px;padding-right:8px;flex-wrap:wrap}
.edit-tools{display:none;gap:2px;align-items:center}
body.is-editing .edit-tools{display:flex}
.icon-btn--danger{color:#F09090}
.icon-btn--danger:hover{background:rgba(226,75,75,.14)}
@media (max-width:700px){
  .top--board .top-actions{order:3;width:100%;margin-left:0;justify-content:space-between;
    padding-top:8px;margin-top:6px;border-top:1px solid var(--line)}
  body:not(.is-editing) .top--board .top-actions{order:0;width:auto;margin-left:auto;
    padding-top:0;margin-top:0;border-top:0}
}
.top-actions{margin-left:auto;display:flex;align-items:center;gap:8px}
#btn-refresh{margin-left:auto}

.icon-btn{
  width:40px;height:40px;flex:0 0 auto;display:grid;place-items:center;
  background:transparent;border:1px solid transparent;border-radius:11px;cursor:pointer;
}
.icon-btn:hover{background:var(--panel-2)}
.icon-btn svg{width:22px;height:22px;fill:currentColor}
.icon-btn:focus-visible,.tool:focus-visible,.btn:focus-visible,.map-card:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

.setup-picker{
  flex:1 1 auto;min-width:0;text-align:left;background:transparent;border:0;padding:2px 4px;cursor:pointer;
}
.setup-map{display:block;font-size:12px;color:var(--accent);letter-spacing:.04em}
.setup-name{
  display:flex;align-items:center;gap:4px;font-size:17px;font-weight:600;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.caret{width:18px;height:18px;flex:0 0 auto;color:var(--muted)}

.level-switch{
  position:absolute;left:12px;top:12px;z-index:15;
  display:flex;background:rgba(20,26,34,.92);border:1px solid var(--line);
  border-radius:11px;padding:3px;gap:2px;box-shadow:0 6px 18px rgba(0,0,0,.35);
}
.level-switch button{
  border:0;background:transparent;color:var(--muted);font-size:13px;font-weight:600;
  padding:6px 11px;border-radius:8px;cursor:pointer;
}
.level-switch button.is-active{background:var(--accent);color:#161009}

/* ---------- map grid ---------- */
/* tien maps: twee kolommen van vijf, gecentreerd, zonder scrollen */
.map-grid{
  flex:1;overflow-y:auto;display:grid;gap:12px;
  padding:14px 14px calc(var(--safe-b) + 18px);
  grid-template-columns:1fr;align-content:center;justify-content:center;
  width:100%;max-width:560px;margin:0 auto;
}
@media (min-width:640px){
  /* eerst de linkerkolom vullen, daarna de rechter */
  .map-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-rows:repeat(5,auto);
    grid-auto-flow:column;
    max-width:900px;
  }
}
.map-card{
  position:relative;border:1px solid var(--line);border-radius:14px;overflow:hidden;
  min-height:0;
  background:var(--panel);cursor:pointer;padding:0;text-align:left;display:block;line-height:0;
}
.map-card-img{
  display:block;width:100%;opacity:.85;
  aspect-ratio:16/9;
  max-height:clamp(74px, calc((100vh - 220px) / 5), 220px);
  background-size:cover;background-position:center;background-repeat:no-repeat;
}
.map-card::after{
  content:"";position:absolute;inset:0;
  background:linear-gradient(180deg,rgba(11,14,19,0) 35%,rgba(11,14,19,.92));
}
.map-card-label{line-height:1.2;position:absolute;left:14px;right:14px;bottom:11px;z-index:1;display:flex;align-items:flex-end;gap:8px}
.map-card-label strong{font-size:19px;font-weight:650;letter-spacing:-.01em}
.map-card-label span{margin-left:auto;font-size:12px;color:var(--muted);padding-bottom:3px}
.map-card:hover .map-card-img{opacity:1}

/* ---------- viewport ---------- */
.viewport{
  position:relative;flex:1;overflow:hidden;
  -webkit-touch-callout:none;user-select:none;-webkit-user-select:none;
  background:
    radial-gradient(circle at 50% 40%,#10161F,#080A0E 70%);
  touch-action:none;cursor:crosshair;
}
/* de radar is een achtergrond en geen <img>: browsers plakken anders hun eigen
   zoek-knopje over afbeeldingen heen (Edge doet dat met visual search) */
.stage{
  position:absolute;top:0;left:0;width:1024px;height:1024px;transform-origin:0 0;
  background-repeat:no-repeat;background-position:0 0;background-size:1024px 1024px;
}
#board{position:absolute;inset:0;width:1024px;height:1024px;overflow:visible}
#board text{user-select:none}

.hint{
  position:absolute;left:50%;transform:translateX(-50%);top:12px;z-index:3;
  background:rgba(20,26,34,.94);border:1px solid var(--line);border-radius:999px;
  padding:7px 14px;font-size:13px;color:var(--text);pointer-events:none;
}

/* ---------- toolbar ---------- */
.toolbar{
  display:flex;gap:6px;overflow-x:auto;padding:10px 10px calc(var(--safe-b) + 10px);
  border-top:1px solid var(--line);background:#0E141C;scrollbar-width:none;
}
.toolbar::-webkit-scrollbar{display:none}
.tool{
  flex:0 0 auto;display:flex;flex-direction:column;align-items:center;gap:5px;
  min-width:62px;padding:9px 8px;border-radius:12px;border:1px solid transparent;
  background:var(--panel);font-size:11px;color:var(--muted);cursor:pointer;
}
.tool svg{width:22px;height:22px}
.tool.is-active{background:var(--panel-2);border-color:var(--accent);color:var(--text)}
.dot{
  width:22px;height:22px;border-radius:50%;display:grid;place-items:center;
  border:2px solid rgba(0,0,0,.45);color:#11161E;font-size:10px;font-weight:800;line-height:1;
}
.dot--red{background:var(--red)}
.dot--blue{background:var(--blue)}
.util-chip{width:20px;height:20px;border-radius:50%;display:block;border:2px solid rgba(0,0,0,.45)}
.util-chip[data-kind=smoke]{background:var(--smoke)}
.util-chip[data-kind=flash]{background:var(--flash)}
.util-chip[data-kind=molotov]{background:var(--molotov)}
.util-chip[data-kind=he]{background:var(--he)}

/* ---------- sheet ---------- */
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:40;
  background:var(--panel);border-top:1px solid var(--line);
  border-radius:18px 18px 0 0;padding:6px 16px calc(var(--safe-b) + 14px);
  max-height:72vh;overflow-y:auto;box-shadow:0 -18px 40px rgba(0,0,0,.45);
  animation:rise .16s ease-out;
}
@keyframes rise{from{transform:translateY(14px);opacity:0}to{transform:none;opacity:1}}
@media (prefers-reduced-motion:reduce){.sheet{animation:none}}
.sheet-grip{width:38px;height:4px;border-radius:2px;background:var(--line);margin:4px auto 8px}
.sheet-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.sheet-head h2{font-size:17px;flex:1}
.sheet-body{display:flex;flex-direction:column;gap:14px}
.sheet-foot{display:flex;gap:10px;margin-top:16px}
.sheet-foot .btn{flex:1}

.field{display:flex;flex-direction:column;gap:6px}
.field > label{font-size:12px;color:var(--muted)}
input[type=text],input[type=url],select,textarea{
  width:100%;background:#0E131B;border:1px solid var(--line);color:var(--text);
  border-radius:10px;padding:11px 12px;font-size:15px;font-family:inherit;
}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--accent)}
.seg{display:flex;gap:6px;flex-wrap:wrap}
.seg button{
  flex:1 1 auto;min-width:74px;padding:10px;border-radius:10px;border:1px solid var(--line);
  background:#0E131B;color:var(--muted);font-size:14px;cursor:pointer;display:flex;
  align-items:center;justify-content:center;gap:7px;
}
.seg button.is-active{border-color:var(--accent);color:var(--text);background:var(--panel-2)}
.swatch{width:14px;height:14px;border-radius:50%;display:inline-block}

.btn{
  padding:12px 16px;border-radius:11px;border:1px solid var(--line);background:var(--panel-2);
  font-size:15px;font-weight:600;cursor:pointer;
}
.btn--primary{background:var(--accent);border-color:var(--accent);color:#161009}
.btn--danger{background:transparent;border-color:#5a2a2a;color:#F09090}
.btn--ghost{background:transparent}
.row{display:flex;gap:10px}
.row .btn{flex:1}
.video-row{display:flex;gap:8px;align-items:center}
.video-row .btn{padding:11px 13px;font-size:14px}
.note{font-size:12px;color:var(--muted);line-height:1.45}

/* ---------- modal ---------- */
.modal{
  position:fixed;inset:0;z-index:60;background:rgba(5,7,10,.78);
  display:flex;align-items:center;justify-content:center;padding:16px;
}
.modal-card{
  width:min(520px,100%);max-height:84vh;overflow-y:auto;background:var(--panel);
  border:1px solid var(--line);border-radius:16px;padding:6px 16px 16px;
}
/* het videovenster heeft geen eigen paneel: alleen de titelregel en het beeld
   zelf, met een dunne rand eromheen. De kaart is precies zo breed als het beeld,
   zodat de titel exact linksboven het filmpje uitkomt. */
.modal-card--video{
  background:transparent;border:0;box-shadow:none;padding:0;overflow:visible;
  width:min(calc(min(1600px, 100%) * var(--video-scale,1)), calc((100vh - 96px) * 16 / 9));
  max-height:none;
}
.modal-card--video .modal-head{padding:0 0 8px;gap:12px}
.modal-card--video .modal-head h2{font-size:16px;font-weight:600}
.modal-card--video .video-holder{
  width:100%;border:1px solid var(--line);
}
.modal-head{display:flex;align-items:center;gap:10px;padding:10px 0}
.modal-head h2{font-size:17px;flex:1}
.video-holder{background:#000;border-radius:12px;overflow:hidden;aspect-ratio:16/9;width:100%}
.video-holder video,.video-holder iframe{width:100%;height:100%;border:0;display:block;object-fit:contain;background:#000}

.menu-list{display:flex;flex-direction:column;gap:4px;padding-bottom:4px}
.menu-item{
  display:flex;align-items:center;gap:12px;padding:13px 12px;border-radius:11px;
  border:0;background:transparent;font-size:15px;text-align:left;cursor:pointer;width:100%;
}
.menu-item:hover{background:var(--panel-2)}
.menu-row{display:flex;align-items:center;gap:2px}
.menu-row .menu-item{flex:1;min-width:0}
.menu-edit{width:38px;height:38px;flex:0 0 auto;color:var(--muted)}
.menu-edit:hover{color:var(--text);background:var(--panel-2)}
.menu-edit svg{width:17px;height:17px}
.menu-row.is-editing{padding:6px 12px}
input.menu-rename{
  width:100%;background:none;border:0;border-bottom:2px solid var(--accent);border-radius:0;
  padding:5px 0;color:var(--text);font-family:inherit;font-size:15px;caret-color:var(--accent);
}
input.menu-rename:focus{outline:none;background:none;border:0;border-bottom:2px solid var(--accent)}
.menu-item small{margin-left:auto;color:var(--muted);font-size:12px}
.menu-item.is-current{background:var(--panel-2)}
.menu-item .tag{font-size:11px;padding:3px 8px;border-radius:999px;border:1px solid var(--line);color:var(--muted)}
.menu-sep{height:1px;background:var(--line);margin:6px 0}

.toast{
  position:fixed;left:50%;bottom:calc(var(--safe-b) + 84px);transform:translateX(-50%);
  background:var(--panel-2);border:1px solid var(--line);border-radius:999px;
  padding:10px 18px;font-size:14px;z-index:80;box-shadow:0 10px 30px rgba(0,0,0,.4);
  pointer-events:none;   /* een melding mag nooit een klik opvangen */
}
.toast button{pointer-events:auto}
.toast button{background:none;border:0;color:var(--accent);font-weight:700;margin-left:10px;cursor:pointer}

.empty{padding:26px 12px;text-align:center;color:var(--muted);font-size:14px;line-height:1.5}

/* ---------- modus ---------- */
.mode-btn{
  display:flex;align-items:center;gap:7px;padding:8px 13px;border-radius:11px;
  border:1px solid var(--line);background:var(--panel-2);font-size:13px;font-weight:600;cursor:pointer;
}
.mode-btn svg{width:16px;height:16px;fill:currentColor}
body.is-editing .mode-btn{background:var(--accent);border-color:var(--accent);color:#161009}
body:not(.is-editing) .toolbar{display:none}

/* ---------- worplijst in inspector ---------- */
.throw-list{display:flex;flex-direction:column;gap:6px}
.throw-item{
  display:flex;align-items:center;gap:10px;padding:11px 12px;border-radius:11px;
  border:1px solid var(--line);background:#0E131B;cursor:pointer;text-align:left;width:100%;color:inherit;
}
.throw-item small{color:var(--muted);font-size:12px}
.throw-item .grow{flex:1;min-width:0}
.throw-item .grow div{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
.chev{width:16px;height:16px;color:var(--muted);flex:0 0 auto}

/* ---------- schuifjes voor weergave ---------- */
/* eigen dialoogvenster */
.modal-card--dialog{width:min(420px,100%)}
.dialog-body{display:flex;flex-direction:column;gap:10px;padding-bottom:4px}
.dialog-body p{margin:0;font-size:14px;color:var(--muted);line-height:1.5}
.dialog-foot{display:flex;gap:10px;margin-top:16px}
.dialog-foot .btn{flex:1}

/* tekst aanpassen op de kaart zelf */
input.inline-text{
  position:absolute;z-index:30;transform:translate(-50%,-50%);
  background:none;border:0;padding:0;box-shadow:none;border-radius:0;
  text-align:center;font-weight:650;font-family:inherit;line-height:1.1;
  caret-color:var(--accent);
  /* zelfde donkere rand als de tekst op de kaart, zodat hij leesbaar blijft */
  text-shadow:0 0 3px #0B0E13, 1px 1px 0 #0B0E13, -1px 1px 0 #0B0E13,
              1px -1px 0 #0B0E13, -1px -1px 0 #0B0E13;
}
input.inline-text:focus{outline:none;border:0;background:none}

/* naam van de tactiek linksboven aanpassen */
.setup-picker input.setup-edit{
  max-width:100%;min-width:90px;background:none;border:0;
  border-bottom:2px solid var(--accent);border-radius:0;
  padding:0 0 1px;color:var(--text);font-family:inherit;
  font-size:17px;font-weight:600;caret-color:var(--accent);
}
.setup-picker input.setup-edit:focus{outline:none;background:none;border:0;border-bottom:2px solid var(--accent)}

/* kleurkiezer */
.swatch-row{display:flex;flex-wrap:wrap;gap:10px}
.swatch-btn{
  width:34px;height:34px;border-radius:50%;border:2px solid transparent;cursor:pointer;
  box-shadow:0 0 0 1px rgba(0,0,0,.45) inset;
}
.swatch-btn.is-active{border-color:var(--text);transform:scale(1.06)}

.slider-row{display:flex;align-items:center;gap:12px}
.slider-row input[type=range]{flex:1;accent-color:var(--accent);height:26px}
.slider-row output{width:46px;text-align:right;font-size:13px;color:var(--muted);font-variant-numeric:tabular-nums}

/* ---------- breed scherm: het paneel komt rechts te staan ---------- */
@media (min-width:900px){
  .sheet{
    right:auto;left:0;top:0;bottom:0;width:380px;max-height:none;
    display:flex;flex-direction:column;
    border-radius:0;border-top:0;border-right:1px solid var(--line);
    padding:calc(var(--safe-t) + 14px) 18px 18px;
    box-shadow:18px 0 44px rgba(0,0,0,.45);
    animation:slide-in .16s ease-out;
  }
  @keyframes slide-in{from{transform:translateX(-16px);opacity:0}to{transform:none;opacity:1}}
  .sheet-grip{display:none}
  .sheet-head{margin-bottom:16px}
  .sheet-head h2{font-size:19px}
  .sheet-body{flex:1;overflow-y:auto;gap:18px}
  .sheet-foot{margin-top:18px}
  .sheet-foot .btn{font-size:14px;padding:12px 8px;white-space:nowrap}

  /* elk veld op een eigen regel: ook de keuzeknoppen onder elkaar */
  .sheet .seg{flex-direction:column}
  .sheet .seg button{width:100%;min-width:0;justify-content:flex-start;padding:11px 14px}
  .throw-item{padding:13px 14px}

  /* het paneel dekt de linkerkant af: schuif de gereedschapsbalk mee op */
  body.panel-open .toolbar{padding-left:394px}
}
@media (min-width:900px) and (prefers-reduced-motion:reduce){
  .sheet{animation:none}
}

/* ververs-knop */
#btn-refresh.is-spinning svg{animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){#btn-refresh.is-spinning svg{animation:none}}
