:root {
  /* Premium Dark Theme Color Palette */
  --bg-primary: #070614;
  --bg-secondary: #0c0924;
  --bg-grad-1: #09061c;
  --bg-grad-2: #0f0b30;
  
  --glass-bg: rgba(20, 15, 45, 0.45);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.03);
  
  --card-dark-bg: rgba(10, 8, 25, 0.6);
  --card-dark-border: rgba(255, 255, 255, 0.04);
  
  /* Accent Colors */
  --primary: #8b5cf6; /* Modern Purple */
  --primary-rgb: 139, 92, 246;
  --primary-hover: #a78bfa;
  --primary-glow: rgba(139, 92, 246, 0.4);
  
  --accent-cyan: #06b6d4; /* Vivid Cyan */
  --accent-cyan-rgb: 6, 182, 212;
  --accent-cyan-glow: rgba(6, 182, 212, 0.35);
  
  --accent-magenta: #ec4899; /* Pink/Magenta */
  
  /* Feedback States */
  --success: #10b981; /* Emerald Green */
  --success-glow: rgba(16, 185, 129, 0.4);
  --error: #ef4444; /* Rose Red */
  --error-glow: rgba(239, 68, 68, 0.4);
  
  /* Text Colors */
  --text-light: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-dark: #0f172a;
  
  /* Gold for Trophy */
  --gold: #f59e0b;
  
  /* Miscellaneous settings */
  --font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 10% 20%, rgba(139, 92, 246, 0.15) 0px, transparent 40%),
    radial-gradient(at 90% 80%, rgba(6, 182, 212, 0.12) 0px, transparent 45%),
    linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  background-attachment: fixed;
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  line-height: 1.6;
}

/* App Wrapper */
.app-container {
  width: 100%;
  max-width: 480px; /* Portrait optimized */
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  animation: fadeIn 0.8s ease;
}

/* Header Panel styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  background: rgba(15, 10, 35, 0.4);
}

.logo-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #ffffff 40%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-title span {
  color: var(--accent-cyan);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 15px var(--accent-cyan-glow);
}

.header-right {
  display: flex;
  gap: 8px;
}

/* Glass Buttons */
.icon-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-bounce);
  font-size: 0.95rem;
}

.icon-btn:hover {
  transform: scale(1.1);
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

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

/* Glassmorphism Main Card */
.main-card {
  flex-grow: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.37),
    inset 0 1px 0 0 var(--glass-highlight);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 520px;
}

/* Screen visibility controls */
.game-screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn 0.4s ease-out forwards;
}

.game-screen.active {
  display: flex;
}

/* 1. WELCOME SCREEN DESIGN */
.welcome-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.logo-animation {
  position: relative;
  height: 110px;
  margin-bottom: 5px;
}

.brain-glow {
  font-size: 3.5rem;
  color: var(--primary);
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.6));
  animation: float 4s ease-in-out infinite;
  display: inline-block;
}

.glow-dots {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 130px;
  height: 130px;
  pointer-events: none;
}

.glow-dots span {
  position: absolute;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent-cyan);
  opacity: 0.7;
  text-shadow: 0 0 8px var(--accent-cyan-glow);
}

.glow-dots span:nth-child(1) { top: 10%; left: 15%; animation: pulse-glow 2.5s infinite 0.2s; }
.glow-dots span:nth-child(2) { top: 15%; right: 10%; animation: pulse-glow 3s infinite 0.5s; color: var(--accent-magenta); }
.glow-dots span:nth-child(3) { bottom: 15%; left: 10%; animation: pulse-glow 2.8s infinite 0.8s; }
.glow-dots span:nth-child(4) { bottom: 10%; right: 15%; animation: pulse-glow 3.2s infinite 1.1s; }

h2 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 90%;
  margin: 0 auto;
}

/* High Score Display */
.high-score-showcase {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 8px 0;
  transition: var(--transition-bounce);
  box-shadow: inset 0 0 15px rgba(139, 92, 246, 0.05);
}

.high-score-showcase:hover {
  transform: translateY(-3px);
  border-color: rgba(139, 92, 246, 0.4);
  box-shadow: 0 5px 15px rgba(139, 92, 246, 0.15);
}

.showcase-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.text-gold {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.showcase-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: #ffffff;
  margin-top: 4px;
}

.showcase-value .unit {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 2px;
}

/* Quick instruction list */
.start-instructions {
  padding: 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.card-dark {
  background: var(--card-dark-bg);
  border: 1px solid var(--card-dark-border);
}

.inst-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inst-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--primary);
  color: var(--primary-hover);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.inst-item p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Settings Checkbox Toggles */
.screen-settings {
  display: flex;
  justify-content: center;
  padding: 5px 0;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-control input {
  display: none;
}

.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 30px;
  transition: var(--transition-smooth);
}

.toggle-control input:checked + .control-label {
  background: rgba(6, 182, 212, 0.1);
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.15);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition-bounce);
  color: #ffffff;
  text-decoration: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-glow-purple {
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-glow-purple:hover {
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6);
}

.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-secondary);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  box-shadow: 0 4px 15px var(--success-glow);
}

.btn-success:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

.w-100 {
  width: 100%;
}

/* 2. GAME SCREEN DESIGN */
.game-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  gap: 20px;
}

.game-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.level-badge {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: var(--primary);
  padding: 4px 12px;
  border-radius: 30px;
  box-shadow: 0 0 10px var(--primary-glow);
}

.digits-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Timer progress bar */
.timer-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: -5px;
}

.timer-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, var(--primary), var(--accent-cyan));
  border-radius: 4px;
  transform-origin: left center;
  transition: transform 0.05s linear; /* Smooth scaling */
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);
}

.timer-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Display portal: Number display / Input text */
.display-portal {
  flex-grow: 1;
  min-height: 160px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.game-phase {
  display: none;
  width: 100%;
  text-align: center;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.game-phase.active {
  display: flex;
}

.neon-number {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: #ffffff;
  text-shadow: 
    0 0 10px rgba(255, 255, 255, 0.8),
    0 0 20px var(--primary-glow),
    0 0 30px var(--accent-cyan-glow);
  word-break: break-all;
  user-select: none;
  line-height: 1.2;
  margin: 10px 0;
  font-family: 'Outfit', sans-serif;
}

/* Adjust font size for longer numbers */
.neon-number.digits-long {
  font-size: 2.2rem;
  letter-spacing: 2px;
}

.neon-number.digits-vlong {
  font-size: 1.6rem;
  letter-spacing: 1px;
}

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

.phase-tip.text-accent {
  color: var(--text-secondary);
}

/* Custom Text Input styling */
.input-wrapper {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 10px 0;
}

#user-number-input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  background: rgba(10, 8, 25, 0.7);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 3px;
  transition: var(--transition-smooth);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
  font-family: 'Outfit', sans-serif;
}

#user-number-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 
    0 0 15px rgba(6, 182, 212, 0.25),
    inset 0 2px 5px rgba(0,0,0,0.2);
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition-smooth);
  display: none;
}

.clear-btn.active {
  display: block;
}

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

/* CUSTOM VIRTUAL KEYPAD */
.keypad-panel {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  display: none;
}

.keypad-panel.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition-bounce);
  font-family: 'Outfit', sans-serif;
  user-select: none;
}

.keypad-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--primary);
}

.keypad-btn:active {
  transform: scale(0.92);
  background: rgba(139, 92, 246, 0.3);
}

.keypad-btn.action-key {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
}

.keypad-btn.submit-key {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
}

.keypad-btn.submit-key:hover {
  background: rgba(6, 182, 212, 0.2);
}

/* 3. RESULT SCREEN DESIGN */
.result-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  text-align: center;
}

.result-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.result-icon-glow {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.8rem;
  margin-bottom: 5px;
}

.result-icon-glow.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  box-shadow: 0 0 20px var(--error-glow);
  animation: pulse-error 2s infinite;
}

.result-icon-glow.success-crown {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
  animation: float 3s ease-in-out infinite;
}

.result-stats-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.stat-box {
  background: var(--card-dark-bg);
  border: 1px solid var(--card-dark-border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-lbl {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.stat-val {
  font-size: 1.35rem;
  font-weight: 800;
}

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

.text-cyan {
  color: var(--accent-cyan);
}

/* Diff Comparisons Card */
.comparison-card {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: left;
}

.comparison-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.comparison-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

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

.comp-value {
  font-size: 1.15rem;
  font-weight: 700;
}

.code-font {
  font-family: 'Outfit', monospace;
  letter-spacing: 1px;
}

/* Diff coloring */
.diff-correct {
  color: var(--success);
}

.diff-wrong {
  color: var(--error);
  text-decoration: underline;
  font-weight: 800;
}

.comp-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

/* Benchmark Info Box */
.benchmark-info {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  text-align: left;
  border-left: 3px solid var(--accent-cyan);
}

.benchmark-icon {
  font-size: 1.4rem;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.benchmark-text h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.benchmark-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Score History */
.history-section {
  width: 100%;
  text-align: left;
}

.history-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.history-date {
  color: var(--text-muted);
}

.history-score {
  font-weight: 700;
  color: #ffffff;
}

.history-score.best {
  color: var(--gold);
}

.history-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 0;
  background: rgba(255,255,255,0.01);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255,255,255,0.05);
}

.action-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
  width: 100%;
  margin-top: 5px;
}

/* MODALS */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 3, 15, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  max-height: 90%;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-smooth);
}

.close-modal-btn:hover {
  color: #ffffff;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-top: 8px;
}

.modal-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-body ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-body li {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.modal-body code {
  background: rgba(255,255,255,0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
}

/* FOOTER */
.app-footer {
  padding: 8px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-footer a {
  color: var(--primary-hover);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.app-footer a:hover {
  color: var(--accent-cyan);
  text-decoration: underline;
}

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

/* KEYFRAMES & MICRO-ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulse-glow {
  0% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); filter: drop-shadow(0 0 8px currentColor); }
  100% { opacity: 0.3; transform: scale(0.9); }
}

@keyframes pulse-error {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Card shaking error indicator */
.shake-error {
  animation: shake 0.4s ease-in-out;
}

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

/* Success glow green flash */
.success-glow-active {
  animation: green-flash 0.5s ease-out;
}

@keyframes green-flash {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { box-shadow: 0 0 25px 5px rgba(16, 185, 129, 0.8); }
  100% { box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); }
}

/* Responsive tweaks for very small devices */
@media (max-height: 600px) {
  .main-card {
    min-height: auto;
    padding: 16px;
  }
  .logo-animation {
    height: 70px;
  }
  .brain-glow {
    font-size: 2.5rem;
  }
  .showcase-value {
    font-size: 1.8rem;
  }
  .keypad-btn {
    padding: 10px 0;
    font-size: 1.15rem;
  }
}
