/* ============================================================================
   ACCEPT ALL — dark in-game-settings UI.
   Stages via body[data-stage="0..3"]: cyan → amber → crimson → gold.
   body.prompt-open enables the scanline/glitch "AI scan" overlays.
   ========================================================================== */

:root {
  --accent: #4adfd2;
  --accent-dim: rgba(74, 223, 210, 0.35);
  --panel-bg: rgba(7, 10, 13, 0.92);
  --panel-border: rgba(74, 223, 210, 0.4);
  --text: #e6ecec;
  --text-soft: #8fa0a0;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Courier New", monospace;
}

body[data-stage="1"] {
  --accent: #d8b34a;
  --accent-dim: rgba(216, 179, 74, 0.35);
  --panel-border: rgba(216, 179, 74, 0.4);
}

body[data-stage="2"] {
  --accent: #d05a6e;
  --accent-dim: rgba(208, 90, 110, 0.35);
  --panel-border: rgba(208, 90, 110, 0.45);
}

body[data-stage="3"] {
  --accent: #e2b85e;
  --accent-dim: rgba(226, 184, 94, 0.4);
  --panel-border: rgba(226, 184, 94, 0.55);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  /* Stop the browser from scrolling/zooming on touch — the game owns gestures. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#scene-container, #scene-container canvas { touch-action: none; }

/* Show/hide by input type. body.touch is set by src/touch.js on touch devices. */
body.touch .desktop-only { display: none !important; }
body:not(.touch) .touch-only { display: none !important; }

body {
  font-family: var(--mono);
  color: var(--text);
  background: #04050a;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

#scene-container { position: fixed; inset: 0; }
#scene-container canvas { display: block; }

/* ---- Fullscreen FX overlays --------------------------------------------- */
#fx-vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(ellipse at center,
    transparent 52%, rgba(0, 0, 0, 0.55) 100%);
  transition: opacity 0.6s;
}

#fx-scanlines {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(120, 255, 240, 0.05) 0px,
    rgba(120, 255, 240, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
  transition: opacity 0.4s;
}

body.prompt-open #fx-scanlines { opacity: 1; }
body.prompt-open #fx-vignette {
  background: radial-gradient(ellipse at center,
    transparent 36%, rgba(0, 4, 6, 0.78) 100%);
}

/* ---- Jump-scare flash + screen shake ------------------------------------ */
.fx-flash {
  position: fixed;
  inset: 0;
  z-index: 50;                 /* above everything, briefly */
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0;
}
.fx-flash.fx-flash-on { animation: fxFlash 0.5s steps(60) forwards; }

@keyframes fxFlash {
  0%   { opacity: 0; }
  6%   { opacity: 1; }
  16%  { opacity: 0.12; }
  24%  { opacity: 1; }
  40%  { opacity: 0.08; }
  58%  { opacity: 0.65; }
  100% { opacity: 0; }
}

/* Cinematic demo jump-cut flash. */
.fx-cut {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: #000;
  pointer-events: none;
  opacity: 0;
}
.fx-cut.cut-on { animation: cutFlash 0.16s ease-out; }
@keyframes cutFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

body.shake #scene-container { animation: shake 0.5s ease-in-out; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-7px, 5px); }
  20% { transform: translate(8px, -6px); }
  30% { transform: translate(-9px, -4px); }
  40% { transform: translate(7px, 7px); }
  50% { transform: translate(-6px, 3px); }
  60% { transform: translate(6px, -7px); }
  70% { transform: translate(-4px, 5px); }
  80% { transform: translate(5px, -3px); }
  90% { transform: translate(-3px, 2px); }
}

/* ---- HUD ----------------------------------------------------------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
}

.hud-brand {
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-dim);
}

.hud-dim { color: var(--text-soft); text-shadow: none; }

.hud-btn {
  pointer-events: auto;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  background: rgba(8, 12, 14, 0.75);
  border: 1px solid rgba(140, 160, 160, 0.25);
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.hud-btn:hover { color: var(--accent); border-color: var(--accent-dim); }

.hud-buttons { display: flex; gap: 8px; align-items: center; }

.hud-objective {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-dim);
  white-space: nowrap;
  animation: objectivePulse 3s ease-in-out infinite;
}

@keyframes objectivePulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

.hud-controls {
  position: absolute;
  bottom: 20px;
  left: 22px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(140, 160, 160, 0.5);
}

.hud-accent { color: var(--accent); text-shadow: 0 0 8px var(--accent-dim); }

/* ---- MUSE subtitle (corruption narration) ------------------------------- */
.hud-subtitle {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(720px, 86vw);
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: #cfeeea;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.9), 0 0 18px var(--accent-dim);
}

/* ---- Examine prompt + caption ------------------------------------------- */
.hud-examine-hint {
  position: absolute;
  bottom: 132px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-dim);
  animation: objectivePulse 2.2s ease-in-out infinite;
}

.hud-examine-box {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(640px, 84vw);
  text-align: center;
  background: rgba(6, 9, 11, 0.82);
  border: 1px solid rgba(140, 160, 160, 0.25);
  border-left: 2px solid var(--accent);
  padding: 12px 18px;
}

.examine-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 6px;
}

.examine-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* ---- Achievement toast --------------------------------------------------- */
.achievement {
  position: fixed;
  top: 64px;
  right: 22px;
  z-index: 30;
  width: 290px;
  background: rgba(8, 11, 13, 0.94);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 28px var(--accent-dim);
  padding: 14px 16px;
}

.achievement.ach-in { animation: achSlide 0.4s cubic-bezier(0.2, 0.9, 0.3, 1) both; }

@keyframes achSlide {
  0% { opacity: 0; transform: translateX(40px); }
  100% { opacity: 1; transform: none; }
}

.ach-row { display: flex; gap: 12px; align-items: flex-start; }

.ach-icon {
  font-size: 20px;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-dim);
  line-height: 1.2;
}

.ach-kicker {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.ach-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.ach-sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 3px;
  letter-spacing: 0.02em;
}

/* ---- EULA overlay -------------------------------------------------------- */
#eula-screen { background: rgba(2, 3, 6, 0.86); z-index: 40; }

.eula-panel {
  width: min(560px, calc(100vw - 40px));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7), 0 0 42px var(--accent-dim);
  padding-bottom: 18px;
}

.eula-scroll {
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 24px 8px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.eula-scroll p { margin-bottom: 12px; }

.eula-clause {
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent-dim);
}

.eula-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 24px 0;
  flex-wrap: wrap;
}

.eula-actions .menu-btn { font-size: 11px; padding: 11px 18px; }

.eula-note {
  padding: 10px 24px 0;
  font-size: 11px;
  color: var(--accent);
  min-height: 16px;
  letter-spacing: 0.02em;
}

/* ---- Screens (centered overlays) ----------------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}
.screen > * { pointer-events: auto; }

.hidden { display: none !important; }

/* Dock the permission panel to the right on wide screens, so the room —
   and whatever MUSE is doing to it — stays visible while you decide. */
@media (min-width: 980px) {
  #prompt-screen { justify-content: flex-end; padding-right: 5vw; }
}

.fade-in { animation: panelIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both; }

@keyframes panelIn {
  0% { opacity: 0; transform: translateY(10px) scaleY(0.96); filter: brightness(2); }
  35% { filter: brightness(1.4); }
  100% { opacity: 1; transform: none; filter: none; }
}

/* ---- Title screen ---------------------------------------------------------- */
#title-screen { background: rgba(3, 4, 7, 0.82); }

.title-box { text-align: center; max-width: 560px; padding: 24px; }

.title-kicker {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--text-soft);
  margin-bottom: 18px;
}

.title-main {
  font-size: clamp(44px, 9vw, 84px);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  text-shadow:
    0 0 18px var(--accent-dim),
    0 0 60px rgba(74, 223, 210, 0.2);
  animation: titleFlicker 7s linear infinite;
}

@keyframes titleFlicker {
  0%, 91%, 94%, 100% { opacity: 1; }
  92%, 93% { opacity: 0.55; }
}

.title-sub {
  margin: 22px 0 30px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-soft);
  letter-spacing: 0.06em;
}

.title-hint {
  margin-top: 24px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(140, 160, 160, 0.5);
  text-transform: uppercase;
}

/* ---- Buttons ----------------------------------------------------------------- */
.menu-btn {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.2em;
  padding: 13px 34px;
  cursor: pointer;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--panel-border);
  transition: all 0.18s;
}

.menu-btn-primary:hover {
  background: var(--accent);
  color: #04080a;
  box-shadow: 0 0 24px var(--accent-dim);
  transform: translateY(-1px);
}

/* ---- Settings panel (prompt / response) ---------------------------------------- */
.settings-panel {
  width: min(520px, calc(100vw - 40px));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--accent);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 18px 60px rgba(0, 0, 0, 0.7),
    0 0 42px var(--accent-dim);
  padding: 0 0 26px;
  backdrop-filter: blur(3px);
}

body.prompt-open .settings-panel { animation: panelGlitch 2.8s steps(1) infinite; }

@keyframes panelGlitch {
  0%, 96.5%, 100% { transform: none; clip-path: none; }
  97% { transform: translateX(2px) skewX(0.6deg); }
  97.5% { transform: translateX(-2px); clip-path: inset(12% 0 64% 0); }
  98% { transform: none; clip-path: none; }
}

.settings-header {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-soft);
  border-bottom: 1px solid rgba(140, 160, 160, 0.18);
  padding: 12px 24px;
  margin-bottom: 22px;
}

.settings-title {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.03em;
  padding: 0 24px;
  color: var(--text);
}

.settings-body {
  margin: 12px 0 24px;
  padding: 0 24px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-soft);
  letter-spacing: 0.03em;
}

.settings-options { display: flex; flex-direction: column; }

.opt {
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: none;
  border-top: 1px solid rgba(140, 160, 160, 0.12);
  padding: 14px 24px;
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: baseline;
  position: relative;
  transition: all 0.15s;
}
.opt:last-child { border-bottom: 1px solid rgba(140, 160, 160, 0.12); }

.opt::before {
  content: "▸";
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
}

.opt:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--accent);
  padding-left: 30px;
}
.opt:hover::before { opacity: 1; }

.opt-key { color: var(--text-soft); font-size: 11px; }

/* ---- Response view ----------------------------------------------------------------- */
#response-view { padding: 0 24px; }

.muse-row {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.muse-cursor {
  width: 8px; height: 14px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.15; } }

.response-text {
  font-size: 15px;
  line-height: 1.8;
  letter-spacing: 0.02em;
  min-height: 84px;
  margin-bottom: 14px;
  color: var(--text);
}

/* Doubt affordance — deliberately faint and unrewarding-looking. */
.doubt-link {
  display: block;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(140, 160, 160, 0.45);
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 16px;
  cursor: pointer;
  transition: color 0.2s;
}
.doubt-link:hover { color: var(--text-soft); text-decoration: underline; }

.doubt-reply {
  font-size: 13px;
  font-style: italic;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: var(--accent);
  opacity: 0.85;
  margin-bottom: 18px;
  padding-left: 12px;
  border-left: 1px solid var(--accent-dim);
}

/* ---- Ending screen ------------------------------------------------------------------ */
#ending-screen { background: rgba(3, 4, 7, 0.7); }

.ending-panel { padding-bottom: 30px; }

.ending-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 24px 0;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-dim);
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 24px;
  margin-bottom: 28px;
}

.meter-row { display: flex; align-items: center; gap: 12px; }

.meter-name {
  width: 190px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-soft);
  white-space: nowrap;
}

.meter-track {
  flex: 1;
  height: 8px;
  background: rgba(140, 160, 160, 0.12);
  border: 1px solid rgba(140, 160, 160, 0.18);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-dim);
  transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.meter-value {
  width: 30px;
  text-align: right;
  font-size: 12px;
  color: var(--text);
}

.ending-wrap {
  width: min(720px, calc(100vw - 28px));
  text-align: center;
}

.ending-card {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 48px var(--accent-dim);
  margin-bottom: 16px;
}

.ending-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Film grain ---------------------------------------------------------- */
#fx-grain {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background-repeat: repeat;
  background-size: 180px 180px;
  image-rendering: pixelated;
  mix-blend-mode: screen;
  transition: opacity 0.8s ease;
}

/* ---- Returning-visitor note --------------------------------------------- */
.returning-note {
  margin: 14px auto 0;
  max-width: 460px;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-dim);
}

/* ---- Death screen -------------------------------------------------------- */
#death-screen { background: rgba(0, 0, 0, 0.92); }

.death-box { text-align: center; max-width: 560px; padding: 24px; }

.death-kicker {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #7a3038;
  margin-bottom: 16px;
}

.death-title {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #c9b06a;
  text-shadow: 0 0 24px rgba(180, 30, 40, 0.45);
}

.death-text {
  margin: 20px 0 30px;
  font-size: 14px;
  line-height: 1.85;
  letter-spacing: 0.04em;
  color: #9a8f8f;
}

/* ---- Pause / options menu ------------------------------------------------ */
#pause-screen { background: rgba(3, 4, 7, 0.8); }

.pause-panel { width: min(440px, calc(100vw - 40px)); padding-bottom: 22px; }

.pause-body { padding: 18px 24px 6px; display: flex; flex-direction: column; gap: 16px; }

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-soft);
}

.opt-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.pause-actions { display: flex; gap: 10px; padding: 16px 24px 0; }

/* ---- Share card buttons -------------------------------------------------- */
.share-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 24px 0;
  flex-wrap: wrap;
}

.share-btn { font-size: 11px; padding: 10px 16px; }

.card-note {
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* ---- Touch controls ------------------------------------------------------ */
/* Virtual joystick: positioned at the touch point, non-interactive itself
   (the canvas underneath reads the touches and drives it). */
.touch-joystick {
  position: fixed;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;       /* center on its left/top coordinates */
  border-radius: 50%;
  border: 2px solid rgba(74, 223, 210, 0.4);
  background: rgba(8, 14, 16, 0.35);
  pointer-events: none;
  z-index: 14;
  display: none;
}
.touch-joystick.active { display: block; }

.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(120,255,245,0.9), rgba(74,223,210,0.45));
  box-shadow: 0 0 18px var(--accent-dim);
}

/* EXAMINE button (touch): right edge, vertically centered — clear of the
   bottom band where the object description / subtitle / objective render. */
.touch-examine {
  position: fixed;
  top: 50%;
  right: calc(16px + env(safe-area-inset-right, 0px));
  transform: translateY(-50%);
  z-index: 15;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #04080a;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  box-shadow: 0 0 22px var(--accent-dim);
  pointer-events: auto;
}
/* Only ever visible on touch devices. */
body:not(.touch) .touch-examine { display: none !important; }

/* The "[E] EXAMINE …" hint is for keyboard users; touch has the button. */
body.touch .hud-examine-hint { display: none !important; }

/* Keep the HUD clear of notches / rounded corners on phones. */
.hud-top {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-left: calc(22px + env(safe-area-inset-left, 0px));
  padding-right: calc(22px + env(safe-area-inset-right, 0px));
}

/* Let the EULA terms scroll with a finger even though the body can't. */
.eula-scroll { touch-action: pan-y; }

/* ---- Small screens ------------------------------------------------------------------- */
@media (max-width: 520px) {
  .settings-title { font-size: 16px; }
  .settings-body { font-size: 12px; }
  .meter-name { width: 130px; font-size: 9px; }
  .hud-controls { display: none; }
  /* Dock the permission panel to the bottom so the joystick has room up-left. */
  #prompt-screen { align-items: flex-end; padding-bottom: 14px; }
  .settings-panel { width: calc(100vw - 20px); }
  .opt { padding: 16px 20px; }   /* bigger tap targets */
  .menu-btn { padding: 14px 22px; }
}
