:root {
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #eaf4f7;
  --muted: #849aa5;
  --cyan: #7be9f6;
  --cyan-strong: #45d7e9;
  --mint: #76e6c4;
  --panel: rgba(9, 17, 23, .78);
  --panel-strong: rgba(8, 15, 20, .94);
  --line: rgba(139, 205, 221, .18);
  --line-strong: rgba(123, 233, 246, .44);
  --shadow: 0 18px 60px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #060b10; }
button, a { font: inherit; }
button { color: inherit; }
.app-shell { position: relative; width: 100%; height: 100%; overflow: hidden; background: #060b10; }
a-scene { width: 100%; height: 100%; }

.play-brand, .game-counter, .control-hint, .interaction-prompt, .game-message,
.status-panel, .play-overlay, .play-toolbar { position: absolute; z-index: 8; }
.play-brand, .game-counter, .control-hint, .interaction-prompt, .game-message, .status-panel { pointer-events: none; }

/* Brand: deliberately unboxed. */
.play-brand {
  top: 23px;
  left: 27px;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  filter: drop-shadow(0 7px 18px rgba(0,0,0,.28));
}
.play-brand img { display: block; width: 152px; height: auto; }
.brand-divider { width: 1px; height: 18px; margin-left: 2px; background: rgba(143, 204, 216, .18); }
.play-brand .live-dot {
  width: 5px;
  height: 5px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 11px rgba(118, 230, 196, .82);
  animation: play-pulse 2.4s ease-in-out infinite;
}
.play-brand small {
  color: #8499a2;
  font: 700 8px ui-monospace, Consolas, monospace;
  letter-spacing: .18em;
}

/* Status chip lives alone in the upper-right. */
.game-counter {
  top: 25px;
  right: 27px;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 11px;
  border: 1px solid rgba(101, 220, 237, .24);
  border-radius: 10px;
  background: linear-gradient(115deg, rgba(7, 18, 24, .78), rgba(8, 29, 36, .58));
  color: #bdf7ff;
  font: 700 9px ui-monospace, Consolas, monospace;
  letter-spacing: .13em;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgba(0,0,0,.16), inset 0 0 18px rgba(73, 201, 221, .035);
}
.game-counter::before {
  content: "";
  width: 12px;
  height: 16px;
  flex: 0 0 auto;
  background: linear-gradient(180deg, #a8f8ff, #43d9ec);
  clip-path: polygon(52% 0, 14% 52%, 45% 52%, 28% 100%, 88% 38%, 55% 38%);
  filter: drop-shadow(0 0 6px rgba(91, 230, 246, .44));
}
.game-counter-label {
  color: #6f9da7;
  font: 700 7px ui-monospace, Consolas, monospace;
  letter-spacing: .16em;
}
.game-counter-value {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: #dffcff;
}
.game-counter-value b {
  color: #aaf5ff;
  font: 700 12px ui-monospace, Consolas, monospace;
  letter-spacing: .02em;
}
.game-counter-value i {
  color: #486b75;
  font: 400 8px ui-monospace, Consolas, monospace;
  font-style: normal;
}

.camera-control-hint { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 25; max-width: calc(100vw - 32px); padding: 7px 12px; border-radius: 6px; background: rgba(5,18,24,.7); color: #c3dce3; font-size: 11px; text-align: center; pointer-events: none; }
.control-hint {
  top: 25px;
  left: 50%;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  opacity: 0;
  transform: translate(-50%, -9px);
  border: 1px solid rgba(145, 210, 223, .14);
  border-radius: 10px;
  background: rgba(7, 14, 19, .54);
  backdrop-filter: blur(13px);
  transition: opacity .35s ease, transform .35s ease;
}
.control-hint.is-visible,
.control-hint.is-pinned { opacity: 1; transform: translate(-50%, 0); }
.control-hint .hint-item { display: flex; gap: 6px; align-items: center; color: #8399a3; font-size: 9px; white-space: nowrap; }
.control-hint kbd {
  min-width: 22px;
  padding: 4px 6px;
  border: 1px solid rgba(155, 219, 231, .2);
  border-radius: 5px;
  background: rgba(25, 39, 47, .72);
  color: #d8edf2;
  font: 700 8px ui-monospace, Consolas, monospace;
  text-align: center;
}
.control-hint .hint-sep { width: 1px; height: 14px; margin: 0 2px; background: rgba(144, 184, 194, .14); }

.interaction-prompt {
  left: 50%;
  bottom: 112px;
  transform: translateX(-50%);
  padding: 10px 14px 10px 46px;
  border: 1px solid rgba(112, 231, 245, .42);
  border-radius: 10px;
  background: rgba(6, 17, 23, .78);
  color: #eaffff;
  font-size: 12px;
  letter-spacing: .05em;
  box-shadow: 0 12px 38px rgba(0,0,0,.24), 0 0 24px rgba(69,215,233,.07);
  backdrop-filter: blur(14px);
}
.interaction-prompt::before {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  content: "E";
  border: 1px solid rgba(123,233,246,.5);
  border-radius: 6px;
  color: var(--cyan);
  font: 700 10px ui-monospace, Consolas, monospace;
}
.game-message {
  left: 50%;
  top: 15%;
  transform: translateX(-50%);
  padding: 11px 16px;
  border: 1px solid rgba(118,230,196,.32);
  border-radius: 10px;
  background: rgba(7, 18, 20, .78);
  color: #dcfff5;
  font-size: 12px;
  box-shadow: 0 14px 48px rgba(0,0,0,.22);
  backdrop-filter: blur(14px);
}

.runtime-warning {
  position: absolute;
  z-index: 9;
  top: 74px;
  left: 50%;
  width: min(680px, calc(100vw - 40px));
  min-height: 58px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto 30px;
  gap: 10px;
  align-items: center;
  transform: translateX(-50%);
  padding: 10px 10px 10px 13px;
  border: 1px solid rgba(240, 184, 92, .34);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(43, 31, 17, .94), rgba(17, 20, 22, .92));
  box-shadow: 0 16px 46px rgba(0,0,0,.32), 0 0 28px rgba(237, 174, 72, .05);
  backdrop-filter: blur(16px);
}
.runtime-warning[hidden] { display: none; }
.runtime-warning-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 191, 103, .45);
  border-radius: 50%;
  color: #ffd28c;
  font: 800 12px ui-monospace, Consolas, monospace;
}
.runtime-warning > div { min-width: 0; }
.runtime-warning strong { display: block; margin-bottom: 3px; color: #e9ba73; font: 700 8px ui-monospace, Consolas, monospace; letter-spacing: .14em; }
.runtime-warning p { margin: 0; color: #c7b69c; font-size: 10px; line-height: 1.5; }
.runtime-warning a {
  min-width: 90px;
  padding: 8px 10px;
  border: 1px solid rgba(238, 191, 112, .25);
  border-radius: 7px;
  color: #f0c98c;
  background: rgba(82, 57, 24, .25);
  font-size: 9px;
  text-align: center;
  text-decoration: none;
}
.runtime-warning a:hover { border-color: rgba(246, 204, 132, .46); color: #ffe1ad; }
.runtime-warning button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #9b876b;
  cursor: pointer;
  font-size: 18px;
}
.runtime-warning button:hover { color: #f5d49e; }

/* Runtime debug remains available, but only through Settings. */
.status-panel {
  top: 72px;
  right: 27px;
  width: min(330px, calc(100vw - 54px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.status-panel[hidden] { display: none; }
.status-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: #8097a1; font: 700 8px ui-monospace, Consolas, monospace; letter-spacing: .16em; }
.status-body { display: grid; grid-template-columns: 6px 1fr; gap: 10px; align-items: start; }
.status-dot { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: #e3b76f; box-shadow: 0 0 10px currentColor; }
.status-dot[data-state="ready"] { background: var(--mint); }
.status-dot[data-state="error"] { background: #ff7c86; }
.status-texts { display: grid; gap: 4px; color: #9cb0b8; font-size: 10px; line-height: 1.35; }

/* Bottom-centered toolbar: the single action surface for PLAY mode. */
.play-toolbar {
  transition: opacity .2s ease, transform .2s ease;
  left: 50%;
  bottom: 24px;
  display: flex;
  gap: 3px;
  align-items: center;
  padding: 5px;
  transform: translateX(-50%);
  border: 1px solid rgba(133, 203, 216, .17);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(10, 21, 28, .80), rgba(6, 14, 19, .73));
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 55px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.025);
}
.play-toolbar.is-fullscreen-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
}
@media (prefers-reduced-motion: reduce) {
  .play-toolbar { transition: none; }
}
.play-tool {
  position: relative;
  width: 68px;
  height: 56px;
  display: grid;
  grid-template-rows: 28px auto;
  place-items: center;
  gap: 2px;
  padding: 6px 5px 5px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #66818b;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease, transform .15s ease;
}
.play-tool svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 0 rgba(83, 223, 241, 0));
  transition: filter .15s ease;
}
.play-tool > span { font: 700 7px ui-monospace, Consolas, monospace; letter-spacing: .05em; }
.play-tool:hover {
  color: #bfeaf0;
  border-color: rgba(107, 221, 236, .18);
  background: rgba(25, 56, 66, .42);
  transform: translateY(-1px);
}
.play-tool:hover svg { filter: drop-shadow(0 0 7px rgba(83, 223, 241, .18)); }
.play-tool.is-active {
  color: #9ef2fb;
  border-color: rgba(100, 228, 244, .28);
  background: linear-gradient(180deg, rgba(36, 103, 116, .27), rgba(17, 59, 69, .18));
  box-shadow: inset 0 -2px rgba(91, 228, 245, .44);
}
.play-tool.is-muted { color: #74838a; }
.play-tool .audio-slash { display: none; }
.play-tool.is-muted .audio-wave { display: none; }
.play-tool.is-muted .audio-slash { display: block; stroke: #e6a28e; }
.play-tool:nth-child(3)::before,
.play-tool:nth-child(5)::before {
  position: absolute;
  left: -3px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  content: "";
  background: rgba(127, 190, 203, .11);
}
.composer-tool {
  color: #7baab4;
  text-decoration: none;
}
.composer-tool::before {
  position: absolute;
  left: -3px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  content: "";
  background: rgba(101, 225, 241, .22);
  box-shadow: 0 0 8px rgba(101, 225, 241, .06);
}
.composer-tool:hover {
  color: #bff7fd;
  background: linear-gradient(180deg, rgba(31, 91, 103, .34), rgba(14, 48, 57, .25));
}
.composer-tool .composer-pen { stroke: #82ebf6; }

/* One unified overlay for Objectives / Settings / Restart / Help. */
.play-overlay {
  left: 50%;
  bottom: 96px;
  width: min(440px, calc(100vw - 32px));
  overflow: hidden;
  transform: translateX(-50%);
  border: 1px solid rgba(125, 205, 219, .19);
  border-radius: 14px;
  background: linear-gradient(155deg, rgba(9, 21, 28, .95), rgba(5, 13, 18, .93));
  backdrop-filter: blur(19px);
  box-shadow: 0 24px 70px rgba(0,0,0,.38);
}
.play-overlay[hidden] { display: none; }
.play-overlay-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px 10px 15px;
  border-bottom: 1px solid rgba(127, 190, 203, .11);
}
.play-overlay-head div { display: grid; gap: 3px; }
.play-overlay-head small { color: #53727d; font: 700 7px ui-monospace, Consolas, monospace; letter-spacing: .17em; }
.play-overlay-head h2 { margin: 0; color: #dcecef; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.play-overlay-head button {
  width: 31px;
  height: 31px;
  border: 1px solid rgba(119, 178, 191, .14);
  border-radius: 8px;
  background: transparent;
  color: #708b95;
  cursor: pointer;
  font-size: 18px;
}
.play-overlay-head button:hover { border-color: rgba(104, 226, 241, .32); color: #dffbff; }
.play-overlay-body { padding: 13px; }
.play-panel[hidden] { display: none; }
.panel-eyebrow { margin: 0 0 8px; color: #587580; font: 700 7px ui-monospace, Consolas, monospace; letter-spacing: .15em; }

.objective-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 13px;
  border: 1px solid rgba(103, 220, 237, .16);
  border-radius: 9px;
  background: rgba(19, 47, 56, .30);
}
.objective-card.is-complete { border-color: rgba(118, 230, 196, .28); background: rgba(22, 65, 54, .25); }
.objective-copy { display: grid; gap: 5px; min-width: 0; }
.objective-copy strong { color: #c8f7fc; font: 700 10px ui-monospace, Consolas, monospace; letter-spacing: .11em; }
.objective-copy span { color: #78919a; font-size: 10px; line-height: 1.5; }
.objective-card b { color: #82eaf5; font: 700 18px ui-monospace, Consolas, monospace; white-space: nowrap; }
.objective-card.is-complete b { color: var(--mint); }

.settings-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(120, 177, 189, .08);
  color: inherit;
}
.settings-row > span { display: grid; gap: 3px; }
.settings-row strong { color: #b9ced4; font-size: 10px; font-weight: 600; }
.settings-row small { color: #607983; font-size: 8px; }
.settings-row input { width: 16px; height: 16px; accent-color: #69deed; }
.play-language-select {
  min-width: 118px;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(118, 178, 190, .18);
  border-radius: 7px;
  background: #091820;
  color: #c7dce1;
  font-size: 10px;
  outline: none;
  cursor: pointer;
}
.play-language-select:focus { border-color: rgba(105, 224, 240, .48); }

.restart-panel { display: grid; gap: 7px; }
.restart-panel > strong { color: #dcecf0; font-size: 13px; }
.restart-panel > span { color: #758d96; font-size: 10px; line-height: 1.5; }
.restart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.restart-actions button {
  min-height: 36px;
  border: 1px solid rgba(118, 178, 190, .15);
  border-radius: 7px;
  background: rgba(15, 34, 42, .72);
  color: #9bb3ba;
  cursor: pointer;
  font-size: 9px;
}
.restart-actions button:hover { border-color: rgba(105, 224, 240, .32); color: #e3fbff; }
.restart-actions .danger { border-color: rgba(226, 118, 118, .20); color: #e6aaa0; background: rgba(81, 35, 34, .24); }
.restart-actions .danger:hover { border-color: rgba(238, 133, 126, .4); color: #ffd4cc; }

.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
.help-grid kbd {
  min-width: 54px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--cyan);
  background: rgba(19, 39, 47, .64);
  font: 700 8px ui-monospace, Consolas, monospace;
  text-align: center;
}
.help-grid span { color: #879ea8; font-size: 10px; }

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(26, 105, 132, .24), transparent 28%),
    radial-gradient(circle at 16% 52%, rgba(16, 87, 128, .13), transparent 34%),
    radial-gradient(circle at 84% 48%, rgba(24, 113, 153, .11), transparent 32%),
    linear-gradient(180deg, #06111a, #02070b 76%);
  opacity: 1;
  visibility: visible;
  transition: opacity .75s cubic-bezier(.22,.8,.2,1), visibility .75s;
}
.loading-screen.is-complete { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-core {
  position: relative;
  z-index: 2;
  width: min(520px, calc(100vw - 40px));
  padding: 34px 38px 30px;
  text-align: center;
}
.loading-logo {
  display: block;
  width: min(310px, 72vw);
  height: auto;
  margin: 0 auto 20px;
  filter: drop-shadow(0 0 18px rgba(71, 216, 239, .12)) drop-shadow(0 14px 28px rgba(0,0,0,.36));
}
.loading-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 8px;
  color: #73dfea;
  font: 700 8px ui-monospace, Consolas, monospace;
  letter-spacing: .24em;
}
.loading-eyebrow span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #73e0bd;
  box-shadow: 0 0 10px rgba(115,224,189,.72);
}
.loading-stage { margin: 13px 0 22px; color: #90aab4; font-size: 11px; letter-spacing: .06em; }
.loading-progress-shell { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.loading-progress {
  --progress: 12%;
  position: relative;
  height: 4px;
  overflow: hidden;
  border: 1px solid rgba(111, 205, 220, .15);
  border-radius: 999px;
  background: rgba(91, 143, 156, .08);
  box-shadow: inset 0 0 12px rgba(0,0,0,.22);
}
.loading-progress::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress);
  content: "";
  border-radius: inherit;
  background: linear-gradient(90deg, #2d95be, #47d9ee 62%, #9cf7ff);
  box-shadow: 0 0 16px rgba(92,229,244,.48);
  transition: width .35s ease;
}
.loading-value { min-width: 34px; color: #75dbe7; font: 700 10px ui-monospace, Consolas, monospace; }
.loading-foot { margin-top: 28px; color: #425d67; font: 700 8px ui-monospace, Consolas, monospace; letter-spacing: .16em; }
.loading-screen.has-error .loading-eyebrow,
.loading-screen.has-error .loading-value { color: #ff8992; }
@keyframes play-pulse { 0%, 100% { opacity: .62; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.08); } }

@media (max-width: 760px) {
  .play-brand { top: 14px; left: 14px; }
  .play-brand img { width: 116px; }
  .brand-divider { display: none; }
  .game-counter { top: 14px; right: 14px; min-height: 32px; padding: 0 9px; font-size: 8px; }
  .control-hint { display: none; }
  .play-toolbar { bottom: 14px; gap: 1px; padding: 4px; }
  .play-tool { width: 43px; height: 45px; grid-template-rows: 1fr; padding: 5px; }
  .play-tool > span { display: none; }
  .play-tool svg { width: 22px; height: 22px; }
  .play-overlay { bottom: 70px; width: min(420px, calc(100vw - 20px)); }
  .interaction-prompt { bottom: 76px; max-width: calc(100vw - 28px); }
  .status-panel { top: 58px; right: 14px; width: min(330px, calc(100vw - 28px)); }
  .runtime-warning {
    top: 58px;
    width: calc(100vw - 28px);
    grid-template-columns: 24px minmax(0, 1fr) 30px;
  }
  .runtime-warning a { grid-column: 2 / 3; justify-self: start; min-width: 0; }
  .runtime-warning button { grid-column: 3; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
.vr-panel {
  position: absolute;
  z-index: 25;
  top: 80px;
  left: 20px;
  width: min(380px, calc(100vw - 40px));
  box-sizing: border-box;
  padding: 18px;
  color: #d9e9ec;
  background: #0a171ef2;
  border: 1px solid #3a616c;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.vr-panel strong { font-size: 18px; }
.vr-panel p { margin: 8px 0 12px; }
.vr-panel .vr-status { color: #b8cdd2; }
.vr-panel button { width: 100%; min-height: 44px; border: 1px solid #6ed9df; border-radius: 6px; background: #145664; color: #fff; font: inherit; cursor: pointer; }
.vr-panel button:disabled { opacity: .55; cursor: default; }
.vr-panel button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.vr-active .vr-panel,
.vr-viewer [data-panel="objectives"],
.vr-viewer [data-panel="help"],
.vr-viewer #game-counter,
.vr-viewer #control-hint { display: none !important; }
.published-game #toolbar-composer,
.published-game #runtime-warning a {
  display: none !important;
}

/* Match the editor's readable 11–13px control scale in Play mode. */
.play-brand small, .game-counter-label, .control-hint .hint-item,
.control-hint kbd, .play-tool > span, .runtime-warning p,
.status-texts, .objective-copy span, .settings-row strong,
.settings-row small, .restart-panel > span, .restart-actions button,
.help-grid span, .help-grid kbd { font-size:12px; }
.play-overlay-head small, .loading-eyebrow, .loading-foot { font-size:11px; }
.play-overlay-head h2 { font-size:17px; }
.loading-stage { font-size:13px; }
.play-tool { width:92px; }
.play-tool > span { white-space:nowrap; }
@media (max-width:760px) {
  .game-counter { font-size:11px; }
  .play-tool { width:43px; }
}
