:root {
  --accent: #45d4ff;
  --accent-dim: #1c7fa0;
  --steel: #1b2129;
  --steel-dark: #0d1116;
  --steel-light: #2e3946;
  --text: #eef2f5;
  --text-dim: #7c8b98;
  --green: #35e0a6;
  --red: #ff4d5e;
  --font: 'Trebuchet MS', 'Segoe UI', Tahoma, sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #05070a;
  font-family: var(--font);
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#game-root { position: fixed; inset: 0; }

#game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  background: #05070a;
}

.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

#title-screen {
  background: radial-gradient(120% 90% at 50% 20%, #18202b 0%, #0b0f14 60%, #05070a 100%);
  flex-direction: column;
}
.title-art {
  position: absolute; inset: 0;
  background-image: url('../assets/title.jpg');
  background-size: cover; background-position: center 30%;
  opacity: 0.55;
  mask-image: radial-gradient(90% 80% at 50% 40%, black 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(90% 80% at 50% 40%, black 30%, transparent 78%);
}
.title-content {
  position: relative; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 24px;
  animation: titleFade 1.2s ease-out;
}
@keyframes titleFade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.title-eyebrow {
  letter-spacing: 0.35em; text-transform: uppercase;
  font-size: 12px; color: var(--text-dim);
}
.title-logo {
  font-size: clamp(52px, 11vw, 110px);
  letter-spacing: 0.14em;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 0 34px rgba(69, 212, 255, 0.35), 0 4px 0 #000;
  line-height: 1;
}
.title-sub { color: var(--accent); font-size: 15px; letter-spacing: 0.08em; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; min-width: 260px; }
.title-hint { margin-top: 26px; font-size: 12px; color: var(--text-dim); letter-spacing: 0.04em; }

/* ---------- language select (first launch) ---------- */
.lang-content {
  position: relative; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 24px;
  animation: titleFade 1.2s ease-out;
}
.lang-title { color: var(--text-dim); font-size: 15px; letter-spacing: 0.08em; }
.lang-buttons { display: flex; gap: 14px; margin-top: 10px; }
.lang-buttons .btn { min-width: 170px; }

/* ---------- buttons & panels ---------- */
.btn {
  font-family: var(--font);
  font-size: 16px;
  padding: 12px 26px;
  background: linear-gradient(180deg, #232c37, #171d24);
  color: var(--text);
  border: 1px solid #3c485488;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: transform .08s ease, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 14px rgba(69,212,255,.18); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, #3fc3ec, #1f8fb5);
  border-color: #8fe6ff99; color: #052430; font-weight: 700;
}
.btn-primary:hover { box-shadow: 0 0 18px rgba(69,212,255,.4); }
.btn-ghost { background: transparent; border-color: #3c485455; }

.panel {
  background: linear-gradient(180deg, #161c22f2, #0d1116f5);
  border: 1px solid #3c485466;
  border-radius: 10px;
  padding: 28px 32px;
  max-width: min(640px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.panel h2 {
  color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase;
  font-size: 18px; margin-bottom: 16px;
  border-bottom: 1px solid #3c485444; padding-bottom: 10px;
}
.panel p { line-height: 1.55; margin-bottom: 12px; font-size: 15px; }
.muted { color: var(--text-dim); font-size: 13px !important; }

.about-panel { max-width: min(560px, 92vw); }
.about-panel .btn { margin-top: 8px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#hud button { pointer-events: auto; }

#objective-box {
  position: absolute; top: 16px; left: 16px;
  max-width: min(380px, 62vw);
  background: #0d1116d9;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  backdrop-filter: blur(3px);
  transition: opacity .4s;
}
#objective-quest {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 3px;
}
#objective-text { font-size: 14px; line-height: 1.4; }
#objective-hint { font-size: 12px; line-height: 1.35; color: var(--text-dim); margin-top: 4px; }

#depth-gauge {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#depth-label {
  font-size: 11px; letter-spacing: .1em; color: var(--accent);
  background: #0d1116d9; padding: 4px 8px; border-radius: 4px;
}
#depth-bar {
  width: 8px; height: min(300px, 40vh);
  background: linear-gradient(180deg, #232c37, #10151b);
  border: 1px solid #3c485466; border-radius: 4px;
  position: relative;
}
#depth-marker {
  position: absolute; left: 50%; transform: translate(-50%, -50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d8f7ff, var(--accent) 60%, #0d4a5c);
  box-shadow: 0 0 10px rgba(69,212,255,.7);
  top: 98%;
  transition: top 0.8s cubic-bezier(.5,0,.3,1);
}

#hud-buttons { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.hud-btn {
  width: 42px; height: 42px; border-radius: 8px;
  background: #0d1116d9; border: 1px solid #3c485466;
  color: var(--text); font-size: 19px; cursor: pointer;
}
.hud-btn:hover { border-color: var(--accent); }

#inventory-bar {
  position: absolute; bottom: 16px; left: 16px;
  display: flex; gap: 8px;
}
.inv-item {
  width: 46px; height: 46px; border-radius: 8px;
  background: #0d1116d9; border: 1px solid #3c485466;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  position: relative;
  animation: invPop .35s cubic-bezier(.3,1.6,.5,1);
}
@keyframes invPop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.inv-item .inv-tip {
  position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%);
  background: #0d1116f0; border: 1px solid #3c4854; border-radius: 4px;
  font-size: 12px; padding: 4px 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.inv-item:hover .inv-tip { opacity: 1; }

#interact-prompt {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #0d1116e6;
  border: 1px solid var(--accent-dim);
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  padding: 6px 12px;
  white-space: nowrap;
  pointer-events: auto;   /* tappable = interact (touch) */
  cursor: pointer;
}
#interact-prompt b { color: var(--accent); }

#toast-container {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(480px, 90vw);
}
.toast {
  background: #0d1116ee;
  border: 1px solid #3c485488;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  text-align: center;
  animation: toastIn .4s cubic-bezier(.2,1.4,.4,1);
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.quest { border-color: var(--accent); color: var(--accent); }
.toast.relic { border-color: var(--green); color: var(--green); }
.toast.fade { opacity: 0; transition: opacity .6s; }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dialogue ---------- */
#dialogue-box {
  position: absolute;
  left: 50%; bottom: 26px; transform: translateX(-50%);
  width: min(680px, 94vw);
  background: linear-gradient(180deg, #12181ef2, #0a0e12f5);
  border: 1px solid #3c485488;
  border-radius: 10px;
  padding: 16px 22px 14px;
  z-index: 45;   /* above the letterbox bars (40): cutscene subtitles must stay readable */
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
#dialogue-speaker {
  color: var(--accent); font-weight: 700; letter-spacing: 0.06em;
  font-size: 14px; margin-bottom: 6px; text-transform: uppercase;
}
#dialogue-text { font-size: 16px; line-height: 1.55; min-height: 44px; }
#dialogue-next {
  text-align: right; color: var(--accent); font-size: 12px;
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(3px);} }
#dialogue-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.choice-btn {
  text-align: left; font-size: 14px; padding: 9px 14px;
  background: #1a2029; border: 1px solid #3c485455; border-radius: 6px;
  color: var(--text); cursor: pointer; font-family: var(--font);
}
.choice-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- journal ---------- */
.journal-panel { width: min(620px, 92vw); }
.journal-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.jtab {
  background: transparent; border: 1px solid #3c485455; color: var(--text-dim);
  padding: 7px 16px; border-radius: 6px; cursor: pointer; font-family: var(--font); font-size: 14px;
}
.jtab.active { color: var(--accent); border-color: var(--accent-dim); }
#journal-content { min-height: 240px; margin-bottom: 16px; }
.quest-entry { padding: 10px 12px; border-radius: 6px; margin-bottom: 8px; background: #141a20; border: 1px solid #3c485433; }
.quest-entry.done { opacity: .55; }
.quest-entry .q-title { color: var(--accent); font-weight: 700; font-size: 14px; }
.quest-entry.done .q-title { color: var(--green); }
.quest-entry .q-obj { font-size: 13px; color: var(--text); margin-top: 4px; }
.quest-entry .q-hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.relic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.relic-card {
  background: #141a20; border: 1px solid #3c485433; border-radius: 8px;
  padding: 12px; text-align: center; font-size: 13px;
}
.relic-card .r-icon { font-size: 30px; margin-bottom: 6px; }
.relic-card.locked { opacity: .35; filter: grayscale(1); }
.relic-card .r-desc { color: var(--text-dim); font-size: 11px; margin-top: 4px; line-height: 1.4; }
.help-list { line-height: 2; font-size: 14px; }
.help-list b { color: var(--accent); display: inline-block; min-width: 110px; }

/* ---------- travel ---------- */
.travel-panel { width: min(460px, 92vw); }
#travel-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 18px; }
.travel-item {
  display: flex; align-items: center; gap: 14px;
  background: #141a20; border: 1px solid #3c485444; border-radius: 8px;
  padding: 12px 16px; cursor: pointer; font-family: var(--font);
  color: var(--text); font-size: 15px; text-align: left;
  transition: border-color .15s, transform .1s;
}
.travel-item:hover:not(.locked):not(.current) { border-color: var(--accent); transform: translateX(4px); }
.travel-item .t-depth {
  font-size: 12px; color: var(--accent); min-width: 58px;
  letter-spacing: .05em; font-weight: 700;
}
.travel-item .t-name { flex: 1; }
.travel-item .t-note { font-size: 11px; color: var(--text-dim); }
.travel-item.locked { opacity: .4; cursor: not-allowed; }
.travel-item.current { border-color: var(--accent-dim); background: #142430; cursor: default; }

/* ---------- minigames ---------- */
.minigame-panel { width: min(560px, 94vw); }
.mg-desc { color: var(--text-dim); font-size: 14px; margin-bottom: 18px; line-height: 1.5; }
.gauge-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.gauge-label { min-width: 120px; font-size: 14px; }
.gauge-track {
  flex: 1; height: 26px; border-radius: 13px;
  background: #0d1116; border: 1px solid #3c4854;
  position: relative; overflow: hidden;
}
.gauge-zone {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg, #2f9e78, #1f6e54);
  border-left: 1px solid #35e0a666; border-right: 1px solid #35e0a666;
}
.gauge-needle {
  position: absolute; top: 2px; bottom: 2px; width: 5px; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 8px rgba(69,212,255,.8);
}
.gauge-row.done .gauge-needle { background: var(--green); box-shadow: 0 0 8px rgba(53,224,166,.8); }
.gauge-row.done .gauge-label { color: var(--green); }
.mg-action { text-align: center; margin-top: 18px; }
.mg-feedback { text-align: center; min-height: 22px; margin-top: 10px; font-size: 14px; color: var(--accent); }

/* terminal — deliberately kept as legacy CRT green, contrasts with the modern HUD */
.terminal {
  background: #05080a; border: 1px solid #1e3a28; border-radius: 6px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px; color: #7ee2a0;
  padding: 14px; height: 300px; overflow-y: auto;
  line-height: 1.5;
  text-shadow: 0 0 6px rgba(126,226,160,.35);
}
.terminal .t-err { color: #e08a7a; }
.terminal .t-sys { color: #6a9bd8; }
.terminal .t-hl { color: #ffd58e; }
.terminal-input-row {
  display: flex; gap: 8px; margin-top: 10px; align-items: center;
  font-family: 'SF Mono', 'Consolas', monospace;
}
.terminal-input-row .t-prompt { color: #7ee2a0; font-size: 13px; }
#terminal-input {
  flex: 1; background: #05080a; border: 1px solid #1e3a28; border-radius: 4px;
  color: #7ee2a0; font-family: inherit; font-size: 13px; padding: 8px 10px;
  outline: none;
}
#terminal-input:focus { border-color: #7ee2a0; }

/* wires */
.wires-board { display: flex; justify-content: space-between; padding: 10px 30px; min-height: 240px; position: relative; }
.wire-col { display: flex; flex-direction: column; gap: 18px; z-index: 2; }
.wire-node {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #0d1116; font-size: 18px;
  transition: transform .1s, box-shadow .15s;
}
.wire-node:hover { transform: scale(1.1); }
.wire-node.sel { box-shadow: 0 0 16px currentColor; transform: scale(1.12); }
.wire-node.done { opacity: .5; cursor: default; }
#wires-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: 1; pointer-events: none; }

/* ---------- cutscene / fader ---------- */
.letterbox {
  position: absolute; left: 0; right: 0; height: 0; background: #000;
  z-index: 40; transition: height .8s cubic-bezier(.6,0,.3,1);
}
#letterbox-top { top: 0; }
#letterbox-bottom { bottom: 0; }
.letterbox.on { height: 11vh; }
#cutscene-skip {
  position: absolute; bottom: 12.5vh; right: 20px; z-index: 41;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
  padding: 6px 10px;
}
#cutscene-skip:hover { color: var(--accent); }

#fader {
  position: absolute; inset: 0; background: #000; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .7s ease;
}
#fader.on { opacity: 1; pointer-events: auto; }
#fader.slow { transition-duration: 2.2s; }

/* ---------- ending ---------- */
#ending-screen {
  background: radial-gradient(100% 100% at 50% 0%, #1b2129 0%, #05070a 70%);
  z-index: 55;
}
.ending-content {
  max-width: min(640px, 90vw); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  animation: titleFade 1.6s ease-out;
}
#ending-title { color: var(--accent); letter-spacing: .15em; font-size: clamp(30px, 6vw, 54px); }
#ending-text { line-height: 1.7; font-size: 16px; color: var(--text); }
#ending-stats { color: var(--text-dim); font-size: 14px; line-height: 1.8; }

/* ---------- character select ---------- */
#charselect-screen {
  background: radial-gradient(100% 100% at 50% 0%, #1b2129 0%, #05070a 70%);
  z-index: 50;
}
.charselect-content { text-align: center; animation: titleFade .8s ease-out; }
.charselect-content h2 { font-size: clamp(22px, 4vw, 30px); letter-spacing: .1em; margin-bottom: 26px; }
.hero-cards { display: flex; gap: 22px; justify-content: center; margin-bottom: 26px; }
.hero-card {
  width: min(210px, 42vw); padding: 18px 14px 16px;
  background: rgba(27, 33, 41, .85);
  border: 1px solid var(--steel-light); border-radius: 14px;
  color: var(--text); font-family: var(--font); cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.hero-card:hover, .hero-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 10px 34px rgba(69, 212, 255, .16);
}
.hero-card img { height: min(190px, 30vh); margin-bottom: 12px; filter: drop-shadow(0 8px 16px rgba(0,0,0,.5)); }
.hero-name { font-size: 20px; font-weight: bold; letter-spacing: .06em; }
.hero-desc { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ---------- prologue ---------- */
#prologue-screen { background: #05070a; z-index: 50; cursor: pointer; }
.prologue-content {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  max-width: min(880px, 94vw); padding: 16px;
}
#prologue-img {
  max-width: 100%; max-height: 60vh;
  border-radius: 12px;
  box-shadow: 0 16px 70px rgba(0, 0, 0, .65);
}
#prologue-text {
  font-size: clamp(14px, 2.2vw, 17px); line-height: 1.6; text-align: center;
  max-width: 660px; min-height: 4.8em; white-space: pre-line;
}
#prologue-dots { display: flex; gap: 8px; }
.pdot { width: 8px; height: 8px; border-radius: 50%; background: var(--steel-light); transition: background .2s; }
.pdot.on { background: var(--accent); }
.prologue-hint { color: var(--text-dim); font-size: 12px; letter-spacing: .06em; }
#btn-prologue-skip { position: absolute; top: 18px; right: 18px; }
.fade-in { animation: proFade .55s ease-out both; }
@keyframes proFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  #objective-box { max-width: 56vw; font-size: 12px; }
  #objective-text { font-size: 12px; }
  #depth-gauge { display: none; }
  #dialogue-text { font-size: 14px; }
  .panel { padding: 20px; }
  .hero-cards { gap: 12px; }
  #prologue-img { max-height: 46vh; }
}
