/* FLUXONAUT — cryo-lab theme */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #070d18; --panel: #0e1828; --panel2: #122036;
  --edge: #27405e; --edge-hi: #4f7ec2;
  --text: #bcd6f2; --dim: #6f8db0;
  --plus: #3fd4ff; --minus: #ff8a64;
  --ok: #52e8a4; --bad: #ff5c69; --gold: #ffd16e; --conj: #caa6ff;
}
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -200px, #0e1d33 0%, var(--bg) 60%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; }

button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--edge); border-radius: 8px;
  padding: 6px 12px; font: 600 13px 'Segoe UI', system-ui, sans-serif;
  cursor: pointer; transition: all .12s;
}
button:hover { border-color: var(--edge-hi); transform: translateY(-1px); }
button.primary { background: #14365a; border-color: #2f6da8; }
button.gold { background: #3a2f12; border-color: #8a6f2f; color: var(--gold); }
button.big { padding: 12px 26px; font-size: 16px; border-radius: 10px; margin: 6px; }
button.mini { padding: 3px 9px; font-size: 11.5px; }
button.mini.warn { border-color: #7c4040; color: #ff9d8a; }

/* ───────── title ───────── */
#screen-title { display: flex; align-items: center; justify-content: center; }
.title-box { text-align: center; max-width: 720px; padding: 40px 20px; }
.title-art { position: relative; width: 130px; height: 130px; margin: 0 auto 10px;
  border: 1.5px solid var(--edge-hi); border-radius: 50%;
  box-shadow: 0 0 60px rgba(63,212,255,.15), inset 0 0 40px rgba(63,212,255,.07); }
.orbit-dot { position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; border-radius: 50%; }
.orbit-dot.plus { background: var(--plus); box-shadow: 0 0 18px var(--plus); animation: orbit 3.4s linear infinite; }
.orbit-dot.minus { background: var(--minus); box-shadow: 0 0 18px var(--minus); animation: orbit 3.4s linear infinite reverse; }
@keyframes orbit {
  from { transform: rotate(0deg) translateX(58px) translate(-50%,-50%); }
  to { transform: rotate(360deg) translateX(58px) translate(-50%,-50%); }
}
h1 { font-size: 54px; letter-spacing: 12px; font-weight: 200; color: #e8f4ff;
  text-shadow: 0 0 30px rgba(63,212,255,.4); }
.small-title { font-size: 26px; letter-spacing: 8px; text-align: center; margin: 18px 0 6px; }
.subtitle { color: var(--dim); margin: 10px 0 26px; line-height: 1.5; }
.subtitle b { color: var(--text); }
.credits { color: var(--dim); font-size: 11.5px; line-height: 1.6; margin-top: 34px; }

/* ───────── level select ───────── */
.levels-box { max-width: 1060px; margin: 0 auto; padding: 10px 18px 60px; }
.world-head { display: flex; align-items: baseline; gap: 14px; margin: 22px 4px 8px;
  font-size: 15px; font-weight: 600; color: #d7eaff; }
.world-tip { font-size: 11.5px; color: var(--dim); font-weight: 400; }
.level-row { display: flex; flex-wrap: wrap; gap: 10px; }
.level-card { background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  width: 150px; padding: 10px 12px; cursor: pointer; transition: all .12s; }
.level-card:hover { border-color: var(--edge-hi); transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(63,212,255,.08); }
.level-card.bonus { border-color: #6a4f8a; }
.level-card.sandbox { border-color: #3f7e62; }
.lv-num { font-size: 11px; color: var(--dim); }
.lv-title { font-size: 13.5px; font-weight: 600; margin: 3px 0; min-height: 32px; }
.lv-stars { color: var(--gold); font-size: 13px; letter-spacing: 2px; }
.reset-wrap { margin-top: 34px; text-align: center; }

/* ───────── game ───────── */
#hud { display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--edge); }
#hud-title { font-weight: 600; font-size: 14.5px; }
.hud-spacer { flex: 1; }
#hud-heat, #hud-parts { font-size: 13px; color: var(--dim); }
#hud-heat b { color: var(--bad); } #hud-parts b { color: var(--text); }

#game-main { display: flex; gap: 12px; padding: 12px; align-items: flex-start;
  max-width: 1500px; margin: 0 auto; }
#palette { width: 132px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.pal-item { background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  padding: 7px; text-align: center; cursor: grab; transition: all .12s; }
.pal-item:hover { border-color: var(--edge-hi); }
.pal-icon { width: 56px; height: 56px; }
.pal-name { font-size: 10.5px; font-weight: 600; line-height: 1.25; }
.pal-count { font-size: 10px; color: var(--dim); }

#board-wrap { flex: 1; min-width: 0; }
#board { width: 100%; max-width: 1100px; display: block; border: 1px solid var(--edge);
  border-radius: 12px; background: #0a111e; cursor: crosshair;
  box-shadow: 0 8px 40px rgba(0,0,0,.45), inset 0 0 80px rgba(40,80,140,.05); }
#case-tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.case-tab { font-size: 11.5px; padding: 4px 10px; border-radius: 14px; }
.case-tab.active { background: #14365a; border-color: #2f6da8; color: #dff0ff; }
.case-tab.done { border-color: var(--ok); color: var(--ok); }
.case-tab.done.active { background: #123b30; border-color: var(--ok); color: #d6ffe9; }

#controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.speed-wrap { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
#speed { width: 90px; accent-color: var(--edge-hi); }
.ctl-tip { font-size: 11px; color: var(--dim); margin-left: auto; }

#inspector { margin-top: 10px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; }
.insp-name { font-weight: 700; }
.insp-blurb { color: var(--dim); font-size: 11.5px; flex-basis: 100%; line-height: 1.45; }

/* persistent level briefing panel (full width, above the board) */
#briefing { max-width: 1476px; margin: 12px auto 0; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 10px; padding: 10px 16px; }
.brief-body { font-size: 13px; line-height: 1.5; color: #cfe2f5; }
.brief-body b { color: #fff; } .brief-body i { color: #9fc6ea; }
.brief-p { margin: 0 0 5px; }
.brief-p:last-child { margin-bottom: 0; }

/* result / fault banner — sits below the board so it never covers the event */
.game-banner { margin-top: 10px; padding: 10px 14px; border-radius: 8px;
  font: 600 12.5px system-ui, sans-serif; line-height: 1.45; color: #fff;
  border: 1px solid rgba(255,255,255,0.25); }
.game-banner.fault { background: rgba(120,28,38,0.92); border-color: rgba(255,120,120,0.4); }
.game-banner.fail  { background: rgba(120,70,28,0.92); border-color: rgba(255,190,120,0.4); }
.game-banner.ok    { background: rgba(22,90,64,0.92); border-color: rgba(120,255,200,0.35); }
.hint-bar { margin-top: 10px; padding: 10px 14px; border-radius: 8px; background: rgba(58,47,18,0.55); border: 1px solid #8a6f2f; color: var(--gold); font-size: 13px; line-height: 1.5; }

/* ───────── modal ───────── */
#modal { position: fixed; inset: 0; background: rgba(4,8,16,.78); display: flex;
  align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(3px); }
#modal-box { background: var(--panel); border: 1px solid var(--edge-hi); border-radius: 14px;
  max-width: 640px; width: calc(100% - 40px); max-height: 84vh; overflow-y: auto;
  padding: 22px 26px; box-shadow: 0 20px 80px rgba(0,0,0,.6); }
#modal-box h2 { font-weight: 600; letter-spacing: 1px; margin-bottom: 12px; }
#modal-box h2.ok { color: var(--ok); } #modal-box h2.bad { color: var(--bad); }
.story { line-height: 1.62; font-size: 14px; color: #cfe2f5; }
.story b { color: #fff; }
.story i { color: #9fc6ea; }
.hint { margin-top: 12px; color: var(--gold); font-size: 13px; line-height: 1.5; }
.stars-big { font-size: 34px; color: var(--gold); letter-spacing: 8px; margin: 6px 0 10px; }
.why { font-size: 13px; color: var(--dim); line-height: 1.7; margin-bottom: 8px; }
.why-bad { color: var(--bad); }
.cert-warn { margin-top: 10px; color: var(--gold); font-size: 13px; line-height: 1.5; }
.case-res { padding: 6px 10px; border-radius: 8px; margin: 5px 0; font-size: 13px;
  background: var(--panel2); }
.case-res.bad b { color: var(--bad); } .case-res.ok b { color: var(--ok); }
.case-res .reasons { color: var(--dim); font-size: 12px; margin-top: 3px; line-height: 1.5; }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.pol-p { color: var(--plus); font-weight: 700; } .pol-m { color: var(--minus); font-weight: 700; }
.conj { color: var(--conj); font-weight: 700; }
.dim { color: var(--dim); font-size: 12px; margin: 6px 0; }

/* notebook */
.notebook details { background: var(--panel2); border: 1px solid var(--edge);
  border-radius: 8px; margin: 6px 0; padding: 8px 12px; }
.notebook summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.notebook details.locked summary { color: var(--dim); cursor: default; }
.nb-body { font-size: 13px; line-height: 1.6; color: #c4d9ee; padding: 8px 2px 4px; }
.nb-body b { color: #fff; }

/* references / bibliography */
.biblio { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.bib-entry { font-size: 12.5px; line-height: 1.55; color: #c4d9ee; padding-left: 1.5em; text-indent: -1.5em; }
.bib-key { color: var(--gold); font-weight: 700; }
.bib-entry a { text-decoration: none; word-break: break-word; }
/* notebook + bibliography hyperlinks: bright pastels for contrast on the dark panel */
.nb-body a:link,    .bib-entry a:link    { color: #8fc4ff; }   /* unclicked: pastel sky-blue */
.nb-body a:visited, .bib-entry a:visited { color: #c9a9ff; }   /* clicked:   pastel lavender */
.nb-body a:hover,   .bib-entry a:hover   { color: #bcdcff; text-decoration: underline; }

/* notebook unlock cues: toolbar dot, NEW badge, and the top "new page" toast */
#btn-notebook { position: relative; }
#btn-notebook.has-unread::after {
  content: ''; position: absolute; top: 1px; right: 1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); border: 1.5px solid var(--panel);
  box-shadow: 0 0 8px var(--gold); animation: nb-pulse 1.6s ease-in-out infinite;
}
@keyframes nb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.nb-new {
  display: inline-block; margin-left: 8px; padding: 0 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em; line-height: 1.6;
  color: #1a1206; background: var(--gold); border-radius: 4px; vertical-align: middle;
}
#nb-toast {
  position: fixed; top: 14px; left: 50%; z-index: 45;
  transform: translateX(-50%) translateY(-16px);
  max-width: 92vw; padding: 11px 20px; border-radius: 10px;
  background: rgba(58, 47, 18, 0.96); border: 1px solid #8a6f2f; color: var(--gold);
  font-size: 14.5px; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  cursor: pointer; opacity: 0; pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
#nb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#nb-toast .nb-toast-cue { color: var(--text); font-weight: 400; font-size: 13px; margin-left: 6px; opacity: .92; }

@media (max-width: 900px) {
  #game-main { flex-direction: column; }
  #palette { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .pal-item { width: 96px; }
}
