/* OPERATION KRAKEN — CRT terminal style */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #4af626;
  --green-dim: #2a9d1a;
  --bg: #050805;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: "Courier New", ui-monospace, Menlo, monospace;
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden; /* the screen area scrolls, not the page */
}

/* CRT scanlines + vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%),
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 4px);
  z-index: 50;
}

/* ---------- top HUD bar ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: #071007;
  border-bottom: 1px solid #1d4d12;
  font-size: 13px;
  z-index: 10;
  text-shadow: 0 0 6px rgba(74,246,38,.6);
}
#hud-title { color: var(--green-dim); letter-spacing: 1px; }
.hud-right { display: flex; gap: 14px; align-items: center; }
#hud button {
  background: #0a1f0a;
  color: var(--green);
  border: 1px solid #2a9d1a;
  font: inherit;
  font-size: 12px;
  padding: 2px 10px;
  cursor: pointer;
}
#hud button:hover { background: #123a12; }

/* ---------- main split: terminal + side panel ---------- */
#main {
  position: fixed;
  inset: 34px 0 0 0;
  display: flex;
  min-height: 0;
}

#terminal {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* the scrollable area — scrolling happens HERE, input row stays visible */
#screen {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 6px;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 6px rgba(74,246,38,.45);
  scrollbar-color: #1d4d12 #050805;
}

.line { min-height: 1.45em; }
.line.error  { color: #ff6b6b; text-shadow: 0 0 6px rgba(255,107,107,.5); }
.line.ok     { color: #b6ff9e; font-weight: bold; }
.line.hint   { color: #ffe066; text-shadow: 0 0 6px rgba(255,224,102,.5); }
.line.story  { color: #7dffb0; }
.line.chapter{ color: #6ee7ff; font-weight: bold; text-shadow: 0 0 8px rgba(110,231,255,.6); }
.line.dim    { color: #3f9e46; }
.line.man    { color: #d8ffd0; }
.line.match  { color: #ffd866; }
.line.boot   { color: #8fffb8; }
.line.input  { color: #eaffea; font-weight: bold; }
.line.dir    { color: #6aa9ff; }
.line.file   { color: var(--green); }
.line.hidden { color: #3f7f5f; }
.line.cmd    { color: #a5ff8f; }
.user  { color: #50fa7b; font-weight: bold; }
.path  { color: #8be9fd; }
.dim   { color: #3f9e46; }

/* input row pinned to the bottom of the terminal area */
#input-row {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  white-space: pre-wrap; /* keep typed spaces visible so the cursor moves on space */
  padding: 4px 16px 12px;
  border-top: 1px solid #0d2b0d;
  background: #050805;
  text-shadow: 0 0 6px rgba(74,246,38,.45);
}
#cursor {
  display: inline-block;
  background: var(--green);
  color: var(--green);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

#keyinput {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 10px;
  height: 10px;
  opacity: 0;
}

/* ---------- side panel (score / mission / hint / log) ---------- */
#panel {
  width: 300px;
  flex: none;
  border-left: 1px solid #1d4d12;
  background: #071007;
  overflow-y: auto;
  padding: 12px;
  font-size: 13px;
  scrollbar-color: #1d4d12 #071007;
}
.pblock { margin-bottom: 18px; }
.plabel {
  color: #6ee7ff;
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 12px;
  border-bottom: 1px solid #1d4d12;
  padding-bottom: 3px;
  margin-bottom: 6px;
}
.pscore { font-size: 30px; font-weight: bold; color: #ffe066; text-shadow: 0 0 8px rgba(255,224,102,.5); }
.small { font-size: 11px; }
.pbar {
  height: 8px;
  border: 1px solid #1d4d12;
  margin-top: 6px;
  background: #050805;
}
#panel-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2a9d1a, #4af626);
  transition: width .3s;
}
.ptitle { color: #b6ff9e; font-weight: bold; margin-bottom: 6px; }
#panel-objectives { list-style: none; }
#panel-objectives li { padding: 2px 0; color: #7dffb0; }
#panel-objectives li.done { color: #3f9e46; text-decoration: line-through; }
.hintbox {
  color: #ffe066;
  background: #171303;
  border: 1px solid #4d4312;
  padding: 8px;
  min-height: 40px;
  white-space: pre-wrap;
}
#panel-log .logitem {
  color: #b6ff9e;
  border-left: 2px solid #2a9d1a;
  padding: 2px 0 2px 8px;
  margin-bottom: 4px;
  font-size: 12px;
  word-break: break-word;
}

@media (max-width: 900px) {
  #panel { display: none; }
}

/* ---------- nano overlay ---------- */
#nano {
  position: fixed; inset: 0;
  background: rgba(0, 20, 0, .82);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
}
#nano.hidden, #end.hidden { display: none; }
#nano-box {
  width: min(760px, 92vw);
  height: min(520px, 84vh);
  display: flex; flex-direction: column;
  background: #04140a;
  border: 1px solid #2a9d1a;
  box-shadow: 0 0 40px rgba(74,246,38,.25);
}
#nano-head {
  padding: 6px 12px;
  background: #e8e8e8;
  color: #111;
  font-weight: bold;
  font-size: 13px;
}
#nano-text {
  flex: 1;
  background: #04140a;
  color: var(--green);
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  font: inherit;
  text-shadow: 0 0 6px rgba(74,246,38,.45);
}
#nano-foot {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 12px;
  background: #e8e8e8;
  color: #111;
  font-size: 13px;
}
#nano-foot .dim { color: #555; margin-left: auto; }
#nano-foot button {
  font: inherit;
  padding: 4px 14px;
  cursor: pointer;
  border: 1px solid #888;
  background: #fff;
}
#nano-foot button:hover { background: #d8ffd0; }

/* ---------- end screen ---------- */
#end {
  position: fixed; inset: 0;
  background: rgba(0, 12, 0, .9);
  display: flex; align-items: center; justify-content: center;
  z-index: 45;
}
#end-box {
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: #04140a;
  border: 1px solid #2a9d1a;
  box-shadow: 0 0 40px rgba(74,246,38,.25);
  padding: 24px 28px;
  text-align: center;
}
#end-box h1 { color: #6ee7ff; letter-spacing: 2px; margin-bottom: 10px; }
.end-big { font-size: 18px; margin-bottom: 12px; }
#end-score { color: #ffe066; font-weight: bold; }
#end-rank { color: #b6ff9e; font-weight: bold; font-size: 18px; }
#end-detail { text-align: left; margin: 14px 0; font-size: 13px; }
.erow { display: flex; gap: 10px; padding: 1px 0; }
.erow span:first-child { color: #ffe066; min-width: 44px; text-align: right; }
#end-again, #end-box button {
  font: inherit;
  font-size: 16px;
  padding: 8px 22px;
  margin-top: 8px;
  background: #0a1f0a;
  color: var(--green);
  border: 1px solid #2a9d1a;
  cursor: pointer;
}
#end-again:hover { background: #123a12; }
