/* ============================================================
   Magic Circle — HUD / layout
   ============================================================ */
:root{
  --gold:#e9b96e;
  --gold-soft:#f4d9a8;
  --gold-dim:rgba(233,185,110,.38);
  --ink:#05060c;
  --panel:rgba(10,12,22,.62);
  --serif:"Cormorant Garamond","Songti SC","Noto Serif SC",Georgia,serif;
  --sans:"Inter","Helvetica Neue","PingFang SC","Microsoft YaHei",system-ui,sans-serif;
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  background:var(--ink);
  color:#e8e3d8;
  font-family:var(--sans);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
}
canvas#gl{position:fixed;inset:0;width:100%;height:100%;display:block}

/* video 源从不展示 */
#cam{position:fixed;width:2px;height:2px;opacity:0;pointer-events:none;left:-9999px}

.mono{font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace;letter-spacing:.04em}

/* ---------------- camera preview ---------------- */
#preview-wrap{
  position:fixed;right:18px;bottom:18px;
  width:210px;border-radius:10px;overflow:hidden;
  border:1px solid rgba(233,185,110,.28);
  background:#000;
  box-shadow:0 10px 40px rgba(0,0,0,.7),0 0 0 1px rgba(0,0,0,.6) inset;
  opacity:0;transform:translateY(12px);
  transition:opacity .5s ease,transform .5s ease;
  z-index:30;
}
#preview-wrap.on{opacity:1;transform:none}
#preview{display:block;width:100%;height:auto;transform:scaleX(-1)}
.preview-label{
  position:absolute;left:0;right:0;bottom:0;
  display:flex;align-items:center;gap:6px;
  padding:5px 8px;font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;
  color:rgba(232,227,216,.72);
  background:linear-gradient(to top,rgba(0,0,0,.85),transparent);
}
#cam-dot{
  width:6px;height:6px;border-radius:50%;background:#5a5a5a;flex:0 0 auto;
  transition:background .3s,box-shadow .3s;
}
#cam-dot.live{background:#6ee7a0;box-shadow:0 0 8px #6ee7a0}

/* ---------------- HUD ---------------- */
#hud{
  position:fixed;inset:0;z-index:20;pointer-events:none;
  display:flex;flex-direction:column;justify-content:space-between;
  padding:22px 26px 20px;
  opacity:0;transition:opacity .8s ease .2s;
}
#hud.on{opacity:1}

#hud-top{display:flex;justify-content:space-between;align-items:flex-start;gap:20px}
.title-block h1{
  font-family:var(--serif);font-weight:400;
  font-size:clamp(18px,2.1vw,27px);
  letter-spacing:.34em;text-indent:.34em;
  color:var(--gold-soft);
  text-shadow:0 0 22px rgba(233,185,110,.35);
}
.subtitle{
  margin-top:7px;font-size:11px;letter-spacing:.16em;
  color:rgba(232,227,216,.42);text-transform:uppercase;
}
.hud-buttons{display:flex;gap:8px;pointer-events:auto}

.btn{
  font-family:var(--sans);font-size:11.5px;letter-spacing:.12em;
  padding:8px 14px;border-radius:6px;cursor:pointer;
  color:var(--gold-soft);
  background:rgba(233,185,110,.07);
  border:1px solid rgba(233,185,110,.32);
  transition:background .25s,border-color .25s,color .25s,transform .15s;
  backdrop-filter:blur(6px);
}
.btn:hover{background:rgba(233,185,110,.16);border-color:rgba(233,185,110,.6)}
.btn:active{transform:translateY(1px)}
.btn.ghost{color:rgba(232,227,216,.6);border-color:rgba(232,227,216,.16);background:rgba(255,255,255,.03)}
.btn.ghost:hover{color:var(--gold-soft);border-color:rgba(233,185,110,.4)}
.btn.primary{
  color:#150f04;
  background:linear-gradient(180deg,#f0c987,#d9a45c);
  border-color:#f0c987;
  font-weight:600;
  box-shadow:0 6px 26px rgba(233,185,110,.32);
}
.btn.primary:hover{background:linear-gradient(180deg,#ffdda1,#e6b06a)}

#hud-bottom{display:flex;justify-content:space-between;align-items:flex-end;gap:20px}

.telemetry{
  display:grid;gap:5px;min-width:186px;
  padding:12px 15px;border-radius:8px;
  background:linear-gradient(180deg,rgba(8,10,18,.5),rgba(8,10,18,.28));
  border:1px solid rgba(233,185,110,.14);
  backdrop-filter:blur(8px);
}
.tel-row{display:flex;justify-content:space-between;align-items:baseline;gap:16px;font-size:11px}
.tel-row .k{color:rgba(232,227,216,.4);letter-spacing:.16em}
.tel-row .v{
  font-family:ui-monospace,Menlo,Consolas,monospace;
  color:var(--gold-soft);font-size:12px;letter-spacing:.02em;
}
.tel-row .v i{font-style:normal;color:rgba(232,227,216,.32);font-size:10px}

.energy-block{position:relative;width:74px;height:74px;flex:0 0 auto;transition:margin-right .5s ease}
/* keep the energy ring clear of the camera preview */
body:has(#preview-wrap.on) .energy-block{margin-right:222px}
@media (max-width:720px){body:has(#preview-wrap.on) .energy-block{margin-right:140px}}
.energy-ring{width:100%;height:100%;transform:rotate(-90deg)}
.energy-ring .track{fill:none;stroke:rgba(233,185,110,.12);stroke-width:3}
.energy-ring .fill{
  fill:none;stroke:url(#g) ;stroke:var(--gold);stroke-width:3;
  stroke-linecap:round;
  stroke-dasharray:326.7;stroke-dashoffset:326.7;
  filter:drop-shadow(0 0 6px rgba(233,185,110,.8));
  transition:stroke-dashoffset .35s ease;
}
.energy-txt{
  position:absolute;inset:0;display:grid;place-items:center;
  font-family:ui-monospace,Menlo,monospace;font-size:15px;color:var(--gold-soft);
}
.energy-txt i{font-style:normal;font-size:9px;opacity:.5;margin-left:1px}

/* ---------------- overlay ---------------- */
#overlay{
  position:fixed;inset:0;z-index:50;
  display:grid;place-items:center;
  padding:28px;
  background:radial-gradient(ellipse at center,rgba(6,8,16,.72),rgba(3,4,9,.94) 65%);
  backdrop-filter:blur(3px);
  opacity:0;visibility:hidden;
  transition:opacity .7s ease,visibility .7s;
}
#overlay.show{opacity:1;visibility:visible}
.ov-inner{
  max-width:620px;text-align:center;
  animation:riseIn .9s cubic-bezier(.22,.8,.24,1) both;
}
@keyframes riseIn{from{opacity:0;transform:translateY(18px)}to{opacity:1;transform:none}}

.sigil{
  font-size:26px;color:var(--gold);
  margin-bottom:14px;
  text-shadow:0 0 20px rgba(233,185,110,.9),0 0 60px rgba(233,185,110,.45);
  animation:pulse 3.2s ease-in-out infinite;
}
@keyframes pulse{0%,100%{opacity:.55;transform:scale(.94)}50%{opacity:1;transform:scale(1.06)}}

.ov-inner h2{
  font-family:var(--serif);font-weight:400;
  font-size:clamp(23px,3.4vw,36px);letter-spacing:.1em;
  color:var(--gold-soft);
  text-shadow:0 0 40px rgba(233,185,110,.3);
}
.lead{
  margin:14px auto 0;max-width:460px;
  font-size:13.5px;line-height:1.75;color:rgba(232,227,216,.62);
}
.hints{
  list-style:none;margin:26px auto 0;max-width:470px;
  display:grid;gap:10px;text-align:left;
}
.hints li{
  display:grid;grid-template-columns:88px 1fr;gap:14px;align-items:baseline;
  padding:10px 14px;border-radius:7px;
  background:rgba(233,185,110,.05);
  border:1px solid rgba(233,185,110,.13);
  border-left:2px solid rgba(233,185,110,.5);
}
.hints b{
  font-weight:500;font-size:12px;letter-spacing:.1em;color:var(--gold-soft);
}
.hints span{font-size:12px;line-height:1.6;color:rgba(232,227,216,.52)}

.ov-actions{display:flex;gap:12px;justify-content:center;margin-top:28px;flex-wrap:wrap}
.ov-actions .btn{font-size:12.5px;padding:11px 22px}
.tiny{margin-top:16px;font-size:11px;color:rgba(232,227,216,.3)}

/* ---------------- loading ---------------- */
#loading{
  position:fixed;inset:0;z-index:60;
  display:grid;place-items:center;background:#04050a;
  transition:opacity .6s ease,visibility .6s;
}
#loading.hide{opacity:0;visibility:hidden}
.ld-inner{display:grid;justify-items:center;gap:20px}
.ld-ring{
  width:46px;height:46px;border-radius:50%;
  border:1.5px solid rgba(233,185,110,.16);
  border-top-color:var(--gold);
  animation:spin 1s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
#ld-text{font-size:11.5px;letter-spacing:.18em;color:rgba(232,227,216,.45);text-transform:uppercase}

/* ---------------- toast ---------------- */
#toast{
  position:fixed;left:50%;top:88px;transform:translate(-50%,-10px);
  z-index:40;pointer-events:none;
  padding:9px 18px;border-radius:20px;
  font-size:12px;letter-spacing:.08em;
  color:var(--gold-soft);
  background:rgba(12,10,6,.82);
  border:1px solid rgba(233,185,110,.35);
  box-shadow:0 8px 30px rgba(0,0,0,.6);
  opacity:0;transition:opacity .35s ease,transform .35s ease;
}
#toast.on{opacity:1;transform:translate(-50%,0)}

/* help sheet */
#help{
  position:fixed;inset:0;z-index:55;display:grid;place-items:center;padding:24px;
  background:rgba(3,4,9,.86);backdrop-filter:blur(6px);
  opacity:0;visibility:hidden;transition:opacity .4s,visibility .4s;
}
#help.show{opacity:1;visibility:visible}
.help-card{
  max-width:520px;width:100%;
  padding:26px 28px;border-radius:12px;
  background:rgba(10,12,20,.9);
  border:1px solid rgba(233,185,110,.22);
  box-shadow:0 20px 70px rgba(0,0,0,.8);
}
.help-card h3{
  font-family:var(--serif);font-weight:400;font-size:20px;letter-spacing:.12em;
  color:var(--gold-soft);margin-bottom:16px;
}
.help-card dl{display:grid;gap:9px}
.help-card dt{font-size:12px;color:var(--gold-soft);letter-spacing:.06em;margin-top:8px}
.help-card dd{font-size:12px;line-height:1.65;color:rgba(232,227,216,.52)}
.help-card kbd{
  font-family:ui-monospace,Menlo,monospace;font-size:11px;
  padding:1px 6px;border-radius:4px;
  background:rgba(233,185,110,.12);border:1px solid rgba(233,185,110,.28);
  color:var(--gold-soft);
}
.help-card .close{margin-top:20px;width:100%}

@media (max-width:720px){
  #hud{padding:16px 16px 14px}
  .subtitle{display:none}
  #preview-wrap{width:132px;right:12px;bottom:12px}
  .telemetry{min-width:0;font-size:10px;padding:9px 11px}
  .energy-block{width:58px;height:58px}
  .hints li{grid-template-columns:1fr;gap:4px}
}
