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

:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --text: #e8e8ec;
  --muted: #6b6b7a;
  --yellow: #f5c842;
  --yellow-glow: rgba(245, 200, 66, 0.4);
  --radius: 50%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  text-align: center;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  transition: opacity 0.3s;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.version {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
  margin-bottom: 2.5rem;
}

.torch-btn {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: var(--radius);
  border: 3px solid rgba(255, 255, 255, 0.08);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0 auto 2rem;
  transition: border-color 0.4s, background 0.4s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

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

.torch-icon {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bulb {
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--muted);
  transition: background 0.4s, box-shadow 0.4s;
  position: relative;
  z-index: 1;
}

.bulb::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 10px;
  background: var(--muted);
  border-radius: 2px;
  transition: background 0.4s;
}

.glow {
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.torch-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.4s;
}

.torch-btn.on {
  border-color: var(--yellow);
  background: #1c1c2a;
}

.torch-btn.on .bulb {
  background: var(--yellow);
  box-shadow: 0 0 20px 5px var(--yellow-glow);
}

.torch-btn.on .bulb::after {
  background: #8a7530;
}

.torch-btn.on .glow {
  opacity: 1;
  animation: pulseGlow 1.8s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow:
      0 0 40px 10px var(--yellow-glow),
      0 0 80px 30px rgba(245, 200, 66, 0.15);
  }
  50% {
    box-shadow:
      0 0 60px 20px var(--yellow-glow),
      0 0 120px 50px rgba(245, 200, 66, 0.12);
  }
}

.torch-btn.on .torch-label {
  color: var(--yellow);
}

.status-msg {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.status-msg.error {
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.status-msg.info {
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.2);
}

.hidden {
  display: none;
}

.fallback-area {
  margin-top: 1.5rem;
}

.fallback-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.white-btn {
  padding: 0.75rem 2rem;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
}

.white-btn:hover,
.white-btn:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.white-screen {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.white-screen.hidden {
  display: none;
}

.exit-btn {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.08);
  color: #333;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, transform 0.2s;
  z-index: 1001;
}

.exit-btn:active {
  transform: scale(0.9);
  background: rgba(0, 0, 0, 0.15);
}
