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

html {
  overflow-y: scroll;
  height: auto;
}

:root {
  --bg: #1a1128;
  --bg2: #261842;
  --accent: #ff6b35;
  --accent2: #ffd166;
  --green: #4ade80;
  --yellow: #facc15;
  --orange: #f97316;
  --red: #ef4444;
  --text: #f0e6ff;
  --text-dim: #a89bc2;
  --energy: 0;
  --energy-color: #4ade80;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: block;
  text-align: center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 20px;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}


/* ===== SCREENS ===== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: calc(100vh - 80px);
}

.screen.active {
  display: flex;
}

/* ===== WELCOME SCREEN ===== */
#screen-welcome {
  justify-content: center;
  gap: 32px;
  text-align: center;
  padding-bottom: 80px;
}

.welcome-icon {
  font-size: 100px;
  animation: bounce 2s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(255, 107, 53, 0.4));
}

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

#tagline {
  font-size: 18px;
  color: var(--text-dim);
  max-width: 280px;
}

#btn-start {
  background: linear-gradient(135deg, var(--accent), #ff8c5a);
  color: white;
  border: none;
  padding: 18px 48px;
  border-radius: 50px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 30px rgba(255, 107, 53, 0.4);
}

#btn-start:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 40px rgba(255, 107, 53, 0.6);
}

#btn-start:active {
  transform: scale(0.97);
}

.tip {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  max-width: 280px;
}

#mic-error {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 100;
}

#mic-error.visible {
  opacity: 1;
}

/* ===== OFFLINE BANNER ===== */
#offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  color: var(--accent2);
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  transform: translateY(100%);
  transition: transform 0.3s;
  z-index: 100;
}

#offline-banner.visible {
  transform: translateY(0);
}

/* ===== MONITOR SCREEN ===== */
#screen-monitor {
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 30px;
  transition: background 0.5s;
}

#screen-monitor.warning-pulse {
  animation: warningPulse 0.5s ease-in-out 3;
}

#screen-monitor.alert-active {
  animation: alertFlash 0.3s ease-in-out infinite;
}

@keyframes warningPulse {
  0%, 100% { background: transparent; }
  50% { background: rgba(249, 115, 22, 0.1); }
}

@keyframes alertFlash {
  0%, 100% { background: rgba(239, 68, 68, 0.05); }
  50% { background: rgba(239, 68, 68, 0.2); }
}

.monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.status-text {
  font-size: 20px;
  font-weight: 700;
  transition: color 0.3s;
  color: var(--text-dim);
}

.status-waiting { color: var(--text-dim); }
.status-heating { color: var(--yellow); }
.status-popping { color: var(--green); }
.status-slowing { color: var(--orange); }
.status-done { color: var(--red); font-size: 28px; }

#timer {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* Microwave area */
.microwave-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 240px;
  height: 240px;
}

.microwave {
  width: 180px;
  height: 140px;
  border: 4px solid var(--text-dim);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  position: relative;
  transition: border-color 0.3s, box-shadow 0.3s;
  background: rgba(255, 255, 255, 0.03);
}

.microwave::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.microwave.status-heating {
  border-color: var(--yellow);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.3);
}

.microwave.status-popping {
  border-color: var(--green);
  box-shadow: 0 0 30px rgba(74, 222, 128, 0.4);
  animation: shake 0.3s ease-in-out infinite;
}

.microwave.status-slowing {
  border-color: var(--orange);
  box-shadow: 0 0 25px rgba(249, 115, 22, 0.4);
  animation: shake 0.5s ease-in-out infinite;
}

.microwave.status-done {
  border-color: var(--red);
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.5);
  animation: shake 0.15s ease-in-out infinite;
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-2px) rotate(-0.5deg); }
  75% { transform: translateX(2px) rotate(0.5deg); }
}

/* Particles */
#particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popcorn-kernel {
  position: absolute;
  font-size: 24px;
  animation: popOut 0.8s ease-out forwards;
  pointer-events: none;
}

@keyframes popOut {
  0% {
    transform: translate(0, 0) scale(0.3);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(1);
    opacity: 0;
  }
}

/* Energy meter */
.energy-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#energy-meter {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

#energy-meter::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--energy) * 100%);
  background: var(--energy-color);
  border-radius: 4px;
  transition: width 0.05s;
}

#waveform {
  width: 100%;
  height: 60px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

/* Pop counter */
.stats-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  width: 100%;
}

#pop-count {
  font-size: 64px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: transform 0.15s;
  line-height: 1;
}

#pop-count.bump {
  transform: scale(1.15);
}

.pop-label {
  font-size: 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Stop button */
#btn-stop {
  background: rgba(239, 68, 68, 0.2);
  border: 2px solid var(--red);
  color: var(--red);
  padding: 14px 48px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

#btn-stop:hover {
  background: var(--red);
  color: white;
}

/* ===== RESULT SCREEN ===== */
#screen-result {
  justify-content: center;
  gap: 40px;
  text-align: center;
}

.result-icon {
  font-size: 80px;
  animation: celebrate 1s ease-in-out;
}

@keyframes celebrate {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

#result-title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg2);
  border-radius: 16px;
  padding: 20px 24px;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent2);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#btn-again {
  background: linear-gradient(135deg, var(--accent), #ff8c5a);
  color: white;
  border: none;
  padding: 16px 48px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 30px rgba(255, 107, 53, 0.4);
}

#btn-again:hover {
  transform: scale(1.05);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .welcome-icon { font-size: 80px; }
  #pop-count { font-size: 48px; }
  .microwave { width: 150px; height: 120px; font-size: 48px; }
}

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

@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ===== SEO CONTENT ===== */
.seo-content {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}

.seo-content h1 {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 12px;
}

.seo-content h2 {
  font-size: 16px;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 8px;
}

.seo-content h3 {
  font-size: 14px;
  color: var(--text);
  margin-top: 16px;
  margin-bottom: 4px;
}

.seo-content p,
.seo-content ul,
.seo-content ol {
  margin-bottom: 10px;
}

.seo-content ul,
.seo-content ol {
  padding-left: 20px;
}

.seo-content li {
  margin-bottom: 4px;
}
