:root {
  --shell-bg-top: #d4d4d4;
  --shell-bg-bottom: #b9b9b9;
  --shell-border: #2e2e2e;
  --screen-black: #050505;
  --screen-border: #3f3f3f;
  --frame-dark: #404040;
  --frame-light: #5f5f5f;
  --green: #74ff5c;
  --red: #ff3d3d;
  --cyan: #3dcfff;
  --magenta: #ff30b7;
  --yellow: #ffe623;
  --status-gray: #9b9b9b;
  --btn-font-xs: clamp(7px, 0.72vw, 9px);
  --btn-font-sm: clamp(9px, 0.95vw, 11px);
  --btn-font-md: clamp(10px, 1.05vw, 12px);
  --btn-font-lg: clamp(11px, 1.18vw, 13px);
  --control-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #0a0a0a;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  line-height: 1.05;
}

.app-shell {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 24px;
}

.device-shell {
  position: relative;
  width: min(980px, 100%);
  padding: 16px 14px 18px;
  border: 2px solid var(--shell-border);
  border-bottom-width: 6px;
  border-radius: 28px 28px 18px 18px;
  background: linear-gradient(180deg, var(--shell-bg-top) 0%, var(--shell-bg-bottom) 100%);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.device-shell::after {
  content: "";
  position: absolute;
  inset: auto -2px -6px;
  height: 16px;
  background: linear-gradient(180deg, #1646a7 0%, #0b2f72 100%);
  border-radius: 0 0 14px 14px;
}

.device-brand {
  margin-bottom: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.65);
  user-select: none;
}

.device-main {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 82px;
  gap: 12px;
  align-items: start;
}

.device-side {
  display: grid;
  justify-items: center;
  align-content: start;
}

.left-rail {
  gap: 10px;
  padding-top: 28px;
}

.rail-button {
  width: 30px;
  min-height: 26px;
  border: 1px solid #b7b7b7;
  border-radius: 6px;
  background: linear-gradient(180deg, #dcdcdc 0%, #c2c2c2 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24);
  color: #4b4b4b;
  font-size: 8px;
  line-height: 1.05;
  font-weight: 700;
  padding: 2px;
  text-align: center;
}

.rail-button.decorative {
  cursor: default;
}

.rail-button.blank {
  color: transparent;
}

.rail-button.rail-toggle.toggled {
  background: linear-gradient(180deg, #fff3aa 0%, #efd151 100%);
  color: #473800;
}

.rail-status-row {
  margin-top: 8px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.rail-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 8px currentColor;
}

.rail-led.green {
  color: #c7ff58;
  background: currentColor;
}

.rail-led.yellow {
  color: #ffd94c;
  background: currentColor;
}

.screen-bezel {
  padding: 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--frame-light) 0%, var(--frame-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 16px rgba(0, 0, 0, 0.24);
}

.monitor-screen {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #010101;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.screen-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 8px;
  min-height: 30px;
  background: #070707;
  border-bottom: 1px solid #1d1d1d;
  font-size: 12px;
}

.topbar-left {
  border-radius: 2px;
  padding: 2px 6px;
  background: linear-gradient(180deg, #106ed3 0%, #0a55af 100%);
  color: #eaf6ff;
  font-weight: 700;
}

.topbar-center {
  color: #ececec;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.battery-pill {
  padding: 2px 8px;
  border-radius: 2px;
  background: #99d96a;
  color: #fff;
}

.session-timer {
  font-size: 13px;
  color: #f8f8f8;
}

.screen-body {
  background: #050505;
}

.wave-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 120px;
  min-height: 82px;
  border-bottom: 1px solid #1a1a1a;
  transition: opacity 0.18s ease;
}

.wave-row:last-child {
  border-bottom: none;
}

.wave-row.channel-off {
  opacity: 0.52;
}

.wave-labels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  padding: 6px 4px 4px 6px;
  font-size: 11px;
  line-height: 1.1;
}

.channel-badge {
  min-width: 32px;
  padding: 3px 4px;
  border-radius: 2px;
  border: 1px solid #838383;
  background: #080808;
  color: #fff;
  font-weight: 700;
  text-align: left;
}

.channel-badge.red {
  color: var(--red);
  border-color: rgba(255, 61, 61, 0.5);
}

.channel-badge.gray {
  color: #eeeeee;
  border-color: rgba(220, 220, 220, 0.5);
}

.channel-badge.yellow {
  color: var(--yellow);
  border-color: rgba(255, 230, 35, 0.55);
}

.channel-badge.sync-flag {
  color: var(--yellow);
  border-color: rgba(255, 230, 35, 0.65);
}

.wave-caption {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.wave-caption.green {
  color: var(--green);
}

.wave-caption.red {
  color: var(--red);
}

.wave-caption.magenta {
  color: var(--magenta);
}

.wave-caption.yellow {
  color: var(--yellow);
}

.wave-caption.dim {
  color: #8a8a8a;
  font-weight: 400;
}

.wave-canvas-wrap {
  position: relative;
  padding: 4px 0;
}

.wave-canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 4px 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 39px,
      rgba(255, 255, 255, 0.04) 39px,
      rgba(255, 255, 255, 0.04) 40px
    ),
    repeating-linear-gradient(
      180deg,
      transparent 0,
      transparent 17px,
      rgba(255, 255, 255, 0.03) 17px,
      rgba(255, 255, 255, 0.03) 18px
    );
  pointer-events: none;
}

canvas {
  display: block;
  width: 100%;
  height: 72px;
  background: transparent;
}

.metric-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  padding: 6px 8px 6px 4px;
  border-left: 1px solid #1d1d1d;
}

.metric-title,
.metric-sub,
.metric-value,
.footer-label,
.footer-status {
  font-weight: 700;
}

.metric-title {
  font-size: 12px;
}

.unit {
  font-size: 10px;
  font-weight: 700;
}

.metric-value {
  font-size: 30px;
  line-height: 0.95;
}

.metric-value.compact {
  font-size: 22px;
}

.metric-sub {
  font-size: 12px;
}

.metric-split {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.pacer-readout {
  width: 100%;
  margin-top: 6px;
  padding: 5px 6px 4px;
  border: 1px solid rgba(255, 245, 150, 0.55);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff59b;
  font-size: 10px;
  line-height: 1.12;
  text-align: right;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.pacer-readout.capture {
  color: #f5fff6;
  border-color: rgba(240, 255, 240, 0.62);
}

.pacer-readout.nocapture {
  color: #fff59b;
}

.pacer-line {
  display: block;
  white-space: nowrap;
}

.green,
.green-panel {
  color: var(--green);
}

.cyan,
.cyan-panel {
  color: var(--cyan);
}

.magenta,
.magenta-panel {
  color: var(--magenta);
}

.yellow,
.yellow-panel {
  color: var(--yellow);
}

.metric-panel.metric-off,
.metric-panel.metric-off *,
.footer-tile.channel-off,
.footer-tile.channel-off * {
  color: #858585 !important;
}

.pleth-rating {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 2px;
  font-size: 10px;
  color: #ffe56a;
}

.pleth-label,
.pleth-score {
  font-weight: 700;
}

.pleth-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
}

.pleth-bars span {
  width: 5px;
  border-radius: 2px 2px 0 0;
  background: rgba(255, 230, 35, 0.2);
}

.pleth-bars span:nth-child(1) { height: 6px; }
.pleth-bars span:nth-child(2) { height: 10px; }
.pleth-bars span:nth-child(3) { height: 14px; }
.pleth-bars span:nth-child(4) { height: 18px; }
.pleth-bars span:nth-child(5) { height: 22px; }

.pleth-bars span.active {
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(255, 230, 35, 0.45);
}

.screen-footer {
  display: grid;
  grid-template-columns: 112px 64px 64px 1fr 118px 118px;
  gap: 1px;
  border-top: 1px solid #1a1a1a;
  background: #101010;
}

.footer-tile,
.footer-status {
  min-height: 50px;
}

.footer-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  background: #020202;
  color: #fff;
  font-size: 12px;
}

.footer-tile.channel-off {
  opacity: 0.5;
}

.footer-art-tile {
  align-items: flex-start;
  padding-left: 4px;
}

.footer-art-tile strong {
  font-size: 18px;
  line-height: 1;
  color: var(--red);
}

.footer-art-tile small {
  color: var(--red);
}

.footer-label.red {
  color: var(--red);
}

.cyan-tile {
  background: linear-gradient(180deg, #1cc5ff 0%, #08a8ea 100%);
  color: #00121b;
  font-weight: 700;
}

.cyan-tile span {
  font-size: 10px;
}

.temp-tile {
  align-items: flex-start;
  padding-left: 12px;
  color: #f1f1f1;
}

.temp-tile strong {
  font-size: 18px;
}

.footer-status {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #040404;
  color: var(--status-gray);
  font-size: 12px;
  letter-spacing: 0.9px;
  text-align: center;
  padding: 0 8px;
}

.footer-status.charge {
  color: #efefef;
}

.footer-status.charge.ready {
  background: rgba(121, 67, 0, 0.45);
  color: #ffe579;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 108, 0.3);
}

.right-rail {
  gap: 8px;
  padding-top: 8px;
}

.standby-block,
.side-control,
.icon-button {
  width: 62px;
  border-radius: 10px;
  border: 1px solid rgba(110, 110, 110, 0.7);
  background: linear-gradient(180deg, #ededed 0%, #d4d4d4 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
  color: #555;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.standby-block {
  min-height: 48px;
  padding: 6px 5px;
  font-size: var(--btn-font-xs);
  letter-spacing: 0.2px;
}

.standby-block.toggled {
  background: linear-gradient(180deg, #ffe2a5 0%, #ebb259 100%);
  color: #543200;
}

.side-control,
.icon-button {
  min-height: 38px;
  padding: 6px 3px;
  font-size: var(--btn-font-xs);
  letter-spacing: 0.2px;
}

.side-control.toggled,
.icon-button.toggled {
  background: linear-gradient(180deg, #fff0a5 0%, #f0d24d 100%);
  color: #493b00;
}

.freeze-button {
  flex-direction: column;
  gap: 1px;
}

.freeze-icon {
  font-size: 15px;
  line-height: 1;
}

.freeze-label {
  font-size: 8px;
  letter-spacing: 0.25px;
}

.standby-overlay {
  position: absolute;
  inset: 30px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  background: radial-gradient(circle at center, rgba(4, 18, 8, 0.95) 0%, rgba(0, 0, 0, 0.98) 55%, #000 100%);
  z-index: 4;
}

.standby-label {
  color: #96ff8b;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: 2px;
}

.standby-subtitle {
  color: rgba(191, 255, 183, 0.82);
  font-size: 13px;
  text-align: center;
  max-width: 280px;
}

.control-deck {
  display: grid;
  grid-template-columns: 182px minmax(0, 1fr) 132px;
  gap: 18px;
  align-items: end;
  margin-top: 16px;
  padding: 0 12px 4px 36px;
}

.pacer-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.round-control {
  border: none;
}

.pacer-control {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3bd0ba 0%, #167567 72%, #0f5c51 100%);
  color: #f5fffd;
  font-weight: 700;
  font-size: var(--btn-font-md);
  letter-spacing: 0.3px;
  border: 4px solid rgba(224, 255, 250, 0.7);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.08), 0 6px 12px rgba(0, 0, 0, 0.18);
}

.pacer-control.toggled {
  box-shadow: 0 0 0 5px rgba(55, 214, 190, 0.18), 0 0 18px rgba(55, 214, 190, 0.45), inset 0 0 0 4px rgba(255, 255, 255, 0.08), 0 6px 12px rgba(0, 0, 0, 0.18);
}

.mini-setting-row {
  display: flex;
  gap: 10px;
}

.mini-setting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #4b4b4b;
  font-size: var(--btn-font-sm);
  font-weight: 700;
}

.mini-setting input {
  width: 60px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid #989898;
  background: rgba(255, 255, 255, 0.75);
  text-align: center;
}

.center-controls {
  display: grid;
  grid-template-columns: repeat(3, 126px);
  justify-content: center;
  gap: 14px;
  align-items: stretch;
  padding: 14px 16px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.15) 100%);
}

.shock-wrap {
  position: relative;
}

.step-number {
  display: none;
}

.tray-button,
.energy-selector,
.energy-step {
  border: 2px solid rgba(230, 214, 150, 0.95);
  background: linear-gradient(180deg, #faf2c4 0%, #d7c068 100%);
  color: #7a3c1a;
  font-weight: 700;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.28), var(--control-shadow);
}

.tray-button,
.energy-selector {
  width: 126px;
  min-height: 74px;
  border-radius: 18px;
}

.tray-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 10px;
  text-align: center;
  font-size: var(--btn-font-md);
  overflow: hidden;
}

.energy-selector {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
  padding: 10px 10px 8px;
  text-align: center;
  overflow: hidden;
}

.energy-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  font-size: var(--btn-font-sm);
  line-height: 1.02;
  color: #b12a1c;
  text-align: center;
}

.energy-adjuster-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
  gap: 4px;
  align-items: center;
  width: 100%;
}

.energy-selector input {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(129, 110, 33, 0.75);
  border-radius: 10px;
  padding: 4px 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.76);
  font-size: var(--btn-font-md);
}

.energy-step {
  min-height: 24px;
  border-radius: 10px;
  font-size: 10px;
  padding: 0;
}

.charge-button.ready {
  background: linear-gradient(180deg, #fff4b5 0%, #f1b73d 100%);
  color: #703100;
  box-shadow: 0 0 0 5px rgba(255, 194, 55, 0.14), 0 0 18px rgba(255, 194, 55, 0.32), inset 0 0 0 3px rgba(255, 255, 255, 0.28), var(--control-shadow);
}

.charge-button.charging {
  background: linear-gradient(180deg, #faf2c4 0%, #ebd179 100%);
}

.shock-wrap {
  display: flex;
  justify-content: flex-end;
}

.shock-step-number {
  left: 50%;
  transform: translateX(-50%);
}

.shock-disc {
  width: 104px;
  height: 104px;
  justify-self: end;
  border: 6px solid #ffd7c4;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9a63 0%, #f25f22 55%, #b73000 100%);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.2), 0 8px 18px rgba(0, 0, 0, 0.28);
}

.shock-disc:disabled {
  cursor: default;
  opacity: 0.65;
}

.shock-disc.armed {
  box-shadow: 0 0 0 5px rgba(255, 77, 77, 0.18), 0 0 24px rgba(255, 77, 77, 0.55), inset 0 0 0 5px rgba(255, 255, 255, 0.16), 0 6px 16px rgba(0, 0, 0, 0.18);
}

.shock-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.shock-bolt {
  font-size: 34px;
  line-height: 1;
}

.side-control:active,
.tray-button:active,
.round-control:active,
.shock-disc:active,
.modal-action:active,
.answer-option:active,
.restore-quiz:active,
.modal-close:active,
.modal-ghost:active,
.energy-step:active,
.standby-block:active,
.rail-toggle:active,
.icon-button:active {
  transform: translateY(1px);
}

.restore-quiz {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  border: 1px solid #d1d1d1;
  border-radius: 999px;
  background: rgba(25, 25, 25, 0.92);
  color: #fff;
  padding: 12px 18px;
  font-size: var(--btn-font-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.72);
  z-index: 90;
}

.hidden {
  display: none !important;
}

.modal-card {
  width: min(760px, 100%);
  border: 1px solid #393939;
  border-radius: 18px;
  background: linear-gradient(180deg, #171717 0%, #101010 100%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  padding: 22px 22px 18px;
}

.modal-header-row,
.modal-header-actions,
.modal-actions {
  display: flex;
  align-items: center;
}

.modal-header-row {
  justify-content: space-between;
  gap: 16px;
}

.modal-header-actions {
  gap: 10px;
}

.modal-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #92ff9b;
}

#modalTitle {
  margin: 6px 0 0;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.08;
}

.modal-ghost,
.modal-close,
.modal-action,
.answer-option {
  border: 1px solid #3d3d3d;
}

.modal-ghost,
.modal-close {
  background: #1b1b1b;
  color: #fff;
}

.modal-ghost {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: var(--btn-font-md);
}

.modal-close {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 28px;
  line-height: 1;
}

.analysis-loading {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px 0 24px;
}

.analysis-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid #2d2d2d;
  border-top-color: #86ff91;
  animation: spin 0.9s linear infinite;
}

.analysis-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.analysis-subtitle {
  margin-top: 6px;
  color: #a8a8a8;
}

.analysis-content {
  padding-top: 16px;
}

.modal-tip {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(122, 255, 135, 0.08);
  color: #c9fecd;
}

.case-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: #203924;
  color: #acffb4;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.case-summary {
  margin: 16px 0 20px;
  color: #efefef;
  font-size: 18px;
  line-height: 1.5;
}

.question-block {
  padding: 14px 16px;
  border: 1px solid #2b2b2b;
  border-radius: 14px;
  background: #171717;
}

.question-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: #8cff94;
}

.question-text {
  margin: 8px 0 0;
  font-size: clamp(18px, 2.4vw, 22px);
  line-height: 1.35;
}

.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.answer-option {
  padding: 14px 16px;
  border-radius: 14px;
  background: #212121;
  color: #fff;
  text-align: left;
  min-height: 62px;
  font-size: var(--btn-font-lg);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.answer-option.correct {
  background: #1d4c27;
  border-color: #76ffa1;
}

.answer-option.incorrect {
  background: #551f1f;
  border-color: #ff9898;
}

.feedback-box {
  margin-top: 18px;
  min-height: 70px;
  padding: 14px 16px;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  background: #131313;
  color: #d5d5d5;
  line-height: 1.5;
}

.feedback-box.good {
  border-color: #76ff9f;
  color: #c7ffd1;
}

.feedback-box.bad {
  border-color: #ff9696;
  color: #ffd2d2;
}

.modal-actions {
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.modal-action {
  border-radius: 12px;
  padding: 12px 16px;
  background: #1d1d1d;
  color: #fff;
  font-size: var(--btn-font-md);
}

.modal-action.primary {
  background: #22422a;
  border-color: #6fff87;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1024px) {
  .app-shell {
    padding: 12px;
  }

  .device-shell {
    width: min(940px, 100%);
  }
}

@media (max-width: 900px) {
  .wave-row {
    grid-template-columns: 54px minmax(0, 1fr) 106px;
  }

  .control-deck {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 4px 4px;
  }

  .center-controls {
    order: 1;
    grid-template-columns: repeat(3, 118px);
  }

  .tray-button,
  .energy-selector {
    width: 118px;
  }

  .pacer-group {
    order: 2;
  }

  .shock-wrap {
    justify-content: center;
    order: 3;
  }

  .shock-step-number {
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (max-width: 920px) and (max-height: 540px) and (orientation: landscape) {
  .control-deck {
    grid-template-columns: minmax(132px, 0.95fr) minmax(0, 1.7fr) minmax(112px, 0.9fr);
    gap: 10px;
    align-items: end;
    padding: 0 6px 4px 12px;
  }

  .pacer-group,
  .center-controls,
  .shock-wrap {
    order: initial;
  }

  .pacer-group {
    justify-self: start;
    gap: 8px;
  }

  .pacer-control {
    width: clamp(58px, 8.2vw, 70px);
    height: clamp(58px, 8.2vw, 70px);
  }

  .mini-setting-row {
    gap: 6px;
  }

  .mini-setting input {
    width: 52px;
  }

  .center-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .tray-button,
  .energy-selector {
    width: 100%;
    min-width: 0;
    min-height: 64px;
  }

  .shock-wrap {
    justify-content: flex-end;
    align-self: end;
  }

  .shock-disc {
    width: clamp(82px, 11vw, 104px);
    height: clamp(82px, 11vw, 104px);
    flex: 0 0 auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .device-shell {
    min-width: 920px;
  }

  .right-rail {
    gap: 6px;
  }

  .standby-block,
  .side-control,
  .icon-button {
    width: 58px;
  }

  .answers-grid {
    grid-template-columns: 1fr;
  }
}


@media (max-width: 920px) and (max-height: 540px) and (orientation: landscape) {
  .modal-backdrop {
    align-items: flex-start;
    overflow-y: auto;
    padding: 8px;
  }

  .modal-card {
    width: min(760px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px 12px;
  }
}


@media (max-width: 720px) and (orientation: portrait) {
  .modal-backdrop {
    align-items: flex-start;
    overflow-y: auto;
    padding: 10px;
  }

  .modal-card {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    border-radius: 16px;
  }

  .modal-header-row {
    align-items: flex-start;
    gap: 10px;
  }

  .modal-header-actions {
    flex: 0 0 auto;
  }

  .modal-kicker {
    font-size: 11px;
  }

  #modalTitle {
    font-size: clamp(22px, 6vw, 28px);
    line-height: 1.15;
  }

  .analysis-content {
    padding-top: 12px;
  }

  .modal-tip,
  .question-block,
  .feedback-box {
    padding: 12px;
  }

  .case-summary {
    margin: 12px 0 16px;
    font-size: 15px;
    line-height: 1.45;
  }

  .question-text {
    font-size: 17px;
    line-height: 1.35;
  }

  .answers-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
  }

  .answer-option {
    min-height: 54px;
    padding: 12px 14px;
    font-size: 15px;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    background: linear-gradient(180deg, rgba(13,13,13,0), #0d0d0d 24%);
  }

  .modal-action {
    width: 100%;
    min-height: 46px;
  }
}
