
/**
 * Pop Spiral — pop-spiral.css
 * Dopamine-friendly bubble-popping game for ADHD minds.
 */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg-deep:    hsl(230, 35%, 7%);
  --color-bg-surface: hsl(230, 28%, 10%);
  --color-bg-card:    hsl(230, 25%, 13%);

  --color-text-primary: hsl(220, 20%, 92%);
  --color-text-muted:   hsl(220, 15%, 55%);
  --color-text-dim:     hsl(220, 12%, 35%);

  --font-display: 'DM Sans', sans-serif;
  --font-body:    'Inter', sans-serif;

  --text-xs:   clamp(0.65rem, 1.5vw, 0.75rem);
  --text-sm:   clamp(0.8rem, 2vw, 0.875rem);
  --text-md:   clamp(1rem, 3vw, 1.125rem);
  --text-lg:   clamp(1.1rem, 3.5vw, 1.375rem);
  --text-xl:   clamp(1.3rem, 4vw, 1.75rem);
  --text-2xl:  clamp(1.6rem, 5vw, 2.25rem);
  --text-3xl:  clamp(2rem, 6vw, 3rem);

  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-xl:   32px;
  --radius-full: 9999px;

  --ease-bounce:     cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out-expo:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-sin: cubic-bezier(0.37, 0, 0.63, 1);

  /* Bubble palette */
  --bub-1: hsl(185, 80%, 60%);   /* teal */
  --bub-2: hsl(260, 70%, 72%);   /* lavender */
  --bub-3: hsl(330, 75%, 68%);   /* rose */
  --bub-4: hsl(45,  90%, 65%);   /* amber */
  --bub-5: hsl(140, 60%, 58%);   /* mint */
  --bub-6: hsl(200, 80%, 65%);   /* sky */
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--color-bg-deep);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Ambient Background ── */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.1;
  animation: blobDrift 18s ease-in-out infinite alternate;
}
.blob-a {
  width: 500px; height: 500px;
  background: hsl(185, 80%, 55%);
  top: -180px; right: -120px;
  animation-duration: 22s;
}
.blob-b {
  width: 380px; height: 380px;
  background: hsl(260, 70%, 65%);
  bottom: -100px; left: -80px;
  animation-duration: 16s;
  animation-delay: -5s;
}
.blob-c {
  width: 260px; height: 260px;
  background: hsl(330, 75%, 65%);
  top: 40%; left: 40%;
  opacity: 0.07;
  animation-duration: 28s;
  animation-delay: -12s;
}
@keyframes blobDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

/* ── Screen System ── */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 400ms var(--ease-out-expo);
}
.screen.is-active {
  opacity: 1;
  pointer-events: all;
}

/* ── Shared Header ── */
.scr-header {
  display: flex;
  align-items: center;
  padding: max(env(safe-area-inset-top), 1.25rem) var(--space-6) var(--space-4);
  position: relative;
  z-index: 10;
}
.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: hsla(220, 25%, 20%, 0.6);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 200ms, color 200ms, transform 200ms var(--ease-bounce);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid hsla(220, 20%, 40%, 0.15);
}@media (hover: hover) and (pointer: fine) {

.nav-back:hover {
  background: hsla(220, 25%, 28%, 0.7);
  color: var(--color-text-primary);
  transform: scale(1.05);
}
}

.nav-back:active { transform: scale(0.95); }

/* ════════════════════════════════════════════════ */
/* START SCREEN                                     */
/* ════════════════════════════════════════════════ */
.scr-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: max(env(safe-area-inset-bottom), var(--space-8));
}

.start-inner {
  padding: 0 var(--space-6);
  gap: var(--space-8);
  justify-content: space-between;
}

/* Preview bubbles cluster */
.start-hero {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  padding-top: var(--space-4);
}

.start-orb-preview {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

.preview-bubble {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: floatBubble 3s ease-in-out infinite;
}

.pb-1 {
  width: 80px; height: 80px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, hsla(185, 90%, 80%, 0.9), hsla(185, 80%, 60%, 0.6));
  box-shadow: 0 0 30px hsla(185, 80%, 60%, 0.5), inset 0 -6px 20px hsla(185, 70%, 40%, 0.3);
  border: 1.5px solid hsla(185, 80%, 80%, 0.4);
  animation-duration: 2.8s;
}
.pb-2 {
  width: 50px; height: 50px;
  top: 10%; left: 60%;
  background: radial-gradient(circle at 35% 30%, hsla(260, 90%, 85%, 0.9), hsla(260, 70%, 70%, 0.6));
  box-shadow: 0 0 20px hsla(260, 70%, 65%, 0.5), inset 0 -4px 14px hsla(260, 60%, 45%, 0.3);
  border: 1.5px solid hsla(260, 70%, 85%, 0.4);
  animation-duration: 3.2s;
  animation-delay: -0.8s;
}
.pb-3 {
  width: 40px; height: 40px;
  bottom: 15%; left: 15%;
  background: radial-gradient(circle at 35% 30%, hsla(330, 90%, 85%, 0.9), hsla(330, 75%, 68%, 0.6));
  box-shadow: 0 0 18px hsla(330, 75%, 65%, 0.5), inset 0 -4px 12px hsla(330, 65%, 45%, 0.3);
  border: 1.5px solid hsla(330, 75%, 85%, 0.4);
  animation-duration: 2.5s;
  animation-delay: -1.2s;
}
.pb-4 {
  width: 32px; height: 32px;
  bottom: 25%; right: 10%;
  background: radial-gradient(circle at 35% 30%, hsla(45, 95%, 78%, 0.9), hsla(45, 90%, 62%, 0.6));
  box-shadow: 0 0 15px hsla(45, 90%, 62%, 0.5), inset 0 -3px 10px hsla(45, 80%, 42%, 0.3);
  border: 1.5px solid hsla(45, 90%, 78%, 0.4);
  animation-duration: 3.5s;
  animation-delay: -2s;
}
.pb-5 {
  width: 24px; height: 24px;
  top: 20%; left: 10%;
  background: radial-gradient(circle at 35% 30%, hsla(140, 80%, 78%, 0.9), hsla(140, 60%, 58%, 0.6));
  box-shadow: 0 0 12px hsla(140, 60%, 55%, 0.5), inset 0 -3px 8px hsla(140, 55%, 38%, 0.3);
  border: 1.5px solid hsla(140, 60%, 78%, 0.4);
  animation-duration: 2.2s;
  animation-delay: -0.4s;
}

@keyframes floatBubble {
  0%, 100% { transform: translate(-50%, -50%) translateY(0px); }
  50%       { transform: translate(-50%, -50%) translateY(-10px); }
}
.pb-2, .pb-3, .pb-4, .pb-5 {
  transform: none;
}
.pb-2 { animation-name: floatFree; }
.pb-3 { animation-name: floatFree; }
.pb-4 { animation-name: floatFree; }
.pb-5 { animation-name: floatFree; }
@keyframes floatFree {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

.start-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, hsl(185, 80%, 70%) 0%, hsl(260, 70%, 75%) 50%, hsl(330, 75%, 72%) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.start-sub {
  font-size: var(--text-md);
  color: var(--color-text-muted);
  line-height: 1.65;
  font-weight: 300;
  max-width: 28ch;
  margin: 0 auto;
}

/* ── Duration Picker ── */
.duration-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
}

.section-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-align: center;
}

.duration-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  flex: 1;
  align-content: start;
}

.dur-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: var(--space-4) var(--space-2);
  background: hsla(220, 25%, 15%, 0.7);
  border: 1.5px solid hsla(220, 20%, 30%, 0.2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  color: var(--color-text-muted);
  transition:
    background 200ms ease,
    border-color 200ms ease,
    transform 200ms var(--ease-bounce),
    box-shadow 200ms ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}
.dur-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsla(260, 70%, 65%, 0.08) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 200ms ease;
  border-radius: inherit;
}@media (hover: hover) and (pointer: fine) {

.dur-btn:hover {
  background: hsla(220, 25%, 20%, 0.8);
  border-color: hsla(260, 50%, 50%, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px hsla(230, 40%, 3%, 0.4);
}
}@media (hover: hover) and (pointer: fine) {


.dur-btn:hover::before { opacity: 1; }
}

.dur-btn:active { transform: scale(0.96); }

.dur-btn.is-selected {
  background: hsla(260, 60%, 20%, 0.6);
  border-color: hsla(260, 65%, 65%, 0.55);
  color: var(--color-text-primary);
  box-shadow: 0 0 20px hsla(260, 65%, 65%, 0.2), 0 4px 16px hsla(230, 40%, 3%, 0.4);
}
.dur-btn.is-selected::before { opacity: 1; }

.dur-time {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: inherit;
  transition: color 200ms;
}
.dur-btn.is-selected .dur-time {
  background: linear-gradient(135deg, hsl(185, 80%, 70%), hsl(260, 70%, 75%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dur-desc {
  font-family: var(--font-body);
  font-size: 0.65rem;
  color: var(--color-text-dim);
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: color 200ms;
  white-space: nowrap;
}
.dur-btn.is-selected .dur-desc {
  color: var(--color-text-muted);
}

.dur-best {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  color: hsl(45, 80%, 60%);
  min-height: 0.8em;
  transition: opacity 200ms;
  white-space: nowrap;
}
.dur-best:empty { opacity: 0; }

/* Start footer */
.start-footer {
  display: flex;
  justify-content: center;
}

.begin-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 1rem 2.5rem;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(185, 70%, 55%) 0%, hsl(260, 65%, 65%) 100%);
  color: hsl(230, 40%, 8%);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.01em;
  box-shadow: 0 0 40px hsla(185, 70%, 55%, 0.4), 0 4px 20px hsla(230, 40%, 3%, 0.5);
  transition: transform 200ms var(--ease-bounce), box-shadow 200ms ease;
  position: relative;
  overflow: hidden;
}
.begin-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsla(255,100%,100%,0.18) 0%, transparent 60%);
  border-radius: inherit;
}@media (hover: hover) and (pointer: fine) {

.begin-btn:hover {
  transform: scale(1.04) translateY(-1px);
  box-shadow: 0 0 60px hsla(185, 70%, 55%, 0.55), 0 6px 30px hsla(230, 40%, 3%, 0.6);
}
}

.begin-btn:active { transform: scale(0.97); }
.btn-icon { font-size: 1.15em; }


/* ════════════════════════════════════════════════ */
/* PLAY SCREEN                                      */
/* ════════════════════════════════════════════════ */
#screen-play {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* HUD */
.play-header {
  display: flex;
  align-items: center;
  padding: max(env(safe-area-inset-top), 1rem) var(--space-5) var(--space-3);
  gap: var(--space-4);
  z-index: 10;
  position: relative;
}

.hud {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: hsla(230, 30%, 10%, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid hsla(220, 20%, 40%, 0.15);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-5);
}

/* Score column with live best beneath */
.hud-score-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
}

.hud-score, .hud-combo {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}

/* Live personal best row */
.hud-best-row {
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0.7;
  transition: opacity 200ms, transform 200ms;
}
.hud-best-row.beating {
  opacity: 1;
  animation: bestPulse 1.2s ease-in-out infinite;
}
@keyframes bestPulse {
  0%, 100% { opacity: 0.8; }
  50%       { opacity: 1; }
}
.hud-best-label {
  font-family: var(--font-display);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  font-weight: 500;
}
.hud-best-val {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  color: hsl(45, 85%, 65%);
  letter-spacing: -0.01em;
}
.hud-best-row.has-score .hud-best-val {
  color: hsl(45, 85%, 65%);
}
.hud-best-row.beating .hud-best-val {
  color: hsl(120, 70%, 60%);
  text-shadow: 0 0 8px hsla(120, 70%, 60%, 0.5);
}
.hud-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-dim);
  font-weight: 500;
}
.hud-val {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.1;
  transition: transform 150ms var(--ease-bounce), color 300ms;
}
.hud-val.pop-anim {
  transform: scale(1.3);
  color: hsl(185, 80%, 70%);
}

.combo-val {
  transition: transform 150ms var(--ease-bounce), color 300ms;
}
.combo-val.active {
  color: hsl(45, 90%, 65%);
}
.combo-val.hot {
  color: hsl(330, 80%, 68%);
  text-shadow: 0 0 12px hsla(330, 80%, 68%, 0.5);
}

/* Timer ring */
.timer-ring {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
.timer-svg {
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}
.timer-track {
  fill: none;
  stroke: hsla(220, 20%, 25%, 0.5);
  stroke-width: 3;
}
.timer-arc {
  fill: none;
  stroke: hsl(185, 80%, 60%);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 113.1; /* 2π × 18 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 1s ease;
}
.timer-arc.warning { stroke: hsl(45, 90%, 62%); }
.timer-arc.critical { stroke: hsl(0, 80%, 65%); }
.timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Bubble field */
.bubble-field {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Individual bubble */
.bubble {
  position: absolute;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 150ms var(--ease-bounce);
  will-change: transform;
  touch-action: manipulation;
  animation: bubbleFloat var(--float-dur, 4s) ease-in-out infinite alternate;
}

.bubble::before {
  content: '';
  position: absolute;
  top: 12%;
  left: 20%;
  width: 30%;
  height: 22%;
  background: hsla(255, 100%, 100%, 0.55);
  border-radius: 50%;
  filter: blur(2px);
}

.bubble::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid hsla(255, 100%, 100%, 0.25);
}@media (hover: hover) and (pointer: fine) {


.bubble:hover {
  transform: scale(1.08);
}
}

.bubble:active {
  transform: scale(0.9);
}

.bubble.popping {
  animation: bubblePop 350ms var(--ease-out-expo) forwards !important;
  pointer-events: none;
}

@keyframes bubbleFloat {
  from { transform: translateY(0px) rotate(0deg); }
  to   { transform: translateY(-14px) rotate(3deg); }
}

@keyframes bubblePop {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.45); opacity: 0.8; }
  100% { transform: scale(0); opacity: 0; }
}

/* Bubble spawn animation */
.bubble.spawning {
  animation: bubbleSpawn 400ms var(--ease-bounce) forwards,
             bubbleFloat var(--float-dur, 4s) 400ms ease-in-out infinite alternate;
}

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

/* ── Particle Layer ── */
.particle-layer, .score-popup-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFly var(--dur, 600ms) var(--ease-out-expo) forwards;
}

@keyframes particleFly {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

.mini-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--ring-color, hsl(185, 80%, 60%));
  pointer-events: none;
  animation: ringExpand 500ms var(--ease-out-expo) forwards;
}

@keyframes ringExpand {
  0%   { transform: scale(0.3); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Score popup */
.score-popup {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 4vw, 1.4rem);
  color: var(--popup-color, hsl(185, 80%, 70%));
  text-shadow: 0 2px 12px var(--popup-shadow, hsla(185, 80%, 60%, 0.6));
  pointer-events: none;
  animation: scoreFloat 900ms var(--ease-out-expo) forwards;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

@keyframes scoreFloat {
  0%   { transform: translateY(0) scale(0.7); opacity: 0; }
  20%  { transform: translateY(-8px) scale(1); opacity: 1; }
  100% { transform: translateY(-50px) scale(0.9); opacity: 0; }
}

/* ════════════════════════════════════════════════ */
/* END OVERLAY                                      */
/* ════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;  /* allow scrolling on short screens */
  justify-content: center;
  padding: max(env(safe-area-inset-top), var(--space-6)) var(--space-6) max(env(safe-area-inset-bottom), var(--space-6));
  overflow-y: auto;         /* scroll if card is taller than viewport */
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms var(--ease-out-expo);
}
.overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}
.overlay-bg {
  position: absolute;
  inset: 0;
  background: hsla(230, 35%, 5%, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  pointer-events: none;  /* purely decorative — never intercept clicks */
}
.overlay-card {
  position: relative;
  background: hsl(230, 28%, 11%);
  border: 1px solid hsla(220, 20%, 40%, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 80px hsla(230, 40%, 3%, 0.7), 0 0 0 1px hsla(220, 20%, 40%, 0.08);
  animation: cardSlideIn 500ms var(--ease-bounce) both;
  /* No overflow:hidden — it clips the action buttons on short screens */
}
.overlay-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsla(185, 70%, 55%, 0.06) 0%, transparent 50%);
  border-radius: inherit;
  pointer-events: none; /* decorative only — was silently blocking the buttons below it */
}

@keyframes cardSlideIn {
  from { transform: translateY(30px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.overlay-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: var(--space-4);
  animation: emojiPulse 2s ease-in-out infinite;
}
@keyframes emojiPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.overlay-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
  background: linear-gradient(135deg, hsl(185, 80%, 70%), hsl(260, 70%, 75%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.overlay-msg {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.65;
  margin-bottom: var(--space-8);
  font-weight: 300;
}

/* Final score display */
.overlay-score-display {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: hsla(220, 25%, 15%, 0.6);
  border: 1px solid hsla(220, 20%, 30%, 0.2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-8);
  overflow: hidden;
}
.final-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-3);
}
.final-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  font-family: var(--font-display);
  font-weight: 500;
  white-space: nowrap;
}
.final-val {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}
.final-divider {
  width: 1px;
  background: hsla(220, 20%, 30%, 0.3);
  align-self: stretch;
}

/* Action buttons */
.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.btn-primary {
  width: 100%;
  padding: 0.9rem var(--space-6);
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, hsl(185, 70%, 55%) 0%, hsl(260, 65%, 65%) 100%);
  color: hsl(230, 40%, 8%);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 0 30px hsla(185, 70%, 55%, 0.35);
  transition: transform 200ms var(--ease-bounce), box-shadow 200ms ease;
  position: relative;
  overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsla(255,100%,100%,0.15) 0%, transparent 60%);
  border-radius: inherit;
}@media (hover: hover) and (pointer: fine) {

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 50px hsla(185, 70%, 55%, 0.5);
}
}

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

.btn-ghost {
  display: block;
  width: 100%;
  padding: 0.75rem var(--space-6);
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid hsla(220, 20%, 35%, 0.25);
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, transform 200ms ease;
}@media (hover: hover) and (pointer: fine) {

.btn-ghost:hover {
  background: hsla(220, 20%, 20%, 0.5);
  color: var(--color-text-primary);
  transform: translateY(-1px);
}
}

.btn-ghost:active { transform: scale(0.98); }

/* ── Burst flash effect ── */
.burst-flash {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
  animation: burstFlash 400ms var(--ease-out-expo) forwards;
  mix-blend-mode: screen;
}
@keyframes burstFlash {
  0%   { transform: scale(0); opacity: 0.7; }
  100% { transform: scale(3); opacity: 0; }
}

/* ── Record Banner (mid-game) ── */
.record-banner {
  position: fixed;
  bottom: calc(max(env(safe-area-inset-bottom), 24px) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.65rem 1.4rem;
  background: linear-gradient(135deg, hsl(45, 90%, 18%) 0%, hsl(45, 80%, 12%) 100%);
  border: 1px solid hsla(45, 90%, 55%, 0.45);
  border-radius: var(--radius-full);
  box-shadow: 0 0 30px hsla(45, 90%, 55%, 0.3), 0 8px 32px hsla(230, 40%, 3%, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 400ms var(--ease-out-expo), transform 400ms var(--ease-bounce);
  white-space: nowrap;
}
.record-banner.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.record-icon {
  font-size: 1.2rem;
  animation: trophyWiggle 0.6s var(--ease-bounce);
}
@keyframes trophyWiggle {
  0%   { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(-15deg) scale(1.2); }
  75%  { transform: rotate(12deg) scale(1.1); }
  100% { transform: rotate(0deg) scale(1); }
}
.record-text {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: hsl(45, 90%, 75%);
  letter-spacing: -0.01em;
}

/* ── New Record Badge (overlay) ── */
.new-record-badge {
  display: none;  /* hidden by default — shown via JS adding .is-visible */
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: 0 auto var(--space-5);
  padding: 0.5rem 1.2rem;
  background: linear-gradient(135deg, hsl(45, 90%, 22%) 0%, hsl(30, 85%, 18%) 100%);
  border: 1px solid hsla(45, 90%, 55%, 0.5);
  border-radius: var(--radius-full);
  box-shadow: 0 0 24px hsla(45, 90%, 55%, 0.25);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 400ms var(--ease-out-expo) 200ms, transform 400ms var(--ease-bounce) 200ms;
}
.new-record-badge.is-visible {
  display: flex;
  opacity: 1;
  transform: scale(1);
}
.record-badge-icon { font-size: 1.1rem; }
.record-badge-text {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: hsl(45, 90%, 75%);
  letter-spacing: -0.01em;
}

/* ── Prev best line ── */
.prev-best-line {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-dim);
  margin-bottom: var(--space-4);
  text-align: center;
}

/* ── Ponoki's "what to try next" line ── */
.next-suggestion {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--color-accent);
  margin-bottom: var(--space-4);
  text-align: center;
}
.next-suggestion:empty { display: none; }

/* ── Confetti ── */
.confetti-piece {
  position: absolute;
  pointer-events: none;
  animation: confettiFly var(--dur, 800ms) var(--ease-out-expo) forwards;
  transform-origin: center;
}
@keyframes confettiFly {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.4); opacity: 0; }
}
