:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --ink: #111827;
  --subtle: #475569;
  --line: #cbd5e1;
  --active: #1f9d8a;
  --active-dark: #137466;
  --warn: #d86f45;
  --gold: #eab308;
  --ok: #28784f;
  --error: #b42318;
  --panel: #f8fafc;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  min-width: 82px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.trainer-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 22px;
}

.workbench {
  display: grid;
  grid-template-rows: auto 1fr;
  height: calc(100vh - 44px);
  min-height: calc(100vh - 44px);
  height: calc(100dvh - 44px);
  min-height: calc(100dvh - 44px);
  max-width: 1500px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-block {
  min-width: 210px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid rgba(15, 118, 110, 0.32);
  border-radius: 999px;
  background: #ccfbf1;
  color: #115e59;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.setup-button {
  display: grid;
  min-width: 210px;
  height: 46px;
  padding: 5px 14px;
  text-align: left;
}

.setup-button span:first-child {
  font-size: 15px;
  line-height: 1.1;
}

.setup-button span:last-child {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.toolbar {
  display: grid;
  gap: 12px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.procedure-switch .mode-button {
  min-width: 112px;
}

.weapon-switch {
  grid-template-columns: repeat(7, 1fr);
}

.mode-button {
  min-width: 82px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.mode-button.active {
  background: #0f766e;
  color: #ffffff;
}

.hint-lock {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #1f2937;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.hint-lock input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #0f766e;
}

.hint-lock.disabled {
  opacity: 0.45;
}

.setup-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.setup-sheet[hidden] {
  display: none;
}

.setup-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: auto;
  height: auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: default;
}

.setup-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.setup-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.setup-panel-header h2 {
  margin: 0;
}

.setup-panel-header .eyebrow {
  margin-bottom: 2px;
}

.setup-panel-header button {
  min-width: 76px;
}

.setup-selects {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.setup-selects label {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.setup-selects select {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 850;
}

.setup-selects select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
  border-color: #0f766e;
}

.setup-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.setup-toolbar .mode-switch {
  display: none;
}

.stage-row {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 0;
}

.sequence-panel {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  min-height: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
}

.step-counter {
  width: fit-content;
  margin-bottom: 14px;
  padding: 5px 9px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

h2 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.2;
}

#stepText {
  min-height: 52px;
  margin: 0 0 10px;
  color: #334155;
  font-size: 16px;
  line-height: 1.45;
}

.feedback {
  min-height: 44px;
  margin: 0 0 16px;
  padding: 10px 11px;
  border-left: 4px solid #94a3b8;
  background: #ffffff;
  color: #334155;
  font-size: 14px;
  line-height: 1.35;
}

.feedback.ok {
  border-left-color: var(--ok);
  color: var(--ok);
}

.feedback.error {
  border-left-color: var(--error);
  color: var(--error);
}

.feedback.hint {
  border-left-color: var(--gold);
  color: #7c5a00;
}

.progress-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.progress-step {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #475569;
  font-size: 13px;
  line-height: 1.25;
}

.progress-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.progress-step.current {
  border-color: #7dd3c7;
  background: #ecfdf9;
  color: #134e4a;
  font-weight: 800;
}

.progress-step.done {
  color: #166534;
}

.progress-step.done .progress-index {
  background: #bbf7d0;
  color: #14532d;
}

.weapon-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(#dfe6ee 1px, transparent 1px),
    linear-gradient(90deg, #dfe6ee 1px, transparent 1px);
  background-color: #eef2f5;
  background-size: 28px 28px;
}

.mobile-quick-controls {
  display: none;
}

.weapon-view-switch {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 9;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.78);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.16);
}

.weapon-view-switch[hidden] {
  display: none;
}

.view-button {
  min-width: 72px;
  height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
}

.view-button.active {
  background: #0f766e;
  color: #ffffff;
}

.model-rotation-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: min(360px, calc(100% - 24px));
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.2);
}

.model-rotation-controls[hidden] {
  display: none;
}

.model-rotation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  flex-wrap: wrap;
}

.model-rotation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}

.model-rotation-actions button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.model-rotation-controls output {
  display: none;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  overflow-x: auto;
  white-space: nowrap;
}

.model-rotation-controls.unlocked {
  border-color: rgba(15, 118, 110, 0.72);
  background: rgba(240, 253, 250, 0.94);
}

.m2-model-debug-picker {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 14;
  display: grid;
  gap: 6px;
  width: min(360px, calc(100% - 24px));
  padding: 10px;
  border: 1px solid rgba(20, 184, 166, 0.8);
  border-radius: 8px;
  background: rgba(240, 253, 250, 0.96);
  color: #0f172a;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.22);
}

.m2-model-debug-picker strong {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.m2-model-debug-picker span {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.m2-model-debug-output {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  padding: 8px;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
}

body:not(.debug-enabled) .m2-model-debug-picker {
  display: none !important;
}

.weapon-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 560px;
  padding: 16px;
  user-select: none;
  touch-action: none;
}

.weapon-stage.model-stage {
  align-items: stretch;
  padding: 16px;
  touch-action: auto;
}

.loading {
  color: var(--subtle);
  font-weight: 800;
}

.weapon-stage svg {
  display: block;
  width: min(100%, 1120px);
  height: auto;
  max-height: calc(100vh - 190px);
  max-height: calc(100dvh - 190px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.m2-model-viewer {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: min(100%, 1120px);
  max-height: calc(100vh - 190px);
  max-height: calc(100dvh - 190px);
  border: 1px solid rgba(71, 85, 105, 0.8);
  border-radius: 8px;
  overflow: hidden;
  background: #101311;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 16px 36px rgba(15, 23, 42, 0.26);
}

.m2-model-frame {
  position: relative;
  min-height: 430px;
  background:
    linear-gradient(180deg, rgba(35, 42, 38, 0.92) 0%, rgba(15, 18, 16, 0.96) 58%, #090b0a 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 34px);
  background-color: #0d100e;
  isolation: isolate;
}

.m2-model-frame::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 16%, transparent 82%, rgba(0, 0, 0, 0.22)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 30%, rgba(0, 0, 0, 0.38));
  content: "";
  pointer-events: none;
}

.m2-model-frame::after {
  position: absolute;
  right: 8%;
  bottom: 7%;
  left: 8%;
  z-index: 0;
  height: 18%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.36);
  filter: blur(18px);
  content: "";
  pointer-events: none;
}

.weapon-stage[data-weapon="m320"] .m2-model-viewer {
  border-color: rgba(148, 163, 184, 0.85);
  background: #e8eef2;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 16px 36px rgba(15, 23, 42, 0.18);
}

.weapon-stage[data-weapon="m320"] .m2-model-frame {
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(226, 232, 240, 0.94) 100%),
    repeating-linear-gradient(0deg, rgba(148, 163, 184, 0.18) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(148, 163, 184, 0.16) 0 1px, transparent 1px 34px);
  background-color: #e8eef2;
}

.weapon-stage[data-weapon="m320"] .m2-model-frame::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.32), transparent 22%, transparent 78%, rgba(100, 116, 139, 0.12)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 58%, rgba(100, 116, 139, 0.14));
}

.weapon-stage[data-weapon="m320"] .m2-model-frame::after {
  background: rgba(71, 85, 105, 0.18);
}

.m2-model-viewer.rotation-unlocked .m2-model-frame {
  cursor: grab;
}

.m2-model-viewer.rotation-unlocked .m2-model-frame.rotating {
  cursor: grabbing;
}

.m2-model-hit-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.m2-model-proxy-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.m2-model-muzzle-flash {
  position: absolute;
  z-index: 3;
  width: 0;
  height: 0;
  pointer-events: none;
}

.m2-model-muzzle-flash::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 92px;
  height: 58px;
  opacity: 0;
  transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(0.7);
  transform-origin: 0 50%;
  clip-path: polygon(0 40%, 9% 28%, 22% 18%, 42% 30%, 100% 50%, 42% 70%, 22% 82%, 9% 72%, 0 60%);
  background:
    radial-gradient(ellipse at 3% 50%, #ffffff 0 13%, rgba(253, 230, 138, 0.92) 18%, transparent 32%),
    radial-gradient(circle at 26% 50%, #ffffff 0 13%, transparent 31%),
    radial-gradient(circle at 47% 50%, #fde68a 0 24%, transparent 54%),
    radial-gradient(circle at 68% 50%, #f97316 0 20%, transparent 62%);
  content: "";
  filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.82));
}

.m2-model-viewer.rotation-unlocked .m2-model-hit,
.m2-model-viewer.rotation-unlocked .m2-model-proxy-control {
  pointer-events: none;
}

.m2-model-muzzle-flash.visible::before {
  animation: m2MuzzleFlash 150ms ease-out;
}

.m2-model-hit {
  position: absolute;
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.001);
  box-shadow: none;
  pointer-events: auto;
}

.m2-model-proxy-control {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.48);
  border-radius: 999px;
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.18), transparent 0 34%),
    var(--proxy-color, #8a9698);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.12),
    0 1px 2px rgba(15, 23, 42, 0.24);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  pointer-events: auto;
}

.m2-model-proxy-control.proxy-state-safe {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.9);
}

.m2-model-proxy-control.proxy-state-fire {
  color: #ef4444;
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.9);
}

.m2-model-proxy-control.proxy-hidden-visual {
  border: 0;
  background: rgba(20, 184, 166, 0.001);
  box-shadow: none;
  color: transparent;
  text-shadow: none;
}

.m2-model-proxy-control:hover,
.m2-model-proxy-control:focus-visible,
.m2-model-proxy-control.current-target {
  outline: 2px solid rgba(20, 184, 166, 0.72);
  outline-offset: 2px;
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.18),
    0 0 0 4px rgba(20, 184, 166, 0.18),
    0 1px 2px rgba(15, 23, 42, 0.24);
}

.m2-model-hit:hover,
.m2-model-hit:focus-visible,
.m2-model-hit.current-target {
  outline: 2px solid rgba(20, 184, 166, 0.72);
  outline-offset: 2px;
  background: rgba(20, 184, 166, 0.1);
}

.m2-model-viewer.visual-hotspots-off .m2-model-hit,
.m2-model-viewer.visual-hotspots-off .m2-model-hit:hover,
.m2-model-viewer.visual-hotspots-off .m2-model-hit:focus-visible,
.m2-model-viewer.visual-hotspots-off .m2-model-hit.current-target {
  outline: 0;
  background: rgba(20, 184, 166, 0.001);
  box-shadow: none;
}

.m2-model-viewer.visual-hotspots-off .m2-model-hit.current-target {
  outline: 2px solid rgba(249, 115, 22, 0.95);
  outline-offset: 2px;
  border-radius: 6px !important;
  clip-path: none !important;
  background: rgba(249, 115, 22, 0.14);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.18);
}

.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual,
.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual:hover,
.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual:focus-visible,
.m2-model-viewer.visual-hotspots-off .m2-model-proxy-control.proxy-hidden-visual.current-target {
  outline: 0;
  box-shadow: none;
}

.m2-model-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 430px;
}

.m2-model-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(17, 19, 17, 0.82);
  color: #e5e7eb;
  font-weight: 900;
}

.m2-model-loading[hidden] {
  display: none;
}

@keyframes m2MuzzleFlash {
  0% {
    opacity: 0;
    transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(0.45);
  }

  35% {
    opacity: 1;
    transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) rotate(var(--muzzle-flash-angle, 0rad)) scale(1.2);
  }
}

.weapon-stage svg #labels,
.weapon-stage svg #legend {
  display: none;
}

.weapon-stage svg .hit {
  fill: rgba(0, 0, 0, 0.001);
  opacity: 1;
  stroke: transparent;
  cursor: pointer;
  touch-action: none;
}

.weapon-stage svg .hit.current-target {
  opacity: 1;
  stroke: transparent;
}

.weapon-stage svg .active-part {
  filter: drop-shadow(0 0 9px rgba(216, 111, 69, 0.85));
}

.weapon-stage svg .inspected {
  filter: drop-shadow(0 0 7px rgba(40, 120, 79, 0.72));
}

.weapon-stage svg .training-part.active-part .photo-outline {
  fill: rgba(216, 111, 69, 0.22);
  stroke: rgba(216, 111, 69, 0.92);
}

.weapon-stage svg .training-part.active-part .photo-detail {
  stroke: rgba(216, 111, 69, 0.95);
}

.weapon-stage svg .training-part.inspected .photo-outline {
  fill: rgba(40, 120, 79, 0.2);
  stroke: rgba(40, 120, 79, 0.82);
}

.weapon-stage svg .training-part.inspected .photo-detail {
  stroke: rgba(40, 120, 79, 0.9);
}

.weapon-stage svg .training-part.tap-confirm {
  animation: confirmPulse 520ms ease-out;
  filter: drop-shadow(0 0 12px rgba(31, 157, 138, 0.9));
}

.weapon-stage svg .training-part.tap-confirm .photo-outline {
  fill: rgba(31, 157, 138, 0.3);
  stroke: rgba(20, 184, 166, 0.98);
}

.weapon-stage svg .training-part.tap-confirm .photo-detail {
  stroke: rgba(20, 184, 166, 0.98);
}

.weapon-stage svg .training-part.tap-confirm .open-cover-body {
  fill: rgba(31, 157, 138, 0.32);
  stroke: rgba(20, 184, 166, 0.98);
}

.weapon-stage svg .training-part.tap-confirm .open-cover-detail {
  stroke: rgba(94, 234, 212, 0.98);
}

.weapon-stage svg .wrong-target {
  animation: shake 160ms linear 2;
}

.orientation-gate {
  display: none;
}

.fullscreen-button {
  display: none;
}

.fullscreen-button[hidden] {
  display: none !important;
}

.event-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 4;
  justify-self: center;
  width: min(420px, calc(100% - 48px));
  min-height: 64px;
  margin: 22px auto 0;
  padding: 0 24px;
  border: 3px solid #0f766e;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.34);
}

.event-notice.danger {
  border-color: #b91c1c;
  background: rgba(254, 226, 226, 0.97);
  color: #7f1d1d;
}

.event-notice.empty {
  border-color: #c2410c;
  background: rgba(255, 237, 213, 0.97);
  color: #7c2d12;
}

.event-notice[hidden] {
  display: flex;
  visibility: hidden;
  opacity: 0;
  box-shadow: none;
}

.target-hold-modal {
  position: absolute;
  z-index: 7;
  top: 94px;
  left: 50%;
  width: min(360px, calc(100% - 48px));
  transform: translateX(-50%);
  pointer-events: none;
}

.target-hold-modal[hidden] {
  display: none;
}

.target-hold-panel {
  padding: 16px 18px 18px;
  border: 2px solid #0f766e;
  border-radius: 8px;
  background: rgba(240, 253, 250, 0.97);
  color: #0f172a;
  text-align: center;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.3);
}

.target-hold-label,
.target-hold-status {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.target-hold-countdown {
  margin-top: 8px;
  font-size: 48px;
  font-weight: 950;
  line-height: 1;
}

.target-hold-track {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ccfbf1;
}

.target-hold-progress {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #0f766e;
}

.target-hold-status {
  margin-top: 12px;
  color: #115e59;
}

.maintenance-action {
  position: absolute;
  z-index: 6;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  padding: 10px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: rgba(255, 247, 237, 0.96);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
}

.maintenance-action[hidden] {
  display: none;
}

.maintenance-action button {
  min-width: 154px;
  height: 54px;
  border-color: #d86f45;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 17px;
  font-weight: 900;
}

.maintenance-action button:hover {
  border-color: #c2410c;
  background: #ffedd5;
}

.orientation-panel {
  width: min(100%, 360px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
}

.orientation-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.orientation-panel p {
  margin: 0 0 16px;
  color: #334155;
  font-size: 15px;
  line-height: 1.4;
}

.rotate-mark {
  position: relative;
  width: 70px;
  height: 46px;
  margin: 0 auto 14px;
  border: 4px solid #0f766e;
  border-radius: 8px;
  transform: rotate(-14deg);
}

.rotate-mark::after {
  position: absolute;
  right: -22px;
  bottom: -14px;
  width: 24px;
  height: 24px;
  border-right: 4px solid #0f766e;
  border-bottom: 4px solid #0f766e;
  border-radius: 0 0 12px;
  content: "";
}

@keyframes confirmPulse {
  0% {
    opacity: 0.35;
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0.95;
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(-5px);
  }

  70% {
    transform: translateX(5px);
  }

  100% {
    transform: translateX(0);
  }
}

@media (max-width: 900px) {
  .trainer-shell {
    min-height: 100svh;
    min-height: 100dvh;
    padding: 0;
  }

  .workbench {
    width: 100%;
    min-height: 100svh;
    height: 100svh;
    min-height: 100dvh;
    height: 100dvh;
    grid-template-rows: 1fr;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    display: none;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px;
  }

  .eyebrow {
    margin-bottom: 1px;
    font-size: 11px;
  }

  h1 {
    font-size: 19px;
  }

  .toolbar {
    display: grid;
    width: 100%;
    gap: 7px;
  }

  .mode-switch {
    grid-column: 1 / -1;
    width: 100%;
  }

  .procedure-switch {
    grid-column: 1 / -1;
  }

  .mode-button,
  .toolbar > button,
  .hint-lock {
    width: 100%;
    min-width: 0;
    height: 42px;
  }

  .hint-lock {
    justify-content: center;
    padding: 0 8px;
    font-size: 13px;
  }

  .stage-row {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .sequence-panel {
    order: 2;
    flex: 0 0 clamp(150px, 27svh, 218px);
    flex-basis: clamp(150px, 27dvh, 218px);
    grid-template-rows: auto auto auto auto auto;
    max-height: none;
    overflow: auto;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid rgba(203, 213, 225, 0.86);
    background: rgba(248, 250, 252, 0.98);
    box-shadow: 0 -14px 30px rgba(15, 23, 42, 0.18);
  }

  .step-counter {
    margin-bottom: 6px;
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 12px;
  }

  h2 {
    margin-bottom: 5px;
    font-size: 18px;
  }

  #stepText {
    min-height: 0;
    margin-bottom: 7px;
    font-size: 14px;
    line-height: 1.3;
  }

  .feedback {
    min-height: 0;
    margin-bottom: 8px;
    padding: 8px 9px;
    border-radius: 0 7px 7px 0;
    font-size: 13px;
    line-height: 1.25;
  }

  .progress-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 3px;
  }

  .progress-step {
    grid-template-columns: 1fr;
    justify-items: center;
    flex: 0 0 42px;
    min-height: 34px;
    padding: 4px;
  }

  .progress-step > span:not(.progress-index) {
    display: none;
  }

  .progress-index {
    width: 27px;
    height: 27px;
  }

  .weapon-panel {
    order: 1;
    flex: 1 1 0;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    padding-top: 0;
    background-color: #101311;
  }

  .event-notice {
    position: absolute;
    top: calc(48px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    width: min(360px, calc(100% - 20px));
    min-height: 48px;
    margin: 0;
    padding: 0 16px;
    font-size: 22px;
  }

  .event-notice[hidden] {
    display: none;
  }

  .model-rotation-controls {
    top: calc(48px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: auto;
    max-width: min(292px, calc(100% - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    padding: 4px;
    border-radius: 7px;
  }

  .model-rotation-header {
    gap: 4px;
    margin-bottom: 0;
  }

  .model-rotation-header > span,
  .model-rotation-controls output {
    display: none;
  }

  .model-rotation-controls.unlocked {
    width: min(292px, calc(100% - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  .model-rotation-controls.unlocked output {
    display: none;
    margin-top: 4px;
    padding: 5px 7px;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
  }

  .model-rotation-actions {
    gap: 4px;
  }

  .model-rotation-actions button {
    height: 30px;
    min-width: 54px;
    padding: 0 8px;
    font-size: 12px;
  }

  #modelRotationToggleButton {
    min-width: 88px;
  }

  .target-hold-modal {
    top: 58px;
    width: min(310px, calc(100% - 20px));
  }

  .target-hold-panel {
    padding: 10px 12px 12px;
  }

  .target-hold-countdown {
    font-size: 34px;
  }

  .maintenance-action {
    top: 44%;
    right: 10px;
    padding: 7px;
  }

  .maintenance-action button {
    min-width: 128px;
    height: 46px;
    font-size: 15px;
  }

  .weapon-stage {
    justify-content: flex-start;
    min-height: 0;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 5px 6px;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .weapon-stage.model-stage {
    justify-content: center;
    overflow: hidden;
    padding: 4px;
    touch-action: none;
  }

  .weapon-stage svg {
    flex: 0 0 auto;
    width: auto;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 6px;
  }

  .m2-model-viewer {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 6px;
  }

  .m2-model-frame {
    min-height: 0;
  }

  .m2-model-canvas {
    min-height: 0;
  }

  .setup-sheet {
    align-items: end;
    justify-items: center;
    padding: 0;
  }

  .setup-panel {
    width: 100%;
    max-height: calc(88svh - env(safe-area-inset-top));
    max-height: calc(88dvh - env(safe-area-inset-top));
    overflow: auto;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    border-radius: 12px 12px 0 0;
  }

  .setup-selects {
    display: grid;
  }

  .setup-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .setup-toolbar .mode-switch {
    display: none;
  }

  .mobile-quick-controls {
    position: absolute;
    top: calc(6px + env(safe-area-inset-top));
    left: calc(6px + env(safe-area-inset-left));
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(130px, 1fr) 56px 62px;
    gap: 6px;
    max-width: calc(100% - 70px - env(safe-area-inset-left) - env(safe-area-inset-right));
    overflow-x: auto;
    padding: 4px;
    border: 1px solid rgba(148, 163, 184, 0.36);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.72);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
    -webkit-overflow-scrolling: touch;
  }

  .mobile-quick-controls button {
    width: 100%;
    min-width: 0;
    height: 36px;
    border: 1px solid rgba(203, 213, 225, 0.32);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    color: #111827;
    font: inherit;
    font-size: 12px;
    font-weight: 850;
    box-shadow: none;
  }

  .mobile-action-button {
    min-width: 0;
    align-self: end;
    background: #ccfbf1;
    color: #115e59;
  }

  .mobile-session-button {
    display: grid;
    align-content: center;
    gap: 1px;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.95) !important;
    color: #111827 !important;
    text-align: left;
  }

  .mobile-session-button span:first-child {
    overflow: hidden;
    font-size: 13px;
    font-weight: 950;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-session-button span:last-child {
    overflow: hidden;
    color: #475569;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fullscreen-button {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    z-index: 20;
    display: block;
    min-width: 56px;
    height: 34px;
    border-color: rgba(203, 213, 225, 0.38);
    background: rgba(15, 23, 42, 0.76);
    color: #ffffff;
    font-size: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(12px);
  }

}

@media (max-width: 480px) {
  .topbar .toolbar {
    grid-template-columns: 1fr 78px 78px;
  }

  .setup-toolbar {
    grid-template-columns: 1fr;
  }

  .hint-lock span {
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sequence-panel {
    flex-basis: clamp(144px, 27svh, 204px);
    flex-basis: clamp(144px, 27dvh, 204px);
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  body {
    overflow: hidden;
  }

  .workbench {
    pointer-events: auto;
  }

  .mobile-quick-controls {
    right: calc(70px + env(safe-area-inset-right));
    max-width: none;
  }

  .mobile-quick-controls button {
    min-width: 0;
    padding: 0 6px;
  }

  .orientation-gate {
    display: none;
  }
}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) {
  .workbench {
    grid-template-rows: 1fr;
  }

  .weapon-panel {
    padding-top: 0;
  }

  .topbar {
    display: none;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 4px 8px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    width: max-content;
    font-size: 15px;
  }

  .toolbar {
    gap: 6px;
  }

  .mode-switch {
    grid-column: auto;
  }

  .mode-button,
  .toolbar > button,
  .hint-lock {
    height: 32px;
    font-size: 13px;
  }

  .stage-row {
    height: 100svh;
    height: 100dvh;
  }

  .weapon-stage {
    align-items: center;
    padding: 4px 6px;
  }

  .event-notice {
    width: min(340px, calc(100% - 18px));
    min-height: 38px;
    margin-top: 4px;
    padding: 0 14px;
    font-size: 18px;
  }

  .weapon-stage svg {
    width: 100%;
    height: auto;
  }

  .sequence-panel {
    flex: 0 0 64px;
    grid-template-columns: 74px minmax(160px, 1fr) minmax(220px, 1.35fr);
    grid-template-rows: auto 1fr;
    gap: 4px 8px;
    height: 64px;
    max-height: none;
    overflow: hidden;
    padding: 4px 7px;
  }

  .fullscreen-button {
    min-width: 78px;
    height: 30px;
    font-size: 12px;
  }

  .mobile-quick-controls {
    top: calc(5px + env(safe-area-inset-top));
    left: calc(5px + env(safe-area-inset-left));
    grid-template-columns: minmax(150px, 1fr) 54px 60px;
    gap: 4px;
    padding: 3px;
    max-width: calc(100% - 86px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .mobile-quick-controls button {
    min-width: 0;
    height: 28px;
    font-size: 12px;
  }

  .weapon-view-switch {
    top: 44px;
    right: 7px;
  }

  .model-rotation-controls {
    top: calc(40px + env(safe-area-inset-top));
    right: calc(6px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
  }

  .view-button {
    min-width: 58px;
    height: 30px;
    font-size: 12px;
  }

  .step-counter,
  #stepText,
  .feedback {
    margin-bottom: 0;
  }

  .step-counter {
    grid-row: 1 / 3;
    padding: 4px 6px;
  }

  h2 {
    grid-column: 2;
    font-size: 14px;
  }

  #stepText {
    grid-column: 2;
    overflow: hidden;
    font-size: 10.5px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  .feedback {
    grid-column: 3;
    grid-row: 1;
    height: 24px;
    min-height: 0;
    padding: 5px 8px;
    overflow: hidden;
    font-size: 10.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .progress-list {
    grid-column: 3;
    grid-row: 2;
    align-self: end;
    min-height: 0;
  }

  .progress-step {
    flex-basis: 30px;
    min-height: 25px;
    padding: 2px;
  }

  .progress-index {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
}
