:root {
  --navy: #101c33; --navy2: #16264a; --teal: #19c3b1; --gold: #d9b26f;
  --cream: #f4efe6; --ink: #1b2433; --muted: #8a94a8;
  --glass: rgba(12, 20, 38, .78);
  --sans: Inter, "Segoe UI", system-ui, sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a1222; color: var(--cream); font: 15px/1.5 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--teal); }
button { font: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.7em; padding: 0 .4em; margin: 0 .1em; border: 1px solid rgba(255,255,255,.3); border-bottom-width: 2px; border-radius: 5px; font: 600 12px/1.6 var(--sans); text-align: center; background: rgba(255,255,255,.06); }

#stage, #stage canvas { position: fixed; inset: 0; display: block; touch-action: none; }
#stage canvas { cursor: grab; }

/* ------------------------------------------------ HUD */
#hud { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 14px; pointer-events: none; flex-wrap: wrap; }
#hud > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; padding: 8px 14px; background: var(--glass); border: 1px solid rgba(217,178,111,.35); border-radius: 12px; text-decoration: none; color: var(--cream); backdrop-filter: blur(8px); }
.brand strong { font: 700 17px/1.1 var(--serif); }
.brand span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
#room-name { display: none; margin: 0; padding: 6px 12px; background: var(--glass); border-radius: 999px; font-weight: 600; font-size: 13px; backdrop-filter: blur(8px); }
#rooms { display: flex; gap: 4px; padding: 4px; background: var(--glass); border-radius: 999px; backdrop-filter: blur(8px); }
#rooms button, .tools button, .btn-link, #quality {
  border: 0; padding: 6px 12px; border-radius: 999px; background: transparent; color: var(--cream); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
#rooms button:hover, .tools button:hover, .btn-link:hover { background: rgba(255,255,255,.1); }
#rooms button.on { background: var(--teal); color: var(--navy); font-weight: 700; }
.tools { margin-left: auto; display: flex; gap: 4px; padding: 4px; background: var(--glass); border-radius: 999px; backdrop-filter: blur(8px); }
#quality { position: fixed; left: 12px; bottom: 12px; background: var(--glass); backdrop-filter: blur(8px); }

#tooltip { position: fixed; z-index: 5; max-width: 320px; padding: 6px 10px; border-radius: 8px; background: var(--glass); font-size: 13px; pointer-events: none; backdrop-filter: blur(6px); }
#prompt { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--glass); font-size: 14px; pointer-events: none; white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(6px); }
body.touch #prompt { display: none; }

#joystick { display: none; position: fixed; left: 24px; bottom: 64px; width: 120px; height: 120px; border-radius: 50%; background: rgba(12,20,38,.45); border: 1px solid rgba(255,255,255,.25); touch-action: none; }
#joystick span { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(25,195,177,.85); }
body.touch #joystick { display: block; }
.touch-only { display: none; }
body.touch .touch-only { display: list-item; }

/* ------------------------------------------------ panel */
#panel { position: fixed; top: 76px; right: 12px; bottom: 12px; width: min(440px, calc(100vw - 24px)); overflow-y: auto; padding: 26px 26px 30px; background: rgba(10, 18, 34, .92); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
#panel h2, .sheet h2 { margin: 4px 0 10px; font: 700 26px/1.2 var(--serif); color: #fff; }
#panel h3 { margin: 20px 0 8px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
.meta { color: #c3cadb; margin: 4px 0; }
.meta strong { color: #fff; }
.gold { color: var(--gold); }
.close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; font-size: 22px; line-height: 1; }
.close:hover { background: rgba(255,255,255,.18); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: transparent; color: var(--cream); text-decoration: none; font-size: 14px; font-weight: 600; }
.btn:hover { background: rgba(255,255,255,.08); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--navy); }
.btn.primary:hover { filter: brightness(1.08); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chips span { padding: 3px 10px; border-radius: 999px; background: rgba(25,195,177,.14); color: #bff3ec; font-size: 12.5px; font-weight: 500; }
.courses { list-style: none; padding: 0; margin: 0; }
.courses li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.courses li a:first-child { color: #fff; text-decoration: none; }
.mini { margin-left: 6px; font-size: 12px; }
.status { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: #5b6677; color: #fff; }
.s-completed { background: #1f8f5f; } .s-audited { background: #3b8fc2; } .s-in-progress { background: #8a2d3b; } .s-queued { background: #6a3d9a; }
.stages { padding-left: 0; list-style: none; counter-reset: st; }
.stages li { counter-increment: st; position: relative; padding: 8px 0 8px 36px; border-radius: 8px; cursor: pointer; color: #aab3c5; }
.stages li::before { content: counter(st); position: absolute; left: 6px; top: 9px; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 12px; font-weight: 700; text-align: center; line-height: 22px; color: #fff; }
.stages li strong { display: block; color: #e6eaf2; }
.stages li span { font-size: 13px; }
.stages li.on { background: rgba(217,178,111,.12); }
.stages li.on::before { background: var(--gold); color: var(--navy); }
.stages li:hover { background: rgba(255,255,255,.05); }

/* ------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(4, 8, 18, .6); backdrop-filter: blur(4px); }
.sheet { position: relative; width: min(880px, 100%); max-height: 100%; overflow-y: auto; padding: 30px 32px; background: #0d172b; border: 1px solid rgba(255,255,255,.1); border-radius: 18px; }
.sheet.small { width: min(560px, 100%); }
.keys { padding-left: 18px; line-height: 2.1; }
.cat-body header input { width: 100%; margin: 14px 0 4px; padding: 11px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.05); color: #fff; font: inherit; }
.cat-body section h3 { margin: 26px 0 6px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.cat-body ul { list-style: none; padding: 0; margin: 0; }
.cat-body li { border-bottom: 1px solid rgba(255,255,255,.07); }
.cat-body .pick, .cat-body li > a.t, .standalone .cat-body li { display: block; width: 100%; padding: 9px 4px; border: 0; background: none; color: inherit; text-align: left; text-decoration: none; }
.cat-body .pick:hover { background: rgba(255,255,255,.05); }
.cat-body .t { display: block; color: #fff; font-weight: 600; }
.cat-body .m { display: block; color: var(--muted); font-size: 13px; }
.cat-body .m strong { color: #dfe4ee; }
.cat-body .links .btn { padding: 3px 10px; margin: 6px 6px 0 0; font-size: 12px; }
.note { padding: 10px 14px; border-radius: 10px; background: rgba(217,178,111,.12); color: #f0dcb3; }
.fineprint { margin-top: 22px; font-size: 13px; color: var(--muted); }

/* plain-list page (no WebGL, or ?list) */
body.standalone { overflow: auto; }
body.standalone #hud, body.standalone #quality, body.standalone #joystick, body.standalone #stage { display: none; }
body.standalone #catalogue { position: static; display: block; background: none; backdrop-filter: none; }
body.standalone #catalogue .sheet { margin: 30px auto; max-height: none; }
body.standalone #catalogue .close { display: none; }

/* ------------------------------------------------ loader */
#loader { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #16264a, #070d1a 70%); transition: opacity .7s; }
#loader.done { opacity: 0; pointer-events: none; }
#loader .inner { text-align: center; padding: 20px; }
#loader h1 { margin: 6px 0 22px; font: 800 clamp(36px, 7vw, 64px)/1 var(--serif); color: #fff; }
#loader .bar { width: min(320px, 70vw); height: 4px; margin: 0 auto; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
#loader .bar span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .4s; }
#loader .msg { color: #c3cadb; }
#loader.error .msg { color: #ffb4b4; }
.noscript { position: fixed; inset: auto 0 0; z-index: 30; margin: 0; padding: 16px; background: #fff; color: #111; text-align: center; }

@media (max-width: 860px) {
  #rooms { order: 3; width: 100%; overflow-x: auto; }
  #room-name { display: none; }
  .tools .btn-link { display: none; }
  #panel { top: auto; left: 12px; width: auto; height: 55vh; }
  #hud { gap: 8px; }
  .brand { padding: 6px 10px; }
  .tools { margin-left: auto; }
  #btn-help { display: none; }
}
