:root {
  --bg: #2a2a30;
  --surface: #363640;
  --accent: #ff7043;
  --text: #eee;
  --text-dim: #888;
  --gold: #f5c518;
  --teal: #a8b8f0;
  --needle: white;
  --needle-glow: rgba(255,255,255,0.4);
  --tick: rgba(255,255,255,0.15);
  --tick-major: rgba(255,255,255,0.2);
  --track-border: rgba(255,255,255,0.1);
  --card-border: rgba(255,255,255,0.08);
  --card-left-bg: #7a2e15;
  --card-right-bg: #2a3368;
  --btn-bg: rgba(255,255,255,0.12);
  --btn-bg-dim: rgba(255,255,255,0.08);
}

[data-theme="light"] {
  --bg: #f0f0f4;
  --surface: #ffffff;
  --accent: #d04a1a;
  --text: #1a1a2e;
  --text-dim: #6b6b80;
  --gold: #e0a800;
  --teal: #2e3878;
  --needle: #1a1a2e;
  --needle-glow: rgba(0,0,0,0.2);
  --tick: rgba(0,0,0,0.1);
  --tick-major: rgba(0,0,0,0.15);
  --track-border: rgba(0,0,0,0.12);
  --card-border: rgba(0,0,0,0.08);
  --card-left-bg: #e8a888;
  --card-right-bg: #a8b0e0;
  --btn-bg: rgba(0,0,0,0.07);
  --btn-bg-dim: rgba(0,0,0,0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 16px;
  -webkit-tap-highlight-color: transparent;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--card-border);
  min-height: 100px;
}

.card-end {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
  gap: 10px;
}

.card-arrow {
  font-size: 1.2rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.card-end.left {
  background: var(--card-left-bg);
  color: var(--accent);
}

.card-end.right {
  background: var(--card-right-bg);
  color: var(--teal);
}

.card-divider {
  width: 1px;
  background: var(--track-border);
}

.scale-wrapper {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.scale-container {
  position: relative;
  width: 100%;
  height: 56px;
  cursor: pointer;
  touch-action: none;
}

.scale-track {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 32px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--track-border);
  overflow: hidden;
}

.target-zone {
  position: absolute;
  top: 0;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.target-zone.revealed {
  opacity: 1;
  transition: opacity 0.4s ease;
}

.target-4 { background: #e05050; }
.target-3 { background: #e8943a; }
.target-2 { background: #f0c840; }

.needle {
  position: absolute;
  top: 2px;
  width: 3px;
  height: 52px;
  background: var(--needle);
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 8px var(--needle-glow);
  transition: left 0.08s ease-out;
  pointer-events: none;
  z-index: 2;
}

.needle::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 13px;
  background: var(--needle);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--needle-glow);
}

.score-badge {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 800;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-badge.visible {
  transform: translateX(-50%) scale(1);
}

.ticks {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 32px;
  pointer-events: none;
  z-index: 1;
}

.tick {
  position: absolute;
  top: 0;
  width: 1px;
  background: var(--tick);
}

.tick.major { height: 32px; background: var(--tick-major); }
.tick.minor { height: 16px; top: 8px; }

.controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 420px;
}

.btn {
  flex: 1;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.btn-reveal {
  background: var(--btn-bg);
  color: var(--text);
}

.btn-reveal.revealed {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--track-border);
}

.btn-new {
  background: var(--btn-bg-dim);
  color: var(--text);
}

.theme-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.theme-btn {
  padding: 6px 14px;
  border: 1px solid var(--track-border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.theme-btn.active {
  background: var(--btn-bg);
  color: var(--text);
  border-color: var(--text-dim);
}

.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--track-border);
  border-radius: 8px;
  padding: 3px;
  line-height: 0;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--text); }
.theme-toggle .icon { width: 10px; height: 10px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
