:root {
  --bg: #0E0A06;
  --bg-2: #160E07;
  --ink: #F2E7D2;
  --ink-muted: #D4C4A8;
  --ink-faint: #9A8968;
  --line: #2A1E12;
  --accent: #E89F4A;
  --accent-soft: #C58843;
  --display: 'Instrument Serif', 'Cormorant Garamond', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --easing: cubic-bezier(0.2, 0.65, 0.3, 1);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  height: 100vh;
  height: 100svh; /* svh vinner: matchar synlig yta, footern göms ej bakom webbläsarens fält */
}

body {
  background:
    radial-gradient(800px 600px at 50% 40%, rgba(232,159,74,0.06), transparent 65%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

/* === Screens === */
.screen { display: none; flex-direction: column; height: 100vh; height: 100svh; position: relative; }
.screen.active { display: flex; }

/* === Start screen === */
.start-screen {
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 32px;
  text-align: center;
}

.start-title {
  font-size: clamp(48px, 12vw, 96px);
  font-style: italic;
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.02em;
  animation: fade-up 1s var(--easing) 0.1s both;
}

.start-sub {
  font-size: clamp(16px, 2.5vw, 22px);
  color: var(--ink-muted);
  max-width: 340px;
  line-height: 1.5;
  animation: fade-up 1s var(--easing) 0.25s both;
}

.start-headphones {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  animation: fade-up 1s var(--easing) 0.3s both;
}

/* Mode buttons */
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  animation: fade-up 1s var(--easing) 0.35s both;
}

.mode-btn {
  padding: 16px 20px;
  font-family: var(--display);
  font-size: 19px;
  font-style: italic;
  color: var(--ink-muted);
  background: rgba(255,240,220,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.3s var(--easing), background 0.3s var(--easing), color 0.2s;
}

.mode-btn:hover, .mode-btn:focus-visible {
  border-color: var(--accent-soft);
  background: rgba(255,240,220,0.06);
  color: var(--ink);
  outline: none;
}

.mode-btn-desc {
  display: block;
  font-family: var(--mono);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-top: 4px;
}

/* Progression menu (fingerläge) */
.step-progression {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  animation: fade-up 0.6s var(--easing) both;
}

.step-progression.active { display: flex; }

.prog-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prog-btn {
  position: relative;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--display);
  color: var(--ink-muted);
  background: rgba(255,240,220,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.3s var(--easing), background 0.3s var(--easing), color 0.2s;
}

.prog-btn:hover, .prog-btn:focus-visible {
  border-color: var(--accent-soft);
  background: rgba(255,240,220,0.06);
  color: var(--ink);
  outline: none;
}

.prog-btn.recommended {
  border-color: var(--accent-soft);
  background: rgba(232, 159, 74, 0.05);
}

.prog-name {
  font-size: 18px;
  font-style: italic;
}

.prog-desc {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.prog-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Duration step */
.step-duration {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fade-up 0.6s var(--easing) both;
}

.step-duration.active { display: flex; }

.btn-back {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  align-self: flex-start;
  transition: color 0.2s;
}

.btn-back:hover { color: var(--ink-muted); }

.duration-buttons {
  display: flex;
  gap: 12px;
}

.dur-btn {
  padding: 14px 22px;
  font-family: var(--display);
  font-size: clamp(17px, 2.5vw, 22px);
  font-style: italic;
  color: var(--ink-muted);
  background: rgba(255,240,220,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.3s var(--easing), background 0.3s var(--easing), color 0.2s;
}

.dur-btn:hover, .dur-btn:focus-visible {
  border-color: var(--accent-soft);
  background: rgba(255,240,220,0.06);
  color: var(--ink);
  outline: none;
}

.start-hint {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  max-width: 280px;
  line-height: 1.6;
}

.start-settings {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.voice-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.voice-btn {
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.voice-btn:hover { border-color: var(--ink-faint); color: var(--ink-muted); }

.voice-btn.active {
  border-color: var(--accent-soft);
  color: var(--accent);
  background: rgba(232, 159, 74, 0.06);
}

.foot {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.foot-link {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color 0.2s;
}

.foot-link:hover { color: var(--ink-muted); }

.foot-link .arrow { color: var(--accent-soft); }

/* === Session screen === */
.session-screen { position: relative; }

.session-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  z-index: 10;
  pointer-events: none;
}

.session-header > * { pointer-events: auto; }

.session-timer {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  transition: color 0.5s;
}

.session-timer.winding-down { color: var(--accent-soft); }

.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,240,220,0.04);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 18px;
  transition: border-color 0.25s, color 0.25s;
}

.btn-icon:hover { border-color: var(--accent-soft); color: var(--ink-muted); }

/* === Tap zones === */
.tap-zones {
  flex: 1;
  display: flex;
  flex-direction: row;
  position: relative;
}

/* Two large tap areas — one per hand. Generös tryckyta; precisionen bor i att
   sikta på mål-punkten, inte i smala väggar. */
.tap-half {
  flex: 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.3s ease;
}

.tap-half + .tap-half {
  border-left: 1px solid rgba(42, 30, 18, 0.5);
}

.tap-half.cue {
  background: rgba(232, 159, 74, 0.11);
}

/* Fixed finger-target points. Position (left/top) sätts av JS; transform
   centrerar och driften (tummode) adderar offset. */
.target-point {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  will-change: transform;
  opacity: 0.22;                 /* övriga prickar dämpade (bara karta) */
  transition: opacity 0.25s ease;
}

/* Bara den aktiva punkten lyser upp — en tydlig ring att sikta på. */
.target-point.active {
  opacity: 1;
}

.target-dot {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: rgba(255, 240, 220, 0.02);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.target-point.active .target-dot {
  border-color: var(--accent);
  background: rgba(232, 159, 74, 0.15);
  box-shadow: 0 0 18px rgba(232, 159, 74, 0.35);
}

/* Re-pulsar varje slag (klassen tas bort + sätts om av JS → animation om). */
.target-point.pulse .target-dot {
  animation: target-pulse 0.5s ease-out;
}

@keyframes target-pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 159, 74, 0.45); }
  100% { box-shadow: 0 0 0 26px rgba(232, 159, 74, 0); }
}

.target-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: color 0.2s, opacity 0.2s;
  opacity: 0.5;
}

.target-point.active .target-label {
  color: var(--accent);
  opacity: 0.85;
}

/* Flash on tap */
.tap-flash {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(232, 159, 74, 0.5), transparent 65%);
  animation: tap-flash-anim 0.45s ease-out forwards;
}

@keyframes tap-flash-anim {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(1.2); opacity: 0; }
}

/* Brighter flash when tapping near the cue ring */
.tap-flash.tap-flash-ring {
  background: radial-gradient(circle, rgba(232, 159, 74, 0.7), transparent 60%);
}

/* === Intro overlay === */
.intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: rgba(14, 10, 6, 0.94);
  text-align: center;
  padding: 40px 32px;
}

.intro-overlay.visible { animation: fade-in 0.4s ease both; }
.intro-overlay.hiding { animation: fade-out 0.5s ease both; pointer-events: none; }

.intro-text {
  font-size: clamp(18px, 3.5vw, 24px);
  color: var(--ink-muted);
  max-width: 320px;
  line-height: 1.6;
}

.intro-demo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
}

.intro-demo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.15;
  transition: opacity 0.15s;
}

.intro-demo-dot.on { opacity: 1; }

.intro-demo-sep {
  color: var(--ink-faint);
  font-size: 8px;
}

.intro-hint {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 8px;
}

/* === Done screen === */
.done-screen {
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px;
  text-align: center;
}

.done-title {
  font-size: clamp(32px, 8vw, 56px);
  font-style: italic;
  font-weight: 400;
  line-height: 1;
  animation: fade-up 0.8s var(--easing) 0.1s both;
}

.done-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  animation: fade-up 0.8s var(--easing) 0.25s both;
}

.done-streak { color: var(--accent); font-size: 14px; margin-top: 6px; }

.done-observation {
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--ink-muted);
  max-width: 320px;
  line-height: 1.5;
  animation: fade-up 0.8s var(--easing) 0.4s both;
}

.done-nudge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 260px;
  animation: fade-up 0.8s var(--easing) 0.5s both;
}

/* hidden-attributet måste slå display:flex (annars syns tom container) */
.done-nudge[hidden] { display: none; }

.done-nudge-text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  line-height: 1.5;
}

.done-nudge .done-btn { width: 100%; }

.done-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 260px;
  animation: fade-up 0.8s var(--easing) 0.55s both;
}

.done-btn {
  padding: 14px 24px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}

.done-btn.primary { color: var(--bg); background: var(--accent); border: 1px solid var(--accent); }
.done-btn.primary:hover { background: var(--accent-soft); }
.done-btn.secondary { color: var(--ink-muted); background: transparent; border: 1px solid var(--line); }
.done-btn.secondary:hover { border-color: var(--ink-faint); color: var(--ink); }

/* === Animations === */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; pointer-events: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
