:root {
  --ink: #e8f4ff;
  --ink-dim: #8fb4d4;
  --cyan: #3de8ff;
  --gold: #ffd56a;
  --danger: #ff6b8a;
  --ok: #5dffb0;
  --panel: rgba(8, 28, 48, 0.82);
  --stroke: rgba(61, 232, 255, 0.35);
  --font-display: "Oxanium", "Outfit", sans-serif;
  --font-body: "Outfit", "Pretendard", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: #041018;
  overflow-x: hidden;
}

/* Android rotation-lock: CSS landscape fallback (same as prism-tycoon). */
html.force-landscape,
html.force-landscape body {
  overflow: hidden;
  touch-action: none;
}
html.force-landscape input,
html.force-landscape textarea,
html.force-landscape button,
html.force-landscape a {
  touch-action: manipulation;
}
html.force-landscape #game-container {
  position: fixed;
  inset: auto;
  right: auto;
  bottom: auto;
  top: 0;
  left: 100vw;
  left: 100dvw;
  width: 100vh;
  width: 100dvh;
  height: 100vw;
  height: 100dvw;
  max-width: none;
  margin: 0;
  transform: rotate(90deg);
  transform-origin: top left;
  background: #041018;
}
html.force-landscape body.hud-overlay-mobile .canvas-wrapper.world-wrap {
  width: min(100%, calc(100% * 960 / 520));
  max-width: 100%;
  max-height: 100%;
}
html.force-landscape .lab-bg {
  display: none;
}
html.force-landscape .modal-backdrop {
  align-items: flex-start;
  overflow: auto;
  height: 100%;
  max-height: 100%;
  -webkit-overflow-scrolling: touch;
}
html.force-landscape .modal-card {
  max-height: none;
}

.lab-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(61, 232, 255, 0.12), transparent 55%),
    linear-gradient(180deg, #061820 0%, #041018 100%);
  pointer-events: none;
  z-index: 0;
}

.game-container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 14px 28px;
}

.game-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.game-header .user-profile-card {
  order: 2;
}
.header-hud-slot {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
  order: 3;
}
.header-left {
  order: 1;
}

.game-title-group h1 {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cyan);
}

.play-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.play-hud-slot {
  display: none;
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 6px 8px;
}
.profile-text { display: flex; flex-direction: column; line-height: 1.2; }
.profile-name { font-size: 0.85rem; font-weight: 700; }
.profile-id { font-size: 0.7rem; color: var(--ink-dim); }
.btn-small-edit {
  background: transparent;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 8px;
}

.btn-sound,
.btn-fullscreen {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  z-index: 9;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(61, 232, 255, 0.35);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  background: rgba(4, 14, 24, 0.82);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.btn-sound {
  right: max(8px, env(safe-area-inset-right, 0px));
}
.btn-sound.muted { opacity: 0.55; }
.btn-sound:hover,
.btn-fullscreen:hover { border-color: var(--accent-cyan); }
.btn-fullscreen {
  right: max(52px, calc(env(safe-area-inset-right, 0px) + 44px));
}
.btn-fullscreen.hidden { display: none !important; }
html.force-landscape .btn-fullscreen { display: none !important; }

.tool-slots {
  display: flex;
  gap: 6px;
}
.tool-slot {
  min-width: 64px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px dashed var(--stroke);
  font-size: 0.75rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
}
.tool-slot.filled {
  border-style: solid;
  background: rgba(61, 232, 255, 0.12);
  color: var(--cyan);
  font-weight: 700;
}
.tank-pips {
  display: flex;
  gap: 5px;
}
.tank-pip {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--stroke);
  background: rgba(255, 107, 138, 0.35);
}
.tank-pip.current { outline: 2px solid var(--gold); }
.tank-pip.fixed { background: rgba(93, 255, 176, 0.55); border-color: var(--ok); }

.time-gauge {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px;
  max-width: min(280px, 46%);
  padding: 5px 10px 5px 8px;
  background: rgba(4, 14, 24, 0.82);
  border: 1px solid rgba(61, 232, 255, 0.38);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.time-gauge-track {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(61, 232, 255, 0.35);
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}
.time-gauge-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6b8a 0%, #ffd56a 35%, #3de8ff 100%);
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 0.15s linear;
}
.time-gauge-fill.low {
  background: linear-gradient(90deg, #ff3d5e, #ff8a5c);
}
.time-gauge-label {
  flex-shrink: 0;
  min-width: 44px;
  text-align: right;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.mission-toast {
  position: absolute;
  left: 50%;
  top: 50px;
  transform: translateX(-50%);
  z-index: 6;
  width: max-content;
  max-width: calc(100% - 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(6, 18, 32, 0.9);
  border: 1px solid rgba(255, 213, 106, 0.55);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.2s ease;
}
.mission-toast.in-scene {
  border-color: rgba(61, 232, 255, 0.5);
}
.mission-toast.dim {
  opacity: 0.25;
  transform: translateX(-50%) scale(0.98);
}
.mission-text {
  font-weight: 800;
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  line-height: 1.35;
  color: #fff;
  text-align: center;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-width: min(640px, 92vw);
}

.canvas-section { margin-bottom: 8px; }
.canvas-wrapper.world-wrap {
  position: relative;
  width: min(100%, calc((100dvh - var(--chrome-h, 200px)) * 960 / 520));
  margin-inline: auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: #0a1a24;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 520;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.scene-chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  z-index: 8;
}
.scene-chrome-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  pointer-events: auto;
}
.btn-scene {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(6, 22, 36, 0.92);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-scene:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-scene-primary {
  background: linear-gradient(135deg, #1ec8e0, #0a8fb8);
  border-color: transparent;
  color: #031018;
  font-family: var(--font-display);
  font-weight: 800;
}

.side-panel {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(280px, calc(100% - 24px));
  background: rgba(6, 22, 36, 0.94);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 14px;
  z-index: 5;
  backdrop-filter: blur(8px);
}
.side-panel h3 {
  font-family: var(--font-display);
  color: var(--cyan);
  margin-bottom: 6px;
  font-size: 1rem;
}
.side-panel-hint {
  font-size: 0.8rem;
  color: var(--ink-dim);
  margin-bottom: 12px;
  line-height: 1.4;
}
.pick-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.pick-btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(61, 232, 255, 0.08);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}
.pick-btn:hover { background: rgba(61, 232, 255, 0.18); }
.pick-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.app-footer {
  text-align: center;
  margin-top: 16px;
}
.privacy-link {
  color: var(--ink-dim);
  font-size: 0.75rem;
  text-decoration: none;
}
.privacy-link:hover { color: var(--cyan); }

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 8, 14, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(520px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: linear-gradient(165deg, #0c2438 0%, #081828 100%);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.btn-modal-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(61, 232, 255, 0.1);
  color: var(--ink);
  font-weight: 800;
  font-family: var(--font-display);
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
}
.btn-modal-action.btn-primary {
  background: linear-gradient(135deg, #1ec8e0, #0a8fb8);
  border-color: transparent;
  color: #031018;
}
.btn-modal-action.btn-secondary {
  background: transparent;
}

.profile-card .opening-banner { text-align: center; margin-bottom: 14px; }
.opening-subtitle {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 6px;
}
.opening-banner h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--cyan);
  margin-bottom: 12px;
}

.champ-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 12px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 213, 106, 0.55);
  background: linear-gradient(135deg, rgba(255, 213, 106, 0.18), rgba(61, 232, 255, 0.08));
  text-align: left;
}
.champ-trophy { font-size: 1.8rem; }
.champ-info { flex: 1; min-width: 0; }
.champ-name {
  display: block;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
}
.champ-id {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-dim);
  margin-top: 2px;
}
.champ-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--gold);
  white-space: nowrap;
}
.champ-score small {
  font-size: 0.7rem;
  margin-left: 2px;
  color: var(--ink-dim);
}

.btn-toggle-opening-leaderboard {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 10px;
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(61, 232, 255, 0.08);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.opening-leaderboard-box {
  max-width: 360px;
  margin: 0 auto 12px;
  text-align: left;
}
.opening-leaderboard-box.hidden { display: none; }

.game-guide-box.short-banner {
  max-width: 360px;
  margin: 0 auto 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(61, 232, 255, 0.28);
  background: rgba(8, 28, 48, 0.65);
  text-align: center;
}
.game-guide-box .guide-title {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--cyan);
  margin-bottom: 4px;
}
.game-guide-box .guide-desc {
  font-size: 0.88rem;
  color: var(--ink-dim);
  line-height: 1.4;
}

.profile-lead {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-dim);
  text-align: center;
}
.profile-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--ink-dim);
}
.profile-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 1rem;
}
.profile-err {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fda4af;
}
body.mode-dorms #label-student-id,
body.mode-dorms #display-profile-id,
body.mode-dorms #result-locked-id-wrap,
body.mode-dorms #th-leaderboard-id,
body.mode-dorms #th-opening-id,
body.mode-dorms #opening-champ-id {
  display: none !important;
}

.quiz-header, .result-header, .gameover-header { text-align: center; margin-bottom: 12px; }
.quiz-header h2, .result-header h2, .gameover-header h2 {
  font-family: var(--font-display);
  color: var(--cyan);
}
.quiz-prompt { text-align: center; margin-bottom: 12px; color: var(--ink-dim); }
.quiz-choices { display: flex; flex-direction: column; gap: 8px; }
.quiz-choice {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(61, 232, 255, 0.08);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.quiz-feedback { text-align: center; margin-top: 10px; min-height: 1.2em; font-weight: 700; }

.hinge-angle-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 4px;
}
.hinge-angle-field input {
  width: 7.5rem;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(6, 22, 36, 0.9);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
}
.hinge-angle-unit {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--gold);
}
.hinge-angle-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}
.hinge-angle-actions .btn-modal-action {
  min-width: 7rem;
}

.assemble-fail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.assemble-fail-actions .btn-modal-action {
  width: 100%;
}

.result-score-badge {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 8px;
}
.result-subtitle, .result-hint {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 6px;
}

.final-score-display { text-align: center; margin-bottom: 14px; }
.score-circle {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 12px;
}
.score-num {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  color: var(--gold);
}
.round-scores-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  font-size: 0.75rem;
}
.round-score-cell {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 6px 4px;
  border: 1px solid var(--stroke);
}
.highscore-banner {
  text-align: center;
  color: var(--gold);
  font-weight: 800;
  margin-bottom: 10px;
}
.send-action-box { margin-bottom: 14px; }
.result-locked-player-box {
  font-size: 0.85rem;
  color: var(--ink-dim);
  text-align: center;
  margin-bottom: 8px;
}
.api-status-msg { text-align: center; font-size: 0.8rem; margin-top: 6px; min-height: 1.2em; }
.leaderboard-section h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--cyan);
}
.leaderboard-table-wrapper { overflow: auto; max-height: 200px; margin-bottom: 12px; }
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.leaderboard-table th, .leaderboard-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(61, 232, 255, 0.15);
  text-align: left;
}

@keyframes lb-skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.lb-skeleton-row td {
  vertical-align: middle;
}

.lb-skeleton-bar {
  display: block;
  height: 0.85em;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(61, 232, 255, 0.12) 25%,
    rgba(61, 232, 255, 0.28) 37%,
    rgba(61, 232, 255, 0.12) 63%
  );
  background-size: 400% 100%;
  animation: lb-skeleton-shimmer 1.15s ease-in-out infinite;
}

.lb-skeleton-bar.w-xs { width: 22%; }
.lb-skeleton-bar.w-sm { width: 36%; }
.lb-skeleton-bar.w-md { width: 58%; }
.lb-skeleton-bar.w-lg { width: 44%; }

.champ-name .lb-skeleton-bar,
.champ-id .lb-skeleton-bar,
.champ-score .lb-skeleton-bar {
  margin: 0.15em 0;
}
.gameover-actions { display: flex; flex-direction: column; gap: 4px; }
.gameover-subtitle { color: var(--ink-dim); font-size: 0.85rem; }

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.intro-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}
.intro-chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}
.intro-alert {
  align-self: flex-start;
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--danger);
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  text-shadow: 0 0 12px rgba(255, 107, 138, 0.6);
}
.intro-alert.success-alert {
  color: #5dffb0;
  text-shadow: 0 0 12px rgba(93, 255, 176, 0.55);
}
.intro-alert.timeout-alert {
  color: #7ec8ff;
  text-shadow: 0 0 12px rgba(126, 200, 255, 0.55);
}
.btn-skip-intro {
  pointer-events: auto;
  align-self: flex-end;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.measure-ref-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 10, 20, 0.72);
  padding: 16px;
}
.measure-ref-overlay.hidden { display: none; }
.measure-ref-card {
  background: rgba(8, 24, 40, 0.96);
  border: 1px solid rgba(61, 232, 255, 0.35);
  border-radius: 14px;
  padding: 14px 16px 12px;
  max-width: 100%;
}
.measure-ref-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.measure-ref-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--cyan);
}
.measure-ref-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--ink-dim);
  text-align: center;
}
#measure-ref-canvas {
  display: block;
  width: min(560px, 92vw);
  height: auto;
  border-radius: 10px;
  background: #061420;
}

@media (max-width: 720px) {
  .scene-chrome-actions { flex-wrap: wrap; }
  .round-scores-grid { grid-template-columns: repeat(3, 1fr); }
  .game-container { padding: 6px 8px 12px; }
}

/* Portrait phones/tablets: block play until landscape (JS toggles .needs-landscape). */
.rotate-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse 70% 50% at 50% 40%, rgba(61, 232, 255, 0.14), transparent 60%),
    rgba(2, 8, 14, 0.94);
  backdrop-filter: blur(6px);
}
.rotate-gate.hidden { display: none !important; }
.rotate-gate-card {
  text-align: center;
  max-width: 280px;
  pointer-events: auto;
}
#btn-rotate-lock {
  margin-top: 14px;
  touch-action: manipulation;
}
.rotate-phone {
  width: 46px;
  height: 76px;
  margin: 0 auto 18px;
  border: 3px solid var(--cyan);
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(61, 232, 255, 0.25);
  position: relative;
  animation: rotate-phone-hint 1.7s ease-in-out infinite;
}
.rotate-phone::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: rgba(61, 232, 255, 0.7);
  transform: translateX(-50%);
}
@keyframes rotate-phone-hint {
  0%, 18% { transform: rotate(0deg); }
  42%, 62% { transform: rotate(90deg); }
  86%, 100% { transform: rotate(0deg); }
}
.rotate-gate-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: #fff;
  margin-bottom: 8px;
}
.rotate-gate-desc {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink-dim);
}
body.needs-landscape {
  overflow: hidden;
}

/* Mobile/tablet landscape: viewport contain fullscreen (keep 960:520). */
body.hud-overlay-mobile {
  overflow: hidden;
  width: 100%;
  height: 100dvh;
  overscroll-behavior: none;
}
body.hud-overlay-mobile .game-header {
  display: none;
}
body.hud-overlay-mobile .app-footer {
  display: none;
}
body.hud-overlay-mobile .game-container {
  max-width: none;
  width: 100%;
  height: 100dvh;
  margin: 0;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
body.hud-overlay-mobile .game-main,
body.hud-overlay-mobile .canvas-section {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.hud-overlay-mobile .canvas-wrapper.world-wrap {
  width: min(
    100%,
    calc((100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 960 / 520)
  );
  max-width: 100%;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  height: auto;
  aspect-ratio: 960 / 520;
  margin: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
body.hud-overlay-mobile #game-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 520;
}
body.hud-overlay-mobile .play-hud-slot {
  display: block;
  position: absolute;
  left: max(8px, env(safe-area-inset-left, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  z-index: 7;
  pointer-events: none;
}
body.hud-overlay-mobile .play-hud {
  pointer-events: auto;
  width: 100%;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(4, 14, 24, 0.82);
  border: 1px solid rgba(61, 232, 255, 0.35);
  backdrop-filter: blur(6px);
}
body.hud-overlay-mobile .tool-slot {
  min-width: 52px;
  padding: 4px 6px;
  font-size: 0.7rem;
}
body.hud-overlay-mobile .mission-toast {
  top: max(48px, calc(env(safe-area-inset-top, 0px) + 42px));
  padding: 7px 14px;
}
body.hud-overlay-mobile .mission-text {
  font-size: clamp(0.92rem, 2.8vw, 1.08rem);
  max-width: min(620px, 90vw);
}
body.hud-overlay-mobile .time-gauge {
  top: max(8px, env(safe-area-inset-top, 0px));
  width: 240px;
  max-width: min(240px, 42%);
  padding: 3px 8px 3px 6px;
}
body.hud-overlay-mobile .time-gauge-track {
  height: 10px;
}
body.hud-overlay-mobile .time-gauge-label {
  font-size: 0.85rem;
  min-width: 40px;
}
body.hud-overlay-mobile .scene-chrome {
  padding:
    12px
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
}
body.hud-overlay-mobile .scene-chrome-actions {
  margin-bottom: 52px;
}
