:root {
  color-scheme: dark;
  --crt-bg: #010503;
  --crt-primary: #0b3a1e;
  --crt-secondary: #062612;
  --crt-glow: #2aff7a;
  --crt-text: #9fffb8;
  --crt-muted: #3b8a52;
  --crt-border: rgba(42, 255, 122, 0.4);
  --crt-shadow: 0 0 60px rgba(0, 0, 0, 0.65);
  --font-primary: 'VT323', 'Share Tech Mono', monospace;
  --bezel-base: #8d9199;
  --bezel-shadow: rgba(26, 29, 34, 0.55);
  --bezel-highlight: rgba(255, 255, 255, 0.35);
  --rdi-caret-smooth-ms: 0ms;
}

* {
  box-sizing: border-box;
}

/* Screen Reader Only - Accessible content that's visually hidden but available to screen readers */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sr-only:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: inherit !important;
  margin: inherit !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: inherit !important;
  border: inherit !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #000;
  font-family: var(--font-primary);
  color: var(--crt-text);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.terminal-bezel {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: min(1260px, 100%);
  height: min(820px, 100vh - clamp(2rem, 5vw, 5.5rem));
  padding: clamp(0.5rem, 1.6vw, 1.3rem);
  border-radius: 22px;
  border: 3px solid var(--bezel-shadow);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.35), rgba(0, 0, 0, 0.18)),
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.28), transparent 55%),
    radial-gradient(circle at 80% 78%, rgba(0, 0, 0, 0.3), transparent 60%),
    repeating-linear-gradient(
      145deg,
      rgba(255, 255, 255, 0.06) 0 2px,
      rgba(70, 73, 79, 0.16) 2px 4px
    ),
    linear-gradient(160deg, var(--bezel-base), #6f747b);
  background-blend-mode: soft-light, multiply, multiply, overlay, normal;
  box-shadow:
    0 36px 70px rgba(0, 0, 0, 0.85),
    inset 0 3px 10px var(--bezel-highlight),
    inset 0 -6px 14px rgba(28, 31, 36, 0.55);
  overflow: hidden;
}

.ambient-toggle {
  position: absolute;
  top: clamp(0.35rem, 1.2vw, 0.9rem);
  right: clamp(0.35rem, 1.2vw, 0.9rem);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.3);
  color: var(--crt-muted);
  font-size: clamp(0.6rem, 1vw, 0.75rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  z-index: 4;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.ambient-toggle:hover,
.ambient-toggle:focus-visible {
  background: rgba(42, 255, 122, 0.12);
  color: var(--crt-glow);
  border-color: rgba(42, 255, 122, 0.32);
  box-shadow: 0 0 16px rgba(42, 255, 122, 0.3);
}

.ambient-toggle[aria-pressed='true'] {
  background: rgba(42, 255, 122, 0.18);
  color: var(--crt-glow);
  border-color: rgba(42, 255, 122, 0.42);
  box-shadow: 0 0 22px rgba(42, 255, 122, 0.35);
}

.ambient-toggle:disabled,
.ambient-toggle[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.ambient-toggle-indicator {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(42, 255, 122, 0.25);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.ambient-toggle[aria-pressed='true'] .ambient-toggle-indicator {
  background: var(--crt-glow);
  box-shadow: 0 0 10px rgba(42, 255, 122, 0.65);
}

.bezel-texture {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.2), transparent 45%),
    radial-gradient(circle at 88% 82%, rgba(0, 0, 0, 0.28), transparent 50%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, rgba(0, 0, 0, 0.08) 1px 2px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.04) 0 3px, rgba(255, 255, 255, 0.06) 3px 6px);
  mix-blend-mode: multiply;
  opacity: 0.55;
  z-index: 1;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px dashed rgba(42, 255, 122, 0.65);
  outline-offset: 4px;
}

.crt-chassis {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, rgba(13, 70, 33, 0.75), rgba(1, 5, 3, 1));
  border-radius: 28px;
  box-shadow:
    var(--crt-shadow),
    inset 0 0 120px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.crt-chassis::before,
.crt-chassis::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

.crt-chassis::before {
  border: 2px solid rgba(42, 255, 122, 0.15);
  mix-blend-mode: screen;
  opacity: 0.8;
}

.crt-chassis::after {
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.8);
}

.crt-bezel {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 30%, rgba(42, 255, 122, 0.08), transparent 55%);
  filter: blur(30px);
  opacity: 0.55;
  pointer-events: none;
}

.crt-scanlines {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0),
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 2px,
      rgba(0, 0, 0, 0.18) 3px
    ),
    repeating-linear-gradient(
      to right,
      rgba(0, 0, 0, 0),
      rgba(0, 0, 0, 0) 3px,
      rgba(0, 0, 0, 0.12) 3px,
      rgba(0, 0, 0, 0.12) 4px
    );
  opacity: 0.35;
  pointer-events: none;
  mix-blend-mode: multiply;
  animation: drift 14s linear infinite;
}

.hud,
.hud-footer {
  position: relative;
  z-index: 1;
  padding: clamp(1rem, 2vw, 1.5rem) clamp(1.2rem, 2.5vw, 2rem);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.hud {
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  color: var(--crt-muted);
}

.hud-title {
  margin: 0;
  color: var(--crt-text);
  letter-spacing: 0.15em;
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
}

.hud-meta {
  margin: 0.35rem 0 0;
  font-size: 0.82em;
  letter-spacing: 0.14em;
  color: var(--crt-muted);
}

.hud-meta:first-of-type {
  margin-top: 0.4rem;
}

.hud-meta-highlight {
  color: var(--crt-glow);
}

.hud-status {
  text-align: right;
  display: grid;
  gap: 0.25rem;
  justify-items: end;
}

.hud-label {
  margin: 0;
  font-size: 0.75em;
  letter-spacing: 0.22em;
  color: rgba(200, 255, 217, 0.45);
}

.hud-clock {
  margin: 0;
  color: var(--crt-glow);
  font-size: clamp(1rem, 2.4vw, 1.3rem);
}

.hud-access {
  margin: 0;
  font-size: 0.75em;
  letter-spacing: 0.16em;
}

.hud-state {
  margin: 0;
}

.console {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(240px, 0.32fr) 1fr;
  gap: clamp(1rem, 2vw, 1.75rem);
  padding: 0 clamp(1.2rem, 2.5vw, 2rem);
  min-height: 0;
}

.console-menu {
  background: linear-gradient(180deg, rgba(6, 32, 18, 0.92), rgba(3, 18, 10, 0.92));
  border: 1px solid rgba(42, 255, 122, 0.25);
  border-top: none;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
  padding: clamp(0.5rem, 1.2vw, 0.9rem) clamp(0.8rem, 1.7vw, 1.2rem) clamp(0.7rem, 1.7vw, 1.2rem);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
  /* Constrain menu to its grid cell so internal scrolling works */
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.console-menu::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(42, 255, 122, 0.1);
  border-top: none;
  pointer-events: none;
}

.menu-heading {
  margin: 0 0 0.3rem;
  font-size: clamp(0.9rem, 1.7vw, 1.05rem);
  color: var(--crt-glow);
  letter-spacing: 0.14em;
}

/* Extended Protocol System spacing (Issue #32) */
.menu-heading:not(:first-of-type) {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(42, 255, 122, 0.2);
}

/* Navigation list styling for accessibility */
.console-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.console-menu::-webkit-scrollbar {
  width: 0.45rem;
}

.console-menu::-webkit-scrollbar-track {
  background: rgba(3, 18, 10, 0.35);
  border-radius: 12px;
}

.console-menu::-webkit-scrollbar-thumb {
  background: rgba(42, 255, 122, 0.35);
  border-radius: 12px;
}

.console-menu {
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 255, 122, 0.35) rgba(3, 18, 10, 0.35);
}

.console-menu li {
  margin: 0;
}

.menu-button {
  position: relative;
  padding: 0.36rem 0.5rem;
  font-size: clamp(0.88rem, 1.6vw, 0.98rem);
  text-align: left;
  border: 1px solid rgba(42, 255, 122, 0.2);
  color: var(--crt-text);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.menu-button::before {
  content: '▸';
  margin-right: 0.5rem;
  color: rgba(42, 255, 122, 0.45);
}

.menu-button:hover,
.menu-button:focus-visible {
  background: rgba(42, 255, 122, 0.12);
  color: var(--crt-glow);
  box-shadow: 0 0 12px rgba(42, 255, 122, 0.25);
}

.menu-button.is-active {
  background: rgba(42, 255, 122, 0.22);
  border-color: rgba(42, 255, 122, 0.45);
  color: var(--crt-glow);
  box-shadow: 0 0 18px rgba(42, 255, 122, 0.35);
  outline: 2px dashed rgba(42, 255, 122, 0.65);
  outline-offset: 4px;
}

.menu-button.is-active::before {
  color: var(--crt-glow);
  content: '▶';
}

.console-screen {
  position: relative;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(6, 32, 18, 0.92), rgba(3, 18, 10, 0.95));
  border: 1px solid rgba(42, 255, 122, 0.35);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.75);
  padding: clamp(1.2rem, 2.5vw, 2rem);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  cursor: text;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(42, 255, 122, 0.12), transparent 85%);
  mix-blend-mode: screen;
  opacity: 0.5;
  pointer-events: none;
}

.terminal-output {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 0.5rem;
  padding-right: clamp(0.35rem, 1vw, 0.75rem);
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 255, 122, 0.45) rgba(3, 18, 10, 0.4);
  min-height: 0;
}

.terminal-output::-webkit-scrollbar {
  width: 0.55rem;
}

.terminal-output::-webkit-scrollbar-track {
  background: rgba(3, 18, 10, 0.35);
  border-radius: 999px;
}

.terminal-output::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(42, 255, 122, 0.6), rgba(42, 255, 122, 0.35));
  border-radius: 999px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.45);
}

.terminal-output::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(200, 255, 217, 0.75), rgba(42, 255, 122, 0.55));
}

.terminal-output p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
  text-shadow: 0 0 8px rgba(42, 255, 122, 0.25);
}

.terminal-link {
  color: var(--crt-glow);
  text-decoration: none;
  border-bottom: 1px dotted rgba(42, 255, 122, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition:
    color 0.2s ease,
    border-color 0.2s ease,
    text-shadow 0.2s ease;
}

.terminal-link:hover,
.terminal-link:focus-visible {
  color: #c8ffd9;
  border-bottom-color: rgba(200, 255, 217, 0.6);
  text-shadow: 0 0 12px rgba(200, 255, 217, 0.45);
}

.terminal-link:focus-visible {
  outline: 1px dashed rgba(200, 255, 217, 0.65);
  outline-offset: 3px;
}

.terminal-output p::before {
  content: '> ';
  color: rgba(42, 255, 122, 0.5);
}

.console-update {
  position: absolute;
  left: clamp(1rem, 2vw, 1.8rem);
  right: clamp(1rem, 2vw, 1.8rem);
  bottom: clamp(1rem, 2.5vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: clamp(0.9rem, 2vw, 1.2rem);
  border-radius: 16px;
  border: 1px solid rgba(42, 255, 122, 0.45);
  background: rgba(4, 24, 14, 0.9);
  box-shadow: 0 0 24px rgba(42, 255, 122, 0.32);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  z-index: 5;
}

.console-update.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.console-update__heading {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.2rem);
  letter-spacing: 0.14em;
  color: var(--crt-glow);
  text-transform: uppercase;
}

.console-update__message {
  margin: 0;
  font-size: clamp(0.92rem, 1.8vw, 1.1rem);
  line-height: 1.5;
  color: var(--crt-text);
}

.console-update__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.console-update__action {
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(42, 255, 122, 0.3);
  background: rgba(42, 255, 122, 0.08);
  color: var(--crt-text);
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.console-update__action:hover,
.console-update__action:focus-visible {
  background: rgba(42, 255, 122, 0.18);
  border-color: rgba(42, 255, 122, 0.45);
  color: var(--crt-glow);
  box-shadow: 0 0 14px rgba(42, 255, 122, 0.35);
}

.console-update__action--primary {
  background: rgba(42, 255, 122, 0.24);
  border-color: rgba(42, 255, 122, 0.5);
  color: var(--crt-glow);
}

.console-update__action--primary:hover,
.console-update__action--primary:focus-visible {
  background: rgba(42, 255, 122, 0.35);
}

.console-update__action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.terminal-output p.system {
  color: var(--crt-muted);
}

.terminal-output p.system::before {
  content: '// ';
}

.terminal-output p.title {
  font-size: 1.1em;
  color: var(--crt-glow);
  text-shadow: 0 0 12px rgba(42, 255, 122, 0.4);
}

.terminal-output p.title::before {
  content: ':: ';
  color: var(--crt-glow);
}

.terminal-output p.subheading {
  font-size: 1.05em;
  color: var(--crt-text);
  letter-spacing: 0.12em;
}

.terminal-output p.subheading::before {
  content: ':: ';
  color: var(--crt-muted);
}

.terminal-output p.spacer::before {
  content: '';
}

.terminal-output p.spacer {
  opacity: 0;
}

.terminal-output p.list-item::before {
  content: '';
}

.terminal-output span.accent {
  color: var(--crt-glow);
  text-shadow: 0 0 10px rgba(42, 255, 122, 0.35);
}

.terminal-output span.code {
  font-family: 'Share Tech Mono', monospace;
  background: rgba(42, 255, 122, 0.12);
  border: 1px solid rgba(42, 255, 122, 0.25);
  padding: 0.05rem 0.3rem;
  margin: 0 0.1rem;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0.04em;
}

.cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: clamp(0.6rem, 1vw, 0.8rem);
  height: clamp(1.1rem, 2.4vw, 1.5rem);
  background: var(--crt-glow);
  box-shadow: 0 0 12px rgba(42, 255, 122, 0.6);
  animation: blink 1.1s steps(2, start) infinite;
  /* Use transform for movement to avoid layout/reflow on left/top changes */
  will-change: transform;
  /* Micro-smoothing after insertion: default small transform transition. */
  transition: transform var(--rdi-caret-smooth-ms) linear;
}

.hud-footer {
  align-items: center;
  border-top: 1px solid rgba(42, 255, 122, 0.12);
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  color: var(--crt-muted);
}

.footer-instructions {
  display: flex;
  gap: clamp(1rem, 2.2vw, 2.5rem);
}

.footer-meta {
  letter-spacing: 0.12em;
}

/* Connection Status Indicator (Issue #33) */
#connection-status {
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
}

.connection-online {
  color: var(--crt-glow);
  background: rgba(42, 255, 122, 0.15);
  border: 1px solid rgba(42, 255, 122, 0.3);
}

.connection-offline {
  color: #ff6b42;
  background: rgba(255, 107, 66, 0.15);
  border: 1px solid rgba(255, 107, 66, 0.3);
  animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

/* Easter Egg Animations (Issue #36) */
@keyframes konami-flash {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.5) hue-rotate(60deg);
  }
}

@keyframes pulse-secret {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(255, 107, 66, 0.3);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 107, 66, 0.8);
    transform: scale(1.02);
  }
}

@keyframes matrix-fall {
  0% {
    transform: translateY(-100vh);
  }
  100% {
    transform: translateY(100vh);
  }
}

/* Secret protocol button styling */
.menu-button-secret {
  position: relative;
  overflow: hidden;
}

.menu-button-secret::after {
  content: '🔒';
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8em;
  opacity: 0.7;
}

/* Halloween mode overrides */
.halloween-mode {
  --crt-glow: #ff6b42;
  --crt-text: #ffab8a;
  --crt-muted: #ff8a6b;
}

/* Hacker mode styling */
.hacker-mode {
  --crt-bg: #000000;
  --crt-glow: #00ff00;
  --crt-text: #00ff00;
  --crt-muted: #008800;
}

.hacker-mode .terminal-bezel {
  border-color: #00ff00;
  animation: pulse-secret 2s ease-in-out infinite;
}

.hacker-mode .crt-scanlines {
  opacity: 0.8;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 255, 0, 0.1) 2px,
    rgba(0, 255, 0, 0.1) 3px
  );
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, -10%, 0);
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* Dynamic Status Animation (Issue #31) */
.status-updating {
  position: relative;
  animation: status-pulse 0.2s ease-out;
}

@keyframes status-pulse {
  0% {
    transform: scale(1);
    text-shadow: 0 0 8px rgba(42, 255, 122, 0.3);
  }
  50% {
    transform: scale(1.02);
    text-shadow: 0 0 12px rgba(42, 255, 122, 0.6);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 8px rgba(42, 255, 122, 0.3);
  }
}

@media (max-width: 1024px) {
  .terminal-bezel {
    height: auto;
  }

  .console {
    grid-template-columns: minmax(150px, 0.34fr) 1fr;
  }
}

@media (max-width: 720px) {
  body {
    padding: 1rem;
  }

  .terminal-bezel {
    width: 100%;
    padding: 1.2rem;
    border-radius: 28px;
  }

  .crt-chassis {
    height: auto;
  }

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

  .console-menu {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .menu-button {
    flex: 1 1 calc(50% - 0.5rem);
    text-align: center;
  }

  .console-screen {
    min-height: 320px;
  }
}

/* Keyboard Help Overlay */
.keyboard-help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.keyboard-help-content {
  background: var(--crt-bg);
  border: 2px solid var(--crt-glow);
  border-radius: 8px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 0 30px rgba(42, 255, 122, 0.3);
}

.keyboard-help-content h2 {
  color: var(--crt-glow);
  margin: 0 0 1.5rem 0;
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border: 1px solid var(--crt-muted);
  border-radius: 4px;
  background: rgba(11, 58, 30, 0.3);
}

.shortcut kbd {
  background: var(--crt-glow);
  color: var(--crt-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: inherit;
  font-weight: bold;
  font-size: 0.9rem;
  min-width: 2rem;
  text-align: center;
}

.shortcut span {
  color: var(--crt-text);
  flex: 1;
  margin-left: 1rem;
}

.help-close {
  text-align: center;
  color: var(--crt-muted);
  font-size: 0.9rem;
  margin: 0;
  font-style: italic;
}

@media (min-width: 600px) {
  .shortcuts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Motion Preferences - Respect user accessibility settings */
@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none !important;
    opacity: 1;
  }

  .crt-chassis::before {
    animation: none !important;
  }

  .ambient-toggle {
    transition: none !important;
  }

  .menu-button {
    transition: none !important;
  }

  /* Reduce scanline effect intensity */
  .crt-scanlines {
    animation: none !important;
    opacity: 0.1 !important;
  }

  /* Disable all pulsing and drift animations */
  .status-updating {
    animation: none !important;
  }

  .connection-offline {
    animation: none !important;
  }

  /* Static mode for typewriter - users can still skip manually */
  .reduced-motion-mode .typewriter-effect {
    animation: none !important;
  }
}

/* User-controlled reduced motion class */
.reduced-motion {
  .cursor {
    animation: none !important;
    opacity: 1;
  }

  .typewriter-effect {
    animation: none !important;
  }

  .crt-scanlines {
    animation: none !important;
    opacity: 0.05 !important;
  }

  .status-updating {
    animation: none !important;
  }

  .connection-offline {
    animation: none !important;
  }

  .ambient-toggle,
  .menu-button,
  #connection-status {
    transition: none !important;
  }
}

/* High Contrast Mode */
.high-contrast {
  --crt-bg: #000000;
  --crt-primary: #ffffff;
  --crt-secondary: #333333;
  --crt-glow: #ffff00;
  --crt-text: #ffffff;
  --crt-muted: #cccccc;
  --crt-border: #ffffff;

  .terminal-bezel {
    border: 3px solid #ffffff;
    background: #000000;
  }

  .crt-chassis {
    background: #000000;
    box-shadow: none;
  }

  .menu-button {
    border: 2px solid #ffffff;
    background: #000000;
    color: #ffffff;
  }

  .menu-button:hover,
  .menu-button:focus-visible {
    background: #ffff00;
    color: #000000;
    outline: 3px solid #ffff00;
  }

  .menu-button.is-active {
    background: #ffff00;
    color: #000000;
    border-color: #ffffff;
  }

  .console-menu,
  .console-screen {
    background: #000000;
    border: 2px solid #ffffff;
  }

  .crt-scanlines {
    display: none;
  }

  .screen-overlay {
    display: none;
  }

  .terminal-output span.link {
    color: #ffff00;
    text-decoration: underline;
  }

  .ambient-toggle {
    border: 2px solid #ffffff;
    background: #000000;
    color: #ffffff;
  }

  .ambient-toggle:focus-visible {
    outline: 3px solid #ffff00;
  }
}

/* Large Text Mode */
.large-text {
  font-size: 125% !important;
}

.large-text .terminal-output {
  font-size: clamp(1.25rem, 2.8vw, 1.6rem);
  line-height: 1.6;
}

.large-text .menu-button {
  font-size: clamp(1.25rem, 2.5vw, 1.4rem);
  padding: 0.7rem 0.8rem;
}

.large-text .hud {
  font-size: clamp(1.1rem, 2rem, 1.25rem);
}

.large-text .hud-clock {
  font-size: clamp(1.25rem, 3rem, 1.6rem);
}

/* Skip Animation Mode */
.skip-animations * {
  animation-duration: 0.01s !important;
  animation-delay: 0s !important;
  transition-duration: 0.01s !important;
}

/* Focus Improvements */
*:focus-visible {
  outline: 2px solid var(--crt-glow);
  outline-offset: 2px;
  border-radius: 4px;
}

.high-contrast *:focus-visible {
  outline: 3px solid #ffff00;
  outline-offset: 3px;
}

/* Skip Links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--crt-glow);
  color: var(--crt-bg);
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
  z-index: 9999;
  font-family: inherit;
  letter-spacing: 0.1em;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 6px;
}

.high-contrast .skip-link {
  background: #ffff00;
  color: #000000;
  border: 2px solid #000000;
}

/* Accessibility Settings Panel */
.accessibility-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--crt-bg);
  border: 2px solid var(--crt-glow);
  border-radius: 8px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 0 30px rgba(42, 255, 122, 0.3);
  z-index: 10000;
  max-height: 80vh;
  overflow-y: auto;
}

/* Compact accessibility micro-trigger (low real-estate) */
.accessibility-micro {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.06);
  background: rgba(11, 58, 30, 0.12);
  display: inline-block;
  margin-left: 0.75rem;
  cursor: pointer;
}
.accessibility-micro:focus {
  outline: 3px solid rgba(42, 255, 122, 0.22);
  box-shadow: 0 0 8px rgba(42, 255, 122, 0.18);
}
.footer-controls {
  display: inline-block;
  vertical-align: middle;
}

.accessibility-panel h2 {
  color: var(--crt-glow);
  margin: 0 0 1.5rem 0;
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
}

.setting-group {
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem;
  border: 1px solid var(--crt-muted);
  border-radius: 4px;
  background: rgba(11, 58, 30, 0.2);
}

.setting-label {
  color: var(--crt-text);
  font-size: 1rem;
  letter-spacing: 0.05em;
  flex: 1;
}

.setting-toggle {
  position: relative;
  width: 50px;
  height: 24px;
  background: rgba(42, 255, 122, 0.2);
  border: 1px solid var(--crt-glow);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.setting-toggle:before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--crt-glow);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.setting-toggle.active {
  background: rgba(42, 255, 122, 0.4);
}

.setting-toggle.active:before {
  transform: translateX(26px);
}

.accessibility-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--crt-muted);
}

.btn {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--crt-glow);
  background: transparent;
  color: var(--crt-glow);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.05em;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
  background: var(--crt-glow);
  color: var(--crt-bg);
}

.btn-primary {
  background: var(--crt-glow);
  color: var(--crt-bg);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--crt-text);
  border-color: var(--crt-text);
}

/* High contrast adjustments for accessibility panel */
.high-contrast .accessibility-panel {
  background: #000000;
  border: 3px solid #ffffff;
}

.high-contrast .setting-group {
  border: 2px solid #ffffff;
  background: #000000;
}

.high-contrast .setting-toggle {
  border: 2px solid #ffffff;
  background: #000000;
}

.high-contrast .setting-toggle:before {
  background: #ffff00;
}

.high-contrast .btn {
  border: 2px solid #ffffff;
  color: #ffffff;
}

.high-contrast .btn:hover,
.high-contrast .btn:focus-visible {
  background: #ffff00;
  color: #000000;
}
