/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0e1a;
  --card-bg:   #141929;
  --card-hover:#1c2540;
  --accent:    #7c6af7;
  --accent-2:  #a78bfa;
  --accent-3:  #c4b5fd;
  --text:      #e8eaf6;
  --text-muted:#8892b0;
  --border:    #2a3254;
  --glow:      rgba(124, 106, 247, 0.35);
  --glow-lg:   rgba(124, 106, 247, 0.15);
  --success:   #34d399;
  --radius:    16px;
  --radius-sm: 10px;
  --transition: 0.25s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ===== SCREEN SYSTEM ===== */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  padding-bottom: env(safe-area-inset-bottom, 20px);
  padding-top: env(safe-area-inset-top, 0);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
.screen.slide-out {
  opacity: 0;
  transform: translateY(-20px);
}

/* ===== HOME SCREEN ===== */
#screen-home {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0 0 32px;
}

.home-header {
  text-align: center;
  padding: 52px 24px 28px;
  position: relative;
}
.home-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.logo-wave {
  font-size: 52px;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 18px rgba(124,106,247,0.6));
  animation: float 4s ease-in-out infinite;
}

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

.app-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.subject-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 24px 16px 0;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.subject-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  cursor: pointer;
  text-align: center;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.subject-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--glow-lg), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.subject-card:hover::before,
.subject-card:active::before { opacity: 1; }

.subject-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--glow), 0 4px 24px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

.subject-card:active {
  transform: scale(0.97);
}

.card-emoji {
  font-size: 36px;
  display: block;
  margin-bottom: 10px;
  transition: transform 0.3s;
}

.subject-card:hover .card-emoji {
  transform: scale(1.15);
}

.card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
  line-height: 1.3;
}

.home-footer {
  text-align: center;
  padding: 28px 24px 0;
}
.footer-text {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ===== DURATION SCREEN ===== */
#screen-duration {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--bg);
}

.duration-header {
  padding: 52px 20px 16px;
  display: flex;
  align-items: center;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.btn-back:hover {
  color: var(--text);
  background: var(--card-bg);
}

.duration-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 24px 40px;
  text-align: center;
}

.selected-subject-emoji {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(124,106,247,0.5));
}

.selected-subject-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.duration-prompt {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.duration-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}

.duration-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
}

.duration-btn:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--glow);
  transform: translateY(-2px);
}

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

.duration-mins {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent-2);
  line-height: 1;
}

.duration-label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ===== PLAYER SCREEN ===== */
#screen-player {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.ambient-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.2;
}

.orb-1 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #7c6af7, transparent);
  top: -100px; left: -100px;
  animation: orbDrift1 14s ease-in-out infinite;
}

.orb-2 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #4f46e5, transparent);
  bottom: -80px; right: -80px;
  animation: orbDrift2 18s ease-in-out infinite;
}

.orb-3 {
  width: 220px; height: 220px;
  background: radial-gradient(circle, #a78bfa, transparent);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: orbDrift3 10s ease-in-out infinite;
}

@keyframes orbDrift1 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(60px, 40px); }
  66% { transform: translate(-30px, 70px); }
}

@keyframes orbDrift2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-60px, -40px); }
}

@keyframes orbDrift3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.3); }
}

.player-header {
  position: relative;
  z-index: 10;
  padding: 52px 20px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-stop {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 20px;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.btn-stop:hover {
  color: var(--text);
  background: rgba(255,255,255,0.1);
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-subject-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.player-duration-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== BREATHING CIRCLE ===== */
.player-visual {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.breath-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(124,106,247,0.7), rgba(79,70,229,0.4));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    0 0 40px rgba(124,106,247,0.5),
    0 0 80px rgba(124,106,247,0.2),
    inset 0 0 30px rgba(255,255,255,0.1);
  animation: breathePulse 8s ease-in-out infinite;
  cursor: default;
}

.breath-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.breath-phase-text {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  letter-spacing: 2px;
  text-transform: lowercase;
  font-style: italic;
}

.breath-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(124,106,247,0.3);
  animation: breathePulse 8s ease-in-out infinite;
}

.breath-ring-1 {
  width: 200px; height: 200px;
  animation-delay: -1s;
  animation-duration: 8s;
}

.breath-ring-2 {
  width: 250px; height: 250px;
  animation-delay: -2s;
  animation-duration: 10s;
  border-color: rgba(124,106,247,0.15);
}

.breath-ring-3 {
  width: 300px; height: 300px;
  animation-delay: -3s;
  animation-duration: 12s;
  border-color: rgba(124,106,247,0.07);
}

@keyframes breathePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 40px rgba(124,106,247,0.5), 0 0 80px rgba(124,106,247,0.2), inset 0 0 30px rgba(255,255,255,0.1);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 60px rgba(124,106,247,0.7), 0 0 120px rgba(124,106,247,0.3), inset 0 0 40px rgba(255,255,255,0.15);
  }
}

/* Phase-specific animations */
.breath-circle.phase-inhale {
  animation: breatheIn 4s ease-in-out forwards !important;
}
.breath-circle.phase-hold {
  animation: none !important;
  transform: scale(1.18);
}
.breath-circle.phase-exhale {
  animation: breatheOut 4s ease-in-out forwards !important;
}
.breath-circle.phase-hold-out {
  animation: none !important;
  transform: scale(1);
}

@keyframes breatheIn {
  from { transform: scale(1); }
  to   { transform: scale(1.18); }
}
@keyframes breatheOut {
  from { transform: scale(1.18); }
  to   { transform: scale(1); }
}

/* ===== INSTRUCTION TEXT ===== */
.player-text-area {
  position: relative;
  z-index: 10;
  padding: 0 28px 20px;
  text-align: center;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.current-instruction {
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.55;
  transition: opacity 0.6s ease;
  max-width: 360px;
}

.current-instruction.fading {
  opacity: 0;
}

/* ===== PROGRESS ===== */
.player-progress {
  position: relative;
  z-index: 10;
  padding: 0 24px 16px;
}

.progress-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width 1s linear;
  box-shadow: 0 0 8px var(--glow);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== CONTROLS ===== */
.player-controls {
  position: relative;
  z-index: 10;
  padding: 8px 24px 36px;
  display: flex;
  justify-content: center;
}

.btn-pause-resume {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  border: none;
  border-radius: 40px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  padding: 14px 36px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 20px rgba(124,106,247,0.45);
  -webkit-user-select: none;
  user-select: none;
}

.btn-pause-resume:hover {
  background: var(--accent-2);
  box-shadow: 0 6px 28px rgba(124,106,247,0.6);
  transform: translateY(-1px);
}

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

.btn-pause-resume.is-paused {
  background: var(--card-hover);
  border: 1px solid var(--accent);
  color: var(--accent-2);
  box-shadow: 0 4px 20px rgba(124,106,247,0.2);
}

/* ===== SESSION COMPLETE OVERLAY ===== */
.session-complete-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.95);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
  opacity: 0;
  animation: fadeIn 1s ease 0.3s forwards;
}

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

.complete-emoji {
  font-size: 64px;
  animation: float 4s ease-in-out infinite;
}

.complete-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.complete-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
}

.btn-done {
  margin-top: 12px;
  background: var(--accent);
  border: none;
  border-radius: 40px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  padding: 14px 44px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,106,247,0.45);
  transition: background var(--transition), transform var(--transition);
}

.btn-done:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}

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

.no-voice-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2540;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 20px;
  max-width: 340px;
  text-align: center;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
  .subject-grid { grid-template-columns: repeat(3, 1fr); }
  .app-title { font-size: 34px; }
}

@media (min-width: 768px) {
  .subject-grid { grid-template-columns: repeat(4, 1fr); }
  .duration-buttons { grid-template-columns: repeat(4, 1fr); max-width: 600px; }
  .breath-circle { width: 200px; height: 200px; }
  .breath-ring-1 { width: 260px; height: 260px; }
  .breath-ring-2 { width: 320px; height: 320px; }
  .breath-ring-3 { width: 380px; height: 380px; }
}
