/* ============================================
   Spell Quest - Fun Spelling Game for Kids
   Mobile-first, colorful, kid-friendly
   ============================================ */

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

:root {
  --primary: #6C63FF;
  --primary-dark: #5A52D5;
  --primary-light: #8B85FF;
  --success: #4CAF50;
  --success-light: #E8F5E9;
  --error: #F44336;
  --error-light: #FFEBEE;
  --warning: #FF9800;
  --bg: #F0F0FF;
  --bg-card: #FFFFFF;
  --text: #2D2D3A;
  --text-light: #6B6B80;
  --text-muted: #9E9EB8;
  --border: #E8E8F0;
  --shadow: 0 2px 12px rgba(108, 99, 255, 0.1);
  --shadow-lg: 0 4px 24px rgba(108, 99, 255, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-height: 64px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
  -webkit-tap-highlight-color: transparent;
}

input, select {
  font-family: inherit;
  font-size: 16px;
}

/* --- Screens --- */
.screen {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* --- Loading Screen --- */
#loading-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #6C63FF 0%, #FF6B9D 50%, #FFA751 100%);
  color: white;
}

.loading-content { text-align: center; padding: 2rem; }

.loading-icon {
  font-size: 5rem;
  animation: bounce 1.5s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-15px) scale(1.1); }
}

#loading-screen h1 { font-size: 2.5rem; font-weight: 900; }

.loading-bar {
  width: 200px; height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  margin: 1.5rem auto 0;
  overflow: hidden;
}

.loading-fill {
  width: 0%; height: 100%;
  background: white;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --- Home Screen --- */
.home-header {
  padding: 1.5rem 1.25rem 1rem;
  background: linear-gradient(135deg, #6C63FF 0%, #8B85FF 100%);
  color: white;
  border-radius: 0 0 28px 28px;
}

.home-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.home-title-row h1 {
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
}

/* Profile button in header */
.profile-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: white;
}

.profile-btn:active { background: rgba(255,255,255,0.35); }

.level-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.level-badge {
  background: rgba(255,255,255,0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}

.level-progress {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
}

.level-progress-fill {
  height: 100%;
  background: #FFD700;
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 1rem;
  margin: -0.75rem 1rem 0.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-icon { font-size: 1.3rem; }
.stat-value { font-size: 1.4rem; font-weight: 900; color: var(--primary); }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Home Body --- */
.home-body {
  flex: 1;
  padding: 0.75rem 1rem;
  padding-bottom: calc(var(--nav-height) + 1.5rem + var(--safe-bottom));
  overflow-y: auto;
}

.home-body h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  margin-top: 0.5rem;
}

/* --- Grade Selector --- */
.grade-selector { margin-bottom: 0.5rem; }

.grade-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.grade-pills::-webkit-scrollbar { display: none; }

.grade-pill {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 800;
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grade-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.grade-pill[data-grade="0"].active { background: #E91E63; border-color: #E91E63; }
.grade-pill[data-grade="1"].active { background: #9C27B0; border-color: #9C27B0; }
.grade-pill[data-grade="2"].active { background: #673AB7; border-color: #673AB7; }
.grade-pill[data-grade="3"].active { background: #3F51B5; border-color: #3F51B5; }
.grade-pill[data-grade="4"].active { background: #2196F3; border-color: #2196F3; }
.grade-pill[data-grade="5"].active { background: #009688; border-color: #009688; }
.grade-pill[data-grade="6"].active { background: #4CAF50; border-color: #4CAF50; }
.grade-pill[data-grade="7"].active { background: #FF9800; border-color: #FF9800; }
.grade-pill[data-grade="8"].active { background: #F44336; border-color: #F44336; }

/* --- Mode Grid --- */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all 0.2s;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--mode-color, var(--primary));
}

.mode-card:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-lg);
}

.mode-card.boss {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 50%, #FFD93D 100%);
  color: white;
  border: none;
}

.mode-card.boss::before { display: none; }

.mode-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.mode-card h3 { font-size: 1rem; font-weight: 800; }
.mode-card p { font-size: 0.8rem; color: var(--text-light); margin-top: 0.2rem; }
.mode-card.boss p { color: rgba(255,255,255,0.9); }

/* --- Bottom Nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  z-index: 100;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.5rem 0.75rem;
  min-width: 60px;
  min-height: 48px;
  transition: all 0.2s;
}

.nav-icon { font-size: 1.3rem; }
.nav-label { font-size: 0.65rem; font-weight: 700; color: var(--text-muted); transition: color 0.2s; }
.nav-btn.active .nav-label { color: var(--primary); }
.nav-btn.active .nav-icon { transform: scale(1.1); }

/* --- Screen Header --- */
.screen-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
  gap: 0.75rem;
}

.screen-header h2 { flex: 1; font-size: 1.1rem; }

.back-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border-radius: 50%;
  background: var(--bg);
  flex-shrink: 0;
}

.back-btn:active { background: var(--border); }

/* --- Game Screen --- */
.game-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.game-progress { flex: 1; display: flex; align-items: center; gap: 0.5rem; }

.progress-bar {
  flex: 1; height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 5px;
  transition: width 0.3s ease;
}

.progress-text { font-size: 0.8rem; font-weight: 700; color: var(--text-light); white-space: nowrap; }

.game-streak { display: flex; align-items: center; gap: 2px; font-weight: 800; color: var(--warning); }
.streak-icon { font-size: 1.1rem; }

/* --- Game Area --- */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  gap: 1rem;
  overflow-y: auto;
}

.game-prompt {
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
}

.hint-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* Speaker button */
.speak-btn {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8B85FF);
  color: white;
  font-size: 2.5rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.3);
  transition: all 0.2s;
}

.speak-btn:active { transform: scale(0.93); }

.speak-btn.speaking {
  animation: pulse 0.8s ease-in-out infinite;
}

.speak-btn-small {
  width: 52px; height: 52px;
  font-size: 1.5rem;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
  50% { box-shadow: 0 0 0 18px rgba(108, 99, 255, 0); }
}

/* Spell input */
.spell-input-container {
  width: 100%;
  max-width: 400px;
  padding: 0 0.5rem;
}

.spell-input {
  width: 100%;
  padding: 1rem;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  letter-spacing: 3px;
}

.spell-input:focus { border-color: var(--primary); }
.spell-input.correct { border-color: var(--success); background: var(--success-light); }
.spell-input.incorrect { border-color: var(--error); background: var(--error-light); }

.speed-input { font-size: 1.3rem; }

/* --- Game Input Area --- */
.game-input-area {
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.submit-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: var(--radius);
  background: var(--primary);
  color: white;
  transition: all 0.2s;
  min-height: 52px;
}

.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { background: var(--border); color: var(--text-muted); }
.submit-btn.next { background: var(--success); }

/* --- Feedback --- */
.game-feedback { display: none; padding: 0.75rem 1rem; }
.game-feedback.visible { display: block; }

.feedback-content {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.feedback-content.correct { background: var(--success-light); color: #2E7D32; }
.feedback-content.incorrect { background: var(--error-light); color: #C62828; }

.correct-answer {
  display: block;
  font-size: 1.2rem;
  font-weight: 900;
  margin-top: 0.25rem;
  letter-spacing: 2px;
}

/* --- Sentence display (Fill the Blank) --- */
.sentence-display {
  font-size: 1.1rem;
  color: var(--text);
  text-align: center;
  max-width: 380px;
  line-height: 1.6;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.blank-word {
  display: inline-block;
  min-width: 80px;
  border-bottom: 3px solid var(--primary);
  color: var(--primary);
  font-weight: 800;
}

.letter-hint {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text-muted);
  font-family: monospace;
}

.emoji-hint {
  font-size: 4rem;
  line-height: 1;
  padding: 0.5rem;
  animation: bounce 1.5s ease-in-out infinite;
}

/* --- Spot the Spelling --- */
.spelling-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 360px;
  padding: 0 0.5rem;
}

.spelling-option {
  padding: 1rem 0.75rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 1px;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  text-align: center;
  transition: all 0.2s;
  min-height: 52px;
}

.spelling-option:active { transform: scale(0.95); border-color: var(--primary); }

.spelling-option.correct-option {
  border-color: var(--success);
  background: var(--success-light);
  color: #2E7D32;
}

.spelling-option.incorrect-option {
  border-color: var(--error);
  background: var(--error-light);
  color: #C62828;
}

/* --- Speed Round --- */
.speed-intro {
  text-align: center;
  padding: 2rem;
}

.speed-icon { font-size: 4rem; margin-bottom: 1rem; }
.speed-intro h2 { font-size: 1.8rem; font-weight: 900; }
.speed-intro p { color: var(--text-light); margin-bottom: 1.5rem; }

.speed-countdown {
  font-size: 4rem;
  font-weight: 900;
  color: var(--primary);
}

.speed-timer-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 2rem;
  font-weight: 900;
}

.timer-icon { font-size: 1.5rem; }
.timer-warning { color: var(--error); animation: blink 0.5s infinite; }

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

.speed-score {
  font-size: 1.1rem;
  color: var(--text-light);
}

.speed-score strong { color: var(--primary); font-size: 1.3rem; }

/* --- Boss Battle --- */
.boss-badge {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(135deg, #FF6B6B, #FF8E53);
  color: white;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 800;
}

/* --- Results Screen --- */
#results-screen {
  justify-content: center;
  align-items: center;
}

.results-content {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
}

.results-icon { font-size: 4.5rem; margin-bottom: 0.5rem; }
.results-content h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: 0.5rem; }

.results-stars {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: 8px;
}

.star-earned { display: inline-block; animation: starPop 0.5s ease; }
.star-empty { opacity: 0.3; }

@keyframes starPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.results-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1.5rem;
}

.result-stat { display: flex; flex-direction: column; align-items: center; }
.result-value { font-size: 2rem; font-weight: 900; color: var(--primary); }
.result-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.results-words {
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.results-word {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.results-word.missed { color: var(--error); }
.results-word.got-it { color: var(--success); }

.results-actions { display: flex; gap: 0.75rem; }

/* --- Buttons --- */
.btn {
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  font-weight: 800;
  border-radius: var(--radius);
  transition: all 0.2s;
  flex: 1;
  min-height: 48px;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); border: 2px solid var(--border); }
.btn-danger { background: var(--error); color: white; }

/* --- Word Vault --- */
.vault-filters {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.vault-filters::-webkit-scrollbar { display: none; }

.filter-btn {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 2px solid var(--border);
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.vault-count { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

.vault-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem;
  padding-bottom: calc(var(--nav-height) + 1rem + var(--safe-bottom));
}

.vault-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.vault-empty-icon { font-size: 3rem; margin-bottom: 1rem; }

.vault-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}

.vault-word { font-weight: 800; font-size: 1rem; flex: 1; }
.vault-level { display: flex; gap: 3px; }

.vault-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.vault-dot.filled { background: var(--success); }
.vault-dot.mastered { background: gold; }

.vault-grade {
  font-size: 0.7rem;
  color: white;
  font-weight: 800;
  background: var(--primary);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  white-space: nowrap;
}

.vault-delete-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--error-light);
  color: var(--error);
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.vault-delete-btn:active { background: var(--error); color: white; }

.vault-actions {
  padding: 0 1rem 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.vault-add-btn {
  padding: 0.6rem;
  font-size: 0.9rem;
}

.vault-practice-missed-btn {
  padding: 0.6rem;
  font-size: 0.9rem;
}

/* --- Settings --- */
.settings-list {
  padding: 1rem;
  padding-bottom: calc(var(--nav-height) + 1rem + var(--safe-bottom));
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}

.setting-item label:first-child { font-weight: 700; font-size: 0.95rem; }

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

.setting-item select {
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.setting-item input[type="range"] { width: 120px; }

.setting-item.danger {
  justify-content: center;
  background: transparent;
  box-shadow: none;
}

/* Toggle */
.toggle { position: relative; width: 52px; height: 28px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 28px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(24px); }

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-overlay.visible { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.modal p { font-size: 0.9rem; color: var(--text-light); margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; }

/* --- Custom Word Form --- */
.custom-word-form {
  text-align: left;
}

.custom-word-form h3 {
  text-align: center;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-light);
}

.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
  border-color: var(--primary);
}

/* --- Profile Modal --- */
.profile-modal-content {
  max-width: 360px;
}

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

.profile-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.profile-item:active { transform: scale(0.98); }

.profile-item.active {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.08);
}

.profile-icon-display {
  font-size: 1.8rem;
  line-height: 1;
}

.profile-name {
  flex: 1;
  font-weight: 800;
  font-size: 1rem;
}

.profile-actions-inline {
  display: flex;
  gap: 0.25rem;
}

.profile-edit-inline,
.profile-delete-inline {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.profile-edit-inline:active { background: var(--border); }
.profile-delete-inline:active { background: var(--error-light); }

/* Profile icon picker */
.profile-icon-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.icon-pick-btn {
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  background: var(--bg);
}

.icon-pick-btn.selected {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.1);
  transform: scale(1.1);
}

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

/* --- Animations --- */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.animate-slide-up { animation: slideUp 0.3s ease forwards; }
.animate-pop { animation: pop 0.3s ease; }

/* --- Responsive --- */
@media (min-width: 480px) {
  .mode-grid { gap: 1rem; }
}

@media (min-width: 768px) {
  body { display: flex; justify-content: center; }

  .screen {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .bottom-nav, .modal-overlay {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}
