:root {
  --bg: #020d05;
  --screen: rgba(1, 14, 5, 0.72);
  --fg: #3dff7a;
  --dim: #1f9a4c;
  --faint: #0f4a25;
  --alert: #ffcf3d;
  --hit: #5cc8ff;
  --glow: 0 0 4px rgba(61, 255, 122, 0.55);
  --font: "Consolas", "Lucida Console", "DejaVu Sans Mono", "Courier New", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* The whole terminal scales with the window: 15px on small screens, up to 26px on big ones. */
html {
  font-size: clamp(15px, 1.4vw, 26px);
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.35;
  text-shadow: var(--glow);
}

.crt {
  position: relative;
  min-height: 100vh;
  padding-inline: 16px;
  padding-block: 1.1rem 2rem;
  background: radial-gradient(ellipse at center, #06200e 0%, var(--bg) 75%);
}

/* scanlines + a faint flicker, drawn over everything but never catching clicks */
.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.22) 3px);
  animation: flicker 6s infinite steps(1);
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: 0.93; } 48% { opacity: 1; } }

/* One centered console: header, practice note and the frame all share the frame's width. */
.console { width: fit-content; max-width: 100%; margin: 0 auto; }
.banner { display: flex; align-items: flex-start; gap: 0.9rem; margin-bottom: 0.9rem; letter-spacing: 0.06em; }
.dim { color: var(--dim); }
.alert { color: var(--alert); text-shadow: 0 0 4px rgba(255, 207, 61, 0.5); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* hamburger */
.term-nav { position: relative; flex-shrink: 0; }
.menu-btn { padding: 0 2px; }
.menu-btn[aria-expanded="true"] { background: var(--fg); color: var(--bg); text-shadow: none; }
.term-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  min-width: 12em;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  background: var(--bg);
  border: 1px solid var(--dim);
  box-shadow: 0 0 12px rgba(61, 255, 122, 0.15);
}
.term-menu[hidden] { display: none; }
.term-menu a { color: var(--fg); text-decoration: none; padding: 0.35em 0.8em; white-space: nowrap; }
.term-menu a[hidden] { display: none; }
.term-menu a:hover, .term-menu a:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }

/* practice note: one compact line above the frame */
.practice {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2em 1.4em;
  border: 1px dashed var(--alert);
  color: var(--alert);
  text-shadow: 0 0 4px rgba(255, 207, 61, 0.5);
  padding: 0.4em 0.9em;
  margin-bottom: 1.1rem;
  font-size: 0.85em;
}
.practice[hidden] { display: none; }
.practice .dim { color: #b8962c; }
.practice button { color: var(--alert); padding: 0; margin-left: auto; }
.practice button:hover, .practice button:focus-visible { background: var(--alert); color: var(--bg); }

/* ------------------------------------------------------------------ the frame
   Double edge (border + offset outline), bright corner brackets, an inner glow, and wide
   padding so the game never crowds the edges. */
.frame {
  --corner: var(--fg);
  --arm: 1.6em;
  position: relative;
  min-width: min(100%, 56em);
  min-height: 27em;
  padding: 1.3em 2.8em 2.4em;
  border: 1px solid var(--dim);
  outline: 1px solid var(--faint);
  outline-offset: 7px;
  border-radius: 2px;
  background:
    linear-gradient(var(--corner), var(--corner)) left top / var(--arm) 3px,
    linear-gradient(var(--corner), var(--corner)) left top / 3px var(--arm),
    linear-gradient(var(--corner), var(--corner)) right top / var(--arm) 3px,
    linear-gradient(var(--corner), var(--corner)) right top / 3px var(--arm),
    linear-gradient(var(--corner), var(--corner)) left bottom / var(--arm) 3px,
    linear-gradient(var(--corner), var(--corner)) left bottom / 3px var(--arm),
    linear-gradient(var(--corner), var(--corner)) right bottom / var(--arm) 3px,
    linear-gradient(var(--corner), var(--corner)) right bottom / 3px var(--arm),
    var(--screen);
  background-repeat: no-repeat;
  background-origin: border-box;
  box-shadow: 0 0 28px rgba(61, 255, 122, 0.10), inset 0 0 70px rgba(61, 255, 122, 0.06);
}
.frame-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5em 2em;
  padding-bottom: 0.7em;
  margin-bottom: 1.4em;
  border-bottom: 1px solid var(--faint);
}
.frame-title { color: var(--dim); letter-spacing: 0.22em; }
.meters { display: flex; flex-wrap: wrap; gap: 0.5em 2em; }
.meters[hidden] { display: none; }
.blocks { letter-spacing: 0.25em; margin-left: 0.5em; }
.blocks .spent { color: var(--faint); text-shadow: none; }

/* prompts */
.prompt { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5em; margin: 0.4em 0 0.8em; }
.stack { display: grid; gap: 0.4em; max-width: 26em; margin-top: 0.8em; }
#stage-pass { margin-top: 1.6em; padding-top: 1em; border-top: 1px solid var(--faint); }
input {
  background: transparent;
  color: var(--fg);
  border: none;
  border-bottom: 1px solid var(--dim);
  font: inherit;
  text-shadow: inherit;
  padding: 2px 4px;
  min-width: 0;
  flex: 1 1 10em;
  max-width: 22em;
  outline: none;
  caret-color: var(--fg);
}
input:focus { border-bottom-color: var(--fg); }
button {
  background: transparent;
  color: var(--fg);
  border: none;
  font: inherit;
  text-shadow: inherit;
  cursor: pointer;
  padding: 2px 4px;
}
button:hover, button:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }
button:disabled { color: var(--faint); cursor: default; background: transparent; }
button.link { padding-left: 0; }
#error { margin: 1.2em 0 0; }

/* ------------------------------------------------------------------ board */
.board-wrap { display: flex; justify-content: center; gap: 2.5em; align-items: stretch; }
.panels { display: flex; gap: 2.5em; outline: none; }
.panels:focus-visible { box-shadow: 0 0 0 1px var(--faint); }
/* wide letter spacing stretches the board sideways without making it taller */
.panel { white-space: pre; user-select: none; letter-spacing: 0.16em; }
.panel .c { text-transform: uppercase; }
.row { display: block; }
.addr { color: var(--dim); margin-right: 0.6em; }
.c { cursor: default; }
.c.hl { background: var(--fg); color: var(--bg); text-shadow: none; cursor: pointer; }
.c.cur { background: var(--fg); color: var(--bg); text-shadow: none; }
.c.spent { color: var(--faint); text-shadow: none; }

/* right-hand instrument panel: SESSION / CURSOR / LOG. The memory dump alone sets the height:
   the panel's content is taken out of flow (absolute) so it can never make the row taller —
   it fills exactly the board's height and the log scrolls inside what is left. */
.side { position: relative; width: 17em; flex-shrink: 0; }
.side-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
}
.side-box {
  border: 1px solid var(--faint);
  padding: 0.35em 0.8em 0.45em;
  background: rgba(61, 255, 122, 0.025);
}
.side-box.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head {
  display: flex;
  justify-content: space-between;
  color: var(--dim);
  font-size: 0.75em;
  letter-spacing: 0.2em;
  padding-bottom: 0.3em;
  margin-bottom: 0.35em;
  border-bottom: 1px solid var(--faint);
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0 1em; margin: 0; font-size: 0.85em; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec { color: #ff5c5c; text-shadow: 0 0 6px rgba(255, 92, 92, 0.8); animation: blink 1.6s steps(1) infinite; }
.entry { font-size: 1.1em; white-space: pre; overflow: hidden; }
.log {
  flex: 1;
  min-height: 0;
  font-size: 0.9em;
  overflow-y: auto;
  scrollbar-width: none;
  overflow-wrap: anywhere;
}
.log::-webkit-scrollbar { display: none; }
/* letters of a wrong guess that appear somewhere in the answer */
.log .hit { color: var(--hit); text-shadow: 0 0 6px rgba(92, 200, 255, 0.75); }
.caret { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .crt::after, .caret, .rec { animation: none; }
}

/* narrower: the instrument panel drops under the memory dump */
@media (max-width: 1000px) {
  .board-wrap { flex-direction: column; gap: 0.8em; }
  .side { width: auto; }
  .side-inner { position: static; }
  .side-box.grow { max-height: 10em; }
}
/* phone: panels stack, frame tightens */
@media (max-width: 640px) {
  .panels { flex-direction: column; gap: 0.6em; }
  .panel { letter-spacing: 0.05em; }
  .frame { min-height: 0; padding: 0.9em 0.9em 1.3em; outline-offset: 3px; --arm: 1em; }
}

/* ------------------------------------------------------------------ security monitor */
.console.wide { width: min(100%, 80em); font-size: 0.78em; }
.console.wide .frame { min-width: 0; }
.plain-link { color: var(--fg); text-decoration: none; }
.plain-link:hover, .plain-link:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5em, 1fr)); gap: 0.8em; margin-bottom: 0.4em; }
.stat { border: 1px solid var(--faint); padding: 0.5em 0.8em; background: rgba(61, 255, 122, 0.025); }
.stat-label, .stat-sub { color: var(--dim); font-size: 0.8em; letter-spacing: 0.15em; }
.stat-value { font-size: 2.1em; line-height: 1.15; }
.stat.hot .stat-value { color: var(--alert); text-shadow: 0 0 6px rgba(255, 207, 61, 0.55); }
table.grid { width: 100%; min-width: 44em; }
table.grid th { border-bottom: 1px solid var(--dim); padding-bottom: 0.3em; }
table.grid td { border-bottom: 1px solid var(--faint); padding: 0.4em 1em 0.4em 0; }
table.grid tr.bad td { color: var(--alert); text-shadow: 0 0 4px rgba(255, 207, 61, 0.4); }
td.names { max-width: 22em; overflow-wrap: anywhere; }
td.actions { white-space: nowrap; text-align: right; }
.small { font-size: 0.8em; }
.pill { display: inline-block; padding: 0 0.45em; border: 1px solid currentColor; white-space: nowrap; }
.pill.blocked { color: #ff5c5c; text-shadow: 0 0 5px rgba(255, 92, 92, 0.6); }
.pill.locked { color: var(--alert); text-shadow: 0 0 5px rgba(255, 207, 61, 0.5); }
.pill.watch { color: var(--dim); }

/* ------------------------------------------------------------------ home */
.menu { list-style: none; padding: 0; margin: 0.5em 0 1.5em; }
.menu li { margin: 0.25em 0; }
.menu a { color: var(--fg); text-decoration: none; padding: 0 4px; }
.menu a:hover, .menu a:focus-visible { background: var(--fg); color: var(--bg); text-shadow: none; outline: none; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 34em; }
th, td { text-align: left; padding: 3px 1em 3px 0; vertical-align: top; }
th { color: var(--dim); font-weight: normal; }
.tokens { font-size: 1.15em; letter-spacing: 0.08em; margin: 0.5em 0; }
h2 { font-size: 1em; font-weight: normal; margin: 1.6em 0 0.4em; color: var(--dim); }
.frame h2:first-of-type { margin-top: 0; }
