/* GARGANTUA — deep-space instrument HUD */
:root {
  --bg: #04060a;
  --ink: #cfe6f2;
  --dim: #5f7484;
  --line: rgba(148, 190, 214, 0.16);
  --line-strong: rgba(148, 190, 214, 0.34);
  --cyan: #8fd8ff;
  --amber: #ffb454;
  --glass: rgba(8, 13, 20, 0.62);
  --mono: "Cascadia Code", "SF Mono", Consolas, "JetBrains Mono", ui-monospace, monospace;
  --sans: "Segoe UI", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; }

#gl {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: grab;
}
#gl:active { cursor: grabbing; }

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > *, #ui .dock, #ui button { pointer-events: auto; }
#ui.hidden { opacity: 0; transition: opacity .5s; pointer-events: none; }
#ui.hidden > * { pointer-events: none !important; }
[hidden] { display: none !important; }

/* ---------- top header ---------- */
#hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: flex-start; align-items: flex-start;
  padding: calc(14px + env(safe-area-inset-top)) 20px 0 22px;
  background: linear-gradient(180deg, rgba(2,4,7,.72), transparent);
}
.brand h1 {
  font-family: var(--mono), "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(17px, 2.2vw, 25px);
  font-weight: 600; letter-spacing: .3em; color: var(--ink);
  text-shadow: 0 0 18px rgba(143, 216, 255, .35);
}
.brand p {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .34em;
  color: var(--dim); margin-top: 5px;
}
.brand .zh { letter-spacing: .5em; font-size: 9px; color: rgba(143,216,255,.45); }

/* ---------- debug label ---------- */
#debug-label {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10px; letter-spacing: .3em;
  color: var(--amber); border: 1px solid rgba(255, 180, 84, .35);
  padding: 5px 14px; background: var(--glass); backdrop-filter: blur(6px);
}

/* ---------- buttons / docks ---------- */
.dock {
  position: absolute; display: flex; gap: 6px; align-items: center;
  background: transparent; border: none; padding: 0;
}
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em;
  color: rgba(220, 230, 240, 0.92); background: transparent;
  border: 1px solid rgba(200, 210, 220, 0.4);
  padding: 9px 18px; cursor: pointer; position: relative;
  transition: color .2s, border-color .2s, background .2s, transform .2s;
  user-select: none; -webkit-user-select: none; white-space: nowrap;
}
.btn:hover { color: #fff; border-color: rgba(220, 230, 240, 0.85); }
.btn:active { transform: scale(.97); }
.btn[aria-pressed="true"], .btn.active {
  color: var(--amber); border-color: rgba(255, 180, 84, .5);
  background: rgba(255, 180, 84, .07);
}
.btn .hint { margin-left: 7px; color: rgba(143, 216, 255, .5); font-size: 9px; }
.sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }

#views { left: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); flex-wrap: wrap; }

/* ---------- toast / fatal ---------- */
#toast {
  position: absolute; top: calc(140px + env(safe-area-inset-top)); left: 50%;
  transform: translate(-50%, -6px); font-family: var(--mono); font-size: 10px;
  letter-spacing: .24em; color: var(--cyan); background: var(--glass);
  border: 1px solid var(--line-strong); padding: 8px 18px;
  opacity: 0; transition: opacity .35s, transform .35s; backdrop-filter: blur(8px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#fatal {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(3,5,8,.9); text-align: center;
}
#fatal h2 { font-family: var(--mono); letter-spacing: .5em; color: var(--amber); font-size: 15px; }
#fatal p { font-family: var(--mono); font-size: 10px; color: var(--dim); margin: 14px 0 20px; max-width: 420px; line-height: 1.8; letter-spacing: .1em; }
#fatal .btn { border-color: var(--line-strong); color: var(--ink); }

/* boot vignette so first paint is never a white flash */
#gl { background: var(--bg); }

/* ---------- responsive ---------- */
@media (max-width: 860px), (max-height: 560px) {
  .brand p { display: none; }
  .brand .zh { display: none; }
  #views {
    left: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(3, auto); gap: 6px;
    justify-items: start;
    max-width: calc(100vw - 24px);
  }
  #views .btn { padding: 6px 7px; font-size: 9px; letter-spacing: .12em; }
  #views .btn .hint { display: none; }
  #views .sep { display: none; }
  #debug-label { top: 70px; }
}

/* ---------- site nav overlay (always visible, independent of HUD) ---------- */
#nav {
  position: fixed; inset: 0; pointer-events: none; z-index: 20;
}
#nav > * { pointer-events: auto; }

.portal-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  color: rgba(220, 230, 240, 0.92);
  background: transparent;
  border: 1px solid rgba(200, 210, 220, 0.4);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .25s, color .25s, transform .25s;
  -webkit-user-select: none; user-select: none;
  white-space: nowrap;
}
.portal-btn:hover {
  border-color: rgba(220, 230, 240, 0.85);
  color: #fff;
}
.portal-btn:active { transform: scale(.97); }

.portal-btn--small { font-size: 11px; letter-spacing: .22em; padding: 9px 18px; }

.portal-btn--entry {
  font-size: 13px; letter-spacing: .26em; padding: 13px 32px;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.portal-btn--entry:hover { transform: translateY(-2px); }

#top-right-nav {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 20px;
  display: flex; gap: 10px; align-items: center;
}

#platform-entries {
  position: absolute; left: 50%; bottom: 28vh;
  transform: translateX(-50%);
  display: flex; gap: 18px;
}

#beian-group {
  position: absolute; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center;
}

#beian {
  font-size: 10px; letter-spacing: .14em; padding: 7px 12px;
  color: rgba(200, 210, 220, 0.7);
  border-color: rgba(200, 210, 220, 0.3);
}
#beian:hover { color: rgba(220, 230, 240, 0.95); border-color: rgba(200, 210, 220, 0.6); }

#beian-ps {
  font-size: 10px; letter-spacing: .14em; padding: 7px 12px;
  color: rgba(200, 210, 220, 0.7);
  border-color: rgba(200, 210, 220, 0.3);
  gap: 6px;
}
#beian-ps:hover { color: rgba(220, 230, 240, 0.95); border-color: rgba(200, 210, 220, 0.6); }
#beian-ps img { width: 12px; height: 12px; display: block; }

@media (max-width: 860px), (max-height: 560px) {
  #platform-entries { bottom: 20vh; gap: 12px; }
  .portal-btn--entry { font-size: 11px; padding: 11px 22px; letter-spacing: .2em; }
  .portal-btn--small { font-size: 10px; padding: 7px 13px; }
  #beian, #beian-ps { font-size: 9px; padding: 6px 9px; }
  #top-right-nav { gap: 8px; }
  #btn-sponsor { font-size: 9px; letter-spacing: .06em; padding: 7px 10px; }
}
