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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background: #0B0E1A;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #F0F2F8;
  -webkit-font-smoothing: antialiased;
}

/* ===== CONTAINER ===== */
#game-container {
  width: 100%;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #0C1021 0%, #111631 100%);
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ===== START SCREEN ===== */
#start-screen {
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.start-group-top,
.start-group-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.start-group-bottom {
  gap: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.start-group-bottom.hydrated {
  opacity: 1;
}

#start-screen h1 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #E8364F 0%, #FFFFFF 50%, #1A56DB 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

[data-mode="world"] #start-screen h1 {
  background-image: linear-gradient(135deg, #00D4AA 0%, #FF6B35 50%, #FFD600 100%);
}

#start-screen .subtitle {
  font-size: 1.05rem;
  color: #9BA3C7;
  margin-bottom: 16px;
  font-weight: 500;
}

#start-screen .instructions {
  font-size: 0.85rem;
  color: #6B7399;
  margin-bottom: 24px;
  line-height: 1.7;
}

/* Trophy / Leaderboard button */
.btn-trophy {
  background: none;
  border: 1px solid rgba(255, 214, 0, 0.3);
  color: #FFD600;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
  letter-spacing: 0.3px;
}

.btn-trophy:hover {
  background: rgba(255, 214, 0, 0.1);
  border-color: rgba(255, 214, 0, 0.5);
}

.btn-trophy:active {
  transform: scale(0.97);
}

/* "Best: X" label on mode buttons */
.mode-best {
  font-size: 0.55rem;
  opacity: 0.75;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-top: 2px;
  min-height: 0.75em;
}

.hs-section {
  margin-bottom: 8px;
  width: 100%;
}

.hs-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5A6199;
  margin-bottom: 3px;
}

.hs-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 1px 0;
}

.hs-rank {
  font-size: 0.6rem;
  font-weight: 700;
  color: #6B7399;
  min-width: 14px;
  text-align: right;
}

.hs-entry-score {
  font-size: 0.8rem;
  font-weight: 700;
  color: #DDE3F8;
  min-width: 48px;
  text-align: right;
}

.hs-entry-meta {
  display: flex;
  align-items: center;
  gap: 3px;
}

.hs-meta-badge {
  font-size: 0.6rem;
}

.hs-meta-date {
  font-size: 0.5rem;
  color: #6B7399;
  font-weight: 500;
}

.hs-empty {
  font-size: 0.85rem;
  color: #6B7399;
  font-style: italic;
  margin-top: 16px;
}

/* ===== LEADERBOARD SCREEN ===== */
#leaderboard-screen {
  align-items: center;
  padding: 24px;
  overflow-y: auto;
}

#leaderboard-screen .btn-back {
  align-self: flex-start;
  margin-bottom: 8px;
}

.leaderboard-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #FFD600;
  letter-spacing: 1px;
  margin-bottom: 20px;
}

.leaderboard-content {
  width: 100%;
  max-width: 400px;
}

.leaderboard-content .hs-section {
  margin-bottom: 22px;
}

.leaderboard-content .hs-section-label {
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.leaderboard-content .hs-entry {
  padding: 4px 0;
  gap: 10px;
}

.leaderboard-content .hs-rank {
  font-size: 0.8rem;
  min-width: 18px;
}

.leaderboard-content .hs-entry-score {
  font-size: 1.1rem;
  min-width: 56px;
}

.leaderboard-content .hs-meta-badge {
  font-size: 0.8rem;
}

.leaderboard-content .hs-meta-date {
  font-size: 0.7rem;
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, #00A99D, #00D4AA);
  color: white;
  border: none;
  padding: 14px 52px;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 18px rgba(0, 169, 157, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 169, 157, 0.55);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 169, 157, 0.3);
}

/* Mode slider viewport */
.mode-slider-viewport {
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  position: relative;
}

.mode-slider-track {
  display: flex;
  width: 200%;
  transition: transform 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.mode-slider-track.show-difficulty {
  transform: translateX(-50%);
}

.mode-panel {
  width: 50%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 20px 22px;
  box-sizing: border-box;
}

/* Mode selector */
.mode-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-mode {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px;
  background: linear-gradient(135deg, #00A99D, #00D4AA);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 18px rgba(0, 169, 157, 0.4);
}

.btn-mode:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 169, 157, 0.55);
}

.btn-mode:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 169, 157, 0.3);
}

.mode-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 2px;
}

.mode-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.mode-desc {
  font-size: 0.65rem;
  opacity: 0.92;
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* Back button (difficulty panel) */
.difficulty-header {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  position: relative;
}

.btn-back {
  background: none;
  border: none;
  color: #00D4AA;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.difficulty-header .btn-back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.btn-back:hover {
  background: rgba(0, 212, 170, 0.1);
  color: #9BA3C7;
}

/* Difficulty selector */
.difficulty-label {
  font-size: 0.85rem;
  color: #9BA3C7;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  width: 100%;
}

.difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-difficulty {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 10px;
  background: linear-gradient(135deg, #00A99D, #00D4AA);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 18px rgba(0, 169, 157, 0.4);
}

.btn-difficulty:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 169, 157, 0.55);
}

.btn-difficulty:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 169, 157, 0.3);
}

.diff-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.diff-desc {
  font-size: 0.65rem;
  opacity: 0.92;
  letter-spacing: 0.3px;
  font-weight: 500;
}


/* ===== GAME SCREEN ===== */
#game-screen {
  display: none;
}

/* Header HUD */
#game-header {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 80px 10px 16px;
  background: rgba(12, 16, 33, 0.92);
  border-bottom: 1px solid rgba(0, 212, 170, 0.15);
  flex-shrink: 0;
  height: 54px;
  position: relative;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.hud-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #5A6199;
  font-weight: 600;
}

.hud-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #DDE3F8;
  font-variant-numeric: tabular-nums;
}

#streak-val {
  color: #FF2D78;
}

#streak-val.on-fire {
  color: #FF8C00;
  text-shadow: 0 0 10px rgba(255, 140, 0, 0.6);
}

/* Sound toggle (shared style) */
.sound-toggle {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #5A6199;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.sound-toggle:hover {
  color: #9BA3C7;
  background: rgba(155, 163, 199, 0.1);
}

#start-screen .sound-toggle:hover {
  background: transparent;
}

.sound-toggle.on {
  color: #00D4AA;
}

/* Voice toggle (start screen — same pattern as sound toggle) */
.voice-toggle {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #5A6199;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.voice-toggle:hover {
  color: #9BA3C7;
  background: rgba(155, 163, 199, 0.1);
}

#start-screen .voice-toggle:hover {
  background: transparent;
}

.voice-toggle.on {
  color: #00D4AA;
}

.voice-toggle.hidden {
  display: none;
}

.voice-toggle svg {
  width: 18px;
  height: 18px;
}

/* Settings rows (two-row layout on start screen) */
.settings-rows {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.speed-buttons {
  display: flex;
}

.toggles-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.btn-speed {
  background: rgba(37, 43, 80, 0.5);
  border: 1px solid #252B50;
  color: #6B7399;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-speed:first-child {
  border-radius: 6px 0 0 6px;
}

.btn-speed:last-child {
  border-radius: 0 6px 6px 0;
}

.btn-speed:not(:first-child) {
  border-left: none;
}

.btn-speed:hover {
  color: #9BA3C7;
  background: rgba(37, 43, 80, 0.8);
}

.btn-speed.active {
  background: #00A99D;
  border-color: #00A99D;
  color: #ffffff;
}

.btn-speed.active + .btn-speed {
  border-left: 1px solid #252B50;
}

/* Hints toggle */
.hints-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.hints-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.hints-check {
  width: 16px;
  height: 16px;
  border: 2px solid #3A4168;
  border-radius: 4px;
  background: rgba(37, 43, 80, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.hints-toggle input:checked + .hints-check {
  background: #00A99D;
  border-color: #00A99D;
}

.hints-toggle input:checked + .hints-check::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.hints-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #5A6199;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.toggle-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #5A6199;
}

/* ===== VOICE GATE (first-run interstitial) ===== */
#voice-gate-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(11, 14, 26, 0.98);
}

.voice-gate-card {
  max-width: 300px;
  padding: 28px 24px;
  background: linear-gradient(135deg, rgba(20, 24, 51, 0.95), rgba(30, 35, 69, 0.95));
  border: 1px solid rgba(0, 212, 170, 0.15);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.voice-gate-icon {
  color: #00D4AA;
  margin-bottom: 12px;
}

.voice-gate-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #DDE3F8;
  margin-bottom: 8px;
}

.voice-gate-desc {
  font-size: 0.78rem;
  color: #9BA3C7;
  margin-bottom: 24px;
  line-height: 1.5;
}

.voice-gate-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voice-gate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.voice-gate-yes {
  background: linear-gradient(135deg, #00A99D, #00D4AA);
  color: white;
  box-shadow: 0 4px 18px rgba(0, 169, 157, 0.4);
}

.voice-gate-yes:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 169, 157, 0.55);
}

.voice-gate-yes:active {
  transform: translateY(0);
}

.voice-gate-no {
  background: rgba(37, 43, 80, 0.7);
  color: #9BA3C7;
  border: 1px solid #3A4168;
}

.voice-gate-no:hover {
  background: rgba(37, 43, 80, 1);
  color: #DDE3F8;
}

.voice-gate-footnote {
  font-size: 0.62rem;
  color: #5A6199;
  margin-top: 16px;
  font-style: italic;
}

/* Speed toggle — game header */
.speed-toggle {
  position: absolute;
  right: 78px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.speed-toggle:hover {
  background: rgba(155, 163, 199, 0.1);
}

/* Sound toggle — game header */
#sound-toggle-game {
  position: absolute;
  right: 44px;
  top: 50%;
  transform: translateY(-50%);
}

/* Quit button */
#quit-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #5A6199;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

#quit-btn:hover {
  color: #FF5252;
  background: rgba(255, 82, 82, 0.1);
}

/* Quit confirmation strip */
#quit-confirm {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(12, 16, 33, 0.97);
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 5;
}

#quit-confirm.visible {
  display: flex;
}

#quit-confirm span {
  font-size: 0.9rem;
  font-weight: 600;
  color: #9BA3C7;
}

#quit-confirm button {
  padding: 5px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.15s;
}

#quit-yes {
  background: #FF3B3B;
  color: white;
}

#quit-no {
  background: #252B50;
  color: #DDE3F8;
}

#quit-confirm button:hover {
  opacity: 0.85;
}

/* ===== PLAY AREA ===== */
#play-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-image:
    linear-gradient(rgba(0, 212, 170, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 170, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
}

/* Mode background watermark */
#play-area::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
  background-position: center 45%;
  background-size: 65% auto;
  opacity: 0.07;
}

[data-mode="world"] #play-area::before {
  background-image: url('../assets/earth-icon.svg');
  opacity: 0.11;
}

[data-mode="us"] #play-area::before {
  background-image: url('../assets/us-flag-icon.svg');
  background-size: 75% auto;
}

#danger-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 59, 59, 0.35) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.8s;
  z-index: 1;
  pointer-events: none;
}

/* ===== INPUT AREA ===== */
#input-area {
  display: flex;
  padding: 10px 12px;
  gap: 8px;
  background: rgba(12, 16, 33, 0.95);
  border-top: 1px solid rgba(0, 212, 170, 0.15);
  flex-shrink: 0;
  height: 56px;
}

#answer-input {
  flex: 1;
  background: #141833;
  border: 2px solid #252B50;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 1rem;
  color: #F0F2F8;
  outline: none;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.2s;
}

#answer-input:focus {
  border-color: #00D4AA;
}

#answer-input.game-active,
#answer-input.game-active:focus {
  border-color: rgba(0, 212, 170, 0.45);
}

#answer-input::placeholder {
  color: #3A4168;
}

#answer-input.wrong {
  border-color: #FF3B3B;
}

#answer-input.close {
  border-color: #FFB74D;
}

#answer-input.locked {
  cursor: default;
}

#submit-btn {
  width: 46px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #00A99D, #00D4AA);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#submit-btn:hover {
  opacity: 0.85;
}

/* ===== MOBILE KEYBOARD ===== */
.mobile-kb-active #input-area {
  display: none !important;
}

#mobile-keyboard {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  background: rgba(12, 16, 33, 0.97);
  border-top: 1px solid rgba(0, 212, 170, 0.15);
  padding: 4px 3px 6px;
  gap: 4px;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.mobile-kb-active #mobile-keyboard {
  display: flex;
}

/* Mobile-specific block sizing */
.mobile-kb-active .block {
  height: 28px;
  font-size: 0.82rem;
}

.mobile-kb-active .block.missed {
  font-size: 0.65rem;
}

/* Display bar */
.kb-display {
  display: flex;
  align-items: center;
  height: 36px;
  background: #141833;
  border: 2px solid #252B50;
  border-radius: 8px;
  padding: 0 12px;
  margin: 0 1px 2px;
  overflow: hidden;
  transition: border-color 0.2s;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.kb-display.game-active {
  border-color: rgba(0, 212, 170, 0.45);
}

.kb-display.wrong {
  border-color: #FF3B3B;
}

.kb-display.close {
  border-color: #FFB74D;
}

.kb-display.shake {
  animation: shake 0.4s ease-in-out;
}

.kb-display.shake-soft {
  animation: shake-soft 0.35s ease-in-out;
}

.kb-display-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: #F0F2F8;
  white-space: nowrap;
}

.kb-display-text.placeholder {
  color: #3A4168;
}

.kb-display.selected .kb-display-text {
  /* no visible highlight — select-all is functional only */
}

.kb-display-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: #00D4AA;
  margin-left: 1px;
  flex-shrink: 0;
  animation: kb-blink 1s step-end infinite;
}

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

/* Key rows */
.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.kb-row-inset {
  padding: 0 14px;
}

/* Keys */
.kb-key {
  flex: 1;
  max-width: 40px;
  height: 48px;
  border: none;
  border-radius: 5px;
  background: #1E2345;
  color: #DDE3F8;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.08s;
  padding: 0;
}

.kb-key:active,
.kb-key.active {
  background: #2D3460;
}

.kb-key-submit {
  flex: 1.5;
  max-width: 60px;
  background: linear-gradient(135deg, #00A99D, #00D4AA);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.kb-key-submit:active,
.kb-key-submit.active {
  opacity: 0.85;
  background: linear-gradient(135deg, #00A99D, #00D4AA);
}

.kb-key-backspace {
  flex: 1.5;
  max-width: 60px;
  font-size: 1.2rem;
}

.kb-key-space {
  max-width: none;
  height: 40px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #5A6199;
}

/* US mode keyboard theming */
[data-mode="us"] #mobile-keyboard {
  border-top-color: rgba(26, 86, 219, 0.15);
}

[data-mode="us"] .kb-display.game-active {
  border-color: rgba(75, 139, 255, 0.45);
}

[data-mode="us"] .kb-key-submit {
  background: linear-gradient(135deg, #1A56DB, #4B8BFF);
}

[data-mode="us"] .kb-key-submit:active,
[data-mode="us"] .kb-key-submit.active {
  background: linear-gradient(135deg, #1A56DB, #4B8BFF);
}

[data-mode="us"] .kb-display-cursor {
  background: #4B8BFF;
}

/* ===== MOBILE VOICE MODE (keyboard hidden, play area expanded) ===== */
#game-screen.mobile-kb-active.voice-mode-active .kb-row {
  display: none !important;
}

#game-screen.mobile-kb-active.voice-mode-active #mobile-keyboard {
  padding: 4px 3px 4px;
  gap: 0;
}

/* Pulsing listening dot in display bar during voice mode */
#game-screen.mobile-kb-active.voice-mode-active .kb-display::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00D4AA;
  flex-shrink: 0;
  margin-right: 8px;
  animation: voice-dot-pulse 1.2s ease-in-out infinite;
}

@keyframes voice-dot-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

[data-mode="us"] #game-screen.mobile-kb-active.voice-mode-active .kb-display::before {
  background: #4B8BFF;
}

/* Processing state: dot morphs into a spinning arc */
#game-screen.mobile-kb-active.voice-mode-active .kb-display.speech-processing-parent::before {
  width: 12px;
  height: 12px;
  background: transparent;
  border: 2px solid rgba(0, 212, 170, 0.2);
  border-top-color: #00D4AA;
  opacity: 1;
  animation: voice-spinner 0.6s linear infinite;
}

[data-mode="us"] #game-screen.mobile-kb-active.voice-mode-active .kb-display.speech-processing-parent::before {
  border-color: rgba(75, 139, 255, 0.2);
  border-top-color: #4B8BFF;
}

@keyframes voice-spinner {
  to { transform: rotate(360deg); }
}

/* ===== MIC BUTTON (Desktop) ===== */
#mic-btn {
  width: 46px;
  flex-shrink: 0;
  background: transparent;
  border: 2px solid #252B50;
  border-radius: 8px;
  color: #5A6199;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.3s;
}

#mic-btn:hover {
  color: #9BA3C7;
  border-color: #3A4168;
}

#mic-btn.listening {
  color: #00D4AA;
  border-color: #00D4AA;
  background: rgba(0, 212, 170, 0.08);
  box-shadow: 0 0 12px rgba(0, 212, 170, 0.3);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 212, 170, 0.25); }
  50%      { box-shadow: 0 0 18px rgba(0, 212, 170, 0.5); }
}

/* Hide desktop mic on mobile keyboard */
.mobile-kb-active #mic-btn {
  display: none !important;
}

/* ===== MIC BUTTON (Mobile — inside kb-display) ===== */
.kb-display {
  position: relative;
}

.kb-mic-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #5A6199;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s, box-shadow 0.3s;
}

.kb-mic-btn:active {
  background: rgba(155, 163, 199, 0.15);
}

.kb-mic-btn.listening {
  color: #00D4AA;
  background: rgba(0, 212, 170, 0.12);
  box-shadow: 0 0 10px rgba(0, 212, 170, 0.3);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

/* US mode mic theming */
[data-mode="us"] #mic-btn.listening {
  color: #4B8BFF;
  border-color: #4B8BFF;
  background: rgba(75, 139, 255, 0.08);
  box-shadow: 0 0 12px rgba(75, 139, 255, 0.3);
  animation: mic-pulse-us 1.2s ease-in-out infinite;
}

[data-mode="us"] .kb-mic-btn.listening {
  color: #4B8BFF;
  background: rgba(75, 139, 255, 0.12);
  box-shadow: 0 0 10px rgba(75, 139, 255, 0.3);
  animation: mic-pulse-us 1.2s ease-in-out infinite;
}

@keyframes mic-pulse-us {
  0%, 100% { box-shadow: 0 0 8px rgba(75, 139, 255, 0.25); }
  50%      { box-shadow: 0 0 18px rgba(75, 139, 255, 0.5); }
}

/* ===== SPEECH UNSUPPORTED (Safari) ===== */
#mic-btn.mic-unsupported,
.kb-mic-btn.mic-unsupported {
  opacity: 0.45;
}

.speech-unsupported-tip {
  position: fixed;
  left: 50%;
  transform: translate(-50%, -100%);
  max-width: calc(100vw - 32px);
  text-align: center;
  background: #1E2347;
  color: #C5CAE9;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #3A4168;
  z-index: 1000;
  pointer-events: none;
  animation: tip-fade 4s ease-out forwards;
}

@keyframes tip-fade {
  0%, 75% { opacity: 1; }
  100%    { opacity: 0; }
}

/* ===== SPEECH PROCESSING (Mobile only) ===== */
.mobile-kb-active #answer-input.speech-processing,
.mobile-kb-active .kb-display-text.speech-processing {
  border-color: #00D4AA;
}

.mobile-kb-active #answer-input.speech-processing::after,
.mobile-kb-active .kb-display.speech-processing-parent::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: #00D4AA;
  animation: speech-progress 1.2s ease-in-out infinite;
}

/* Processing shimmer bar on the mobile keyboard display */
.kb-display.speech-processing-parent {
  position: relative;
  overflow: hidden;
}

.kb-display.speech-processing-parent::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 40%;
  background: linear-gradient(90deg, transparent, #00D4AA, transparent);
  animation: speech-shimmer 1s ease-in-out infinite;
}

@keyframes speech-shimmer {
  0%   { left: -40%; }
  100% { left: 100%; }
}

/* Block pause visual — float + pulsing glow */
.block.speech-paused {
  animation: block-float 1s ease-in-out infinite, block-glow 1.2s ease-in-out infinite;
}

@keyframes block-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

@keyframes block-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 212, 170, 0.3); }
  50%      { box-shadow: 0 0 16px rgba(0, 212, 170, 0.6); }
}

/* US mode processing theming */
[data-mode="us"] .block.speech-paused {
  animation: block-float 1s ease-in-out infinite, block-glow-us 1.2s ease-in-out infinite;
}

@keyframes block-glow-us {
  0%, 100% { box-shadow: 0 0 6px rgba(75, 139, 255, 0.3); }
  50%      { box-shadow: 0 0 16px rgba(75, 139, 255, 0.6); }
}

[data-mode="us"] .kb-display.speech-processing-parent::after {
  background: linear-gradient(90deg, transparent, #4B8BFF, transparent);
}

/* Hide processing shimmer in mobile voice mode (pulsing dot is sufficient) */
.voice-mode-active .kb-display.speech-processing-parent::after {
  display: none;
}

/* ===== BLOCKS ===== */
.block {
  position: absolute;
  height: 42px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 10;
  padding: 0 14px;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s, opacity 0.3s;
  will-change: top;
}

.block.falling {
  background: linear-gradient(135deg, #FF6B35 0%, #FFAA00 100%);
  box-shadow:
    0 3px 12px rgba(255, 107, 53, 0.45),
    0 0 20px rgba(255, 107, 53, 0.15);
}

.block.correct {
  background: linear-gradient(135deg, #00E676, #00C853) !important;
  box-shadow: 0 0 28px rgba(0, 230, 118, 0.7), 0 0 56px rgba(0, 230, 118, 0.25);
  transform: scale(1.04);
  z-index: 12;
}

.block.missed {
  background: linear-gradient(135deg, #FF3B3B, #D32F2F) !important;
  box-shadow: 0 2px 8px rgba(255, 59, 59, 0.35);
  z-index: 5;
  font-size: 0.85rem;
  opacity: 0.9;
  transition: background 0.3s, box-shadow 0.3s, transform 0.3s, opacity 0.3s, top 0.4s ease-out, height 0.4s ease-out;
}

/* Landing impact squish */
.block.missed.impact {
  animation: block-land 0.38s cubic-bezier(0.22, 0.8, 0.36, 1) forwards;
}

@keyframes block-land {
  0%   { transform: scaleY(1) scaleX(1); }
  22%  { transform: scaleY(0.72) scaleX(1.06); }
  48%  { transform: scaleY(1.08) scaleX(0.98); }
  70%  { transform: scaleY(0.95) scaleX(1.01); }
  100% { transform: scaleY(1) scaleX(1); }
}

/* Play area screen shake — intensity scales via CSS variable */
.play-shake {
  animation: play-area-shake 0.32s ease-out;
}

@keyframes play-area-shake {
  0%        { transform: translateY(0); }
  20%       { transform: translateY(calc(4px * var(--shake-intensity, 1))); }
  40%       { transform: translateY(calc(-3px * var(--shake-intensity, 1))); }
  60%       { transform: translateY(calc(2px * var(--shake-intensity, 1))); }
  80%       { transform: translateY(calc(-1px * var(--shake-intensity, 1))); }
  100%      { transform: translateY(0); }
}

.block .check {
  font-size: 1.15rem;
}

.block.fade-out {
  opacity: 0;
  transform: scale(0.6);
}

/* Hint on falling block */
.block.hinted {
  line-height: 1.15;
}

.block-label {
  transition: font-size 0.24s ease, transform 0.24s ease;
  transform: translateY(0);
}

.block.hinted .block-label {
  font-size: 0.92rem;
  transform: translateY(-6px);
}

.block-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0);
  transform: translate(-50%, 6px);
  transition: color 0.22s ease-in, transform 0.24s ease;
  white-space: nowrap;
  font-family: 'Courier New', Courier, monospace;
  pointer-events: none;
}

.block-hint.visible {
  color: rgba(255, 255, 255, 0.75);
  transform: translate(-50%, 4px);
}

.mobile-kb-active .block.hinted .block-label {
  font-size: 0.72rem;
  transform: translateY(-5px);
}

.mobile-kb-active .block-hint {
  font-size: 0.52rem;
  letter-spacing: 1px;
}

/* ===== PARTICLES ===== */
.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  z-index: 15;
  pointer-events: none;
  animation: particle-scatter 0.6s ease-out forwards;
}

@keyframes particle-scatter {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); }
}

/* ===== PULSING DANGER BORDER ===== */
#play-area::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 2;
  opacity: var(--glow-opacity, 0);
  box-shadow:
    inset 0 0 calc(8px * var(--glow-intensity, 0)) rgba(255, 59, 59, 0.4),
    inset 0 0 calc(25px * var(--glow-intensity, 0)) rgba(255, 59, 59, 0.15);
  animation: danger-pulse var(--pulse-speed, 2.5s) ease-in-out infinite;
  transition: opacity 0.6s;
}

@keyframes danger-pulse {
  0%, 100% { opacity: var(--glow-opacity, 0); }
  50%      { opacity: calc(var(--glow-opacity, 0) * 0.45); }
}

/* ===== POINTS POPUP ===== */
.points-popup {
  position: absolute;
  font-weight: 700;
  font-size: 1.15rem;
  z-index: 20;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(0, 230, 118, 0.5);
  animation: float-up 1s ease-out forwards;
}

@keyframes float-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-65px); }
}

/* ===== FEEDBACK (wrong guess) ===== */
.feedback {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 30;
  pointer-events: none;
  white-space: nowrap;
  animation: feedback-pop 1.6s ease-out forwards;
}

.feedback.error {
  background: rgba(15, 20, 50, 0.95);
  color: #FF5252;
  border: 2px solid rgba(255, 82, 82, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.feedback.close {
  background: rgba(20, 18, 8, 0.95);
  color: #FFB74D;
  border: 2px solid rgba(255, 183, 77, 0.5);
  letter-spacing: 0.03em;
}

@keyframes feedback-pop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  65%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== ANSWER REVEAL (missed block) ===== */
.answer-reveal {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 20, 50, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 14px 28px;
  z-index: 35;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 60px rgba(255, 107, 53, 0.15);
  animation: answer-reveal-anim 2.2s ease-out forwards;
}

.answer-reveal-state {
  font-size: 1.05rem;
  font-weight: 600;
  color: #FF6B35;
}

.answer-reveal-arrow {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.35);
}

.answer-reveal-capital {
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.25);
}

@keyframes answer-reveal-anim {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  10%  { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  18%  { transform: translate(-50%, -50%) scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* ===== COUNTDOWN ===== */
.countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4rem;
  font-weight: 800;
  color: #00D4AA;
  z-index: 50;
  pointer-events: none;
  text-shadow: 0 0 30px rgba(0, 212, 170, 0.5);
}

.countdown.pop {
  animation: countdown-pop 0.55s ease-out;
}

@keyframes countdown-pop {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  50%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ===== LEVEL UP ===== */
.level-up-notice {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  font-weight: 800;
  color: #FF6B35;
  text-shadow: 0 0 24px rgba(255, 107, 53, 0.5);
  z-index: 40;
  pointer-events: none;
  animation: level-up 1.3s ease-out forwards;
}

@keyframes level-up {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  75%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* ===== SHAKE ===== */
.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.shake-soft {
  animation: shake-soft 0.35s ease-in-out;
}

@keyframes shake-soft {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  50%      { transform: translateX(3px); }
  75%      { transform: translateX(-2px); }
}

/* ===== GAME OVER SCREEN ===== */
#gameover-screen {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(11, 14, 26, 0.96);
  overflow-y: auto;
}

#gameover-screen h2 {
  font-size: 2.4rem;
  font-weight: 800;
  color: #FF3B3B;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

#new-high {
  display: none;
  color: #FFD600;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 24px;
  animation: pulse-glow 1.2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(255, 214, 0, 0.4); }
  50%      { opacity: 0.7; text-shadow: 0 0 16px rgba(255, 214, 0, 0.6); }
}

/* ===== SCORE CARD ===== */
.scorecard {
  margin-bottom: 24px;
  width: 100%;
  max-width: 320px;
}

.scorecard-final {
  font-size: 3rem;
  font-weight: 800;
  color: #DDE3F8;
  margin-bottom: 18px;
}

.scorecard-multiplier {
  font-size: 0.72rem;
  color: #9BA3C7;
  font-weight: 500;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.scorecard-details {
  background: rgba(20, 24, 51, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
}

.scorecard-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}

.scorecard-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.scorecard-stat .stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6B7399;
  font-weight: 600;
}

.scorecard-stat .stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #DDE3F8;
}

.scorecard-badges {
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
  margin-top: 12px;
}

.scorecard-badge-text {
  font-size: 0.65rem;
  color: #6B7399;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.scorecard-nudge {
  font-size: 0.62rem;
  color: #5A6199;
  font-weight: 500;
  font-style: italic;
  margin-bottom: 14px;
  min-height: 1.2em;
}

.scorecard-high {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.scorecard-high .stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6B7399;
  font-weight: 600;
}

.scorecard-high .stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #FFD600;
}

/* Victory scorecard overrides */
.victory-scorecard .scorecard-final {
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.victory-scorecard .scorecard-nudge {
  color: #5A6199;
}

.victory-scorecard .scorecard-high .stat-value {
  color: #FFD700;
}

/* ===== US MODE THEME (Stars & Stripes Arcade) ===== */

/* -- Blocks -- */
[data-mode="us"] .block.falling {
  background: linear-gradient(135deg, #E8364F 0%, #FF6B81 100%);
  box-shadow:
    0 3px 12px rgba(232, 54, 79, 0.5),
    0 0 20px rgba(255, 107, 129, 0.2);
}

/* correct block: inherit default green from .block.correct */

/* -- Play area -- */
[data-mode="us"] #play-area {
  background-image:
    linear-gradient(rgba(26, 86, 219, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 86, 219, 0.04) 1px, transparent 1px);
}

/* -- Header & input chrome -- */
[data-mode="us"] #game-header {
  border-bottom-color: rgba(26, 86, 219, 0.15);
}

[data-mode="us"] #input-area {
  border-top-color: rgba(26, 86, 219, 0.15);
}

[data-mode="us"] #answer-input:focus {
  border-color: #4B8BFF;
}

[data-mode="us"] #answer-input.game-active,
[data-mode="us"] #answer-input.game-active:focus {
  border-color: rgba(75, 139, 255, 0.45);
}

[data-mode="us"] #submit-btn {
  background: linear-gradient(135deg, #1A56DB, #4B8BFF);
}

/* -- Buttons -- */
[data-mode="us"] .btn-primary {
  background: linear-gradient(135deg, #1A56DB, #4B8BFF);
  box-shadow: 0 4px 18px rgba(26, 86, 219, 0.4);
}

[data-mode="us"] .btn-primary:hover {
  box-shadow: 0 6px 24px rgba(26, 86, 219, 0.55);
}

[data-mode="us"] .btn-primary:active {
  box-shadow: 0 2px 10px rgba(26, 86, 219, 0.3);
}

/* -- HUD accents -- */
[data-mode="us"] #streak-val {
  color: #FFD700;
}

[data-mode="us"] #streak-val.on-fire {
  color: #FF8C00;
  text-shadow: 0 0 10px rgba(255, 140, 0, 0.6);
}

/* -- Sound & speed toggles -- */
[data-mode="us"] .sound-toggle.on {
  color: #4B8BFF;
}

/* -- Quit button -- */
[data-mode="us"] #quit-btn:hover {
  color: #4B8BFF;
  background: rgba(75, 139, 255, 0.1);
}

[data-mode="us"] #quit-yes {
  background: #FF3B3B;
}

/* -- Countdown & level-up -- */
[data-mode="us"] .countdown {
  color: #4B8BFF;
  text-shadow: 0 0 30px rgba(75, 139, 255, 0.5);
}

[data-mode="us"] .level-up-notice {
  color: #FFD700;
  text-shadow: 0 0 24px rgba(26, 86, 219, 0.6);
}

/* -- Points popup -- */
[data-mode="us"] .points-popup {
  text-shadow: 0 0 12px rgba(0, 230, 118, 0.5);
}

/* -- Answer reveal -- */
[data-mode="us"] .answer-reveal {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 60px rgba(26, 86, 219, 0.15);
}

[data-mode="us"] .answer-reveal-state {
  color: #E8364F;
}

/* -- Game over screen -- */
[data-mode="us"] #gameover-screen h2 {
  color: #E8364F;
}

[data-mode="us"] #new-high {
  color: #FFD700;
}

[data-mode="us"] .scorecard-high .stat-value {
  color: #FFD700;
}

[data-mode="us"] .scorecard-nudge {
  color: #5A6199;
}

/* ===== VICTORY SCREEN ===== */
#victory-screen {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(40, 35, 10, 0.97) 0%, rgba(11, 14, 26, 0.98) 70%);
  overflow-y: auto;
}

#victory-screen h2 {
  font-size: 2.6rem;
  font-weight: 800;
  color: #FFD700;
  letter-spacing: 3px;
  margin-bottom: 4px;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

#victory-sub {
  font-size: 0.95rem;
  color: #FFC107;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

#victory-new-high {
  display: none;
  color: #FFD600;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 24px;
  animation: pulse-glow 1.2s ease-in-out infinite;
}

.victory-badge {
  display: none;
}

#victory-mode-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #6B7399;
  margin-bottom: 20px;
}

#victory-screen .scorecard {
  margin-bottom: 20px;
}

#victory-screen .btn-primary {
  background: linear-gradient(135deg, #FFC107, #FFD700);
  color: #1a1a2e;
  box-shadow: 0 4px 18px rgba(255, 193, 7, 0.4);
}

#victory-screen .btn-primary:hover {
  box-shadow: 0 6px 24px rgba(255, 193, 7, 0.55);
}

#victory-screen .btn-primary:active {
  box-shadow: 0 2px 10px rgba(255, 193, 7, 0.3);
}

/* ===== VICTORY PARTICLES ===== */
.particle.victory-particle {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: particle-scatter 1.1s ease-out forwards;
}

/* ===== PROGRESS HUD ===== */
#progress-val {
  color: #FFC107;
}

/* ===== LANDSCAPE ORIENTATION BLOCKER (mobile only) ===== */
#landscape-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0B0E1A;
  align-items: center;
  justify-content: center;
}

.landscape-message {
  text-align: center;
  padding: 24px;
}

.landscape-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-20deg); }
  75%      { transform: rotate(20deg); }
}

.landscape-message p {
  font-size: 1.1rem;
  font-weight: 600;
  color: #9BA3C7;
  line-height: 1.5;
}

@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  #landscape-overlay {
    display: flex;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  #start-screen {
    justify-content: space-between;
    padding-top: 8vh;
    padding-bottom: 6vh;
  }

  #start-screen h1 {
    font-size: 2.1rem;
  }

  #start-screen .subtitle {
    margin-bottom: 14px;
  }

  #start-screen .instructions {
    font-size: 0.78rem;
    margin-bottom: 20px;
    line-height: 1.5;
  }

  #game-header {
    height: 48px;
    padding: 8px 116px 8px 8px;
  }

  .hud-value {
    font-size: 1.05rem;
  }

  #input-area {
    height: 52px;
    padding: 8px 10px;
  }

  #answer-input {
    font-size: 0.95rem;
  }

  .block {
    font-size: 0.95rem;
  }

  .block.missed {
    font-size: 0.78rem;
  }

  .answer-reveal {
    padding: 10px 20px;
    gap: 8px;
  }

  .answer-reveal-state {
    font-size: 0.9rem;
  }

  .answer-reveal-capital {
    font-size: 1.1rem;
  }

  #gameover-screen,
  #victory-screen {
    justify-content: flex-start;
    padding-top: 10vh;
    padding-bottom: 20px;
  }

  #gameover-screen h2 {
    font-size: 2rem;
  }

  .scorecard-final {
    font-size: 2.4rem;
  }

  .scorecard-stat .stat-value {
    font-size: 1.1rem;
  }

  .scorecard-details {
    padding: 14px 16px;
  }

  .scorecard-stats {
    gap: 8px 14px;
  }

  .scorecard-nudge {
    font-size: 0.58rem;
  }

  .mode-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .btn-mode {
    padding: 14px 10px;
    gap: 4px;
  }

  .mode-icon {
    font-size: 1.2rem;
    margin-bottom: 0;
  }

  .mode-title {
    font-size: 0.9rem;
  }

  .mode-desc {
    font-size: 0.58rem;
  }

  .mode-best {
    font-size: 0.5rem;
  }

  .difficulty-buttons {
    gap: 8px;
  }

  .btn-difficulty {
    padding: 10px 14px;
    gap: 2px;
  }

  .diff-desc {
    font-size: 0.6rem;
  }

  .difficulty-label {
    font-size: 0.75rem;
  }

  .btn-speed {
    padding: 4px 10px;
    font-size: 0.65rem;
  }

  #victory-screen h2 {
    font-size: 2rem;
  }

  #progress-val {
    font-size: 0.9rem !important;
  }

  .hud-progress .hud-label {
    font-size: 0.5rem;
  }

  .hud-progress {
    max-width: 60px;
  }
}

/* ===== START SCREEN HEIGHT RESPONSIVENESS ===== */

/* --- Light tightening: short desktop / laptop windows --- */
@media (max-height: 670px) {
  #start-screen {
    justify-content: space-between;
    gap: 8px;
    padding: 20px 24px 16px;
  }

  #start-screen h1 {
    font-size: 2.2rem;
    margin-bottom: 4px;
  }

  #start-screen .subtitle {
    margin-bottom: 8px;
  }

  #start-screen .instructions {
    margin-bottom: 14px;
    line-height: 1.45;
  }

  .mode-panel {
    padding: 8px 20px 14px;
  }

  .btn-mode {
    padding: 12px 10px;
  }

  .btn-trophy {
    margin-top: 6px;
    padding: 6px 16px;
  }

  .settings-rows {
    gap: 10px;
    margin-top: 10px;
  }

  .difficulty-header {
    margin-bottom: 12px;
  }

  .difficulty-buttons {
    gap: 8px;
  }

  .btn-difficulty {
    padding: 10px 10px;
  }
}

/* --- Aggressive: very short viewports --- */
@media (max-height: 550px) {
  #start-screen {
    justify-content: space-between;
    gap: 4px;
    padding: 10px 20px;
  }

  #start-screen h1 {
    font-size: 1.8rem;
    margin-bottom: 2px;
  }

  #start-screen .subtitle {
    font-size: 0.9rem;
    margin-bottom: 4px;
  }

  #start-screen .instructions {
    display: none;
  }

  .mode-panel {
    padding: 6px 16px 10px;
  }

  .btn-mode {
    padding: 8px 8px;
    gap: 2px;
  }

  .mode-icon {
    font-size: 1.2rem;
  }

  .btn-trophy {
    margin-top: 4px;
    padding: 5px 14px;
    font-size: 0.72rem;
  }

  .settings-rows {
    gap: 6px;
    margin-top: 6px;
  }

  .btn-speed {
    padding: 3px 8px;
    font-size: 0.62rem;
  }

  .difficulty-header {
    margin-bottom: 8px;
  }

  .difficulty-buttons {
    gap: 6px;
  }

  .btn-difficulty {
    padding: 8px 8px;
  }
}
