/* ============ THE OREGON TRAIL — CRT PHOSPHOR TERMINAL ============ */

:root {
  --phos-bright: #d2ffdd;
  --phos: #4dff7c;
  --phos-mid: #2bcf5c;
  --phos-dim: #1d7a3c;
  --phos-faint: #0c3a1d;
  --tube: #03130a;
  --tube-deep: #010a05;
  --glow: 0 0 6px rgba(77, 255, 124, 0.55), 0 0 22px rgba(77, 255, 124, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(ellipse 120% 90% at 50% -10%, #1d2024 0%, #0c0d10 45%, #050507 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2vh 2vw;
  font-family: "VT323", "Courier New", monospace;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------- MONITOR SHELL ---------------- */

.monitor {
  width: min(97vw, 1060px);
  background: linear-gradient(175deg, #43454c 0%, #2c2d33 18%, #202126 60%, #17181c 100%);
  border-radius: 30px;
  padding: clamp(16px, 2.6vw, 30px) clamp(16px, 2.6vw, 30px) 12px;
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.12),
    inset 0 -4px 10px rgba(0, 0, 0, 0.6),
    0 30px 70px rgba(0, 0, 0, 0.75),
    0 6px 18px rgba(0, 0, 0, 0.5);
  position: relative;
}

.screen-wrap {
  position: relative;
  height: min(76vh, 690px);
  background: var(--tube);
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px #000,
    inset 0 0 90px 26px rgba(0, 0, 0, 0.85);
  animation: powerOn 1.1s ease-out 1, tubeFlicker 4.3s infinite;
}

@keyframes powerOn {
  0%   { filter: brightness(3) saturate(0); transform: scaleY(0.005); }
  35%  { filter: brightness(2.4); transform: scaleY(0.012); }
  60%  { filter: brightness(1.6); transform: scaleY(1.04); }
  100% { filter: brightness(1); transform: scaleY(1); }
}

@keyframes tubeFlicker {
  0%, 100% { opacity: 1; }
  3%  { opacity: 0.985; }
  7%  { opacity: 1; }
  31% { opacity: 0.99; }
  32% { opacity: 1; }
  64% { opacity: 0.992; }
  65% { opacity: 1; }
  92% { opacity: 0.987; }
}

/* ---------------- CONTENT AREA ---------------- */

#content {
  position: absolute;
  inset: 0;
  padding: clamp(16px, 3.2vh, 30px) clamp(20px, 3.4vw, 44px);
  overflow-y: auto;
  overflow-x: hidden;
  color: var(--phos);
  font-size: clamp(17px, 2.45vh, 23px);
  line-height: 1.32;
  text-shadow: var(--glow);
  letter-spacing: 0.4px;
  scrollbar-width: thin;
  scrollbar-color: var(--phos-dim) transparent;
  z-index: 1;
}

#content::-webkit-scrollbar { width: 8px; }
#content::-webkit-scrollbar-thumb { background: var(--phos-faint); }

/* ---------------- CRT OVERLAYS ---------------- */

.overlay { position: absolute; inset: 0; pointer-events: none; }

.scanlines {
  z-index: 5;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 2px,
    rgba(0, 0, 0, 0.22) 2px, rgba(0, 0, 0, 0.22) 4px
  );
  mix-blend-mode: multiply;
}

.scanband {
  z-index: 6;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(110, 255, 160, 0.035) 48%,
    rgba(110, 255, 160, 0.06) 50%,
    rgba(110, 255, 160, 0.035) 52%,
    transparent 100%
  );
  height: 24%;
  animation: bandRoll 7s linear infinite;
}

@keyframes bandRoll {
  0%   { transform: translateY(-30vh); }
  100% { transform: translateY(110vh); }
}

.vignette {
  z-index: 7;
  background: radial-gradient(
    ellipse 110% 105% at 50% 50%,
    transparent 55%,
    rgba(0, 0, 0, 0.38) 88%,
    rgba(0, 0, 0, 0.78) 100%
  );
}

.glare {
  z-index: 8;
  background: linear-gradient(
    118deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.015) 22%,
    transparent 40%
  );
  border-radius: 22px;
}

/* ---------------- BEZEL BOTTOM ---------------- */

.bezel-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 6px;
}

.brand {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: #888c94;
  letter-spacing: 2px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.8);
}

.brand-dim { color: #4b4e55; font-size: 8px; letter-spacing: 1px; }

/* empowered.guru credit silkscreened on the bezel, next to TRAILTRON */
.brand-sep { color: #4b4e55; font-size: 8px; }
.brand-link {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  letter-spacing: 1px;
  color: #6f7480;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(0,0,0,0.8);
  transition: color 0.15s, text-shadow 0.15s;
}
.brand-link:hover, .brand-link:active {
  color: var(--phos-mid);
  text-shadow: 0 0 6px rgba(77,255,124,0.6);
}

.bezel-controls { display: flex; align-items: center; gap: 14px; }

.knob {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #55585f, #1c1d21 70%);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.2), 0 2px 3px rgba(0,0,0,0.6);
}

.led-wrap { display: flex; align-items: center; gap: 6px; }

.led {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #51ff7e;
  box-shadow: 0 0 8px #51ff7e, 0 0 16px rgba(81,255,126,0.5);
  animation: ledPulse 3s infinite;
}

@keyframes ledPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.led-label {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: #5a5e66;
  letter-spacing: 1px;
}

/* ---------------- TYPOGRAPHY & ELEMENTS ---------------- */

.px {
  font-family: "Press Start 2P", monospace;
  line-height: 1.6;
}

.title-the {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(10px, 1.6vh, 15px);
  color: var(--phos-mid);
  letter-spacing: 10px;
  margin-bottom: 8px;
}

.title-big {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(20px, 4.4vh, 40px);
  color: var(--phos-bright);
  text-shadow:
    0 0 10px rgba(120, 255, 160, 0.8),
    0 0 36px rgba(77, 255, 124, 0.45),
    3px 3px 0 var(--phos-faint);
  letter-spacing: 3px;
  line-height: 1.25;
}

.subtitle {
  color: var(--phos-dim);
  font-size: clamp(15px, 2vh, 19px);
  letter-spacing: 3px;
  margin-top: 6px;
}

.bright { color: var(--phos-bright); }
.dim    { color: var(--phos-dim); text-shadow: 0 0 4px rgba(77,255,124,0.25); }
.mid    { color: var(--phos-mid); }

/* phosphor links (e.g. the empowered.guru credit) */
#content a {
  color: var(--phos-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-shadow: var(--glow);
  cursor: pointer;
}
#content a:hover, #content a:active {
  background: var(--phos);
  color: var(--tube-deep);
  text-shadow: none;
}

.invert {
  background: var(--phos);
  color: var(--tube-deep);
  text-shadow: none;
  padding: 1px 8px;
  /* keep hugging its text (a location pill) when #content is a flex column on
     mobile, instead of stretching to full width */
  align-self: flex-start;
}

.center { text-align: center; }

.rule {
  border: none;
  border-top: 2px dashed var(--phos-faint);
  margin: 10px 0;
}

.frame {
  border: 2px solid var(--phos-dim);
  outline: 1px solid var(--phos-faint);
  outline-offset: 3px;
  padding: 10px 16px;
  margin: 8px 0;
}

pre.art {
  font-family: "VT323", monospace;
  line-height: 1.02;
  font-size: clamp(13px, 1.9vh, 18px);
  /* pre-wrap keeps the intentional newlines and ASCII-art spacing, but lets
     long prose lines (written ~52 chars wide for desktop) wrap instead of
     running off the right edge on narrow/mobile screens. */
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--phos);
}

/* ---------------- MENUS ---------------- */

.menu { margin-top: 10px; }

.menu-item {
  padding: 3px 10px 3px 34px;
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: none;
}

.menu-item::before {
  content: "";
  position: absolute;
  left: 10px;
}

.menu-item.sel {
  background: var(--phos);
  color: var(--tube-deep);
  text-shadow: none;
  box-shadow: 0 0 14px rgba(77, 255, 124, 0.35);
}

.menu-item.sel::before { content: "►"; }

.menu-item.danger.sel { background: var(--phos-bright); }

/* store rows: item name on the left, price + owned count aligned right.
   Stays one tidy line on mobile (VT323 is condensed); wraps the meta below
   only in extreme cases instead of breaking mid-phrase like inline text. */
.menu-item.store-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; column-gap: 8px; row-gap: 2px; }
.menu-item.store-row .si-name { flex: 1 1 auto; }
.menu-item.store-row .si-meta { margin-left: auto; white-space: nowrap; color: var(--phos-mid); }
.menu-item.store-row .si-cost { color: var(--phos-bright); }
.menu-item.store-row.sel .si-name,
.menu-item.store-row.sel .si-meta,
.menu-item.store-row.sel .si-cost { color: var(--tube-deep); }

/* +N buy button: one tap buys a step. Dedicated tap target so scrolling the
   list never triggers a purchase. Dims when the next step is unaffordable. */
.menu-item.store-row .si-buy {
  flex: 0 0 auto;
  align-self: center;
  border: 2px solid var(--phos-dim);
  background: transparent;
  color: var(--phos-bright);
  font-family: inherit;
  font-size: inherit;
  line-height: 1;
  letter-spacing: inherit;
  padding: 3px 14px;
  min-width: 54px;
  text-align: center;
  cursor: pointer;
  text-shadow: var(--glow);
}
.menu-item.store-row .si-buy:hover,
.menu-item.store-row .si-buy:active {
  background: var(--phos);
  color: var(--tube-deep);
  text-shadow: none;
}
.menu-item.store-row .si-buy.cant {
  opacity: 0.32;
  cursor: not-allowed;
  text-shadow: none;
}
/* Keep the button readable when its row is highlighted (row goes phosphor). */
.menu-item.store-row.sel .si-buy { border-color: var(--tube-deep); color: var(--tube-deep); text-shadow: none; }
.menu-item.store-row.sel .si-buy:hover,
.menu-item.store-row.sel .si-buy:active { background: var(--tube-deep); color: var(--phos); }

/* ---------------- STATUS / TABLES ---------------- */

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 30px;
  margin: 8px 0;
}

table.tbl {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
}

table.tbl td, table.tbl th {
  padding: 1px 10px;
  text-align: left;
  font-weight: normal;
}

table.tbl td.num, table.tbl th.num { text-align: right; }

.hl-row {
  background: var(--phos);
  color: var(--tube-deep);
  text-shadow: none;
}

/* ---------------- PROMPTS / EFFECTS ---------------- */

.blink { animation: blinkAnim 0.9s steps(1) infinite; }

@keyframes blinkAnim {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

.cursor::after {
  content: "█";
  animation: blinkAnim 0.8s steps(1) infinite;
  color: var(--phos-bright);
}

.prompt-bar {
  margin-top: 14px;
  color: var(--phos-mid);
}

.alert-flash { animation: alertFlash 0.5s steps(1) 4; }

@keyframes alertFlash {
  0%, 49% { filter: invert(0); }
  50%, 100% { filter: invert(0.9) hue-rotate(180deg); }
}

.shake { animation: shakeAnim 0.4s linear 1; }

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* ---------------- CANVASES ---------------- */

canvas.scene {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  border: 2px solid var(--phos-faint);
  background: var(--tube-deep);
  margin: 6px 0;
}

canvas.hunt { cursor: none; touch-action: none; }

/* ---------------- INPUTS & TAP BUTTONS ---------------- */

.term-input {
  font-family: "VT323", "Courier New", monospace;
  font-size: inherit;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--phos-dim);
  border-radius: 0;
  color: var(--phos-bright);
  text-shadow: var(--glow);
  letter-spacing: 1px;
  width: 240px;
  max-width: 70vw;
  padding: 0 4px;
  outline: none;
  text-transform: uppercase;
  caret-color: var(--phos-bright);
}

.term-input::placeholder { color: var(--phos-faint); }
.term-input:focus { border-bottom-color: var(--phos); }

.btn-row { display: flex; gap: 14px; margin: 12px 0; flex-wrap: wrap; }

.btn {
  display: inline-block;
  border: 2px solid var(--phos-dim);
  padding: 4px 18px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--phos);
}

.btn:hover, .btn:active {
  background: var(--phos);
  color: var(--tube-deep);
  text-shadow: none;
  box-shadow: 0 0 14px rgba(77, 255, 124, 0.35);
}

.hud-strip {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 22px;
  color: var(--phos-mid);
}

.input-line {
  display: inline-block;
  min-width: 220px;
  border-bottom: 2px solid var(--phos-dim);
  color: var(--phos-bright);
  padding: 0 4px;
}

/* small screens / touch */
@media (max-width: 640px) {
  body { padding: 0; overflow: auto; }
  .monitor { border-radius: 0; width: 100vw; padding: 10px 8px 6px; }
  .screen-wrap { height: 86vh; border-radius: 10px; }
  /* Center each screen vertically so short screens use the whole tube instead
     of clustering at the top. `safe center` keeps tall/scrolling screens
     (store, supplies) anchored to the top so their content stays reachable. */
  #content {
    font-size: 17px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    justify-content: safe center;
  }
  .menu-item { padding: 8px 10px 8px 34px; }
  .menu-item.store-row .si-buy { padding: 8px 16px; min-width: 60px; }
  .btn { padding: 9px 22px; }
  .status-grid { grid-template-columns: 1fr; }
  .brand-dim { display: none; }
}

/* phones: item names are too long to share a line with the buy button, so stack
   each store row as a card — name + button on top, price/owned on the line below. */
@media (max-width: 480px) {
  .menu-item.store-row .si-meta { order: 1; flex-basis: 100%; margin-left: 0; }
}
