:root{
  --wood-dark:#20140c;
  --wood:#2c1c11;
  --wood-light:#3d2818;
  --parchment:#e9dcbd;
  --parchment-dark:#d9c79c;
  --ink:#241a10;
  --brass:#b8935f;
  --brass-bright:#e0b878;
  --torch:#e8823a;
  --torch-glow:#ffb066;
  --error:#e08a8a;
  /* Belt-and-suspenders alongside index.html's <meta name="color-scheme">
     — same "opt out of the browser's forced-dark-mode heuristic" purpose,
     in case anything ever renders without that meta tag present (see its
     comment for the full rationale). */
  color-scheme:light;
}
*{box-sizing:border-box;}
/* [hidden] must win over any other display rule for that same element —
   without !important, a normal-priority author rule like .screen{display:
   flex} always beats the UA stylesheet's [hidden]{display:none}, because
   origin (author > user-agent) is resolved before selector specificity
   for non-important declarations. Without this, #noneScreen/#loginScreen/
   #viewerScreen all stay laid out simultaneously in body's flex column
   any time JS sets .hidden=true, each squeezed into a fraction of the
   viewport — the exact "login box is huge / cut off by the map canvas"
   bug this rule exists to prevent. */
[hidden]{display:none !important;}
html,body{
  margin:0;height:100%;
  font-family:'Spectral',serif;
  background:var(--wood-dark);
  color:var(--parchment);
  overflow:hidden;
}
body{
  display:flex;
  flex-direction:column;
}

#topBar{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 16px;
  background:linear-gradient(180deg,#1a1008,#251708);
  border-bottom:2px solid var(--brass);
}
#topBar .brand{
  font-family:'Cinzel',serif;
  color:var(--brass-bright);
  letter-spacing:.04em;
  font-size:14px;
  margin-right:8px;
}
#topBar label{font-size:11px;color:var(--parchment-dark);}
#campaignSelect{
  background:rgba(255,248,232,.08);
  color:var(--parchment);
  border:1px solid rgba(184,147,95,.4);
  border-radius:5px;
  padding:5px 8px;
  font-size:12px;
  font-family:'Spectral',serif;
}
/* The closed select box honors the translucent background above (light
   text over the dark page behind it, readable), but most browsers render
   the OPEN option list as a native popup that ignores that background
   and falls back to a plain light system surface — while still applying
   the select's own light `color`, making the open list unreadable even
   though the closed box looks fine. Styling <option> directly forces a
   guaranteed-readable dark-on-light pairing for the popup specifically,
   without touching the closed-box styling above. */
#campaignSelect option, #mapSelect option{
  color:var(--ink);
  background:#fff8ec;
}

.screen{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:20px;
}
.screen h1{
  font-family:'Cinzel',serif;
  color:var(--brass-bright);
  letter-spacing:.04em;
  margin:0 0 10px;
}
.screen .hint{color:var(--parchment-dark);font-size:13px;max-width:360px;margin:0 auto 16px;line-height:1.5;}
.screen .hint.error{color:var(--error);min-height:1.2em;}

#loginForm{
  background:rgba(20,12,6,.9);
  border:1px solid var(--brass);
  border-radius:8px;
  padding:28px 32px;
  width:320px;
  max-width:calc(100vw - 40px);
  box-shadow:0 10px 40px rgba(0,0,0,.6);
}
#passphraseInput{
  width:100%;
  padding:10px 12px;
  border:1px solid rgba(184,147,95,.5);
  border-radius:5px;
  background:rgba(255,248,232,.08);
  color:var(--parchment);
  font-size:14px;
  margin-bottom:12px;
}
#loginForm button{
  width:100%;
  padding:10px;
  border:none;
  border-radius:5px;
  background:var(--torch);
  color:#1a0f04;
  font-weight:700;
  font-family:'Cinzel',serif;
  letter-spacing:.05em;
  cursor:pointer;
}
#loginForm button:hover{background:var(--torch-glow);}

#viewerScreen{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
}

#mapPicker{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  background:linear-gradient(180deg,#1a1008,#251708);
  border-bottom:2px solid var(--brass);
}
#mapSearchInput{
  flex:0 1 220px;
  min-width:0;
  background:rgba(255,248,232,.08);
  color:var(--parchment);
  border:1px solid rgba(184,147,95,.4);
  border-radius:5px;
  padding:6px 10px;
  font-size:12px;
  font-family:'Spectral',serif;
}
#mapSelect{
  flex:1 1 auto;
  min-width:0;
  background:rgba(255,248,232,.08);
  color:var(--parchment);
  border:1px solid rgba(184,147,95,.4);
  border-radius:5px;
  padding:6px 8px;
  font-size:12px;
  font-family:'Spectral',serif;
}

#landingScreen{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background-image:url('/img/landing-parchment.svg');
  background-size:cover;
  background-position:center;
}
#landingCard{
  text-align:center;
  padding:28px 44px;
  max-width:min(80%, 520px);
}
#landingCard h1{
  font-family:'Cinzel',serif;
  font-weight:700;
  letter-spacing:.06em;
  font-size:clamp(26px, 4vw, 42px);
  color:var(--ink);
  text-shadow:0 1px 0 rgba(255,255,255,.35), 0 2px 3px rgba(36,26,16,.25);
  margin:0 0 14px;
}
#landingCard h1 span{
  color:var(--torch);
  padding:0 .15em;
}
#landingCard p{
  font-family:'Spectral',serif;
  font-size:15px;
  color:var(--ink);
  opacity:.8;
  margin:0;
}

#canvasScroll{
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  overflow:auto;
  display:flex;
  background-color:#cdb98a;
  background-image:
    radial-gradient(ellipse at 15% 20%, rgba(255,250,230,.4), transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(255,248,220,.25), transparent 50%),
    radial-gradient(ellipse at 75% 85%, rgba(110,82,42,.22), transparent 55%),
    radial-gradient(ellipse at 10% 90%, rgba(110,82,42,.28), transparent 55%);
}
#canvasPad{
  margin:auto;
  display:flex;
  align-items:center;
  justify-content:center;
  box-sizing:content-box;
}
#canvasWrap{
  display:inline-block;
  flex:0 0 auto;
  box-shadow:0 10px 40px rgba(0,0,0,.7), 0 0 0 10px var(--wood-light), 0 0 0 14px var(--wood-dark);
  transform-origin:center center;
}
canvas{display:block;background:#ffffff;}

#bottomRightPanel{
  position:fixed;
  right:14px; bottom:14px;
  z-index:20;
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:flex-end;
  pointer-events:none;
}
#bottomRightPanel > *{ pointer-events:auto; }

#zoomBar{
  background:rgba(20,12,6,.85);border:1px solid var(--brass);
  border-radius:6px;padding:8px 12px;display:flex;align-items:center;gap:8px;
  font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--parchment);
}
#zoomBar input{accent-color:var(--torch);}

.panelLabel{
  font-family:'Cinzel',serif;font-size:10px;letter-spacing:.1em;text-transform:uppercase;
  color:var(--torch);margin-bottom:5px;display:block;
}

#initiativeBox, #notesBox{
  background:rgba(20,12,6,.92);border:1px solid var(--brass);
  border-radius:6px;padding:8px 10px;
  width:240px;
  max-width:calc(100vw - 28px);
  box-shadow:0 4px 16px rgba(0,0,0,.5);
}
#initiativeList{
  display:flex;flex-direction:column;gap:4px;
  max-height:160px;overflow-y:auto;
}
#initiativeList .hint{font-size:10.5px;color:#b9a679;opacity:.85;margin:2px 0;}
.initrow{
  display:flex;align-items:center;gap:6px;
  background:rgba(255,248,232,.08);
  border:1px solid rgba(184,147,95,.4);
  border-radius:4px;padding:4px 6px;font-size:11px;color:var(--parchment);
}
.initrow .initName{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.initrow .initDetail{font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--parchment-dark);white-space:nowrap;}
.initrow .initTotal{font-weight:700;color:var(--torch-glow);}
.initrow .locateBtn{
  border:none;background:none;color:var(--torch-glow);cursor:pointer;font-size:12px;opacity:.85;padding:0 3px;
}
.initrow .locateBtn:hover{opacity:1;}

#notesText{
  font-size:12px;
  line-height:1.5;
  color:var(--parchment);
  white-space:pre-wrap;
  max-height:160px;
  overflow-y:auto;
}
#notesText:empty::before{content:'No notes yet.';color:#b9a679;opacity:.7;}
