@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --primary: #0D0221;
  --secondary: #0A0E27;
  --tertiary: #150E56;
  --accent: #3D2C8D;
  --accent-glow: rgba(0, 212, 255, 0.3);
  --accent-dim: #C5C5C5;
  --gold: #ffd700;
  --gold-glow: rgba(255, 215, 0, 0.3);
  --danger: #ff4757;
  --danger-glow: rgba(255, 71, 87, 0.3);
  --success: #2ed573;
  --success-glow: rgba(46, 213, 115, 0.3);
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --text-muted: #555577;
  --card-bg: rgba(26, 26, 62, 0.8);
  --card-border: rgba(0, 212, 255, 0.15);
  --wire-red: #ff4757;
  --wire-blue: #3742fa;
  --wire-green: #2ed573;
  --wire-yellow: #ffa502;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

::selection {
  background: var(--accent);
  color: var(--primary);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--primary);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.escape-room {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 215, 0, 0.03) 0%, transparent 50%),
    linear-gradient(180deg, var(--primary) 0%, #0a0a1a 100%);
}

/* ===== BUTTONS ===== */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  color: var(--primary);
  border: none;
  padding: 14px 32px;
  border-radius: var(--radius);
  font-family: 'Orbitron', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-glow {
  box-shadow: 0 0 20px var(--accent-glow);
  animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(0, 212, 255, 0.1); }
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--card-border);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--accent);
}

.btn-small {
  background: var(--tertiary);
  color: var(--accent);
  border: 1px solid var(--card-border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-small:hover {
  background: var(--accent);
  color: var(--primary);
}

.btn-hint {
  background: var(--gold);
  color: var(--primary);
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-hint:hover {
  box-shadow: 0 4px 16px var(--gold-glow);
  transform: translateY(-1px);
}

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.welcome-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--accent);
  border-radius: 50%;
  left: var(--x);
  top: -10px;
  animation: particleFall var(--duration) var(--delay) linear infinite;
  opacity: 0.4;
}

@keyframes particleFall {
  0% { transform: translateY(-10px); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(100vh); opacity: 0; }
}

.welcome-content {
  text-align: center;
  z-index: 1;
  padding: 2rem;
  max-width: 600px;
  animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.lock-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  animation: lockFloat 3s ease-in-out infinite;
}

@keyframes lockFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.welcome-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  letter-spacing: 3px;
}

.welcome-subtitle {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 2.5rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 300;
}

.welcome-actions {
  animation: fadeInUp 1s ease-out 0.3s both;
}

.welcome-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

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

.briefing-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: left;
  animation: fadeInUp 0.6s ease-out;
  backdrop-filter: blur(10px);
}

.briefing-card h2 {
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.briefing-card p {
  color: var(--text-dim);
  line-height: 1.8;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.briefing-warning {
  color: var(--gold);
  font-weight: 500;
  padding: 0.75rem;
  background: rgba(255, 215, 0, 0.05);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--gold);
}

.briefing-card .btn-primary {
  margin-top: 1.5rem;
  width: 100%;
}

/* ===== GAME HEADER ===== */
.game-header {
  background: rgba(10, 10, 26, 0.95);
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.timer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timer-display {
  font-family: 'Orbitron', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

.timer-urgent .timer-display {
  color: var(--danger);
  animation: timerBlink 1s ease-in-out infinite;
}

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

.stage-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hints-counter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 500;
}

.progress-track {
  position: relative;
  height: 4px;
  background: var(--tertiary);
  border-radius: 2px;
  margin-top: 1rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 2px;
  transition: width 0.8s ease;
}

.progress-stages {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 2%;
}

.progress-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--tertiary);
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.dot-complete {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.dot-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ===== PUZZLE STAGE ===== */
.puzzle-stage {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.stage-intro {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInUp 0.6s ease-out;
}

.stage-name {
  font-family: 'Orbitron', monospace;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

.stage-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ===== PUZZLE CARDS ===== */
.puzzle-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  backdrop-filter: blur(10px);
  animation: fadeInUp 0.6s ease-out;
  transition: all 0.5s ease;
}

.puzzle-solved {
  border-color: var(--success);
  box-shadow: 0 0 30px var(--success-glow);
}

.puzzle-narrative {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: rgba(0, 212, 255, 0.03);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.puzzle-narrative p {
  color: var(--text-dim);
  line-height: 1.7;
  font-size: 0.95rem;
}

.puzzle-narrative strong, .puzzle-narrative em {
  color: var(--accent);
}

.answer-section {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.answer-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  align-self: flex-start;
}

.answer-input {
  width: 100%;
  padding: 14px 18px;
  background: var(--tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: 'Orbitron', monospace;
  letter-spacing: 2px;
  outline: none;
  transition: all 0.3s ease;
}

.answer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.answer-input::placeholder {
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  letter-spacing: normal;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
  animation: shakeX 0.4s ease;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.solved-badge {
  margin-top: 1.5rem;
  text-align: center;
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success);
  animation: fadeInUp 0.5s ease-out;
}

/* ===== STAGE 1: CIPHER ===== */
.encrypted-display {
  text-align: center;
  margin-bottom: 1.5rem;
}

.encrypted-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.75rem;
}

.encrypted-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.cipher-char {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 44px;
  background: var(--tertiary);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  animation: charReveal 0.4s ease-out both;
}

.cipher-char:nth-child(1) { animation-delay: 0s; }
.cipher-char:nth-child(2) { animation-delay: 0.05s; }
.cipher-char:nth-child(3) { animation-delay: 0.1s; }
.cipher-char:nth-child(4) { animation-delay: 0.15s; }
.cipher-char:nth-child(5) { animation-delay: 0.2s; }
.cipher-char:nth-child(6) { animation-delay: 0.25s; }
.cipher-char:nth-child(7) { animation-delay: 0.3s; }
.cipher-char:nth-child(8) { animation-delay: 0.35s; }
.cipher-char:nth-child(9) { animation-delay: 0.4s; }
.cipher-char:nth-child(10) { animation-delay: 0.45s; }
.cipher-char:nth-child(11) { animation-delay: 0.5s; }
.cipher-char:nth-child(12) { animation-delay: 0.55s; }
.cipher-char:nth-child(13) { animation-delay: 0.6s; }

@keyframes charReveal {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.cipher-space {
  background: transparent;
  border-color: transparent;
  width: 20px;
}

.tool-toggle {
  display: block;
  margin: 0 auto 1.5rem;
}

.cipher-wheel {
  background: rgba(15, 15, 35, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.wheel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.shift-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 80px;
  text-align: center;
}

.wheel-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wheel-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.row-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  width: 55px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.wheel-char {
  width: 22px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--tertiary);
  border-radius: 2px;
}

.shifted .wheel-char {
  color: var(--gold);
  background: rgba(255, 215, 0, 0.08);
}

/* ===== STAGE 2: WIRES ===== */
.wire-board {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 1.5rem 0;
  min-height: 260px;
  position: relative;
}

.wire-column {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 0.75rem;
  flex: 0 0 140px;
  z-index: 2;
}

.wire-lines {
  flex: 1;
  position: relative;
  min-width: 80px;
}

.wire-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.wire-line {
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px currentColor);
}

.wire-node {
  padding: 12px 16px;
  background: var(--tertiary);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.wire-node:hover {
  border-color: var(--accent);
}

.node-selected {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  background: rgba(0, 212, 255, 0.1);
}

.node-connected {
  border-color: var(--success);
}

.node-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  font-weight: 600;
}

.node-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.color-red { background: var(--wire-red); box-shadow: 0 0 8px rgba(255, 71, 87, 0.5); }
.color-blue { background: var(--wire-blue); box-shadow: 0 0 8px rgba(55, 66, 250, 0.5); }
.color-green { background: var(--wire-green); box-shadow: 0 0 8px rgba(46, 213, 115, 0.5); }
.color-yellow { background: var(--wire-yellow); box-shadow: 0 0 8px rgba(255, 165, 2, 0.5); }

.disconnect-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ===== STAGE 3: RIDDLES ===== */
.riddle-progress {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.riddle-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tertiary);
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.riddle-complete {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.riddle-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--primary);
  box-shadow: 0 0 16px var(--accent-glow);
}

.riddle-card {
  animation: fadeInUp 0.5s ease-out;
}

.riddle-number {
  font-family: 'Orbitron', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1rem;
}

.riddle-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 2rem;
  font-style: italic;
  border-left: 3px solid var(--gold);
  padding-left: 1rem;
}

.riddle-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.riddle-option {
  padding: 14px 20px;
  background: var(--tertiary);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.riddle-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.08);
}

.riddle-option:disabled {
  cursor: not-allowed;
}

.option-correct {
  background: rgba(46, 213, 115, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.option-wrong {
  background: rgba(255, 71, 87, 0.15);
  border-color: var(--danger);
  color: var(--danger);
  animation: shakeX 0.4s ease;
}

/* ===== STAGE 4: MEMORY ===== */
.memory-ready {
  text-align: center;
  padding: 2rem;
}

.ready-text {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.memory-display {
  text-align: center;
}

.display-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1.5rem;
}

.sequence-display {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.seq-symbol {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--tertiary);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
}

.sym-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  background: rgba(0, 212, 255, 0.1);
  transform: scale(1.15);
}

.sym-shown {
  opacity: 0.4;
}

.sym-hidden {
  opacity: 0.3;
}

.memory-input {
  text-align: center;
}

.input-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1.5rem;
}

.player-sequence {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.seq-slot {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: var(--tertiary);
  border: 2px dashed var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.slot-filled {
  border-style: solid;
  border-color: var(--accent);
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 320px;
  margin: 0 auto 1.5rem;
}

.symbol-btn {
  padding: 16px;
  background: var(--tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 1.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.symbol-btn:hover {
  background: rgba(0, 212, 255, 0.08);
  border-color: var(--accent);
  transform: scale(1.08);
}

.symbol-btn:active {
  transform: scale(0.95);
}

/* ===== STAGE 5: FINAL ===== */
.clue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.clue-card {
  background: rgba(15, 15, 35, 0.5);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.clue-revealed {
  border-color: var(--gold);
  background: rgba(255, 215, 0, 0.03);
}

.clue-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.clue-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
  text-align: center;
}

.clue-reveal-btn {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.5rem;
}

.clue-reveal-btn:hover {
  color: var(--accent);
}

.vault-lock {
  text-align: center;
  padding: 2rem;
  background: rgba(15, 15, 35, 0.5);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
}

.vault-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1.5rem;
}

.code-inputs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.code-digit {
  width: 60px;
  height: 72px;
  text-align: center;
  font-family: 'Orbitron', monospace;
  font-size: 2rem;
  font-weight: 700;
  background: var(--tertiary);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  outline: none;
  transition: all 0.3s ease;
}

.code-digit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.lock-shake {
  animation: shakeX 0.4s ease;
}

.vault-open-animation {
  animation: fadeInUp 0.6s ease-out;
}

.final-solved {
  font-size: 1.5rem;
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow);
}

/* ===== VICTORY SCREEN ===== */
.victory-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.victory-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  left: var(--x);
  top: -20px;
  border-radius: 2px;
  animation: confettiFall var(--duration) var(--delay) ease-in infinite;
}

.confetti:nth-child(3n) { background: var(--accent); }
.confetti:nth-child(3n+1) { background: var(--gold); }
.confetti:nth-child(3n+2) { background: var(--success); }

@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(var(--rotation)); opacity: 0; }
}

.victory-content {
  text-align: center;
  z-index: 1;
  padding: 2rem;
  max-width: 500px;
  animation: fadeInUp 0.8s ease-out;
}

.trophy-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: lockFloat 2s ease-in-out infinite;
}

.victory-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.victory-subtitle {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.star-rating {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.star-filled {
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  animation: starPop 0.4s ease-out both;
}

.star-filled:nth-child(1) { animation-delay: 0.2s; }
.star-filled:nth-child(2) { animation-delay: 0.4s; }
.star-filled:nth-child(3) { animation-delay: 0.6s; }
.star-filled:nth-child(4) { animation-delay: 0.8s; }
.star-filled:nth-child(5) { animation-delay: 1s; }

@keyframes starPop {
  from { opacity: 0; transform: scale(0.3); }
  50% { transform: scale(1.3); }
  to { opacity: 1; transform: scale(1); }
}

.star-empty {
  color: var(--text-muted);
}

.victory-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.v-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.v-stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.v-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== GAME OVER SCREEN ===== */
.gameover-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, rgba(255, 71, 87, 0.05) 0%, transparent 60%),
    linear-gradient(180deg, var(--primary) 0%, #0a0a1a 100%);
}

.gameover-content {
  text-align: center;
  padding: 2rem;
  max-width: 500px;
  animation: fadeInUp 0.8s ease-out;
}

.gameover-icon {
  font-size: 5rem;
  margin-bottom: 1rem;
}

.gameover-title {
  font-family: 'Orbitron', monospace;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 900;
  color: var(--danger);
  margin-bottom: 0.5rem;
}

.gameover-subtitle {
  color: var(--text-dim);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.gameover-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.go-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.go-stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--danger);
}

.go-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.gameover-encourage {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  font-style: italic;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  position: relative;
  animation: fadeInUp 0.3s ease-out;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--tertiary);
  color: var(--text);
}

.hint-title {
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 1.5rem;
}

.hint-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.hint-item {
  padding: 1rem;
  background: rgba(255, 215, 0, 0.03);
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-radius: var(--radius-sm);
}

.hint-number {
  font-family: 'Orbitron', monospace;
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 0.5rem;
}

.hint-text {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}

.hint-warning {
  color: var(--danger);
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 1rem;
}

.hint-modal .btn-secondary {
  width: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .game-header {
    padding: 0.75rem 1rem;
  }

  .header-top {
    flex-direction: column;
    gap: 0.5rem;
  }

  .timer-display {
    font-size: 1.2rem;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .puzzle-stage {
    padding: 1.5rem 1rem 3rem;
  }

  .puzzle-card {
    padding: 1.5rem;
  }

  .wire-column {
    flex: 0 0 100px;
  }

  .wire-node {
    padding: 8px 10px;
  }

  .node-label {
    font-size: 0.65rem;
  }

  .riddle-options {
    grid-template-columns: 1fr;
  }

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

  .code-digit {
    width: 50px;
    height: 60px;
    font-size: 1.5rem;
  }

  .seq-symbol, .seq-slot {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
  }

  .symbol-grid {
    max-width: 260px;
  }

  .symbol-btn {
    padding: 12px;
    font-size: 1.5rem;
  }

  .cipher-char {
    width: 28px;
    height: 36px;
    font-size: 0.9rem;
  }

  .wheel-row {
    min-width: 640px;
  }

  .cipher-wheel {
    overflow-x: scroll;
  }

  .welcome-stats {
    flex-direction: column;
    gap: 1rem;
  }

  .victory-stats, .gameover-stats {
    flex-direction: column;
    gap: 1rem;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--primary);
}

::-webkit-scrollbar-thumb {
  background: var(--tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}
```

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to The Cipher Vault! This is a virtual escape room with 5 interconnected puzzle stages. You have 60 minutes to escape.", "view": "player", "highlight_selector": ".welcome-content", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Click 'Enter the Vault' to read the mission briefing, then start the timer.", "view": "player", "highlight_selector": ".btn-glow", "wait_for": "user_interaction"},
  {"step": 3, "narration": "The timer counts down from 60 minutes. The header shows your current stage, progress, and hints used.", "view": "player", "highlight_selector": ".game-header", "wait_for": "tap_to_continue"},
  {"step": 4, "narration": "Stage 1: Decode the Caesar cipher. Use the cipher wheel tool to shift letters and find the hidden message.", "view": "player", "highlight_selector": ".cipher-puzzle", "wait_for": "tap_to_continue"},
  {"step": 5, "narration": "Stage 2: Connect the wire terminals to the correct color ports by reading the riddle clue.", "view": "player", "highlight_selector": ".wire-puzzle", "wait_for": "tap_to_continue"},
  {"step": 6, "narration": "Stage 3: Answer three riddles correctly. Wrong answers cost time!", "view": "player", "highlight_selector": ".riddle-puzzle", "wait_for": "tap_to_continue"},
  {"step": 7, "narration": "Stage 4: Memorize a sequence of 5 symbols and reproduce it exactly.", "view": "player", "highlight_selector": ".memory-puzzle", "wait_for": "tap_to_continue"},
  {"step": 8, "narration": "Stage 5: The final vault! Reveal clues from each stage to determine the 4-digit code.", "view": "player", "highlight_selector": ".final-puzzle", "wait_for": "tap_to_continue"},
  {"step": 9, "narration": "Need help? Click 'Get Hint' anytime — but each hint reduces your final star rating!", "view": "player", "highlight_selector": ".btn-hint", "wait_for": "tap_to_continue"},
  {"step": 10, "narration": "Complete all 5 stages before time runs out to earn your star rating and escape the vault!", "view": "player", "highlight_selector": ".escape-room", "wait_for": "tap_to_continue"}
]
-->

.room-panel { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.room-field { display: flex; flex-direction: column; gap: 6px; }
.room-field input { padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.06); color: inherit; }
.room-code { margin-top: 12px; }
.room-error { color: #ff8a8a; margin-top: 8px; }
.primary-button, .secondary-button { padding: 10px 14px; border-radius: 8px; border: none; cursor: pointer; }
.primary-button { background: #5b7cff; color: #fff; }
.secondary-button { background: rgba(255,255,255,0.12); color: inherit; }

.presence-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.presence-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success-glow);
  animation: presencePulse 1.8s ease-in-out infinite;
}

@keyframes presencePulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.35); opacity: 1; }
}

.presence-avatars {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.presence-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  background: linear-gradient(135deg, var(--tertiary), rgba(0, 212, 255, 0.12));
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.presence-avatar.me {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.08);
}

.presence-avatar.me::after {
  content: 'you';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.45rem;
  line-height: 1;
  color: var(--accent);
  background: rgba(15, 15, 35, 0.9);
  padding: 0 3px;
  border-radius: 999px;
}

.presence-more {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-left: 0.15rem;
}

@media (max-width: 640px) {
  .presence-panel {
    width: 100%;
    justify-content: center;
  }

  .presence-avatars {
    justify-content: center;
  }
}

.memory-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.memory-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.memory-attempts {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
}

.memory-status {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
}

.status-active {
  color: var(--accent);
  border-color: var(--accent);
}

.status-solved {
  color: var(--success);
  border-color: var(--success);
}

.leaderboard-panel {
  margin: 0 0 2.5rem;
  padding: 1.25rem;
  background: rgba(15, 15, 35, 0.55);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  text-align: left;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.leaderboard-title {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  color: var(--gold);
}

.leaderboard-status {
  color: var(--accent);
  font-size: 0.8rem;
}

.leaderboard-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
}

.leaderboard-rank {
  font-family: 'Orbitron', monospace;
  color: var(--accent);
  font-weight: 700;
  min-width: 2.5rem;
}

.leaderboard-player {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.leaderboard-name {
  color: var(--text);
  font-weight: 600;
}

.leaderboard-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.leaderboard-time {
  font-family: 'Orbitron', monospace;
  color: var(--gold);
  font-weight: 700;
}

.leaderboard-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}

@media (max-width: 640px) {
  .leaderboard-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      'rank player'
      'time time';
  }

  .leaderboard-rank { grid-area: rank; }
  .leaderboard-player { grid-area: player; }
  .leaderboard-time {
    grid-area: time;
    justify-self: end;
  }
}

.victory-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.share-btn {
  min-width: 180px;
}

@media (max-width: 640px) {
  .victory-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .share-btn {
    width: 100%;
  }
}
