/* The Silicon Trail — CRT monitor chrome + Apple II-flavored text UI */

:root {
  --green:  #14f53c;
  --white:  #ffffff;
  --purple: #ff44fd;
  --orange: #ff6a3c;
  --blue:   #14cffd;
  --bg:     #0a0a0a;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: "Courier New", Courier, monospace;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#monitor {
  width: min(96vw, 720px);
}

#bezel {
  position: relative;
  background: #000;
  border: 4px solid #2a2a22;
  border-radius: 14px;
  box-shadow:
    0 0 0 6px #14140f,
    0 0 40px rgba(20, 245, 60, 0.10),
    inset 0 0 60px rgba(0, 0, 0, 0.9);
  padding: 14px 14px 10px;
}

#screen {
  display: block;
  width: 100%;
  aspect-ratio: 280 / 192;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

/* scanlines + faint phosphor vignette over graphics AND text */
#scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0)   0px,
      rgba(0, 0, 0, 0)   2px,
      rgba(0, 0, 0, 0.22) 3px
    );
  mix-blend-mode: multiply;
}

#textui {
  margin-top: 8px;
  border-top: 2px solid #123a18;
  padding-top: 8px;
  min-height: 270px;
  display: flex;
  flex-direction: column;
}

#out {
  white-space: pre-wrap;
  font-size: clamp(11px, 2.1vw, 15px);
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(20, 245, 60, 0.45);
}

#out .w { color: var(--white); text-shadow: 0 0 6px rgba(255,255,255,.4); }
#out .o { color: var(--orange); text-shadow: 0 0 6px rgba(255,106,60,.4); }
#out .b { color: var(--blue); text-shadow: 0 0 6px rgba(20,207,253,.4); }
#out .p { color: var(--purple); text-shadow: 0 0 6px rgba(255,68,253,.4); }
#out .dim { opacity: 0.65; }
#out .big { font-size: 1.3em; font-weight: bold; }
#out .hd { font-size: 1.15em; font-weight: bold; }
#out .hr { color: #0d7a22; }

#menu {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#menu button {
  appearance: none;
  background: rgba(20, 245, 60, 0.06);
  border: 1px solid rgba(20, 245, 60, 0.55);
  border-radius: 3px;
  box-shadow: inset 0 0 14px rgba(20, 245, 60, 0.06);
  color: var(--green);
  font: inherit;
  font-size: clamp(12px, 2.1vw, 15px);
  letter-spacing: 0.04em;
  text-align: left;
  padding: 9px 12px;
  min-height: 42px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(20, 245, 60, 0.45);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* hover only on devices with a real pointer — on touch screens the
   browser leaves a phantom :hover on whatever ends up under the last
   tap after the menu re-renders */
@media (hover: hover) and (pointer: fine) {
  #menu button:hover {
    background: rgba(20, 245, 60, 0.14);
    color: var(--white);
  }
}

#menu button:focus-visible {
  background: rgba(20, 245, 60, 0.14);
  outline: none;
  color: var(--white);
}

/* inverse video on press, like a real terminal */
#menu button:active {
  background: var(--green);
  color: #000;
  text-shadow: none;
}

#menu button.primary {
  border-color: var(--green);
  background: rgba(20, 245, 60, 0.12);
  color: var(--white);
}

/* the non-interactive prompt line above text inputs */
#menu button:disabled {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  min-height: 0;
  padding: 3px 2px;
  cursor: default;
}

#menu input {
  background: #000;
  border: 1px solid var(--green);
  border-radius: 3px;
  color: var(--white);
  font: inherit;
  font-size: 16px; /* 16px+ keeps iOS from auto-zooming the page */
  padding: 9px 12px;
  width: 100%;
  max-width: 18em;
  text-transform: uppercase;
}
#menu input:focus { outline: 1px solid var(--white); }

#hintrow {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#hint {
  flex: 1;
  font-size: clamp(9px, 1.7vw, 12px);
  color: #0d9a2a;
  opacity: 0.8;
  animation: blink 1.6s step-end infinite;
}

#mute {
  appearance: none;
  background: transparent;
  border: 1px solid #0d7a22;
  border-radius: 3px;
  color: #0d9a2a;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 6px 9px;
  min-height: 32px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#mute:active { background: var(--green); color: #000; }

@keyframes blink { 50% { opacity: 0.25; } }

/* ---- DOT: tutorial + tip overlay ---- */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
}
#overlay.dim { background: rgba(0, 0, 0, 0.82); }

#spot {
  position: absolute;
  display: none;
  border: 2px dashed var(--orange);
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.82);
  animation: spotpulse 1.2s step-end infinite;
  pointer-events: none;
}
@keyframes spotpulse { 50% { border-color: var(--white); } }

#guidebox {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(92vw, 460px);
  background: #000;
  border: 2px solid var(--green);
  border-radius: 4px;
  box-shadow: 0 0 0 4px #000, 0 0 24px rgba(20, 245, 60, 0.25);
  padding: 10px;
}
#guidebox.top {
  bottom: auto;
  top: calc(16px + env(safe-area-inset-top));
}

#guidehead {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

#face {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border: 1px solid #123a18;
}

#guidename {
  color: var(--blue);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-shadow: 0 0 6px rgba(20, 207, 253, 0.4);
}

#bubble {
  min-height: 4.2em;
  color: var(--green);
  font-size: clamp(13px, 3.4vw, 15px);
  line-height: 1.45;
  letter-spacing: 0.04em;
  white-space: pre-wrap;
  text-shadow: 0 0 6px rgba(20, 245, 60, 0.45);
  cursor: pointer;
}
#bubble .hi { color: var(--white); font-weight: bold; }
#bubble.typing::after {
  content: '\258C';
  color: var(--white);
  animation: blink 0.9s step-end infinite;
}

#guidebtns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#guidebtns button {
  appearance: none;
  flex: 1;
  background: rgba(20, 245, 60, 0.06);
  border: 1px solid rgba(20, 245, 60, 0.55);
  border-radius: 3px;
  color: var(--green);
  font: inherit;
  font-size: clamp(12px, 3vw, 14px);
  letter-spacing: 0.04em;
  padding: 9px 10px;
  min-height: 44px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(20, 245, 60, 0.45);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#guidebtns button:active { background: var(--green); color: #000; text-shadow: none; }
#guidebtns button.primary {
  border-color: var(--green);
  background: rgba(20, 245, 60, 0.12);
  color: var(--white);
}
#guidebtns button.ghost {
  flex: 0 1 auto;
  border-color: #0d7a22;
  color: #0d9a2a;
  background: transparent;
}

#badge {
  text-align: center;
  color: #5a5a48;
  font-size: 10px;
  letter-spacing: 0.3em;
  margin-top: 8px;
}

@media (max-height: 740px) {
  #textui { min-height: 220px; }
}

/* phones: the monitor becomes the whole device */
@media (max-width: 520px) {
  body { padding: 0; align-items: stretch; }

  #monitor {
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }

  #bezel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-width: 0;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9);
    padding: calc(8px + env(safe-area-inset-top)) 10px
             calc(10px + env(safe-area-inset-bottom));
  }

  #scanlines { border-radius: 0; }
  #textui { flex: 1; min-height: 0; }
  #out { font-size: clamp(13px, 3.6vw, 16px); }
  #menu button { font-size: 16px; min-height: 48px; }
  #hint { font-size: 11px; }
  #badge { margin: 6px 0; }
}
