:root {
  --bg: #0a0612;
  --panel: #140a1f;
  --panel-2: #1c1030;
  --ink: #f3e9ff;
  --dim: #9a7fb8;
  --magenta: #ff2d95;
  --cyan: #21e6ff;
  --gold: #ffd36b;
  --danger: #ff5a5a;
  --edge: #38264f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(90deg, var(--panel), var(--panel-2));
  border-bottom: 1px solid var(--edge);
}
#game-title {
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 14px;
  color: var(--ink);
  text-shadow: 0 0 8px rgba(255, 45, 149, .6);
}
#controls { display: flex; gap: 6px; }
#controls button {
  background: transparent;
  border: 1px solid var(--edge);
  color: var(--cyan);
  border-radius: 8px;
  width: 34px; height: 34px;
  font-size: 16px;
  cursor: pointer;
  transition: .15s;
}
#controls button:active { transform: scale(.92); background: var(--panel-2); }
#controls button.off { color: var(--dim); border-color: var(--edge); opacity: .55; }

/* ---------- Stage ---------- */
#stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
#stage {
  position: relative;
  width: 100%;
  max-height: 100%;
}
#scene-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}
#stage.no-image { aspect-ratio: 9 / 16; }
#stage.no-image #scene-image { display: none; }

#stage-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background:
    radial-gradient(120% 80% at 70% 20%, rgba(255,45,149,.22), transparent 60%),
    radial-gradient(120% 80% at 20% 90%, rgba(33,230,255,.18), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(255,255,255,.02) 22px 23px),
    linear-gradient(180deg, #160a26, #090414);
  text-align: center;
  padding: 24px;
}
#stage.no-image #stage-placeholder { display: flex; }
.ph-title {
  font-size: 26px; font-weight: 800; letter-spacing: 1px;
  color: var(--ink); text-shadow: 0 0 14px rgba(33,230,255,.6);
}
.ph-note { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--dim); }

/* ---------- Hotspots ---------- */
#hotspots { position: absolute; inset: 0; }
.hotspot {
  position: absolute;
  cursor: pointer;
  border-radius: 6px;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 4px;
}
.hotspot .hs-label {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  background: rgba(10,6,18,.75); color: var(--cyan);
  padding: 2px 6px; border-radius: 4px;
  opacity: 0; transition: .15s; pointer-events: none;
  white-space: nowrap;
}
body.show-hotspots .hotspot {
  outline: 1.5px dashed rgba(33,230,255,.55);
  background: rgba(33,230,255,.06);
}
body.show-hotspots .hotspot .hs-label { opacity: 1; }
.hotspot:active { background: rgba(255,45,149,.25); }

/* ---------- Text panel ---------- */
#text-panel {
  flex: 0 0 auto;
  min-height: 78px;
  max-height: 32vh;
  overflow-y: auto;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid var(--edge);
  border-bottom: 1px solid var(--edge);
}
#text-content { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink); }
#text-content.fail { color: var(--danger); }

/* ---------- Inventory ---------- */
#inventory-bar {
  flex: 0 0 auto;
  padding: 8px 12px 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
#inventory-label {
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--dim); margin-bottom: 6px;
}
#inventory-items { display: flex; gap: 8px; overflow-x: auto; min-height: 48px; align-items: center; }
#inventory-items .empty { color: var(--dim); font-size: 13px; font-style: italic; }
.inv-item {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 56px; cursor: pointer;
}
.inv-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; overflow: hidden;
  box-shadow: 0 0 10px rgba(255,211,107,.25);
}
.inv-icon img { width: 100%; height: 100%; object-fit: cover; }
.inv-name { font-size: 9px; color: var(--ink); text-align: center; line-height: 1.1;
  max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Overlays ---------- */
.hidden { display: none !important; }
#dialog-overlay, #info-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,2,10,.78); backdrop-filter: blur(3px);
  padding: 20px;
}
#dialog-box, #info-box {
  width: 100%; max-width: 420px;
  background: var(--panel-2);
  border: 1px solid var(--magenta);
  border-radius: 14px; padding: 18px;
  box-shadow: 0 0 30px rgba(255,45,149,.35);
}
#dialog-speaker {
  font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--magenta); margin-bottom: 8px; font-weight: 700;
}
#dialog-text, #info-text { margin: 0 0 14px; font-size: 15px; line-height: 1.5; }
#dialog-options { display: flex; flex-direction: column; gap: 8px; }
.dialog-opt, #info-close {
  background: var(--panel); color: var(--cyan);
  border: 1px solid var(--edge); border-radius: 10px;
  padding: 11px 14px; font-size: 14px; text-align: left; cursor: pointer;
  transition: .15s;
}
.dialog-opt:active, #info-close:active { background: var(--magenta); color: #fff; }
#info-close { text-align: center; color: var(--gold); border-color: var(--gold); }
