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

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(ellipse at 30% 20%, #1a1a3e 0%, #0e0e24 40%, #0a0a14 100%);
  color: #c8dcff;
  font-family: 'Courier New', Courier, monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ============================================
   Shared utilities
   ============================================ */
.hidden {
  display: none !important;
}

/* ============================================
   TITLE SCREEN
   ============================================ */
#title-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#title-bg-circles {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#title-bg-circles svg {
  width: min(600px, 90vw);
}

#title-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  z-index: 1;
}

#title-logo {
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 300;
  letter-spacing: 0.15em;
  color: #e0eeff;
  text-shadow:
    0 0 40px rgba(74, 158, 255, 0.6),
    0 0 80px rgba(74, 158, 255, 0.3);
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 40px rgba(74,158,255,0.6), 0 0 80px rgba(74,158,255,0.3); }
  50%       { text-shadow: 0 0 60px rgba(74,158,255,0.9), 0 0 120px rgba(74,158,255,0.5); }
}

#title-subtitle {
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.35;
  margin-top: -24px;
}

#level-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#level-label {
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.3em;
  opacity: 0.4;
  text-transform: uppercase;
}

#level-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 260px;                /* wider to accommodate larger text */
}

.level-btn {
  background: transparent;
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-radius: 6px;
  color: #c8dcff;
  font-family: inherit;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
  width: 100%;
}

.level-btn.active {
  border-color: rgba(74, 158, 255, 0.7);
  background: rgba(74, 158, 255, 0.08);
}

.level-btn.active:hover {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.15);
  box-shadow: 0 0 20px rgba(74, 158, 255, 0.2);
}

.level-btn.locked {
  opacity: 0.25;
  cursor: not-allowed;
}

.level-name { font-size: 1.05rem; letter-spacing: 0.1em; }
.level-desc { font-size: 0.9rem;  letter-spacing: 0.05em; opacity: 0.6; }

/* ============================================
   TUTORIAL SCREEN
   ============================================ */
#tutorial-screen {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(4px);
}

#tutorial-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 360px;
  width: 90%;
}

#tutorial-title {
  font-size: 1.1rem;
  letter-spacing: 0.25em;
  opacity: 0.6;
  text-transform: uppercase;
}

#tutorial-svg {
  width: 100%;
  max-width: 340px;
  border: 1px solid rgba(74, 158, 255, 0.15);
  border-radius: 8px;
  background: rgba(5, 8, 20, 0.6);
  padding: 8px;
}

#tutorial-desc {
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  color: #e0eeff;
  text-align: center;
}

#tutorial-hint {
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.12em;
  opacity: 0.45;
  text-align: center;
  text-transform: uppercase;
}

#btn-tutorial-ok {
  background: transparent;
  border: 1px solid rgba(74, 158, 255, 0.5);
  border-radius: 6px;
  color: #c8dcff;
  font-family: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  padding: 12px 48px;
  cursor: pointer;
  margin-top: 6px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#btn-tutorial-ok:hover {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.12);
  box-shadow: 0 0 20px rgba(74, 158, 255, 0.2);
}

/* ============================================
   GAME VIEW
   ============================================ */
#game-view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Logo — top-left fixed */
#ui {
  position: fixed;
  top: 16px;
  left: 24px;
  z-index: 10;
}

#logo {
  font-size: 1.1rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  color: #4a9eff;
  opacity: 0.5;
  text-transform: uppercase;
}

/* Question display: screen above game-container */
#question-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 700px;
  padding: 14px 20px;
  background: rgba(5, 8, 20, 0.85);
  border: 1px solid rgba(74, 158, 255, 0.3);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  box-shadow:
    0 0 30px rgba(74, 158, 255, 0.07) inset,
    0 -4px 20px rgba(74, 158, 255, 0.05);
}

#question-text {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 300;
  letter-spacing: 0.2em;
  color: #e0eeff;
  text-shadow: 0 0 24px rgba(74, 158, 255, 0.5);
  transition: opacity 0.25s ease;
  min-height: 2.6rem;
  display: flex;
  align-items: center;
}

#question-counter {
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.2em;
  opacity: 0.35;
}

/* Game container */
#game-container {
  position: relative;
  width: 100%;
  max-width: 700px;
  border: 1px solid rgba(74, 158, 255, 0.15);
  border-radius: 0 0 6px 6px;
  overflow: hidden;
  background: rgba(5, 8, 20, 0.25);
}

/* Game header: pause | timer | score — flex row */
#game-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 12px;
  background: rgba(5, 8, 20, 0.5);
  border-bottom: 1px solid rgba(74, 158, 255, 0.1);
}

/* Pause button — in game-header */
#pause-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(200, 220, 255, 0.15);
  border-radius: 5px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  transition: border-color 0.2s, background 0.2s;
}

#pause-btn:hover {
  border-color: rgba(74, 158, 255, 0.5);
  background: rgba(74, 158, 255, 0.08);
}

#pause-btn span {
  display: block;
  width: 3px;
  height: 11px;
  background: #c8dcff;
  border-radius: 2px;
  opacity: 0.55;
}

/* Timer — fills space between pause and score */
#timer-container {
  flex: 1;
  position: relative;
  height: 6px;
}

#timer-bar-bg {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

#timer-bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 100%;
  background: #4a9eff;
  border-radius: 3px;
  transition: width 0.05s linear, background-color 0.3s ease;
}

#timer-bar.warning { background: #f59e0b; }
#timer-bar.danger  { background: #ef4444; }

/* Score display — in game-header */
#score-display {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  min-width: 3.5ch;
}

#score-label {
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.2em;
  opacity: 0.35;
}

#score-value {
  font-size: 1.8rem;
  font-weight: 300;
  color: #4a9eff;
  text-align: right;
  transition: transform 0.15s ease;
  line-height: 1;
}

#score-value.bump {
  transform: scale(1.3);
}

#game-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Result overlay (correct / wrong) */
#result-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.3s ease;
}

#result-overlay.hidden { opacity: 0; }

#result-text {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

#result-text.success {
  color: #4ade80;
  text-shadow: 0 0 30px rgba(74, 222, 128, 0.7);
}

#result-text.failure {
  color: #f87171;
  text-shadow: 0 0 30px rgba(248, 113, 113, 0.7);
}

/* Controls hint — below game-container */
#controls-hint {
  width: 100%;
  max-width: 700px;
  text-align: center;
  padding: 8px 0 0;
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.12em;
  opacity: 0.55;
  text-transform: uppercase;
  color: #a0bce0;
}

/* ============================================
   PAUSE SCREEN
   ============================================ */
#pause-screen {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

#pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
}

#pause-title {
  font-size: 1.3rem;
  letter-spacing: 0.4em;
  opacity: 0.5;
  text-transform: uppercase;
}

#pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 260px;
}

.pause-btn {
  background: transparent;
  border: 1px solid rgba(74, 158, 255, 0.5);
  border-radius: 6px;
  color: #c8dcff;
  font-family: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  padding: 14px 24px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  width: 100%;
}

.pause-btn:hover {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.12);
  box-shadow: 0 0 20px rgba(74, 158, 255, 0.2);
}

.pause-btn.secondary {
  border-color: rgba(200, 220, 255, 0.2);
  opacity: 0.7;
}

.pause-btn.secondary:hover {
  border-color: rgba(200, 220, 255, 0.5);
  background: rgba(200, 220, 255, 0.06);
  box-shadow: none;
  opacity: 1;
}

/* ============================================
   RESULT SCREEN
   ============================================ */
#result-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #1a1a3e 0%, #0e0e24 50%, #0a0a14 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

#result-level-label {
  font-size: 0.9rem;           /* minimum size */
  letter-spacing: 0.35em;
  opacity: 0.35;
  text-transform: uppercase;
}

#final-grade {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  min-height: 2.4rem;
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

#final-score-display {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

#final-score-value {
  font-size: 5rem;
  font-weight: 300;
  color: #e0eeff;
  text-shadow: 0 0 40px rgba(74, 158, 255, 0.4);
  line-height: 1;
}

#final-score-denom {
  font-size: 1.3rem;
  opacity: 0.4;
  letter-spacing: 0.1em;
}

#final-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 260px;
  margin-top: 8px;
}

/* ============================================
   Explorer animations
   ============================================ */
@keyframes explorerFloat {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-3px); }
}

#explorer {
  animation: explorerFloat 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(160, 196, 255, 0.4));
  transition: filter 0.3s ease;
}

#explorer.moving {
  animation: none;
  filter: drop-shadow(0 0 10px rgba(160, 196, 255, 0.7));
}

/* Region glow animation */
@keyframes regionGlow {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

#region-glows.visible {
  animation: regionGlow 0.5s ease-out forwards;
}

/* Venn circle subtle glows */
#circle-a { filter: drop-shadow(0 0 4px rgba(74, 158, 255, 0.3)); }
#circle-b { filter: drop-shadow(0 0 4px rgba(255, 107, 157, 0.3)); }

/* Area indicator: smooth fill-opacity transition between areas */
#area-indicator circle,
#area-indicator rect {
  transition: fill-opacity 0.25s ease;
}

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 600px) {
  #logo          { font-size: 0.95rem; }
  #question-text { font-size: 1.4rem; }
  #score-value   { font-size: 1.5rem; }
  #controls-hint { font-size: 0.9rem; } /* keep at minimum */
}
