@font-face {
  font-family: 'RoboFan';
  src: url('/assets/fonts/robofan.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000000;
  --bg-soft: #05070a;
  --fg: #e8edf2;          /* near-white */
  --blue: #4b92db;        /* UN blue */
  --blue-dim: #2c5a86;
  --green: #37d67a;
  --red: #ff4d4d;
  --yellow: #ffd23f;
  --dim: #6b7783;
  --line: #10202f;
  --glow: 0 0 6px rgba(75, 146, 219, 0.45);
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
  /* Display font = the attached RoboFan, with the mono stack as fallback so
     character-grid alignment still holds if the glyph is missing. */
  --display: "RoboFan", var(--mono);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--display); font-size: 15px; line-height: 1.5;
}
body { overflow: hidden; }

/* faint scanline / CRT vibe */
#scanlines {
  pointer-events: none; position: fixed; inset: 0; z-index: 5;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.02) 0, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
}

#terminal {
  position: absolute; inset: 0; padding: 18px 22px 70px;
  overflow-y: auto; scroll-behavior: smooth;
}
#terminal::-webkit-scrollbar { width: 8px; }
#terminal::-webkit-scrollbar-thumb { background: var(--blue-dim); border-radius: 4px; }

/* Terminal body stays monospace so dotted columns & box art align.
   Every row glows in its own colour for the CRT phosphor feel. */
#output .row { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); text-shadow: 0 0 4px currentColor; }
.c-ok { color: var(--green); text-shadow: 0 0 5px rgba(55,214,122,0.55); }
.c-err { color: var(--red); text-shadow: 0 0 5px rgba(255,77,77,0.55); }
.c-warn { color: var(--yellow); text-shadow: 0 0 5px rgba(255,210,63,0.5); }
.c-dim { color: var(--dim); text-shadow: none; }
.c-head { color: var(--blue); text-shadow: 0 0 6px rgba(75,146,219,0.7), 0 0 14px rgba(75,146,219,0.35); font-weight: 600; }
.c-imglink { color: var(--blue); cursor: pointer; text-decoration: underline dotted; }
.c-imglink:hover { color: var(--green); text-shadow: 0 0 8px rgba(55,214,122,0.7); }
.c-echo { color: var(--blue); }
.c-echo .caret { color: var(--dim); }

/* glowing entrance banner (RoboFan) */
.banner {
  font-family: var(--display); color: var(--blue); font-size: 30px; line-height: 1.15;
  letter-spacing: 2px; margin: 4px 0 2px;
  text-shadow: 0 0 8px rgba(75,146,219,0.85), 0 0 22px rgba(75,146,219,0.5), 0 0 40px rgba(75,146,219,0.25);
  animation: flicker 4s infinite;
}
.banner .sub { display: block; font-size: 13px; color: var(--dim); letter-spacing: 3px; text-shadow: none; margin-top: 4px; }
@keyframes flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 1; }
  49% { opacity: 0.72; }
  50% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.85; }
  94% { opacity: 1; }
}

/* input line */
#inputline {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 22px; background: linear-gradient(0deg, var(--bg) 70%, transparent);
  border-top: 1px solid var(--line);
}
#prompt { color: var(--blue); text-shadow: var(--glow); white-space: nowrap; font-family: var(--mono); }
#cmd {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--fg); font-family: var(--mono); font-size: 15px; caret-color: var(--blue);
  text-shadow: 0 0 4px currentColor;
}
#cmd:disabled { opacity: 0.4; }

/* blinking block cursor for entrance */
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* loading bar */
.loading { color: var(--blue); }
.loadbar { color: var(--green); letter-spacing: 1px; }

/* ---------- floating windows (forms, read viewer, image viewer) ---------- */
#windows { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.win {
  position: absolute; pointer-events: auto;
  width: 600px; max-width: 94vw; max-height: 82vh;
  display: flex; flex-direction: column;
  background: var(--bg-soft); border: 1px solid var(--blue-dim);
  box-shadow: 0 0 0 1px rgba(75,146,219,0.15), 0 12px 44px rgba(0,0,0,0.65), 0 0 42px rgba(75,146,219,0.20);
}
.win.dragging { opacity: 0.97; }
.win-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  color: var(--blue); font-family: var(--display); font-size: 17px; letter-spacing: 1px; font-weight: 600;
  text-shadow: 0 0 8px rgba(75,146,219,0.75), 0 0 18px rgba(75,146,219,0.35);
  cursor: move; user-select: none; flex: 0 0 auto;
}
.win-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-head .x {
  cursor: pointer; color: var(--red); border: 1px solid var(--red);
  width: 24px; height: 24px; display: grid; place-items: center; line-height: 1; flex: 0 0 auto;
}
.win-head .x:hover { background: var(--red); color: #000; }
.win-body { padding: 16px; overflow-y: auto; flex: 1 1 auto; }
.win-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex: 0 0 auto; }

.field { margin-bottom: 16px; }
.field > label.q { display: block; color: var(--fg); margin-bottom: 6px; text-shadow: 0 0 5px rgba(232,237,242,0.25); }
.field .hint { color: var(--dim); font-size: 12px; margin-top: 3px; }
.field input[type=text] {
  width: 100%; background: #000; border: 1px solid var(--blue-dim); color: var(--fg);
  padding: 8px 10px; font-family: var(--mono); outline: none;
}
.field input[type=text]:focus { border-color: var(--blue); box-shadow: var(--glow); }

.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  border: 1px solid var(--blue-dim); padding: 6px 12px; cursor: pointer; user-select: none;
  color: var(--fg); position: relative; background: #000;
}
.opt:hover { border-color: var(--blue); }
.opt.sel { background: var(--blue); color: #000; border-color: var(--blue); font-weight: 600; }
.opt .tip {
  display: none; position: absolute; bottom: 118%; left: 0; z-index: 3;
  width: 240px; background: #000; border: 1px solid var(--blue); color: var(--dim);
  padding: 6px 8px; font-size: 12px; box-shadow: var(--glow);
}
.opt:hover .tip { display: block; }

.group-title { color: var(--blue); font-size: 12px; letter-spacing: 1px; margin: 12px 0 6px; text-transform: uppercase; }

.btn {
  background: #000; border: 1px solid var(--blue); color: var(--blue);
  padding: 8px 18px; cursor: pointer; font-family: var(--display); letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(75,146,219,0.6); box-shadow: 0 0 10px rgba(75,146,219,0.12) inset;
}
.btn:hover { background: var(--blue); color: #000; }
.btn.ghost { border-color: var(--dim); color: var(--dim); }
.btn.ghost:hover { background: var(--dim); color: #000; }
.form-err { color: var(--red); margin-bottom: 10px; min-height: 18px; }

/* read viewer */
.rv-role { color: var(--yellow); margin-bottom: 10px; }
.rv-grid { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; }
.rv-grid .k { color: var(--dim); }
.rv-section { margin-top: 18px; }
.rv-section h4 { color: var(--blue); text-shadow: var(--glow); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.rv-note { border-left: 2px solid var(--blue-dim); padding: 4px 10px; margin: 8px 0; }
.rv-note .t { color: var(--green); }
.rv-note .m { color: var(--dim); font-size: 12px; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery img { width: 120px; height: 120px; object-fit: cover; border: 1px solid var(--blue-dim); cursor: pointer; }
.gallery img:hover { border-color: var(--blue); box-shadow: var(--glow); }
.imgmodal img { max-width: 100%; max-height: 78vh; display: block; margin: 0 auto; }

/* sound toggle (top-right) */
#sound {
  position: fixed; top: 12px; right: 16px; z-index: 8;
  font-family: var(--mono); font-size: 13px; color: var(--blue); cursor: pointer;
  border: 1px solid var(--blue-dim); padding: 4px 9px; background: rgba(0,0,0,0.5);
  text-shadow: var(--glow); user-select: none;
}
#sound:hover { border-color: var(--blue); box-shadow: var(--glow); }
#sound.off { color: var(--dim); border-color: var(--line); text-shadow: none; }
