:root {
  --green: #33ff66;
  --green-dim: #1f9e44;
  --body-text: #e8fff0;
  --amber: #ffb000;
  --amber-dim: #9c6c00;
  --red: #ff4d4d;
  --blue: #6fa8ff;
  --violet: #c49bff;
  --bg: #020603;
  --metal: #1a1812;
  --metal-light: #353025;
  --metal-edge: #5c5136;
  --metal-shadow: #0a0905;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--metal-shadow);
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  /* Without this, body's default stretch caps #device at exactly one viewport tall (html/body are
     height:100%), so once the terminal output grows past that, it spills out past the metal frame
     instead of the frame growing to contain it. flex-start lets #device size to its own content. */
  align-items: flex-start;
  padding: 16px;
  font-family: "Roboto Mono", "SF Mono", "Courier New", monospace;
}

/* The handheld device casing: brushed metal frame around the glass screen */
#device {
  position: relative;
  width: 100%;
  max-width: 880px;
  min-width: 0;
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background:
    /* Fine brushed-metal grain */
    repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 3px),
    linear-gradient(160deg, var(--metal-light), var(--metal) 55%, #100f0a 100%);
  border: 1px solid var(--metal-edge);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 0 0 6px rgba(0, 0, 0, 0.35),
    0 0 0 9px var(--metal-shadow),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

/* Corner bolts, purely decorative -- a handheld device has rivets */
.bolt {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a7f5c, #2a2619 70%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}
.bolt-tl { top: 8px; left: 8px; }
.bolt-tr { top: 8px; right: 8px; }
.bolt-bl { bottom: 8px; left: 8px; }
.bolt-br { bottom: 8px; right: 8px; }

/* A recessed control strip, not a title bar -- no app-window buttons live here */
.nameplate {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.1));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  color: var(--amber-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
}

.nameplate-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* A decorative rotary knob, the kind a real console has instead of window controls */
.dial {
  flex: none;
  margin-left: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--metal-edge), var(--metal) 70%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  position: relative;
}
.dial::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  width: 1px;
  height: 5px;
  background: var(--amber);
  box-shadow: 0 0 3px var(--amber);
  transform: translateX(-50%) rotate(35deg);
  transform-origin: bottom center;
}

#screen {
  flex: 1;
  min-width: 0;
  color: var(--green);
  background:
    repeating-linear-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 1px, rgba(0, 0, 0, 0.25) 2px, rgba(0, 0, 0, 0.25) 3px),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.45) 100%),
    var(--bg);
  padding: 16px 16px 12px;
  border-radius: 10px;
  border: 1px solid #000;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.7);
  font-size: clamp(13px, 2vw, 17px);
  line-height: 1.5;
  letter-spacing: 0.01em;
  text-shadow: 0 0 4px rgba(51, 255, 102, 0.55);
  display: flex;
  flex-direction: column;
}

#output { margin: 0; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }

/* The bottom control strip, below the glass -- where a real device would put a status light and vents */
.panel {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.1));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.status-light {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 5px var(--green);
  animation: pulse 2.4s ease-in-out infinite;
}

.panel-label {
  color: var(--green-dim);
  font-size: 10px;
  letter-spacing: 0.12em;
}

/* Cooling-vent slits, purely decorative, pushed to the right */
.panel-vents {
  flex: none;
  margin-left: auto;
  width: 40px;
  height: 8px;
  background: repeating-linear-gradient(90deg,
    rgba(0, 0, 0, 0.85) 0, rgba(0, 0, 0, 0.85) 2px,
    rgba(255, 255, 255, 0.08) 2px, rgba(255, 255, 255, 0.08) 3px,
    transparent 3px, transparent 6px);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* System chrome: boot messages, prompts, hints -- stays in the green family */
#output .dim { color: var(--green-dim); }
#output .error { color: var(--red); font-weight: 700; }

/* The Asky character's own voice: amber, like switching the Pip-Boy to its warning channel */
#output .asky { color: var(--amber); }

/* The boot logo and fake system readouts */
#output .logo { color: var(--amber); font-weight: 700; text-shadow: 0 0 6px rgba(255, 176, 0, 0.6); }
#output .meter-label { color: var(--green-dim); }
#output .meter-bar { color: var(--amber); }

/* The answer text, and reference titles/links below it */
#output .amber { color: var(--amber); font-weight: 700; }
#output .body { color: var(--body-text); }
#output .link { color: var(--blue); }

/* A Wikipedia reference, kept in a visually distinct violet -- a reminder it's not the reviewed library */
#output .wiki-title { color: var(--violet); font-weight: 700; }
#output .wiki-image {
  display: block;
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
  margin: 4px 0 12px;
  border: 1px solid var(--violet);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(196, 155, 255, 0.25);
}

#line {
  display: flex;
  align-items: center;
  gap: 8px;
}

#prompt {
  flex: none;
  color: var(--green);
}

#cmd {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--green);
  caret-color: var(--green);
  font: inherit;
  text-shadow: inherit;
}

#cmd:disabled { opacity: 0.4; }

@media (prefers-reduced-motion: no-preference) {
  #screen { animation: flicker 7s infinite; }
}

@keyframes flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.94; }
  98% { opacity: 1; }
  99% { opacity: 0.97; }
}
