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

:root {
  --bg: #0a0a0a;
  --panel: #111111;
  --text: #cccccc;
  --muted: #666666;
  --accent: #8b0000;
  --border: #333333;
  --border-bright: #555555;
  --correct-bg: #0d2a0d;
  --correct-border: #1a4a1a;
  --correct-text: #4caf50;
  --wrong-bg: #2a0d0d;
  --wrong-border: #4a1a1a;
  --wrong-text: #cc4444;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  overflow-x: hidden;
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><line x1='16' y1='3' x2='16' y2='13' stroke='%23cc0000' stroke-width='1.5' opacity='0.9'/><line x1='16' y1='19' x2='16.5' y2='24' stroke='%23cc0000' stroke-width='1.5' opacity='0.9'/><line x1='17.2' y1='25' x2='17.8' y2='29' stroke='%23cc0000' stroke-width='1.5' opacity='0.9'/><line x1='3' y1='16' x2='13' y2='16' stroke='%23cc0000' stroke-width='1.5' opacity='0.9'/><line x1='19' y1='16' x2='29' y2='16' stroke='%23cc0000' stroke-width='1.5' opacity='0.9'/><circle cx='16' cy='16' r='2' fill='%238b0000'/></svg>") 16 16, crosshair;
}

.btn, button {
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><line x1='16' y1='3' x2='16' y2='13' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='16' y1='19' x2='16.5' y2='24' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='17.2' y1='25' x2='17.8' y2='29' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='3' y1='16' x2='13' y2='16' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='19' y1='16' x2='29' y2='16' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><circle cx='16' cy='16' r='2' fill='%23ff0000'/></svg>") 16 16, crosshair;
}

/* ========== SCREENS ========== */

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.screen.active {
  display: flex;
}

/* ========== FADE OVERLAY ========== */

#fade-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.6s ease;
}

#fade-overlay.fading {
  opacity: 1;
  pointer-events: all;
}

/* ========== DISCLAIMER ========== */

#screen-disclaimer {
  background: #000;
  text-align: center;
}

.disclaimer-content {
  max-width: 600px;
  width: 100%;
}

.disclaimer-title {
  font-size: 2.5rem;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.disclaimer-body {
  text-align: left;
  color: #e0e0e0;
  line-height: 1.8;
}

.disclaimer-body p {
  margin-bottom: 16px;
}

.press-any-key {
  margin-top: 40px;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

.blink-cursor {
  animation: blink 1s step-end infinite;
}

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

/* ========== GAME TITLE BAR ========== */

.game-title-bar {
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 24px;
  text-align: center;
}

/* ========== START SCREEN ========== */

#screen-start {
  position: relative;
  overflow: hidden;
}

.start-bg-decor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#screen-start > *:not(.start-bg-decor) {
  position: relative;
  z-index: 1;
}

.game-title {
  font-size: 2.8rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: var(--text);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 40px;
}

.section-group {
  width: 100%;
  max-width: 500px;
  margin-bottom: 24px;
}

.section-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.section-label {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-transform: uppercase;
}

.difficulty-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.difficulty-buttons .btn {
  background: #0d0d0d;
  border-left: 3px solid #3a0000;
  border-top: 1px solid #1a1a1a;
  border-right: 1px solid #1a1a1a;
  border-bottom: 1px solid #1a1a1a;
  box-shadow: inset 0 0 24px rgba(139,0,0,0.06), 0 2px 8px rgba(0,0,0,0.6);
  padding: 14px 24px;
  transition: all 0.15s ease;
}

.difficulty-buttons .btn:hover {
  border-left-color: #8b0000;
  background: #111;
  box-shadow: inset 0 0 24px rgba(139,0,0,0.15), 0 2px 12px rgba(0,0,0,0.8);
}

.difficulty-desc {
  font-size: 0.72rem;
  color: #555;
  letter-spacing: 0.08em;
  text-align: center;
  margin-top: 10px;
  min-height: 1.2em;
  font-family: 'Courier New', Courier, monospace;
}

.section-divider {
  border: none;
  border-top: 1px solid #1a1a1a;
  margin: 20px auto;
  width: 60%;
  max-width: 500px;
}

.meta-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 500px;
  margin-bottom: 16px;
}

.meta-buttons .btn {
  flex: 1;
}

/* ========== BUTTONS ========== */

.btn {
  background: #1a1a1a;
  border: 1px solid #444;
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 16px;
  width: 100%;
  text-align: center;
  border-radius: 0;
  outline: none;
  user-select: none;
}

.btn:hover {
  background: #2a0000;
  border-color: var(--accent);
}

.btn:active {
  background: #1a0000;
}

.btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.btn:disabled:hover {
  background: #1a1a1a;
  border-color: #444;
}

.btn.active {
  background: #2a0000;
  border-color: var(--accent);
  color: var(--text);
}

/* ========== SETTINGS ========== */

.settings-panel {
  width: 100%;
  max-width: 500px;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  margin-top: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.settings-label {
  flex: 1;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
}

.lang-buttons {
  display: flex;
  gap: 4px;
}

.lang-btn {
  width: auto;
  padding: 6px 12px;
  font-size: 0.75rem;
}

.toggle-btn {
  width: auto;
  padding: 6px 20px;
  font-size: 0.75rem;
}

/* ========== TOOLTIPS ========== */

.info-icon {
  position: relative;
  color: var(--muted);
  font-size: 0.85rem;
  display: inline-block;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  border: 1px solid #555;
  color: #aaa;
  font-size: 0.72rem;
  padding: 8px 12px;
  white-space: pre;
  text-align: left;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  min-width: 200px;
  letter-spacing: 0.05em;
  font-family: 'Courier New', Courier, monospace;
}

.info-icon:hover::after {
  opacity: 1;
}

/* ========== TUTORIAL ========== */

.tutorial-screen {
  background: #111;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 29px, #1a1a1a 29px, #1a1a1a 30px),
    repeating-linear-gradient(90deg, transparent, transparent 29px, #1a1a1a 29px, #1a1a1a 30px);
  justify-content: flex-start;
  padding-top: 16px;
}

.tutorial-header {
  text-align: center;
  width: 100%;
  margin-bottom: 8px;
}

.training-label {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: #6b0000;
  text-transform: uppercase;
  border: 1px solid #3a0000;
  padding: 4px 16px;
  display: inline-block;
}

.tutorial-body {
  display: flex;
  gap: 20px;
  max-width: 700px;
  width: 100%;
  margin: 12px auto;
  align-items: flex-start;
}

.agent-panel {
  width: 200px;
  min-width: 200px;
  border: 1px solid var(--border-bright);
  background: #0d0d0d;
  flex-shrink: 0;
}

.agent-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-align: center;
  padding: 6px;
  border-bottom: 1px solid var(--border-bright);
  text-transform: uppercase;
}

.agent-svg {
  width: 200px;
  height: 300px;
  display: block;
}

.dialogue-panel {
  flex: 1;
  border: 1px solid var(--border-bright);
  background: #0e0e0e;
  padding: 16px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialogue-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  min-height: 100px;
  white-space: pre-wrap;
}

.dialogue-hint {
  font-size: 0.65rem;
  color: #444;
  letter-spacing: 0.15em;
  text-align: right;
}

.dialogue-next-btn {
  width: auto;
  align-self: flex-end;
  padding: 8px 24px;
}

/* ========== TUTORIAL QUESTION AREA ========== */

.tutorial-question-area {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

/* ========== GAME SCREEN ========== */

#screen-game {
  justify-content: flex-start;
  padding-top: 20px;
}

.question-counter {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  text-align: center;
}

.streak-display {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: #8b0000;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 8px;
  font-family: 'Courier New', Courier, monospace;
}

@keyframes streakPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); color: #cc0000; }
  100% { transform: scale(1); }
}

.streak-display.pulse {
  animation: streakPulse 0.3s ease;
}

/* ========== IMAGE PLACEHOLDER ========== */

.image-placeholder {
  width: 100%;
  max-width: 500px;
  height: 300px;
  background: #111;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0 auto 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.question-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.img-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  color: var(--muted);
}

.img-fallback svg {
  width: 60px;
  height: 75px;
  opacity: 0.4;
}

.img-fallback span {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  opacity: 0.5;
}

.person-reveal {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.82);
  color: #ccc;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  padding: 5px 8px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ========== TIMER BAR ========== */

.timer-bar-container {
  width: 100%;
  max-width: 500px;
  height: 4px;
  background: #1a1a1a;
  margin: 0 auto 16px;
  border: 1px solid #222;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: #555;
}

/* ========== ANSWERS GRID ========== */

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 16px;
}

.answer-btn {
  min-height: 56px;
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  padding: 12px;
}

.answer-btn.correct-answer {
  background: var(--correct-bg);
  border-color: var(--correct-border);
  color: var(--correct-text);
}

.answer-btn.wrong-answer {
  background: var(--wrong-bg);
  border-color: var(--wrong-border);
  color: var(--wrong-text);
}

/* ========== IN-GAME CONTROL BUTTONS ========== */

.game-controls {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto 12px;
}

.game-ctrl-btn {
  flex: 1;
  background: #0d0d0d;
  border: 1px solid #2a0000;
  color: #555;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 12px;
  text-align: center;
  outline: none;
  user-select: none;
  border-radius: 0;
  transition: all 0.12s ease;
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><line x1='16' y1='3' x2='16' y2='13' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='16' y1='19' x2='16.5' y2='24' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='17.2' y1='25' x2='17.8' y2='29' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='3' y1='16' x2='13' y2='16' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><line x1='19' y1='16' x2='29' y2='16' stroke='%23ff2222' stroke-width='1.5' opacity='0.95'/><circle cx='16' cy='16' r='2' fill='%23ff0000'/></svg>") 16 16, crosshair;
}

.game-ctrl-btn:hover {
  border-color: #8b0000;
  color: #999;
}

.game-ctrl-btn:active {
  background: #110000;
}

/* ========== KEYBOARD HINT ========== */

.keyboard-hint {
  font-size: 0.62rem;
  color: #333;
  letter-spacing: 0.08em;
  text-align: center;
  margin: 4px auto 8px;
  max-width: 500px;
  width: 100%;
  font-family: 'Courier New', Courier, monospace;
}

/* ========== EXPLANATION ========== */

.explanation {
  width: 100%;
  max-width: 500px;
  margin: 0 auto 16px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ========== NEXT BUTTON ========== */

.next-btn {
  max-width: 500px;
  margin: 0 auto;
}

/* ========== GAME OVER SCREEN ========== */

.gameover-content {
  text-align: center;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.gameover-heading {
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
}

.gameover-score {
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.15em;
}

/* ========== RESULT SCREEN ========== */

.result-heading {
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 24px;
  color: var(--text);
  text-align: center;
}

.score-display {
  text-align: center;
  margin-bottom: 24px;
}

.score-number {
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  color: var(--text);
  margin-bottom: 8px;
}

.score-detail {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.new-record-badge {
  display: inline-block;
  margin-left: 12px;
  font-size: 0.7rem;
  color: #8b0000;
  border: 1px solid #5a0000;
  padding: 2px 8px;
  letter-spacing: 0.1em;
  vertical-align: middle;
}

.perfect-message {
  border: 1px solid var(--accent);
  padding: 12px 24px;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 24px;
  max-width: 500px;
  width: 100%;
}

.result-buttons {
  display: flex;
  gap: 8px;
  max-width: 500px;
  width: 100%;
}

.result-buttons .btn {
  flex: 1;
}

/* ========== REVIEW SCREEN ========== */

.review-list {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.review-item {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 0;
  overflow: hidden;
}

.review-item .image-placeholder {
  height: 180px;
  margin: 0;
  font-size: 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
}

.review-answer {
  display: flex;
  gap: 16px;
  padding: 10px 12px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.review-correct {
  color: var(--correct-text);
}

.review-wrong {
  color: var(--wrong-text);
}

.review-timeout {
  color: var(--accent);
  letter-spacing: 0.1em;
}

.review-explanation {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ========== STATS SCREEN ========== */

.stats-content {
  width: 100%;
  max-width: 480px;
}

.stats-heading {
  font-size: 1.6rem;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 32px;
}

.stats-section {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  margin-bottom: 16px;
}

.stats-section-label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: #444;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #1a1a1a;
  font-size: 0.82rem;
}

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

.stats-label {
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.stats-value {
  color: var(--text);
  letter-spacing: 0.1em;
}

.stats-value.highlight {
  color: #8b0000;
}

/* ========== UTILITY ========== */

.hidden {
  display: none !important;
}

#replit-badge, [data-cy="replit-badge"], iframe[src*="replit.com/badge"], .replit-badge {
  display: none !important;
}

/* ========== ENDLESS RUN ========== */

.btn-endless {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  padding: 12px 24px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}
.btn-endless:hover {
  background: var(--accent);
  color: #fff;
}

.bump-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  gap: 20px;
  text-align: center;
  padding: 40px 24px;
}
.bump-label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.35em;
}
.bump-message {
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 0.12em;
  max-width: 460px;
  line-height: 1.7;
  border: 1px solid var(--accent);
  padding: 18px 24px;
}
.bump-tier {
  color: var(--text);
  font-size: 2.2rem;
  letter-spacing: 0.45em;
  margin-top: 8px;
}
.bump-sub {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.25em;
}
.bump-continue {
  margin-top: 32px;
}

.endless-counter {
  color: var(--accent);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-align: center;
  margin-top: -6px;
  margin-bottom: 4px;
}
