/* ============================================================
   BREAKING BAD CHRISTMAS - MOBILE FIRST STYLES
   ============================================================ */

:root {
  --primary: #00d4ff;
  --secondary: #ff6b35;
  --accent: #ffd700;
  --bg-dark: #0a0e1a;
  --bg-card: #151b2d;
  --bg-card-hover: #1e2742;
  --text: #e0e6ed;
  --text-muted: #8b9dc3;
  --success: #00ff88;
  --error: #ff4757;
  --warning: #ffa502;
  --border: #2d3748;
  --shadow: 0 8px 32px rgba(0, 212, 255, 0.15);
  --glow: 0 0 20px rgba(0, 212, 255, 0.4);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 64px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

/* Background particles */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 107, 53, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(255, 215, 0, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Snow effect */
.snow-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  animation: fall linear infinite;
  will-change: transform;
}

@keyframes fall {
  0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* ========== HEADER - Compact for mobile ========== */
.game-header {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(255, 107, 53, 0.15));
  border-bottom: 1px solid var(--border);
  padding: calc(0.75rem + var(--safe-top)) 1rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: bold;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.logo-icon {
  font-size: 1.5rem;
  -webkit-text-fill-color: initial;
}

.header-stats {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.header-stats::-webkit-scrollbar {
  display: none;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(21, 27, 45, 0.8);
  padding: 0.4rem 0.75rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

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

.stat-value {
  font-weight: bold;
  color: var(--accent);
  font-size: 0.9rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(21, 27, 45, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn:active {
  transform: scale(0.95);
  background: var(--bg-card-hover);
}

.progress-wrapper {
  max-width: 1400px;
  margin: 0.5rem auto 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-container {
  flex: 1;
  height: 6px;
  background: rgba(21, 27, 45, 0.8);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--primary);
  border-radius: 10px;
}

.progress-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}

/* ========== BOTTOM NAVIGATION ========== */
.game-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: var(--safe-bottom);
}

.nav-content {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-height);
  max-width: 600px;
  margin: 0 auto;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  transition: all 0.2s;
  position: relative;
  padding: 0.5rem 0.25rem;
}

.nav-btn:active {
  transform: scale(0.92);
}

.nav-icon {
  font-size: 1.4rem;
  transition: all 0.2s;
}

.nav-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn.active .nav-icon {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 8px var(--primary));
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 0 10px var(--primary);
}

/* ========== MAIN CONTAINER ========== */
.game-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
  z-index: 2;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.screen.active {
  display: block;
}

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

/* Screen headers */
.screen-header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.screen-title {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.screen-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ========== STORY ========== */
.story-intro {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.story-intro::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.06) 0%, transparent 70%);
  animation: rotate 20s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.story-content {
  position: relative;
  z-index: 1;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
  font-size: 0.95rem;
}

/* ========== CHAPTER CARDS ========== */
.chapters-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chapter-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  position: relative;
  overflow: hidden;
}

.chapter-card:active {
  transform: scale(0.98);
}

.chapter-card.locked {
  opacity: 0.5;
}

.chapter-card.completed {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.08), var(--bg-card));
}

.chapter-number {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: bold;
  flex-shrink: 0;
  color: white;
}

.chapter-card.locked .chapter-number {
  background: var(--bg-card-hover);
  color: var(--text-muted);
}

.chapter-card.completed .chapter-number {
  background: linear-gradient(135deg, var(--success), var(--primary));
}

.chapter-info {
  flex: 1;
  min-width: 0;
}

.chapter-info h3 {
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.chapter-progress {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.chapter-status {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ========== PUZZLE CARDS ========== */
.puzzle-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.puzzle-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.puzzle-card.solved {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.06), var(--bg-card));
}

.puzzle-card.skipped {
  border-color: var(--warning);
  opacity: 0.7;
}

.puzzle-header {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.puzzle-number {
  background: var(--primary);
  color: var(--bg-dark);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: bold;
}

.puzzle-type {
  background: var(--bg-card-hover);
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
}

.puzzle-physical {
  background: var(--secondary);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
}

.puzzle-card h4 {
  margin-bottom: 0.375rem;
  color: var(--text);
  font-size: 1.05rem;
}

.puzzle-desc {
  color: var(--text-muted);
  margin-bottom: 0.875rem;
  line-height: 1.55;
  font-size: 0.9rem;
}

.puzzle-input-area {
  margin-bottom: 0.875rem;
}

.puzzle-input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.875rem 1rem;
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.puzzle-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.puzzle-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.input-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.morse-display, .binary-display {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 0.875rem;
  border-radius: 10px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.875rem;
  word-break: break-all;
  letter-spacing: 1px;
  line-height: 1.6;
}

.logic-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.logic-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 0.875rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
}

.logic-option:active {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.logic-option input[type="radio"] {
  accent-color: var(--primary);
  width: 20px;
  height: 20px;
}

.puzzle-actions {
  display: flex;
  gap: 0.625rem;
}

.puzzle-feedback {
  margin-top: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  display: none;
  font-size: 0.9rem;
  line-height: 1.4;
}

.puzzle-feedback.feedback-success {
  display: block;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
}

.puzzle-feedback.feedback-error {
  display: block;
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

.puzzle-feedback.feedback-warning {
  display: block;
  background: rgba(255, 165, 2, 0.1);
  border: 1px solid var(--warning);
  color: var(--warning);
}

.puzzle-feedback.feedback-hint {
  display: block;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--primary);
  color: var(--primary);
}

.puzzle-solved-badge {
  background: rgba(0, 255, 136, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 0.75rem;
  border-radius: 10px;
  text-align: center;
  font-weight: bold;
  font-size: 0.9rem;
}

.puzzle-skipped-badge {
  background: rgba(255, 165, 2, 0.15);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 0.75rem;
  border-radius: 10px;
  text-align: center;
  font-size: 0.9rem;
}

/* ========== BUTTONS ========== */
.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

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

.btn-submit {
  background: linear-gradient(135deg, var(--primary), #0090b3);
  color: var(--bg-dark);
  flex: 1;
}

.btn-hint {
  background: var(--bg-card-hover);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-buy {
  background: linear-gradient(135deg, var(--secondary), #d4541e);
  color: white;
  padding: 0.625rem 1rem;
  min-height: 40px;
  font-size: 0.85rem;
}

.btn-scan {
  background: linear-gradient(135deg, var(--success), #00cc6a);
  color: var(--bg-dark);
  font-size: 1rem;
  padding: 0.875rem 1.5rem;
  width: 100%;
}

.btn-decode {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: white;
  margin-top: 0.875rem;
  width: 100%;
}

.btn-quiz {
  background: linear-gradient(135deg, var(--accent), #e6c200);
  color: var(--bg-dark);
  width: 100%;
}

.btn-close {
  background: var(--bg-card-hover);
  color: var(--text);
  margin-top: 0.875rem;
}

.btn-back {
  background: var(--bg-card-hover);
  color: var(--text);
  padding: 0.625rem 1rem;
  font-size: 0.85rem;
  min-height: 40px;
}

/* ========== QR SECTION ========== */
.qr-header {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.qr-progress-display {
  font-size: 1rem;
  color: var(--accent);
  text-align: center;
  font-weight: 600;
}

.qr-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.qr-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.875rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.qr-card.found {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.06), var(--bg-card));
}

.qr-card.not-found {
  opacity: 0.7;
}

.qr-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.qr-info {
  flex: 1;
  min-width: 0;
}

.qr-info h4 {
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.qr-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.qr-reward {
  color: var(--accent);
  font-weight: bold;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ========== SHOP ========== */
.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.shop-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--border);
}

.shop-card.affordable {
  border-color: var(--success);
}

.shop-card.expensive {
  opacity: 0.7;
}

.shop-card h4 {
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.shop-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.shop-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-cost {
  color: var(--accent);
  font-weight: bold;
  font-size: 1rem;
}

/* ========== ACHIEVEMENTS ========== */
.achievements-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.achievement-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.875rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.achievement-card.unlocked {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.06), var(--bg-card));
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.achievement-info {
  flex: 1;
  min-width: 0;
}

.achievement-info h4 {
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.achievement-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.achievement-status {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ========== STATS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.stats-achievements h3 {
  margin-bottom: 0.875rem;
  font-size: 1rem;
}

.achievement-progress {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ach-badge {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border: 2px solid var(--border);
}

.ach-badge.unlocked {
  border-color: var(--accent);
  background: rgba(255, 215, 0, 0.1);
}

.ach-badge.locked {
  opacity: 0.3;
  filter: grayscale(1);
}

/* ========== QUIZ ========== */
.quiz-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--border);
  text-align: center;
}

.quiz-card.completed {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.06), var(--bg-card));
}

.quiz-card h4 {
  margin-bottom: 0.25rem;
}

.quiz-card p {
  color: var(--text-muted);
  margin-bottom: 0.875rem;
  font-size: 0.85rem;
}

.quiz-question {
  text-align: center;
}

.quiz-q-text {
  font-size: 1.1rem;
  margin: 1rem 0;
  color: var(--text);
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.quiz-option {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.875rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  min-height: 48px;
  text-align: left;
}

.quiz-option:active {
  border-color: var(--primary);
  background: var(--bg-card);
}

.quiz-result {
  text-align: center;
  padding: 1.5rem;
}

.quiz-result h3 {
  margin-bottom: 0.75rem;
}

/* ========== DECODERS ========== */
.decoder-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  margin-bottom: 1.5rem;
}

.decoder-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 1rem 0.5rem;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  min-height: 80px;
  justify-content: center;
}

.decoder-btn:active {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: scale(0.97);
}

.decoder-icon {
  font-size: 1.75rem;
}

.decoder-result {
  margin-top: 0.875rem;
  padding: 0.875rem;
  background: var(--bg-dark);
  border-radius: 10px;
  border: 1px solid var(--success);
  color: var(--success);
  font-family: 'Courier New', monospace;
  word-break: break-all;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ========== MODALS ========== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 1.25rem;
  width: 100%;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-bottom: none;
  animation: slideUp 0.3s ease;
  padding-bottom: calc(1.25rem + var(--safe-bottom));
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: var(--bg-card-hover);
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:active {
  color: var(--error);
  background: rgba(255, 71, 87, 0.1);
}

.modal p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.875rem;
  line-height: 1.5;
}

/* ========== NOTIFICATIONS ========== */
.notifications {
  position: fixed;
  top: calc(70px + var(--safe-top));
  left: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.notification {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  border-left: 3px solid var(--primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  line-height: 1.4;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification-success {
  border-left-color: var(--success);
}

.notification-error {
  border-left-color: var(--error);
}

.notification-warning {
  border-left-color: var(--warning);
}

.notification-achievement {
  border-left-color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), var(--bg-card));
}

/* ========== VICTORY SCREEN ========== */
.victory-screen {
  text-align: center;
  padding: 2rem 1rem;
}

.victory-title {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse 2s ease-in-out infinite;
  line-height: 1.3;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.victory-message {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.victory-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.victory-stat {
  text-align: center;
}

.victory-stat-value {
  font-size: 1.75rem;
  font-weight: bold;
  color: var(--primary);
}

.victory-stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========== CHAPTER HEADER NAV ========== */
.chapter-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.chapter-nav-title {
  flex: 1;
  text-align: center;
}

.chapter-nav-title h2 {
  font-size: 1.1rem;
}

.chapter-nav-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

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

/* ========== TABLET & DESKTOP ========== */
@media (min-width: 640px) {
  html {
    font-size: 17px;
  }

  .game-container {
    padding: 1.5rem;
  }

  .chapters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .qr-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .shop-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .quiz-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .decoder-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .modal-content {
    max-width: 480px;
    border-radius: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
    animation: fadeIn 0.3s ease;
  }

  .modal {
    align-items: center;
  }

  .victory-title {
    font-size: 2.25rem;
  }
}

@media (min-width: 1024px) {
  html {
    font-size: 18px;
  }

  .game-container {
    padding: 2rem;
  }

  .chapters-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .qr-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .shop-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .achievements-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .decoder-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .screen-title {
    font-size: 2rem;
  }

  .victory-title {
    font-size: 3rem;
  }

  /* Hover effects only on desktop */
  .chapter-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
  }

  .chapter-card.locked:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border);
  }

  .puzzle-card:hover {
    border-color: var(--primary);
  }

  .qr-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }

  .shop-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
  }

  .decoder-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }

  .btn:hover:not(:disabled) {
    transform: translateY(-2px);
  }

  .btn-submit:hover:not(:disabled) {
    box-shadow: var(--glow);
  }

  .btn-scan:hover {
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.4);
  }

  .nav-btn:hover {
    color: var(--text);
  }

  .icon-btn:hover {
    background: var(--bg-card-hover);
  }

  .logic-option:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
  }

  .quiz-option:hover {
    border-color: var(--primary);
    background: var(--bg-card);
  }
}

/* ========== LANDSCAPE PHONE ========== */
@media (max-height: 500px) and (orientation: landscape) {
  .game-header {
    padding: 0.5rem 1rem;
  }

  .logo {
    font-size: 1rem;
  }

  .nav-label {
    display: none;
  }

  .nav-icon {
    font-size: 1.5rem;
  }

  .modal-content {
    max-height: 90vh;
  }
}

/* ========== DARK MODE (prefers-color-scheme) ========== */
@media (prefers-color-scheme: light) {
  /* Keep dark theme regardless - it's a design choice */
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .snowflake {
    display: none;
  }
}

/* ========== PRINT ========== */
@media print {
  .game-nav, .notifications, .snow-container, .modal {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}
