/* ROBCO TERMLINK — CRT terminal styling */

:root {
  --green: #4fff6e;
  --green-rgb: 79, 255, 110;
  --screen-bg: #041104;
  --rows: 16; /* kept in sync by js/terminal.js */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  font-family: "Consolas", "Courier New", monospace;
  overflow: hidden;
}

/* ---------- CRT shell ---------- */

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0a1a0a 0%, #000000 100%);
}

.crt {
  position: relative;
  width: min(96vw, 900px);
  height: min(94vh, 680px);
  background: var(--screen-bg);
  border-radius: 18px;
  box-shadow:
    0 0 0 10px #0d0d0d,
    0 0 0 14px #1a1a1a,
    0 0 40px 10px rgba(0, 0, 0, 0.8),
    inset 0 0 60px 10px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  padding: 26px 32px;
  color: var(--green);
  text-shadow:
    0 0 2px var(--green),
    0 0 8px rgba(var(--green-rgb), 0.6),
    0 0 16px rgba(var(--green-rgb), 0.25);
  font-size: 15px;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: flicker 6s infinite;
}

.curve::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0) 55%),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
  z-index: 6;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.28) 2px,
    rgba(0, 0, 0, 0.28) 3px
  );
  background-size: 100% 3px;
  pointer-events: none;
  z-index: 7;
  animation: scanmove 8s linear infinite;
  mix-blend-mode: multiply;
}

.sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
  animation: sweepmove 7s linear infinite;
  pointer-events: none;
  z-index: 8;
}

@keyframes scanmove {
  0%   { background-position: 0 0; }
  100% { background-position: 0 6px; }
}

@keyframes sweepmove {
  0%   { top: -60px; }
  100% { top: 100%; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.82; }
  94% { opacity: 1; }
  97% { opacity: 0.9; }
  98% { opacity: 1; }
}

@keyframes blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ---------- header ---------- */

.topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
}

/* Shrinks before the buttons do, so the actions stay on one row. */
.brand {
  font-size: 14px;
  letter-spacing: 1px;
  min-width: 0;
}

.topactions { flex-shrink: 0; }

.topactions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.newgame {
  cursor: pointer;
  border: 1px solid var(--green);
  padding: 2px 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;   /* after `font`, which would otherwise reset it */
  text-shadow: inherit;
  letter-spacing: 1px;
}

.newgame:hover { background: rgba(var(--green-rgb), 0.15); }

.hint {
  opacity: 0.65;
  font-size: 12px;
  letter-spacing: 0.5px;
  margin: 2px 0 4px;
}

/* ---------- menu ---------- */

.menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.menu .ascii {
  white-space: pre;
  font-size: 13px;
  line-height: 1.15;
  margin-bottom: 18px;
  text-align: center;
}

.menu .prompt {
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.diffbtn {
  display: block;
  width: 260px;
  text-align: left;
  margin: 4px 0;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid rgba(var(--green-rgb), 0.5);
  color: inherit;
  font: inherit;
  text-shadow: inherit;
  cursor: pointer;
  letter-spacing: 1px;
}

.diffbtn:hover {
  background: rgba(var(--green-rgb), 0.15);
  border-color: var(--green);
}

.diffbtn .tag {
  float: right;
  opacity: 0.7;
  font-size: 12px;
}

/* word-wrap selector: three exclusive options sharing the button row width */
.menu .wraplabel { margin: 16px 0 8px; }

.wraprow {
  display: flex;
  gap: 6px;
  width: 260px;
}

.wrapbtn {
  flex: 1;
  padding: 6px 0;
  background: transparent;
  border: 1px solid rgba(var(--green-rgb), 0.5);
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-shadow: inherit;
  cursor: pointer;
  letter-spacing: 1px;
}

.wrapbtn:hover {
  background: rgba(var(--green-rgb), 0.15);
  border-color: var(--green);
}

.wrapbtn.sel {
  background: var(--green);
  border-color: var(--green);
  color: var(--screen-bg);
  text-shadow: none;
}

.wraphint {
  width: 300px;
  margin-top: 8px;
  opacity: 0.6;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-align: center;
}

/* ---------- boot ---------- */

.boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.boot div { white-space: pre; }

/* ---------- game ---------- */

.attemptsRow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 6px;
  flex-shrink: 0;
}

.attemptsRow .lbl { letter-spacing: 1px; }

.pip {
  width: 12px;
  height: 16px;
  border: 1px solid var(--green);
  display: inline-block;
  margin-right: 3px;
  background: rgba(var(--green-rgb), 0.8);
}

.pip.used {
  background: transparent;
  opacity: 0.35;
}

.body {
  flex: 1;
  display: flex;
  gap: 22px;
  min-height: 0;
  margin-top: 6px;
}

.dump {
  flex: 1 1 55%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--rows), auto);
  gap: 0 18px;
  overflow: hidden;
  align-content: start;
  font-size: 14.5px;
  user-select: none;
}

.dump.immersive { pointer-events: none; }
.dump.immersive .token { cursor: default; }

.line {
  display: flex;
  gap: 8px;
  padding: 1px 4px;
  white-space: pre;
}

.line.row-active { background: rgba(var(--green-rgb), 0.13); }

.addr {
  opacity: 0.65;
  flex-shrink: 0;
}

.token { cursor: pointer; }
.token.char { opacity: 0.85; }

.token-hover {
  background: var(--green);
  color: var(--screen-bg);
  text-shadow: none;
  opacity: 1;
}

.token.used {
  opacity: 0.3;
  text-decoration: line-through;
  cursor: default;
  pointer-events: none;
}

/* ---------- log ---------- */

.log {
  flex: 1 1 45%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid rgba(var(--green-rgb), 0.3);
  padding-left: 18px;
}

.logscroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}

.logscroll::-webkit-scrollbar { width: 6px; }
.logscroll::-webkit-scrollbar-thumb { background: rgba(var(--green-rgb), 0.4); }

.logline {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 2px;
}

.cursorline {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-top: 4px;
}

.preview { color: var(--green); }

.cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--green);
  margin-left: 6px;
  animation: blink 1s steps(1) infinite;
}

/* ---------- result ---------- */

.resultwrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.resultwrap .big {
  font-size: 22px;
  letter-spacing: 2px;
}

.again {
  margin-top: 10px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--green);
  color: inherit;
  font: inherit;
  text-shadow: inherit;
  cursor: pointer;
  letter-spacing: 1px;
}

.again:hover { background: rgba(var(--green-rgb), 0.15); }

/* ---------- narrow screens ---------- */

@media (max-width: 640px) {
  .body { flex-direction: column; }
  .dump { font-size: 12px; }
  .log {
    border-left: none;
    border-top: 1px solid rgba(var(--green-rgb), 0.3);
    padding-left: 0;
    padding-top: 10px;
  }
}
