*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --accent: #6ee7b7;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --danger: #f87171;
  --radius: 12px;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(ellipse at top, #1e1b4b 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  max-height: 100dvh;
  padding: 10px 12px 12px;
  gap: 8px;
  max-width: 360px;
  margin: 0 auto;
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}

.title-wrap h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.score-panel {
  text-align: center;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px 14px;
  min-width: 72px;
  flex-shrink: 0;
}

.score-label {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.score-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s ease;
}

.score-value.bump {
  transform: scale(1.08);
}

.camera-wrap {
  position: relative;
  width: 100%;
  max-height: min(42dvh, 240px);
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 1;
}

#video,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#overlay {
  pointer-events: none;
}

.status-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: background 0.2s, color 0.2s;
}

.status-badge.open {
  background: rgba(52, 211, 153, 0.25);
  color: var(--accent);
  border-color: rgba(110, 231, 183, 0.4);
}

.status-badge.closed {
  color: var(--muted);
}

.status-badge.error {
  background: rgba(248, 113, 113, 0.2);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

.meter {
  width: 100%;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.meter-track {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #34d399, #6ee7b7);
  border-radius: 999px;
  transition: width 0.08s linear;
}

.meter-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.7);
  left: 35%;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
  min-height: 2.2em;
  padding: 0 4px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: auto;
}

.actions .btn-primary {
  grid-column: 1 / -1;
}

.btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #34d399, #059669);
  color: #042f2e;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

@media (min-width: 400px) {
  .app {
    max-width: 380px;
  }
}

@media (max-height: 600px) {
  .camera-wrap {
    max-height: min(36dvh, 200px);
  }

  .score-value {
    font-size: 1.4rem;
  }

  .hint {
    min-height: 1.6em;
  }
}
