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

[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --accent: #f97316;
  --accent-hot: #ef4444;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#bg, #bg-poster {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: #000;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.65) 0%,
    rgba(0, 0, 0, 0.25) 35%,
    rgba(0, 0, 0, 0.35) 65%,
    rgba(0, 0, 0, 0.85) 100%
  );
  pointer-events: none;
}

#cam {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

main {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  height: 100dvh;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  gap: 1rem;
}

header {
  text-align: center;
  margin-top: 0.5rem;
}

h1 {
  font-size: clamp(1.6rem, 8.5vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.85);
  line-height: 1;
  white-space: nowrap;
}

.tagline {
  font-size: clamp(0.9rem, 3.6vw, 1.1rem);
  opacity: 0.85;
  margin-top: 0.6rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

#meter, #calibration {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 1.25rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#calibration {
  gap: 1.1rem;
  padding: 1.5rem 1.25rem;
}

.spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.calibration-label {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.meter-label {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bar {
  width: min(86vw, 380px);
  height: 30px;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ade80 0%, #fbbf24 55%, #ef4444 100%);
  transition: width 0.08s linear;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
}

.hint {
  font-size: 0.9rem;
  opacity: 0.8;
}

#result {
  text-align: center;
  padding: 1.25rem 1rem;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 1.25rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.result-label {
  font-size: 0.95rem;
  opacity: 0.85;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.result-value {
  font-size: clamp(2.4rem, 11vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.7);
  line-height: 1.05;
}

.result-comment {
  margin-top: 0.6rem;
  font-size: 1rem;
  opacity: 0.85;
}

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

button {
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-size: clamp(1.15rem, 4.5vw, 1.5rem);
  padding: 1.15rem 1.5rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  transition: transform 0.1s ease, filter 0.2s ease, background 0.2s ease;
  text-transform: uppercase;
}

button:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}

#start-btn {
  background: var(--accent);
  color: #fff;
}

#reset-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.error {
  font-size: 0.85rem;
  text-align: center;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.55);
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@media (min-width: 720px) {
  main { max-width: 480px; margin: 0 auto; }
}
