:root {
  --ink: #f2f5f8;
  --dim: #9fb0c0;
  --amber: #ffb02e;
  --red: #ff5a3c;
  --green: #57d98a;
  --panel: rgba(12, 16, 22, 0.88);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #05070a;
  color: var(--ink);
  font: 15px/1.65 "Noto Sans Thai", "Sukhumvit Set", "Thonburi", system-ui, sans-serif;
}
canvas { display: block; }
.hidden { display: none !important; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  color: var(--dim); letter-spacing: 0.04em;
}

.panel {
  position: fixed; inset: 0; margin: auto; width: min(760px, 92vw); height: fit-content;
  max-height: 92vh; overflow: auto;
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 176, 46, 0.25); border-radius: 14px;
  padding: 20px 26px 22px; z-index: 20;
}
.panel h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.panel h1::before { content: "🔥 "; }
.lead { color: var(--dim); margin: 0 0 12px; font-size: 14px; }
/* The controls list was 218px of a 670px panel — the single biggest block, and
   the one with the most air in it. Tighter leading and a smaller hanging indent
   keep every line while giving back about 70px. */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cols h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--amber); margin: 0 0 5px; }
.cols ul { margin: 0; padding-left: 15px; color: var(--dim); font-size: 13.5px; line-height: 1.35; }
.cols li { margin: 0; }
.cols .fine { margin-top: 8px; }
.fine { color: #6c7d8c; font-size: 12px; margin: 8px 0 0; line-height: 1.4; }

button {
  margin-top: 22px; padding: 12px 22px; font: inherit; font-weight: 600;
  color: #10151b; background: var(--amber); border: 0; border-radius: 8px; cursor: pointer;
}
button:hover { background: #ffc45c; }
/* One row for the three controls. They were laid out with per-element margins,
   which meant the VR element — whose width three.js sets, and which changes
   with its state — could push itself onto a line of its own. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.actions button, .actions #vrslot { margin: 0 !important; }
.actions #vrslot > * { margin: 0 !important; }
#vrslot { display: inline-flex; }
/* three.js hands back a <button> when navigator.xr exists and an <a> when it
   does not — which is the case in Safari. Targeting only `button` left the
   anchor with the library's inline absolute positioning, floating it over the
   text at the bottom of the panel. Match whatever element it gives us. */
#vrslot > * {
  position: static !important; width: auto !important; padding: 12px 22px !important;
  background: rgba(255,255,255,0.1) !important; color: var(--ink) !important;
  border: 1px solid rgba(255,255,255,0.25) !important; border-radius: 8px !important;
  font: inherit !important; font-weight: 600 !important; opacity: 1 !important;
  transform: none !important; left: auto !important; right: auto !important;
  top: auto !important; bottom: auto !important; margin: 22px 0 0 !important;
  display: inline-block !important; text-decoration: none !important;
  text-align: center !important; line-height: normal !important;
  white-space: nowrap; vertical-align: top;
}
/* The unavailable state is a link off to immersiveweb.dev; make it read as
   information rather than as the primary action. */
#vrslot a { opacity: 0.75 !important; font-weight: 500 !important; }

#hud {
  position: fixed; left: 20px; top: 18px; z-index: 10; pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
#stage {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--amber);
}
#objective { font-size: 17px; max-width: 40ch; }
#meters { margin-top: 8px; display: flex; gap: 14px; font-size: 13px; color: var(--dim); }
.meter b { color: var(--ink); font-variant-numeric: tabular-nums; }

#prompt {
  position: fixed; left: 50%; bottom: 16%; transform: translateX(-50%); z-index: 10;
  background: rgba(0,0,0,0.62); padding: 7px 14px; border-radius: 20px; font-size: 14px;
  pointer-events: none; white-space: nowrap;
}
#prompt kbd {
  background: var(--amber); color: #10151b; border-radius: 4px; padding: 1px 6px;
  font: 600 12px/1.4 inherit; margin-right: 4px;
}
#crosshair {
  position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: rgba(255,255,255,0.7); z-index: 10; pointer-events: none;
}
#toast {
  position: fixed; left: 50%; top: 14%; transform: translateX(-50%); z-index: 12;
  background: rgba(255, 90, 60, 0.92); color: #fff; font-weight: 600;
  padding: 10px 20px; border-radius: 8px; pointer-events: none;
}
#reportBody { color: var(--dim); }
#reportBody .row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
#reportBody .row b { color: var(--ink); font-weight: 600; }
#reportBody .ok b { color: var(--green); }
#reportBody .bad b { color: var(--red); }
#reportBody .grade { font-size: 40px; color: var(--amber); margin: 14px 0 4px; }

/* AI coach (ADISAC ADVICE) — distinct from the scripted red toasts */
#advice {
  position: fixed; left: 50%; bottom: 26%; transform: translateX(-50%); z-index: 12;
  max-width: 46ch; background: rgba(12, 34, 48, 0.92); color: #d6f2ff;
  border-left: 3px solid #4fc3f7; border-radius: 8px;
  padding: 11px 18px; font-size: 16px; line-height: 1.5; pointer-events: none;
}

/* Microphone permission must be granted here: Chromium cannot raise a
   permission prompt once an immersive WebXR session owns the display. */
button.mic {
  background: rgba(255,255,255,0.1); color: var(--ink);
  border: 1px solid rgba(255,255,255,0.25);
}
button.mic:hover { background: rgba(255,255,255,0.18); }
button.mic.ready { background: #2f8f63; border-color: #3fd39a; color: #f2fff9; cursor: default; }
button.mic.failed { background: #7d2f24; border-color: #c4523f; color: #ffe9e4; }
#micHint { margin-top: 6px; }

/* Training mode picker. Which mode a trainee ran is recorded with their result,
   so the choice has to be explicit rather than a hidden default. */
/* Three across, always. As flex with a 240px basis they needed 740px and the
   panel gives 694, so the third card wrapped onto its own row — which made the
   start panel 150px taller than it had to be. In a headset that is the
   difference between the whole panel being on the board and not. */
#modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
#modes button.mode {
  margin: 0; text-align: left; padding: 10px 12px; min-width: 0;
  background: rgba(255,255,255,0.06); color: var(--ink);
  border: 1px solid rgba(255,255,255,0.18); border-radius: 10px; cursor: pointer;
}
/* Below about 620px three columns stop being readable, so let them stack. */
@media (max-width: 620px) { #modes { grid-template-columns: 1fr; } }
#modes button.mode:hover { background: rgba(255,255,255,0.12); }
#modes button.mode.on { background: rgba(255,176,44,0.16); border-color: var(--amber); }
#modes .mname { display: block; font-weight: 650; font-size: 14.5px; }
#modes .msub  { display: block; color: #cfd8e0; font-size: 11.5px; margin-top: 1px; }
#modes .mdesc { display: block; color: #8fa0ae; font-size: 11px; margin-top: 5px; line-height: 1.38; }
#modes .mbadge {
  display: inline-block; margin-top: 7px; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; background: rgba(255,255,255,0.12); color: #dfe7ee;
}
#modes button.mode.on .mbadge { background: var(--amber); color: #10151b; }


/* ---- trainee sign-in on the start panel ----
   One row, no wrapping: the headset viewport is 1280x600 and the panel was
   tuned to fit it without joystick scrolling — a second line here undoes
   that. Everything shares the row; the error text truncates before it can
   push anything out. */
#member { margin: 6px 0 2px; }
#memberForm { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
#memberForm .mlabel { font-weight: 600; color: #ffcf7d; font-size: 14px; white-space: nowrap; }
#memberForm input { background: #171d26; border: 1px solid #2e3a49; color: #e8eef5;
  border-radius: 8px; padding: 6px 10px; font-size: 13.5px;
  flex: 0 1 150px; min-width: 90px; }
#memberForm button { font-size: 13.5px; padding: 6px 14px; border-radius: 8px; border: 0;
  margin: 0; background: #2e6b46; color: #eafff1; cursor: pointer; white-space: nowrap; }
#memberError { color: #ff9a8a; font-size: 12.5px; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#memberDone { display: flex; align-items: center; gap: 12px; }
#memberHello { color: #9fe0b2; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#memberDone button { font-size: 13px; padding: 5px 12px; border-radius: 8px;
  border: 1px solid #2e3a49; background: transparent; color: #9aa7b5;
  cursor: pointer; white-space: nowrap; }


/* debrief navigation buttons (desktop report) */
#report button.alt { background: #2e6b46; color: #eafff1; margin-left: 10px; }
#report button.quiet { background: transparent; color: #9aa7b5;
  border: 1px solid #2e3a49; margin-left: 10px; }
