:root {
  --bg: #05070f;
  --panel: rgba(10, 14, 28, 0.82);
  --line: rgba(159, 182, 255, 0.18);
  --fg: #eef2ff;
  --muted: #9aa6c8;
  --main: #9fb6ff;
  --ai: #b06cff;
  --sec: #3dffa8;
  --sw: #4cc3ff;
  --c: var(--main);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--fg);
  background: var(--bg);
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#scroll-space { width: 1px; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--bg); color: var(--muted); font-size: 14px; transition: opacity 0.6s ease;
}
body.ready #loader { opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--main); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent; text-decoration: none; font-weight: 600; font-size: 14px;
  background: var(--c); color: #060912; transition: transform 0.15s ease, filter 0.15s ease, background 0.2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); color: var(--fg); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--c); }
.btn.icon { width: 38px; padding: 0; justify-content: center; background: rgba(255, 255, 255, 0.04); color: var(--fg); border-color: var(--line); }

/* ---------- header ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; padding: 14px 20px;
  background: linear-gradient(to bottom, rgba(5, 7, 15, 0.85), rgba(5, 7, 15, 0));
}
.logo {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(176, 108, 255, 0.35), rgba(76, 195, 255, 0.35));
  font-weight: 800; letter-spacing: 0.5px;
}
#chips { display: flex; gap: 6px; flex: 1; justify-content: center; }
.chip {
  --c: var(--main);
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all 0.2s ease;
}
.chip i { color: var(--c); }
.chip:hover { color: var(--fg); border-color: var(--c); }
.chip.active { color: #060912; background: var(--c); border-color: var(--c); }
.chip.active i { color: #060912; }
.actions { display: flex; gap: 8px; }

/* ---------- intro ---------- */
#intro {
  position: fixed; left: 7vw; top: 50%; transform: translateY(-50%); z-index: 5; max-width: 520px;
  transition: opacity 0.2s linear;
}
#intro .eyebrow { margin: 0; color: var(--muted); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; font-size: 13px; }
#intro h1 {
  margin: 6px 0 10px; font-size: clamp(44px, 6vw, 84px); line-height: 1; font-weight: 800; letter-spacing: -0.03em;
  background: linear-gradient(100deg, #ffffff 20%, var(--main) 55%, var(--ai) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#intro .role { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
#intro .tag { margin: 0 0 22px; color: var(--muted); font-size: 16px; }
#intro .tag b { color: var(--line); }
#intro .tag em { font-style: normal; font-weight: 600; }
#intro .tag .ai { color: var(--ai); }
#intro .tag .sec { color: var(--sec); }
#intro .links { display: flex; gap: 10px; }
#intro .links a {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); font-size: 18px; transition: border-color 0.2s, transform 0.2s;
}
#intro .links a:hover { border-color: var(--main); transform: translateY(-2px); }

#hint {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px;
  transition: opacity 0.4s ease; pointer-events: none;
}
#hint i { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(6px); } }

/* ---------- progress ---------- */
#progress {
  position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 3px; height: 160px; border-radius: 3px; background: var(--line); overflow: hidden;
}
#progress span { display: block; width: 100%; height: 100%; background: var(--c); transform-origin: top; transform: scaleY(0); }

/* ---------- chooser ---------- */
#chooser, #ends {
  position: fixed; left: 50%; bottom: 26px; z-index: 6; width: min(760px, calc(100vw - 32px));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all 0.35s ease;
  text-align: center;
}
#chooser.show, #ends.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#chooser h2, #ends h2 { margin: 0 0 12px; font-size: 22px; font-weight: 800; text-shadow: 0 2px 12px #000; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice {
  display: grid; gap: 4px; justify-items: center; padding: 16px 14px; border-radius: var(--radius); text-align: center;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); transition: all 0.2s ease;
}
.choice i { font-size: 22px; color: var(--c); margin-bottom: 4px; }
.choice strong { font-size: 17px; color: var(--c); }
.choice span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.choice:hover { border-color: var(--c); transform: translateY(-3px); box-shadow: 0 10px 30px -10px var(--c); }
.small { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }

/* ---------- nearby card ---------- */
#near {
  position: fixed; left: 24px; bottom: 24px; z-index: 6; width: min(360px, calc(100vw - 48px));
  padding: 18px 18px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--c); backdrop-filter: blur(10px);
  transform: translateX(-20px); opacity: 0; pointer-events: none; transition: all 0.3s ease;
}
#near.show { transform: none; opacity: 1; pointer-events: auto; }
.kicker { color: var(--c); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
#near h3 { margin: 6px 0 6px; font-size: 18px; }
#near p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
#near .btn { height: 34px; }

#back {
  position: fixed; right: 44px; bottom: 26px; z-index: 6; height: 38px; padding: 0 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
#back.show { opacity: 1; pointer-events: auto; }
#back:hover { border-color: var(--main); }

/* ---------- floating bits ---------- */
#tooltip {
  position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; padding: 6px 10px; border-radius: 8px;
  background: rgba(10, 14, 28, 0.92); border: 1px solid var(--line); font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity 0.15s;
}
#tooltip.show { opacity: 1; }
#bubble {
  position: fixed; left: 0; top: 0; z-index: 7; max-width: 240px; padding: 10px 14px; border-radius: 14px;
  background: #eef2ff; color: #0b1020; font-size: 13.5px; font-weight: 500; line-height: 1.4; pointer-events: none;
  opacity: 0; transition: opacity 0.25s; margin-top: -12px;
}
#bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #eef2ff; }
#bubble.show { opacity: 1; }
#toast {
  position: fixed; top: 76px; left: 50%; transform: translate(-50%, -10px); z-index: 30; padding: 10px 16px;
  border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 14px;
  opacity: 0; pointer-events: none; transition: all 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast a { color: var(--main); }

/* ---------- dialogs ---------- */
dialog {
  width: min(620px, calc(100vw - 32px)); max-height: min(80vh, 760px); overflow: auto;
  padding: 24px 26px 26px; border-radius: 18px; border: 1px solid var(--line); border-top: 3px solid var(--c);
  background: rgba(10, 14, 28, 0.96); color: var(--fg); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
dialog::backdrop { background: rgba(3, 5, 12, 0.55); backdrop-filter: blur(3px); }
dialog[open] { animation: pop 0.22s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
dialog header { display: flex; justify-content: space-between; align-items: center; }
dialog h2 { margin: 6px 0 10px; font-size: 26px; letter-spacing: -0.01em; }
.close { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; }
.close:hover { border-color: var(--c); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tags span { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--c); background: rgba(255, 255, 255, 0.03); }
#panel-body { color: #d6ddf3; font-size: 15px; line-height: 1.65; }
#panel-body ul, #panel-body ol { padding-left: 1.2em; }
#panel-body li { margin: 4px 0; }
#panel-body b, #panel-body strong { color: #fff; }
#panel-body a { color: var(--c); }
.muted { color: var(--muted); }
.facts { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 8px; }
.facts li { margin: 0 !important; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); font-size: 13px; color: var(--muted); }
.facts b { display: block; font-size: 20px; color: var(--c) !important; }
.role { padding: 10px 0; border-bottom: 1px solid var(--line); }
.role:last-child { border-bottom: 0; }
.role h4 { margin: 0 0 4px; font-size: 16px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.role h4 span { font-weight: 500; color: var(--muted); font-size: 13px; }
.role p { margin: 0; }
.verdict { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.verdict.ok { background: rgba(61, 255, 168, 0.15); color: #3dffa8; }
.verdict.warn { background: rgba(255, 210, 122, 0.15); color: #ffd27a; }
.verdict.bad { background: rgba(255, 99, 120, 0.15); color: #ff6378; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 18px; }
.contact-grid a, .contact-grid button {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; text-decoration: none; font-size: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); text-align: left;
}
.contact-grid a:hover, .contact-grid button:hover { border-color: var(--c); }
.contact-grid i { color: var(--c); width: 16px; }
.contact-grid [hidden] { display: none; }
#contact-form { display: grid; gap: 8px; }
#contact-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#contact-form input, #contact-form textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  color: var(--fg); font: inherit; font-size: 14px; resize: vertical;
}
#contact-form input:focus, #contact-form textarea:focus { outline: none; border-color: var(--c); }
#contact-form .btn { justify-self: start; }

.noscript { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; }

@media (max-width: 900px) {
  .btn span, .chip span { display: none; }
  .chip { padding: 0 11px; }
  #intro { left: 24px; right: 24px; }
}

/* ---------- mini-map ---------- */
#minimap {
  position: fixed; right: 44px; bottom: 76px; z-index: 5; width: 160px; height: 210px; cursor: pointer;
  border-radius: var(--radius); background: rgba(10, 14, 28, 0.6); border: 1px solid var(--line); backdrop-filter: blur(6px);
}
#sound.on { border-color: var(--main); color: var(--main); }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .hud { padding: 10px 12px; gap: 8px; }
  .logo { width: 36px; height: 36px; }
  #chips { gap: 4px; justify-content: flex-start; }
  .chip { height: 32px; padding: 0 10px; }
  .actions { gap: 6px; }
  .actions .btn { height: 34px; padding: 0 11px; }
  .actions .btn.icon { width: 34px; padding: 0; }
  #intro { left: 16px; right: 16px; top: 22%; transform: none; }
  #intro .role { font-size: 16px; }
  #intro .tag { font-size: 14px; }
  #progress, #minimap { display: none; }
  #chooser { bottom: 14px; }
  #chooser h2, #ends h2 { font-size: 18px; margin-bottom: 8px; }
  .choices { gap: 6px; }
  .choice { padding: 12px 6px; }
  .choice span { display: none; }
  #chooser .small { display: none; }
  #near { left: 12px; right: 12px; bottom: 12px; width: auto; padding: 14px; }
  #near h3 { font-size: 16px; }
  #near p { font-size: 13px; margin-bottom: 10px; }
  #back { top: 60px; bottom: auto; right: 12px; height: 32px; font-size: 12px; }
  #tooltip { display: none; }
  #bubble { max-width: 200px; font-size: 12.5px; }
  dialog { padding: 18px; max-height: 86vh; }
  dialog h2 { font-size: 21px; }
  .contact-grid, #contact-form .row { grid-template-columns: 1fr; }
}
#near .btn span, #chooser .btn span { display: inline; }
@media (max-width: 760px) {
  #intro { top: 11%; }
  #intro h1 { font-size: 40px; }
}

.linkish { background: none; border: 0; padding: 0; color: var(--main); text-decoration: underline; font-size: inherit; }
#ends .small a { color: var(--main); }
body.warp::after { content: ''; position: fixed; inset: 0; z-index: 40; background: var(--bg); animation: warp 0.7s ease; pointer-events: none; }
@keyframes warp { 0% { opacity: 0; } 45%, 55% { opacity: 1; } 100% { opacity: 0; } }
@media (max-width: 760px) {
  #ends { bottom: 14px; }
  #ends .choice span, #ends .small { display: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- daylight overlay tweaks ---------- */
:root[data-theme="day"] body, :root[data-theme="day"] html { background: #bfd6f2; }
:root[data-theme="day"] .hud { background: linear-gradient(to bottom, rgba(191, 214, 242, 0.85), rgba(191, 214, 242, 0)); }
:root[data-theme="day"] #intro .eyebrow, :root[data-theme="day"] #intro .tag { color: #3a4670; }
:root[data-theme="day"] #intro .role { color: #0b1020; }
:root[data-theme="day"] #intro h1 { background: linear-gradient(100deg, #0b1020 20%, #4a64c9 55%, #7a3fd6 90%); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="day"] #intro .tag .ai { color: #7a3fd6; }
:root[data-theme="day"] #intro .tag .sec { color: #0c9a62; }
:root[data-theme="day"] #intro .links a { color: #0b1020; background: rgba(255, 255, 255, 0.5); border-color: rgba(30, 50, 100, 0.2); }
:root[data-theme="day"] #hint { color: #3a4670; }
:root[data-theme="day"] #chooser h2, :root[data-theme="day"] #ends h2 { color: #0b1020; text-shadow: 0 1px 10px rgba(255, 255, 255, 0.8); }
:root[data-theme="day"] .small { color: #3a4670; }
:root[data-theme="day"] .chip, :root[data-theme="day"] .btn.ghost, :root[data-theme="day"] .btn.icon, :root[data-theme="day"] .logo {
  background: rgba(255, 255, 255, 0.65); color: #1b2440; border-color: rgba(30, 50, 100, 0.22);
}
:root[data-theme="day"] .chip.active { color: #060912; background: var(--c); border-color: var(--c); }
:root[data-theme="day"] #minimap { background: rgba(10, 14, 28, 0.75); }

/* ---------- guided tour ---------- */
.tour-cta { margin: 0 0 18px; height: 42px; }
#tour {
  position: fixed; top: 74px; left: 50%; z-index: 12; width: min(560px, calc(100vw - 24px));
  padding: 14px 18px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(10px); transform: translate(-50%, -10px); opacity: 0; pointer-events: none; transition: all 0.3s ease;
}
#tour.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.tour-row { display: flex; justify-content: space-between; align-items: center; }
.tour-step { color: var(--main); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.tour-row button { background: none; border: 0; color: var(--muted); font-size: 12.5px; padding: 2px 0; }
.tour-row button:hover { color: var(--fg); }
.tour-text { margin: 6px 0 10px; font-size: 15px; line-height: 1.5; min-height: 2.9em; }
.tour-bar { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.tour-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--main), var(--ai)); transform-origin: left; transform: scaleX(0); transition: transform 0.6s ease; }
body.touring #toast { display: none; }
@media (max-width: 760px) { #tour { top: 58px; } .tour-text { font-size: 14px; } }

/* ---------- phone header menu ---------- */
#hud-menu { display: none; }
@media (max-width: 760px) {
  #chips { flex: 1; justify-content: center; }
  #hud-menu { display: inline-flex; width: 36px; height: 36px; flex: none; }
  .hud .actions {
    position: absolute; top: calc(100% - 2px); right: 12px; flex-direction: column; align-items: stretch; gap: 6px;
    min-width: 190px; padding: 8px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
    backdrop-filter: blur(12px); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
    opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .hud.open .actions { opacity: 1; transform: none; pointer-events: auto; }
  .hud .actions .btn, .hud .actions .btn.icon { width: auto; height: 40px; padding: 0 14px; justify-content: flex-start; gap: 12px; }
  .hud .actions .btn i { width: 18px; text-align: center; }
  .hud .actions .btn span, .hud .actions .btn .lbl { display: inline; }
  .hud .actions .btn.icon::after { content: attr(aria-label); font-weight: 600; font-size: 14px; }
}
:root[data-theme="day"] .hud .actions { background: rgba(255, 255, 255, 0.92); }

/* ---------- short landscape phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .hud { padding: 8px 14px; }
  .logo { width: 34px; height: 34px; }
  .chip, .actions .btn { height: 32px; }
  .actions .btn.icon { width: 32px; }
  #intro { top: 56px; transform: none; max-width: 46vw; }
  #intro .eyebrow { font-size: 11px; }
  #intro h1 { font-size: 34px; margin: 2px 0 4px; }
  #intro .role { font-size: 14px; margin: 0 0 4px; }
  #intro .tag { font-size: 13px; margin: 0 0 10px; }
  .tour-cta { height: 34px; margin-bottom: 8px; font-size: 13px; }
  #intro .links { display: none; }
  #minimap, #progress, #hint { display: none; }
  #tour { top: 52px; }
  #near { bottom: 10px; padding: 12px; max-width: 360px; }
  #near p { display: none; }
  #back { top: 54px; bottom: auto; }
  dialog { max-height: 92vh; }
}
