:root {
  --crt-bg: #050a07;
  --crt-panel: #0a140e;
  --crt-border: #1e4d2b;
  --crt-green: #00ff66;
  --crt-green-dim: #198a47;
  --crt-amber: #ffb000;
  --crt-red: #ff2a2a;
  --crt-cyan: #00e5ff;
  --crt-text: #d7ffe6;
  --font-mono: 'JetBrains Mono', 'Cascadia Mono', 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--crt-bg);
  background-image: radial-gradient(circle at 50% 35%, rgba(0, 255, 102, 0.06) 0%, rgba(5, 10, 7, 0.96) 78%);
  color: var(--crt-text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.35;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
  touch-action: manipulation;
}

/* Non-blocking CRT scanlines & error flash */
.crt-scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px,
    rgba(0, 0, 0, 0.22) 4px
  );
}

#flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: rgba(255, 25, 25, 0.55);
  opacity: 0;
}

#flash-overlay.active {
  animation: crt-error-flash 320ms ease-out forwards;
}

@keyframes crt-error-flash {
  0% {
    opacity: 1;
  }
  30% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

/* Main mobile-first shell */
.crt-shell {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid rgba(30, 77, 43, 0.45);
  border-right: 1px solid rgba(30, 77, 43, 0.45);
  background: rgba(5, 10, 7, 0.88);
  position: relative;
}

/* Fixed compact top HUD */
.hud {
  flex-shrink: 0;
  background: var(--crt-panel);
  border-bottom: 1px solid var(--crt-border);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.hud-top,
.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.seed-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border: 1px solid var(--crt-border);
  border-radius: 3px;
  background: rgba(0, 255, 102, 0.06);
  color: var(--crt-green);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.seed-badge.is-practice {
  border-color: rgba(255, 176, 0, 0.55);
  background: rgba(255, 176, 0, 0.1);
  color: var(--crt-amber);
}

.lives-display {
  font-size: 1rem;
  letter-spacing: 0.12em;
  line-height: 1;
  white-space: nowrap;
}

.hud-mute-btn {
  min-width: 82px;
  font-size: 0.72rem;
  padding: 4px 8px;
  min-height: 28px;
}

.hud-mute-btn.is-muted {
  border-color: rgba(255, 176, 0, 0.6);
  color: var(--crt-amber);
}

.hud-pause-btn {
  flex-shrink: 0;
  min-width: 78px;
  font-size: 0.7rem;
  padding: 4px 8px;
  min-height: 26px;
  border-color: rgba(0, 229, 255, 0.5);
  color: var(--crt-cyan);
  background: rgba(0, 229, 255, 0.08);
  white-space: nowrap;
}

.hud-pause-btn.is-paused {
  border-color: rgba(255, 176, 0, 0.75);
  color: var(--crt-amber);
  background: rgba(255, 176, 0, 0.14);
  box-shadow: 0 0 10px rgba(255, 176, 0, 0.25);
}

.round-indicators {
  display: flex;
  align-items: center;
  gap: 4px;
}

.round-led {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--crt-border);
  border-radius: 3px;
  color: var(--crt-green-dim);
  background: rgba(5, 10, 7, 0.9);
  transition: border-color 120ms ease, color 120ms ease, background-color 120ms ease;
}

.round-led.is-active {
  border-color: var(--crt-cyan);
  color: var(--crt-cyan);
  background: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.25);
}

.round-led.is-won {
  border-color: var(--crt-green);
  color: var(--crt-bg);
  background: var(--crt-green);
}

.round-led.is-lost {
  border-color: var(--crt-red);
  color: #ffffff;
  background: var(--crt-red);
}

.timer-display {
  font-size: 1.38rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--crt-green);
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.35);
  min-width: 78px;
  text-align: right;
  line-height: 1;
}

.timer-display.is-amber {
  color: var(--crt-amber);
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.4);
}

.timer-display.is-critical {
  color: var(--crt-red);
  text-shadow: 0 0 12px rgba(255, 42, 42, 0.65);
  animation: timer-pulse 450ms ease-in-out infinite alternate;
}

@keyframes timer-pulse {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0.7;
    transform: scale(1.04);
  }
}

/* Main stage */
.stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.screen.is-active {
  display: flex;
}

/* Standby screen */
#screen-standby {
  justify-content: center;
  gap: 14px;
}

.standby-hero {
  text-align: center;
  flex-shrink: 0;
}

.terminal-tag {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--crt-green-dim);
  margin-bottom: 4px;
}

.terminal-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--crt-green);
  text-shadow: 0 0 14px rgba(0, 255, 102, 0.35);
}

.standby-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.briefing-text {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--crt-text);
  text-align: center;
}

.briefing-text strong {
  color: var(--crt-amber);
}

.briefing-sub {
  margin: 0;
  font-size: 0.78rem;
  color: var(--crt-green-dim);
  text-align: center;
}

.standby-done-label {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--crt-cyan);
  font-weight: 700;
}

/* Auto-pause toggle */
.autopause-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 4px;
  background: rgba(0, 229, 255, 0.05);
  transition: border-color 120ms ease, background-color 120ms ease;
}

.autopause-toggle:hover {
  border-color: rgba(0, 229, 255, 0.7);
  background: rgba(0, 229, 255, 0.1);
}

.autopause-toggle--compact {
  padding: 5px 8px;
  gap: 7px;
}

.autopause-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.autopause-box {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--crt-border);
  border-radius: 3px;
  background: #040906;
  color: var(--crt-green);
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1;
}

.autopause-box::before {
  content: ' ';
}

.autopause-input:checked + .autopause-box {
  border-color: var(--crt-green);
  background: rgba(0, 255, 102, 0.16);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.25);
}

.autopause-input:checked + .autopause-box::before {
  content: '✓';
}

.autopause-input:focus-visible + .autopause-box {
  outline: 2px solid var(--crt-cyan);
  outline-offset: 2px;
}

.autopause-text {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--crt-cyan);
  line-height: 1.2;
}

/* Practice selector screen */
#screen-practice {
  justify-content: center;
}

.practice-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 100%;
  overflow-y: auto;
}

.practice-header {
  text-align: center;
}

.practice-title {
  margin: 2px 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--crt-amber);
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.3);
}

.practice-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(5, 10, 7, 0.75);
  border: 1px solid var(--crt-border);
  border-radius: 3px;
}

.practice-mode-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--crt-green-dim);
  white-space: nowrap;
}

.practice-mode-btns {
  display: flex;
  gap: 6px;
}

.practice-mode-btn {
  min-height: 28px;
  padding: 3px 8px;
  font-size: 0.72rem;
}

.practice-mode-btn.is-active,
.practice-mode-btn[aria-pressed='true'] {
  background: var(--crt-amber);
  color: var(--crt-bg);
  border-color: var(--crt-amber);
}

.practice-random-btn {
  width: 100%;
  min-height: 38px;
  font-size: 0.82rem;
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.practice-mod-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 5px 4px;
  border-color: rgba(255, 176, 0, 0.38);
  background: rgba(255, 176, 0, 0.05);
}

.practice-mod-btn:hover:not(:disabled) {
  border-color: var(--crt-amber);
  background: rgba(255, 176, 0, 0.16);
}

.practice-mod-num {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--crt-cyan);
}

.practice-mod-name {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--crt-text);
  word-break: break-word;
}

.practice-back-btn {
  width: 100%;
  min-height: 34px;
  font-size: 0.78rem;
}

/* Playing screen */
#screen-playing {
  gap: 6px;
}

.module-meta {
  flex-shrink: 0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--crt-cyan);
  padding: 4px 8px;
  background: rgba(0, 229, 255, 0.06);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playing-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.module-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.module-container.is-paused {
  visibility: hidden;
  pointer-events: none;
}

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px;
  background: #060e09;
  border: 1px solid rgba(0, 229, 255, 0.45);
  border-radius: 4px;
  box-shadow: inset 0 0 24px rgba(0, 229, 255, 0.08), 0 0 18px rgba(0, 0, 0, 0.85);
  overflow-y: auto;
}

.pause-header {
  text-align: center;
  border-bottom: 1px solid var(--crt-border);
  padding-bottom: 10px;
}

.pause-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--crt-amber);
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.35);
}

.pause-sub {
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--crt-cyan);
}

.pause-instructions {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 6px 2px;
}

.pause-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--crt-green);
}

.pause-mod-desc,
.pause-mod-rule {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--crt-text);
  background: rgba(0, 255, 102, 0.05);
  border: 1px solid rgba(30, 77, 43, 0.7);
  border-radius: 3px;
  padding: 10px 12px;
}

.pause-mod-rule-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pause-mod-rule {
  border-color: rgba(255, 176, 0, 0.45);
  background: rgba(255, 176, 0, 0.07);
  color: var(--crt-amber);
  font-weight: 700;
}

.pause-resume-btn {
  flex-shrink: 0;
  width: 100%;
  min-height: 48px;
}

/* End screen */
#screen-end {
  justify-content: center;
}

.end-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.end-mode-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--crt-cyan);
}

.end-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
}

.end-title.is-win {
  color: var(--crt-green);
  text-shadow: 0 0 12px rgba(0, 255, 102, 0.35);
}

.end-title.is-lose {
  color: var(--crt-red);
  text-shadow: 0 0 12px rgba(255, 42, 42, 0.45);
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-box {
  background: rgba(5, 10, 7, 0.85);
  border: 1px solid var(--crt-border);
  border-radius: 3px;
  padding: 8px;
  text-align: center;
}

.stat-box--full {
  grid-column: 1 / -1;
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--crt-green-dim);
  margin-bottom: 3px;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--crt-text);
}

.share-preview {
  margin: 0;
  padding: 10px;
  background: rgba(5, 10, 7, 0.95);
  border: 1px dashed var(--crt-border);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--crt-text);
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================================================
   Shared Module & Terminal Utility Classes
   ========================================================================== */

.crt-panel {
  background: var(--crt-panel);
  border: 1px solid var(--crt-border);
  border-radius: 4px;
  padding: 10px;
  box-shadow: inset 0 0 16px rgba(0, 255, 102, 0.04);
}

.crt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--crt-border);
  border-radius: 4px;
  background: rgba(10, 20, 14, 0.92);
  color: var(--crt-text);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  cursor: pointer;
  transition: background-color 100ms ease, border-color 100ms ease, color 100ms ease, box-shadow 100ms ease, transform 60ms ease;
}

.crt-btn:hover:not(:disabled) {
  border-color: var(--crt-green);
  background: rgba(0, 255, 102, 0.12);
}

.crt-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.crt-btn:focus-visible {
  outline: 2px solid var(--crt-cyan);
  outline-offset: 2px;
}

.crt-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.crt-btn--primary {
  border-color: var(--crt-green);
  color: var(--crt-green);
  background: rgba(0, 255, 102, 0.1);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.12);
}

.crt-btn--primary:hover:not(:disabled) {
  background: rgba(0, 255, 102, 0.2);
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.25);
}

.crt-btn--danger {
  border-color: var(--crt-red);
  color: var(--crt-red);
  background: rgba(255, 42, 42, 0.1);
}

.crt-btn--danger:hover:not(:disabled) {
  background: rgba(255, 42, 42, 0.22);
}

.crt-btn--amber {
  border-color: var(--crt-amber);
  color: var(--crt-amber);
  background: rgba(255, 176, 0, 0.08);
}

.crt-btn--amber:hover:not(:disabled) {
  background: rgba(255, 176, 0, 0.2);
}

.crt-btn--cyan {
  border-color: var(--crt-cyan);
  color: var(--crt-cyan);
  background: rgba(0, 229, 255, 0.08);
}

.crt-btn--cyan:hover:not(:disabled) {
  background: rgba(0, 229, 255, 0.18);
}

.crt-btn--sm {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 0.76rem;
}

.crt-btn--lg {
  min-height: 48px;
  padding: 12px 16px;
  font-size: 0.96rem;
}

.crt-btn.is-active,
.crt-btn[aria-pressed='true'] {
  background: var(--crt-green);
  color: var(--crt-bg);
  border-color: var(--crt-green);
}

/* Module sub-structure classes */
.mod-header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(0, 255, 102, 0.04);
  border: 1px solid var(--crt-border);
  border-left: 3px solid var(--crt-green);
  border-radius: 3px;
}

.mod-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--crt-green);
  text-transform: uppercase;
}

.mod-instruction {
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--crt-text);
}

.mod-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}

.mod-footer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding-top: 6px;
}

.crt-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.crt-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.crt-status {
  padding: 6px 8px;
  border: 1px dashed var(--crt-border);
  border-radius: 3px;
  background: rgba(5, 10, 7, 0.85);
  color: var(--crt-amber);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.crt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1px solid var(--crt-border);
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.crt-bar {
  width: 100%;
  height: 14px;
  background: rgba(5, 10, 7, 0.95);
  border: 1px solid var(--crt-border);
  border-radius: 3px;
  overflow: hidden;
}

.crt-bar-fill {
  height: 100%;
  background: var(--crt-green);
  transition: width 60ms linear;
}

.crt-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
}

.crt-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: rgba(30, 77, 43, 0.65);
  border: 1px solid var(--crt-border);
  border-radius: 4px;
}

.crt-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border-radius: 3px;
  background: var(--crt-green);
  border: 2px solid var(--crt-bg);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

.crt-slider::-moz-range-track {
  height: 8px;
  background: rgba(30, 77, 43, 0.65);
  border: 1px solid var(--crt-border);
  border-radius: 4px;
}

.crt-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 3px;
  background: var(--crt-green);
  border: 2px solid var(--crt-bg);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

.text-green { color: var(--crt-green); }
.text-amber { color: var(--crt-amber); }
.text-red { color: var(--crt-red); }
.text-cyan { color: var(--crt-cyan); }
.text-dim { color: var(--crt-green-dim); }

/* Very compact viewport safeguard (e.g. 375x600 or short mobile viewport) */
@media (max-height: 620px) {
  .hud {
    padding: 6px 10px;
    gap: 4px;
  }
  .stage {
    padding: 6px 10px;
  }
  .terminal-title {
    font-size: 1.65rem;
  }
  .mod-header {
    padding: 6px 8px;
    margin-bottom: 6px;
  }
  .crt-btn {
    min-height: 36px;
  }
  .crt-btn--lg {
    min-height: 42px;
  }
}

/* ==========================================================================
   Desktop / PC Responsive Console Scaling (>= 768px)
   ========================================================================== */
@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
  }

  .crt-shell {
    max-width: 680px;
    height: min(94vh, 920px);
    height: min(94dvh, 920px);
    border: 1px solid var(--crt-border);
    border-radius: 10px;
    box-shadow: 0 0 42px rgba(0, 255, 102, 0.12), inset 0 0 28px rgba(0, 255, 102, 0.04);
  }

  .hud {
    padding: 14px 20px;
    gap: 10px;
  }

  .seed-badge {
    padding: 5px 11px;
    font-size: 0.95rem;
  }

  .lives-display {
    font-size: 1.35rem;
  }

  .hud-mute-btn {
    min-width: 108px;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.88rem;
  }

  .hud-pause-btn {
    min-width: 112px;
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.88rem;
  }

  .round-indicators {
    gap: 8px;
  }

  .round-led {
    min-width: 40px;
    height: 32px;
    font-size: 0.92rem;
  }

  .timer-display {
    font-size: 1.95rem;
    min-width: 106px;
  }

  .stage {
    padding: 18px 24px;
  }

  .terminal-tag {
    font-size: 0.9rem;
    letter-spacing: 0.18em;
  }

  .terminal-title {
    font-size: 3rem;
  }

  .standby-card,
  .end-card {
    padding: 20px;
    gap: 16px;
  }

  .briefing-text {
    font-size: 1.18rem;
  }

  .briefing-sub {
    font-size: 0.98rem;
  }

  .standby-done-label,
  .end-mode-badge {
    font-size: 0.9rem;
  }

  .autopause-toggle {
    padding: 11px 14px;
    gap: 10px;
  }

  .autopause-toggle--compact {
    padding: 8px 12px;
  }

  .autopause-box {
    width: 24px;
    height: 24px;
    font-size: 1rem;
  }

  .autopause-text {
    font-size: 0.9rem;
  }

  .practice-card {
    padding: 20px;
    gap: 14px;
  }

  .practice-title {
    font-size: 1.7rem;
  }

  .practice-mode-bar {
    padding: 10px 14px;
  }

  .practice-mode-label {
    font-size: 0.86rem;
  }

  .practice-mode-btn {
    min-height: 36px;
    padding: 5px 12px;
    font-size: 0.86rem;
  }

  .practice-random-btn {
    min-height: 50px;
    font-size: 1rem;
  }

  .practice-grid {
    gap: 10px;
  }

  .practice-mod-btn {
    min-height: 66px;
    padding: 10px 12px;
    gap: 4px;
  }

  .practice-mod-num {
    font-size: 0.78rem;
  }

  .practice-mod-name {
    font-size: 0.9rem;
  }

  .practice-back-btn {
    min-height: 44px;
    font-size: 0.94rem;
  }

  .end-title {
    font-size: 1.85rem;
  }

  .stat-box {
    padding: 12px;
  }

  .stat-label {
    font-size: 0.82rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .share-preview {
    padding: 14px;
    font-size: 1rem;
  }

  .crt-btn {
    min-height: 48px;
    font-size: 1rem;
    padding: 10px 18px;
  }

  .crt-btn--lg {
    min-height: 58px;
    font-size: 1.15rem;
    padding: 14px 22px;
  }

  .module-meta {
    font-size: 0.95rem;
    padding: 8px 14px;
    margin-bottom: 4px;
  }

  .module-container {
    justify-content: center;
  }

  .pause-overlay {
    padding: 24px 26px;
    gap: 18px;
  }

  .pause-title {
    font-size: 1.55rem;
  }

  .pause-sub {
    font-size: 0.88rem;
  }

  .pause-section-label {
    font-size: 0.84rem;
  }

  .pause-mod-desc,
  .pause-mod-rule {
    font-size: 1.05rem;
    padding: 14px 16px;
  }

  .pause-resume-btn {
    min-height: 58px;
    font-size: 1.12rem;
  }

  /* Scale all 10 procedural module shells on desktop */
  .crt-shell .ovr-wires,
  .crt-shell .ovr-bin,
  .crt-shell .ovr-math,
  .crt-shell .ovr-glyph,
  .crt-shell .ovr-fh,
  .crt-shell .ovr-mf,
  .crt-shell .ovr-fa,
  .crt-shell .ovr-pp,
  .crt-shell .ovr-rl,
  .crt-shell .ovr-vs,
  .crt-shell .ovr-tm,
  .crt-shell .ovr-ms,
  .crt-shell .ovr-so,
  .crt-shell .ovr-st,
  .crt-shell .ovr-rb {
    max-width: 560px !important;
  }

  /* 1. Wires */
  .crt-shell .ovr-wires {
    padding: 14px;
    gap: 12px;
  }
  .crt-shell .ovr-wires-rule {
    padding: 12px 14px;
  }
  .crt-shell .ovr-wires-tag {
    font-size: 12px;
  }
  .crt-shell .ovr-wires-rule-text {
    font-size: 16px;
  }
  .crt-shell .ovr-wires-list {
    gap: 10px;
  }
  .crt-shell .ovr-wire-btn {
    min-height: 58px;
    padding: 8px 14px;
    gap: 12px;
  }
  .crt-shell .ovr-wire-pos {
    flex-basis: 32px;
    font-size: 14px;
  }
  .crt-shell .ovr-wire-label {
    min-width: 132px;
    padding: 6px 10px;
    font-size: 14.5px;
  }
  .crt-shell .ovr-wires-status {
    font-size: 13px;
  }

  /* 2. Binary Switches */
  .crt-shell .ovr-bin {
    padding: 14px;
    gap: 16px;
  }
  .crt-shell .ovr-bin-header {
    padding: 14px 16px;
  }
  .crt-shell .ovr-bin-sub,
  .crt-shell .ovr-bin-box-lbl {
    font-size: 12px;
  }
  .crt-shell .ovr-bin-box-val {
    font-size: 34px;
  }
  .crt-shell .ovr-bin-grid {
    gap: 10px;
  }
  .crt-shell .ovr-bin-sw {
    min-height: 165px;
    padding: 12px 4px;
  }
  .crt-shell .ovr-bin-weight {
    font-size: 16px;
  }
  .crt-shell .ovr-bin-track {
    width: 30px;
    height: 56px;
  }
  .crt-shell .ovr-bin-thumb {
    height: 22px;
  }
  .crt-shell .ovr-bin-state {
    font-size: 12px;
  }
  .crt-shell .ovr-bin-exec {
    min-height: 60px;
    font-size: 19px;
  }
  .crt-shell .ovr-bin-status {
    font-size: 13px;
  }

  /* 3. Math Order */
  .crt-shell .ovr-math {
    padding: 14px;
    gap: 16px;
  }
  .crt-shell .ovr-math-header {
    padding: 12px 14px;
  }
  .crt-shell .ovr-math-top {
    font-size: 12px;
  }
  .crt-shell .ovr-math-dir {
    font-size: 16px;
  }
  .crt-shell .ovr-math-grid {
    gap: 12px;
  }
  .crt-shell .ovr-math-btn {
    min-height: 80px;
    padding: 12px;
  }
  .crt-shell .ovr-math-expr {
    font-size: 26px;
  }
  .crt-shell .ovr-math-badge,
  .crt-shell .ovr-math-status {
    font-size: 13px;
  }

  /* 4. Glyph Rules */
  .crt-shell .ovr-glyph {
    padding: 14px;
    gap: 14px;
  }
  .crt-shell .ovr-glyph-rule {
    padding: 12px 14px;
  }
  .crt-shell .ovr-glyph-tag {
    font-size: 12px;
  }
  .crt-shell .ovr-glyph-text {
    font-size: 15.5px;
  }
  .crt-shell .ovr-glyph-grid {
    gap: 12px;
  }
  .crt-shell .ovr-glyph-cell {
    min-height: 92px;
  }
  .crt-shell .ovr-glyph-sym {
    font-size: 34px;
  }
  .crt-shell .ovr-glyph-id {
    font-size: 12px;
  }
  .crt-shell .ovr-glyph-status {
    font-size: 13px;
  }

  /* 5. Fallout Hack */
  .crt-shell .ovr-fh {
    padding: 14px;
    gap: 10px;
  }
  .crt-shell .ovr-fh-head {
    font-size: 14px;
  }
  .crt-shell .ovr-fh-chip {
    height: 36px;
    font-size: 14px;
  }
  .crt-shell .ovr-fh-dump {
    padding: 10px;
    gap: 6px;
  }
  .crt-shell .ovr-fh-row {
    min-height: 44px;
    gap: 8px;
  }
  .crt-shell .ovr-fh-addr,
  .crt-shell .ovr-fh-noise {
    font-size: 13px;
  }
  .crt-shell .ovr-fh-tok {
    min-width: 68px;
    min-height: 42px;
    padding: 0 12px;
    font-size: 15.5px;
  }

  /* 6. Memory Flash */
  .crt-shell .ovr-mf {
    padding: 14px;
    gap: 14px;
  }
  .crt-shell .ovr-mf-status {
    font-size: 15.5px;
  }
  .crt-shell .ovr-mf-bar-track {
    height: 10px;
  }
  .crt-shell .ovr-mf-grid {
    grid-template-columns: repeat(3, 112px);
    grid-template-rows: repeat(3, 112px);
    gap: 14px;
  }
  .crt-shell .ovr-mf-cell {
    width: 112px;
    height: 112px;
  }
  .crt-shell .ovr-mf-cell-idx {
    font-size: 12px;
  }
  .crt-shell .ovr-mf-cell-glyph {
    font-size: 28px;
  }
  .crt-shell .ovr-mf-foot {
    font-size: 14px;
  }

  /* 7. Freq Align */
  .crt-shell .ovr-fa {
    padding: 14px;
    gap: 14px;
  }
  .crt-shell .ovr-fa-head {
    font-size: 14.5px;
  }
  .crt-shell .ovr-fa-scope-wrap {
    height: 240px;
  }
  .crt-shell .ovr-fa-lock-head {
    font-size: 13.5px;
  }
  .crt-shell .ovr-fa-bar {
    height: 14px;
  }
  .crt-shell .ovr-fa-slider {
    height: 56px;
  }
  .crt-shell .ovr-fa-scale {
    font-size: 12.5px;
  }

  /* 8. Pressure Purge */
  .crt-shell .ovr-pp {
    padding: 14px;
    gap: 14px;
  }
  .crt-shell .ovr-pp-head {
    font-size: 14.5px;
  }
  .crt-shell .ovr-pp-body {
    height: 260px;
    gap: 20px;
  }
  .crt-shell .ovr-pp-scale {
    font-size: 12px;
    width: 38px;
  }
  .crt-shell .ovr-pp-tube {
    width: 116px;
  }
  .crt-shell .ovr-pp-lbl {
    font-size: 12px;
  }
  .crt-shell .ovr-pp-val {
    font-size: 30px;
  }
  .crt-shell .ovr-pp-range {
    font-size: 18px;
  }
  .crt-shell .ovr-pp-led {
    font-size: 14px;
    padding: 10px;
  }
  .crt-shell .ovr-pp-btn {
    min-height: 70px;
    font-size: 16px;
  }

  /* 9. Rotor Lock */
  .crt-shell .ovr-rl {
    padding: 14px;
    gap: 12px;
  }
  .crt-shell .ovr-rl-title {
    font-size: 14.5px;
  }
  .crt-shell .ovr-rl-led {
    font-size: 13px;
    padding: 6px 12px;
  }
  .crt-shell .ovr-rl-dial-wrap,
  .crt-shell .ovr-rl-canvas {
    width: 260px;
    height: 260px;
  }
  .crt-shell .ovr-rl-status {
    font-size: 14.5px;
  }
  .crt-shell .ovr-rl-btn {
    min-height: 66px;
    font-size: 19px;
  }

  /* 10. Valve Sequence */
  .crt-shell .ovr-vs {
    padding: 14px;
    gap: 12px;
  }
  .crt-shell .ovr-vs-head-top {
    font-size: 14.5px;
  }
  .crt-shell .ovr-vs-sub {
    font-size: 12.5px;
  }
  .crt-shell .ovr-vs-list {
    gap: 10px;
  }
  .crt-shell .ovr-vs-card {
    min-height: 86px;
    padding: 12px 14px;
    gap: 10px;
  }
  .crt-shell .ovr-vs-top {
    font-size: 15px;
  }
  .crt-shell .ovr-vs-status {
    font-size: 12.5px;
    padding: 3px 8px;
  }
  .crt-shell .ovr-vs-track {
    height: 20px;
  }

  /* 11. Tactical Map */
  .crt-shell .ovr-tm {
    padding: 12px;
    gap: 10px;
  }
  .crt-shell .ovr-tm-rule {
    font-size: 14px;
    padding: 9px 12px;
  }
  .crt-shell .ovr-tm-target {
    font-size: 19px;
    padding: 8px;
  }
  .crt-shell .ovr-tm-board {
    grid-template-columns: 38px repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
  }
  .crt-shell .ovr-tm-axis {
    min-height: 36px;
    font-size: 17px;
  }
  .crt-shell .ovr-tm-cell {
    min-height: 48px;
    font-size: 16px;
  }
  .crt-shell .ovr-tm-status {
    font-size: 13px;
  }

  /* 12. Magnetic Scale */
  .crt-shell .ovr-ms {
    padding: 14px;
    gap: 14px;
  }
  .crt-shell .ovr-ms-rule {
    font-size: 14.5px;
    padding: 10px 14px;
  }
  .crt-shell .ovr-ms-lbl {
    font-size: 11.5px;
  }
  .crt-shell .ovr-ms-val {
    font-size: 26px;
  }
  .crt-shell .ovr-ms-weight {
    min-height: 86px;
  }
  .crt-shell .ovr-ms-wval {
    font-size: 26px;
  }
  .crt-shell .ovr-ms-wunit {
    font-size: 12px;
  }
  .crt-shell .ovr-ms-status {
    font-size: 13px;
  }

  /* 13. Stroop Override */
  .crt-shell .ovr-so {
    padding: 14px;
    gap: 14px;
  }
  .crt-shell .ovr-so-rule {
    font-size: 15px;
    padding: 11px 14px;
  }
  .crt-shell .ovr-so-step {
    padding: 7px;
    font-size: 13px;
  }
  .crt-shell .ovr-so-display {
    min-height: 108px;
  }
  .crt-shell .ovr-so-word {
    font-size: 48px;
  }
  .crt-shell .ovr-so-btn {
    min-height: 74px;
    font-size: 20px;
  }
  .crt-shell .ovr-so-status {
    font-size: 13px;
  }

  /* 14. Signal Tuner */
  .crt-shell .ovr-st {
    padding: 14px;
    gap: 12px;
  }
  .crt-shell .ovr-st-rule {
    font-size: 14px;
    padding: 10px 12px;
  }
  .crt-shell .ovr-st-tx-lbl {
    font-size: 12px;
  }
  .crt-shell .ovr-st-dot {
    width: 22px;
    height: 22px;
  }
  .crt-shell .ovr-st-dash {
    width: 58px;
    height: 18px;
  }
  .crt-shell .ovr-st-tx-text {
    font-size: 21px;
  }
  .crt-shell .ovr-st-ch {
    min-height: 72px;
  }
  .crt-shell .ovr-st-ch-id {
    font-size: 12.5px;
  }
  .crt-shell .ovr-st-ch-pat {
    font-size: 19px;
  }
  .crt-shell .ovr-st-status {
    font-size: 13px;
  }

  /* 15. Reactor Balance */
  .crt-shell .ovr-rb {
    padding: 14px;
    gap: 12px;
  }
  .crt-shell .ovr-rb-rule {
    font-size: 14.5px;
    padding: 10px 12px;
  }
  .crt-shell .ovr-rb-total {
    font-size: 15px;
    padding: 9px 14px;
  }
  .crt-shell .ovr-rb-name {
    font-size: 13.5px;
  }
  .crt-shell .ovr-rb-seg {
    height: 24px;
  }
  .crt-shell .ovr-rb-val {
    font-size: 16px;
  }
  .crt-shell .ovr-rb-step-btn {
    min-height: 44px;
    font-size: 22px;
  }
  .crt-shell .ovr-rb-exec {
    min-height: 54px;
    font-size: 17px;
  }
  .crt-shell .ovr-rb-status {
    font-size: 13px;
  }
}

/* Laptop / short desktop safeguard (e.g. 1366x768) */
@media (min-width: 768px) and (max-height: 760px) {
  body {
    padding: 8px;
  }
  .crt-shell {
    height: 96vh;
    height: 96dvh;
  }
  .hud {
    padding: 10px 16px;
    gap: 6px;
  }
  .stage {
    padding: 10px 16px;
  }
  .terminal-title {
    font-size: 2.35rem;
  }
  .crt-shell .ovr-wire-btn {
    min-height: 50px;
  }
  .crt-shell .ovr-bin-sw {
    min-height: 140px;
  }
  .crt-shell .ovr-math-btn {
    min-height: 68px;
  }
  .crt-shell .ovr-glyph-cell {
    min-height: 78px;
  }
  .crt-shell .ovr-fh-row {
    min-height: 38px;
  }
  .crt-shell .ovr-mf-grid {
    grid-template-columns: repeat(3, 96px);
    grid-template-rows: repeat(3, 96px);
    gap: 10px;
  }
  .crt-shell .ovr-mf-cell {
    width: 96px;
    height: 96px;
  }
  .crt-shell .ovr-fa-scope-wrap {
    height: 200px;
  }
  .crt-shell .ovr-pp-body {
    height: 220px;
  }
  .crt-shell .ovr-rl-dial-wrap,
  .crt-shell .ovr-rl-canvas {
    width: 220px;
    height: 220px;
  }
  .crt-shell .ovr-vs-card {
    min-height: 74px;
  }
  .practice-card {
    padding: 14px 18px;
    gap: 10px;
  }
  .practice-mod-btn {
    min-height: 48px;
    padding: 6px 8px;
  }
  .autopause-toggle--compact {
    padding: 6px 10px;
  }
  .crt-shell .ovr-tm-cell {
    min-height: 40px;
  }
  .crt-shell .ovr-ms-weight {
    min-height: 72px;
  }
  .crt-shell .ovr-so-btn {
    min-height: 60px;
  }
  .crt-shell .ovr-st-ch {
    min-height: 60px;
  }
  .crt-shell .ovr-rb-seg {
    height: 20px;
  }
  .crt-shell .ovr-rb-step-btn {
    min-height: 36px;
  }
}

/* Shared Variant Mode indicator across minigame modules */
.crt-shell .ovr-variant-mode {
  border-color: #ff9d00 !important;
  box-shadow: 0 0 14px rgba(255, 157, 0, 0.34), inset 0 0 14px rgba(255, 157, 0, 0.12) !important;
}

.crt-shell .ovr-variant-banner {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 8px;
  border: 1px solid #ff9d00;
  border-radius: 4px;
  background: rgba(255, 157, 0, 0.16);
  color: #ffb000;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-align: center;
  line-height: 1.25;
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.45);
}

@media (min-width: 768px) {
  .crt-shell .ovr-variant-banner {
    font-size: 13px;
    padding: 6px 10px;
  }
}

/* Homepage Language Selector */
.lang-selector {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
}

.lang-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--crt-cyan, #00e5ff);
}

.lang-btns {
  display: flex;
  gap: 6px;
}

.lang-btn {
  min-width: 54px;
  min-height: 30px;
  padding: 3px 8px;
}

.lang-btn.is-active {
  border-color: var(--crt-green, #00ff66);
  background: rgba(0, 255, 102, 0.2);
  color: var(--crt-green, #00ff66);
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.35);
}
