:root {
  --bg: #000;
  --fg: #b7bbb7;
  --bright: #e0e7e1;
  --dim: #555a56;
  --accent: #a7d8af;
  --accent-low: rgba(116, 190, 129, .11);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; background: #000; }
body {
  overflow: hidden;
  color: var(--fg);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  touch-action: none;
}
button, input { font: inherit; }
button { color: inherit; }

#experience {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

#field { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

.terminal {
  position: absolute;
  z-index: 5;
  left: clamp(22px, 6vw, 84px);
  top: clamp(28px, 7.5vh, 82px);
  width: min(88vw, 920px);
  height: min(74vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: none;
  user-select: none;
  font-size: clamp(15px, 1.42vw, 21px);
  line-height: 1.68;
  letter-spacing: .045em;
  text-shadow: 0 0 12px rgba(180,255,194,.025);
  mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 92%, transparent 100%);
}

.terminal::-webkit-scrollbar { display: none; }

.terminal__output {
  position: relative;
  min-height: 100%;
  padding: 18px 0 52px;
  transition: transform .38s cubic-bezier(.2,.7,.2,1), opacity 1.8s ease, filter 1.8s ease;
  will-change: transform, opacity;
}

.terminal__line {
  min-height: 1.55em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: opacity 1.3s ease, filter 1.3s ease;
}
.terminal__line.dim { color: var(--dim); }
.terminal__line.accent { color: #c8dbc9; text-shadow: 0 0 16px rgba(114,190,130,.07); }
.terminal__line.alert { color: var(--bright); }
.terminal__line.user { color: #d5ddd6; }
.terminal__line.spacer { height: .86em; }
.terminal__line.stale { opacity: .23; filter: blur(.15px); }

.caret {
  position: absolute;
  left: 0;
  bottom: 18px;
  display: inline-block;
  width: .66em;
  height: 1.05em;
  background: #9ea29f;
  opacity: .78;
  animation: caretBlink 1.08s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: .08; } }

.choice-panel {
  position: absolute;
  z-index: 8;
  left: clamp(22px, 6vw, 84px);
  bottom: clamp(34px, 8vh, 88px);
  width: min(88vw, 760px);
  padding-top: 12px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,.86) 26%);
}
.choice-panel__question {
  margin: 0 0 16px;
  color: #8a8e8b;
  font-size: clamp(14px, 1.25vw, 18px);
  line-height: 1.55;
  letter-spacing: .045em;
}
.choice-panel__options { display: grid; gap: 4px; width: fit-content; max-width: 100%; }
.choice {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 5px 0;
  color: #8b908c;
  text-align: left;
  cursor: pointer;
  letter-spacing: .09em;
  transition: color .12s ease, transform .12s ease, text-shadow .12s ease;
}
.choice::before { content: '> '; color: #3a3e3b; }
.choice:hover, .choice:focus-visible {
  outline: none;
  color: #e3e8e4;
  transform: translateX(3px);
  text-shadow: 0 0 13px rgba(138,205,150,.12);
}
.choice:hover::before, .choice:focus-visible::before { color: #7e9c84; }

.free-answer {
  width: min(100%, 660px);
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  column-gap: 9px;
  border-bottom: 1px solid #2a2d2b;
  padding: 3px 0;
}
.free-answer__prompt { color: #616662; }
.free-answer input {
  min-width: 0;
  width: 100%;
  color: #e1e7e2;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 10px 0;
  caret-color: #d5dbd6;
  letter-spacing: .045em;
  text-shadow: 0 0 12px rgba(180,255,194,.05);
}
.free-answer button {
  border: 0;
  background: transparent;
  color: #494e4a;
  cursor: pointer;
  padding: 10px 0 10px 18px;
  letter-spacing: .1em;
}
.free-answer button:hover, .free-answer button:focus-visible { color: #949b95; outline: none; }

.sound-gate {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 128px;
  padding: 14px 20px;
  color: #9fa39f;
  border: 1px solid #292c29;
  background: #000;
  cursor: pointer;
  letter-spacing: .24em;
  transition: color .25s ease, border-color .25s ease, opacity .4s ease;
}
.sound-gate:hover, .sound-gate:focus-visible { outline: none; color: #d0d4d1; border-color: #565a57; }

.hint {
  position: absolute;
  z-index: 4;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  color: #232624;
  font-size: 10px;
  letter-spacing: .18em;
  opacity: 0;
  transition: opacity 1.1s ease;
  pointer-events: none;
  white-space: nowrap;
}
.hint.visible { opacity: 1; }

.flash {
  position: absolute; inset: 0; z-index: 30;
  background: #d8eadb;
  opacity: 0; pointer-events: none;
  mix-blend-mode: screen;
}
.flash.fire { animation: flash .16s linear; }
@keyframes flash { 0%{opacity:0} 15%{opacity:.028} 32%{opacity:0} 64%{opacity:.014} 100%{opacity:0} }

.presence {
  position: absolute; inset: -10%; z-index: 2; pointer-events: none;
  opacity: .35;
  background:
    radial-gradient(circle at 50% 48%, rgba(70,100,76,.022), transparent 30%),
    radial-gradient(circle at 18% 70%, rgba(52,83,59,.016), transparent 27%),
    radial-gradient(circle at 78% 24%, rgba(68,89,72,.012), transparent 25%);
  animation: breathe 9s ease-in-out infinite alternate;
}
@keyframes breathe {
  from { transform: scale(1); opacity: .20; }
  to { transform: scale(1.025); opacity: .42; }
}

.vignette {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 29%, rgba(0,0,0,.23) 61%, rgba(0,0,0,.88) 100%),
    repeating-linear-gradient(to bottom, rgba(255,255,255,.008) 0, rgba(255,255,255,.008) 1px, transparent 1px, transparent 5px);
  opacity: .84;
}

body.knock-shake #experience { animation: knockShake .26s cubic-bezier(.2,.7,.2,1); }
@keyframes knockShake {
  0%,100% { transform: translate(0,0); }
  18% { transform: translate(-1.7px,.4px); }
  38% { transform: translate(1.2px,-.3px); }
  58% { transform: translate(-.8px,.2px); }
}

body.blackout .terminal,
body.blackout .choice-panel { opacity: .015; transition: opacity 1.1s ease; }
body.blackout .presence { opacity: 0; transition: opacity 1.1s ease; }

@media (max-width: 700px) {
  .terminal { top: 6.5vh; left: 20px; width: calc(100vw - 40px); height: 67vh; font-size: 15px; line-height: 1.58; }
  .choice-panel { left: 20px; bottom: 38px; width: calc(100vw - 40px); }
  .choice-panel__options { width: 100%; }
  .choice { padding: 7px 0; }
  .free-answer { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .caret { animation-duration: 1.6s; }
  .presence { animation: none; }
}
