/* ============================================================
   Diabolo — Premium UI System
   Design: Midnight Zen with Golden Amber Accent
   ============================================================ */

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

:root {
  /* Palette — Deep midnight with celestial amber */
  --bg-abyss: #05050f;
  --bg-deep: #0a0a1a;
  --bg-mid: #0f0f22;
  --bg-surface: #14142b;
  --bg-elevated: #1a1a35;
  --bg-glass: rgba(15, 15, 34, 0.72);
  --bg-glass-strong: rgba(22, 22, 48, 0.92);
  --bg-glass-light: rgba(26, 26, 53, 0.6);

  --border-subtle: rgba(180, 150, 100, 0.08);
  --border: rgba(212, 175, 115, 0.14);
  --border-strong: rgba(212, 175, 115, 0.28);
  --border-glow: rgba(212, 175, 115, 0.4);

  --text: #f5efe2;
  --text-muted: #a39a8a;
  --text-dim: #635c50;
  --text-faint: #3d3830;

  --brand: #d4af73;
  --brand-light: #ecd7b0;
  --brand-warm: #c49848;
  --brand-deep: #8b6914;
  --brand-glow: rgba(212, 175, 115, 0.4);
  --brand-glow-soft: rgba(212, 175, 115, 0.15);

  --accent: #7b9bd9;
  --accent-light: #a8c0e8;
  --accent-glow: rgba(123, 155, 217, 0.3);

  --success: #7bc97b;
  --warning: #e0b060;
  --danger: #d47070;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-2xl: 36px;
  --radius-full: 999px;

  /* Typography */
  --font-display: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 80px rgba(0, 0, 0, 0.65);
  --shadow-glow-sm: 0 0 20px rgba(212, 175, 115, 0.15);
  --shadow-glow: 0 0 40px rgba(212, 175, 115, 0.25);
  --shadow-glow-lg: 0 0 80px rgba(212, 175, 115, 0.35);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --topbar-height: 64px;
  --trick-panel-height: 180px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-abyss);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
  position: relative;
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(123, 155, 217, 0.08), transparent 60%),
    radial-gradient(ellipse 70% 60% at 50% 120%, rgba(212, 175, 115, 0.06), transparent 60%),
    var(--bg-abyss);
}

/* ============================================================
   Ambient Background Decorations
   ============================================================ */

.ambient-orbs {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(212, 175, 115, 0.12), transparent 70%);
  top: -100px;
  right: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(123, 155, 217, 0.1), transparent 70%);
  bottom: 20%;
  left: -80px;
  animation-delay: -7s;
}

.orb-3 {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(212, 175, 115, 0.08), transparent 70%);
  top: 30%;
  left: 40%;
  animation-delay: -14s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.05); }
  50% { transform: translate(-20px, 30px) scale(0.95); }
  75% { transform: translate(20px, 20px) scale(1.02); }
}

/* ============================================================
   Top Bar
   ============================================================ */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: var(--topbar-height);
  gap: 16px;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(10, 10, 26, 0.9), rgba(10, 10, 26, 0.6));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.top-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 28px;
  right: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-display);
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-light), var(--brand-warm));
  box-shadow: 0 0 12px var(--brand-glow), 0 0 24px var(--brand-glow-soft);
  position: relative;
  animation: brandPulse 3s ease-in-out infinite;
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  opacity: 0.4;
}

@keyframes brandPulse {
  0%, 100% { box-shadow: 0 0 12px var(--brand-glow), 0 0 24px var(--brand-glow-soft); }
  50% { box-shadow: 0 0 16px var(--brand-glow), 0 0 32px var(--brand-glow-soft); }
}

.hud-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0;
}

.rpm-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 120px;
  position: relative;
  padding: 0 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.hud-center .rpm-gauge + .score-pill {
  border-left: none;
}

.rpm-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-dim);
  font-weight: 600;
  line-height: 1;
  order: 2;
}

.rpm-value {
  font-size: 30px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -1px;
  background: linear-gradient(180deg, var(--brand-light) 0%, var(--brand) 50%, var(--brand-warm) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  order: 1;
}

.rpm-bar-container {
  width: 100%;
  height: 3px;
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  margin-top: 5px;
  overflow: hidden;
  order: 3;
}

.rpm-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand-light));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--brand-glow);
}

.score-pill {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1px;
  padding: 0 20px 0 24px;
  background: transparent;
  border: none;
  border-radius: 0;
}

.score-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: var(--text-dim);
  font-weight: 600;
  line-height: 1;
}

.score-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  min-width: 68px;
  backdrop-filter: blur(8px);
  transition: all 0.2s var(--ease-out);
}

.stat-mini:hover {
  border-color: var(--border);
  background: var(--bg-glass-strong);
}

.stat-mini-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.stat-mini-value {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  color: var(--brand-light);
  border-color: var(--border-strong);
  background: var(--bg-glass-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-sm);
}

.icon-btn:active { transform: translateY(0); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.5; }

/* ============================================================
   Game Area
   ============================================================ */

.game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#canvas:active { cursor: grabbing; }

/* Vignette overlay */
.game-area::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 50% 50%, transparent 40%, rgba(5, 5, 15, 0.4) 100%),
    linear-gradient(180deg, rgba(5, 5, 15, 0.3) 0%, transparent 15%, transparent 85%, rgba(5, 5, 15, 0.4) 100%);
  z-index: 5;
}

/* ============================================================
   Start Overlay
   ============================================================ */

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 20;
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
  background:
    radial-gradient(ellipse at 50% 30%, rgba(212, 175, 115, 0.06), transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(123, 155, 217, 0.04), transparent 50%),
    rgba(5, 5, 15, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.start-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.03);
}

.start-content {
  text-align: center;
  position: relative;
}

/* Decorative rings */
.start-rings {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 500px;
  height: 500px;
  pointer-events: none;
  opacity: 0.6;
}

.start-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--border);
  animation: ringRotate 30s linear infinite;
}

.start-ring:nth-child(1) {
  inset: 0;
  animation-duration: 40s;
}

.start-ring:nth-child(2) {
  inset: 40px;
  border-color: var(--border-subtle);
  animation-duration: 25s;
  animation-direction: reverse;
}

.start-ring:nth-child(3) {
  inset: 80px;
  animation-duration: 60s;
}

@keyframes ringRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Diabolo illustration */
.start-diabolo {
  width: 80px;
  height: 100px;
  margin: 0 auto 32px;
  position: relative;
  opacity: 0;
  animation: fadeInScale 0.8s var(--ease-out) 0.1s forwards;
}

.start-diabolo-cup {
  position: absolute;
  left: 50%;
  width: 64px;
  height: 44px;
  transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(180deg, #e8cfa0, #8b6538);
  box-shadow:
    inset 0 2px 4px rgba(255, 240, 210, 0.4),
    0 4px 16px rgba(212, 175, 115, 0.3),
    0 0 40px rgba(212, 175, 115, 0.15);
  animation: diaboloFloat 4s ease-in-out infinite;
}

.start-diabolo-cup.top {
  top: 0;
}

.start-diabolo-cup.bottom {
  bottom: 0;
  background: linear-gradient(180deg, #6a4a2a, #3a2810);
  animation-delay: -2s;
}

.start-diabolo-axle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f0dca8, #7a5820);
  box-shadow: 0 0 12px rgba(212, 175, 115, 0.5);
}

@keyframes diaboloFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

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

.start-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 5px;
  color: var(--brand);
  margin-bottom: 16px;
  font-weight: 500;
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.2s forwards;
}

.start-title {
  font-size: 84px;
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 0.95;
  font-family: var(--font-display);
  background: linear-gradient(180deg, #ffffff 0%, var(--brand-light) 50%, var(--brand-warm) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.3s forwards;
  filter: drop-shadow(0 4px 24px rgba(212, 175, 115, 0.2));
}

.start-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 44px;
  letter-spacing: 0.02em;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.4s forwards;
  line-height: 1.6;
}

.start-cta {
  position: relative;
  padding: 18px 52px;
  font-size: 15px;
  font-weight: 600;
  color: #1a1510;
  background: linear-gradient(180deg, #f0d8a8, #c49550);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  letter-spacing: 0.05em;
  font-family: var(--font-display);
  box-shadow:
    0 4px 24px rgba(212, 175, 115, 0.4),
    0 0 0 1px rgba(212, 175, 115, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.25s var(--ease-out);
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.5s forwards;
}

.start-cta::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-light), var(--brand-warm));
  z-index: -1;
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.3s;
}

.start-cta:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 8px 36px rgba(212, 175, 115, 0.5),
    0 0 0 1px rgba(212, 175, 115, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.start-cta:hover::before {
  opacity: 0.5;
}

.start-cta:active {
  transform: translateY(0) scale(0.98);
}

.start-instructions {
  display: flex;
  gap: 36px;
  margin-top: 52px;
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.65s forwards;
}

.instruction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  max-width: 100px;
  line-height: 1.5;
  transition: transform 0.2s var(--ease-out);
}

.instruction:hover {
  transform: translateY(-2px);
}

.instruction-icon {
  width: 52px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-light);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.instruction-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212, 175, 115, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.instruction:hover .instruction-icon {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow-sm);
}

.instruction:hover .instruction-icon::before {
  opacity: 1;
}

.instruction-icon svg { width: 22px; height: 22px; stroke-width: 1.5; position: relative; z-index: 1; }

.start-kbd {
  margin-top: 36px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) 0.8s forwards;
}

.start-kbd kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-glass);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Trick Panel
   ============================================================ */

.trick-panel {
  border-top: 1px solid var(--border-subtle);
  background:
    linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.3)),
    var(--bg-mid);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.trick-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  pointer-events: none;
}

.trick-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(180deg, var(--bg-mid), rgba(15, 15, 34, 0.9));
  z-index: 2;
  backdrop-filter: blur(8px);
  gap: 12px;
}

.trick-panel-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.trick-panel-toggle:hover {
  color: var(--brand-light);
  border-color: var(--border);
  background: rgba(212, 175, 115, 0.08);
}

.trick-panel-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.35s var(--ease-out);
}

.trick-panel.collapsed .trick-panel-toggle svg {
  transform: rotate(180deg);
}

.trick-panel-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.35s var(--ease-out);
  position: relative;
}

.trick-panel.collapsed .trick-panel-body {
  grid-template-rows: 0fr;
}

.trick-panel-body > .trick-list {
  min-height: 0;
  cursor: grab;
  transition: padding 0.35s var(--ease-out);
}

.trick-panel.collapsed .trick-panel-body > .trick-list {
  padding-top: 0;
  padding-bottom: 0;
}

.trick-panel-body::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 36px;
  background: linear-gradient(to right, transparent, var(--bg-mid));
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.3s;
}

.trick-panel-body.at-end::after {
  opacity: 0;
}

.trick-panel-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.trick-panel-title::before {
  content: '';
  width: 14px;
  height: 1px;
  background: var(--text-dim);
  opacity: 0.5;
}

.trick-panel-title::after {
  content: '';
  width: 14px;
  height: 1px;
  background: var(--text-dim);
  opacity: 0.5;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  padding: 4px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
}

.progress-pill strong {
  color: var(--brand-light);
  font-weight: 600;
}

.trick-list {
  display: flex;
  gap: 12px;
  padding: 6px 28px 20px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.trick-list::-webkit-scrollbar {
  height: 4px;
}

.trick-list::-webkit-scrollbar-track {
  background: transparent;
}

.trick-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

.trick-card {
  flex-shrink: 0;
  width: 140px;
  padding: 16px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  transition: all 0.3s var(--ease-out);
  scroll-snap-align: start;
  position: relative;
  overflow: hidden;
}

.trick-status {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 16px;
  height: 16px;
  z-index: 2;
  transition: all 0.3s var(--ease-out);
}

.trick-status svg {
  width: 100%;
  height: 100%;
}

.trick-status.locked {
  color: var(--text-dim);
  opacity: 0.8;
}

.trick-status.done {
  color: var(--brand);
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--brand-glow-soft));
}

.trick-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.trick-card:not(.completed) .trick-icon {
  opacity: 0.35;
}

.trick-card:not(.completed) .trick-name {
  color: var(--text-muted);
}

.trick-card:not(.completed) .trick-desc {
  color: var(--text-faint);
}

.trick-card.completed {
  border-color: var(--border-strong);
  background:
    linear-gradient(180deg, rgba(212, 175, 115, 0.08), transparent 50%),
    var(--bg-elevated);
  box-shadow:
    0 0 0 1px rgba(212, 175, 115, 0.1),
    0 4px 20px rgba(0, 0, 0, 0.35),
    0 0 30px rgba(212, 175, 115, 0.08);
  transform: translateY(-2px);
}

.trick-card.completed::before {
  opacity: 1;
}

.trick-card.completed .trick-icon {
  color: var(--brand);
  background: rgba(212, 175, 115, 0.12);
  border-color: rgba(212, 175, 115, 0.25);
  box-shadow: inset 0 1px 0 rgba(212, 175, 115, 0.1);
  opacity: 1;
}

.trick-card.unlocking {
  animation: trickUnlock 0.6s var(--ease-bounce);
}

@keyframes trickUnlock {
  0% { transform: scale(1) translateY(0); }
  30% { transform: scale(1.08) translateY(-4px); box-shadow: var(--shadow-glow); }
  100% { transform: scale(1) translateY(-2px); }
}

.trick-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-surface);
  transition: all 0.3s var(--ease-out);
}

.trick-icon svg { width: 18px; height: 18px; stroke-width: 1.8; }

.trick-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

.trick-desc {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.45;
}

.trick-points {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  font-family: var(--font-display);
  transition: all 0.3s var(--ease-out);
}

.trick-points svg {
  width: 11px;
  height: 11px;
}

.trick-card.completed .trick-points {
  color: var(--brand);
}

/* Progress bar in header */
.trick-panel-progress {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.trick-panel-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-warm), var(--brand-light));
  border-radius: 2px;
  transition: width 0.6s var(--ease-out);
  box-shadow: 0 0 8px rgba(212, 175, 115, 0.4);
}

/* ============================================================
   Side Panel (Share)
   ============================================================ */

.side-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  background:
    linear-gradient(180deg, var(--bg-surface), var(--bg-mid));
  border-left: 1px solid var(--border-subtle);
  z-index: 30;
  transition: right 0.5s var(--ease-out);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 60px rgba(0, 0, 0, 0.6);
}

.side-panel.active { right: 0; }

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.side-panel-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 28px;
  right: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.side-panel-title {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.close-btn:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-elevated);
}

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.side-panel-body::-webkit-scrollbar {
  width: 4px;
}

.side-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.side-panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

/* Share Card */
.share-card-preview {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 115, 0.1), transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(123, 155, 217, 0.06), transparent 50%),
    linear-gradient(180deg, #1a1a38, #0c0c1e);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  text-align: center;
  margin-bottom: 24px;
  overflow: hidden;
}

.share-card-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.5;
}

/* Decorative orbs */
.share-card-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.share-card-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
}

.share-card-orb.orb-1 {
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: rgba(212, 175, 115, 0.12);
}

.share-card-orb.orb-2 {
  bottom: -40px;
  left: -40px;
  width: 140px;
  height: 140px;
  background: rgba(123, 155, 217, 0.08);
}

.share-card-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.share-card-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text);
  font-family: var(--font-display);
}

.share-card-mark {
  width: 8px;
  height: 8px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-warm));
  border-radius: 50%;
  box-shadow: 0 0 8px var(--brand-glow);
}

.share-card-grade {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-display);
  background: linear-gradient(180deg, #a39a8a, #635c50);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.share-card-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
}

.share-card-score {
  position: relative;
  font-size: 64px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -2px;
  background: linear-gradient(180deg, var(--text), var(--brand-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(212, 175, 115, 0.2));
}

.share-card-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.share-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.share-stat-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  line-height: 1;
}

.share-stat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.share-card-tricks {
  margin-top: 18px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
}

.share-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 10px;
  color: var(--text-faint);
}

.share-card-url {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 9px;
}

/* Share Buttons */
.share-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.share-btn {
  flex: 1;
  min-width: 92px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.share-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
  color: var(--text);
  transform: translateY(-1px);
}

.share-btn svg { width: 16px; height: 16px; }

.copy-link-row {
  display: flex;
  gap: 8px;
}

.copy-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}

.copy-input:focus { border-color: var(--border-strong); }

.copy-btn {
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--brand-light), var(--brand-warm));
  border: none;
  border-radius: var(--radius-sm);
  color: #1a1510;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  transition: all 0.2s;
}

.copy-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-sm);
}

/* Conversion Section */
.conversion-section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--border-subtle);
}

.conversion-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}

.conversion-title::before {
  content: '';
  width: 12px;
  height: 1px;
  background: var(--text-dim);
  opacity: 0.5;
}

.newsletter-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.newsletter-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
}

.newsletter-input:focus { border-color: var(--border-strong); }
.newsletter-input::placeholder { color: var(--text-dim); }

.newsletter-btn {
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #0e1525;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-display);
  white-space: nowrap;
  transition: all 0.2s;
}

.newsletter-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.premium-teaser {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin-bottom: 12px;
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.premium-teaser::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(212, 175, 115, 0.05), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.premium-teaser:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.premium-teaser:hover::before {
  opacity: 1;
}

.premium-info { flex: 1; position: relative; z-index: 1; }

.premium-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-display);
}

.premium-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

.premium-lock {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(212, 175, 115, 0.12);
  color: var(--brand-light);
  position: relative;
  z-index: 1;
}

.premium-lock svg { width: 14px; height: 14px; }

.social-follow {
  display: flex;
  gap: 10px;
}

.follow-btn {
  flex: 1;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  text-decoration: none;
}

.follow-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.follow-btn svg { width: 16px; height: 16px; }

/* ============================================================
   Game Over Overlay
   ============================================================ */

.gameover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 24px 16px;
  background: rgba(5, 5, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease-out);
}

.gameover-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.gameover-card {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 115, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-mid));
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 44px 40px;
  width: 90%;
  max-width: 440px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: all 0.6s var(--ease-out);
  margin: auto;
  flex-shrink: 0;
}

.gameover-overlay.active .gameover-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.gameover-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.6;
}

.new-best-badge {
  display: none;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-warm));
  color: #1a1510;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 20px;
  font-family: var(--font-display);
  box-shadow: 0 4px 16px var(--brand-glow);
  animation: badgePulse 2s ease-in-out infinite;
}

.new-best-badge.show {
  display: inline-block;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 4px 16px var(--brand-glow); }
  50% { box-shadow: 0 4px 24px var(--brand-glow), 0 0 40px var(--brand-glow-soft); }
}

.gameover-title {
  font-size: 28px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  color: var(--text);
}

.gameover-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.score-display {
  font-size: 72px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -2.5px;
  background: linear-gradient(180deg, #ffffff 0%, var(--brand-light) 60%, var(--brand-warm) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 24px rgba(212, 175, 115, 0.25));
}

.score-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--text-dim);
  font-weight: 500;
}

/* Decorative rings */
.gameover-rings {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  height: 180px;
  pointer-events: none;
  opacity: 0.5;
}

.gameover-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1px solid var(--border);
  transform: translate(-50%, -50%);
}

.gameover-ring.ring-1 {
  width: 100%;
  height: 100%;
  animation: ringSlowSpin 25s linear infinite;
  border-style: dashed;
  border-color: rgba(212, 175, 115, 0.15);
}

.gameover-ring.ring-2 {
  width: 70%;
  height: 70%;
  animation: ringSlowSpin 18s linear infinite reverse;
  border-color: rgba(212, 175, 115, 0.2);
}

.gameover-ring.ring-3 {
  width: 45%;
  height: 45%;
  animation: ringSlowSpin 12s linear infinite;
  border-style: dotted;
  border-color: rgba(212, 175, 115, 0.25);
}

@keyframes ringSlowSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Diabolo icon */
.gameover-diabolo {
  width: 44px;
  height: 56px;
  margin: 0 auto 18px;
  position: relative;
  filter: drop-shadow(0 4px 12px rgba(212, 175, 115, 0.2));
}

.gameover-diabolo-cup {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 24px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #e8cfa0, #a88750);
  border-radius: 50% 50% 50% 50% / 100% 100% 0% 0%;
}

.gameover-diabolo-cup.top {
  top: 0;
  background: linear-gradient(180deg, #f0dba8, #b89050, #8b6538);
}

.gameover-diabolo-cup.bottom {
  bottom: 0;
  background: linear-gradient(180deg, #8b6538, #5a3e1e, #3a2810);
  border-radius: 50% 50% 50% 50% / 0% 0% 100% 100%;
}

.gameover-diabolo-axle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: radial-gradient(circle at 30% 30%, #e8cfa0, #8b6914);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(212, 175, 115, 0.4);
}

/* Score display with glow */
.score-display-wrap {
  position: relative;
  margin-bottom: 6px;
}

.score-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 100px;
  background: radial-gradient(ellipse at center, rgba(212, 175, 115, 0.15), transparent 70%);
  pointer-events: none;
  animation: scoreGlow 3s ease-in-out infinite;
}

@keyframes scoreGlow {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.gameover-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.stat-box {
  padding: 12px 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.stat-box:hover {
  border-color: var(--border);
  background: var(--bg-surface);
  transform: translateY(-1px);
}

.stat-icon {
  width: 18px;
  height: 18px;
  margin: 0 auto 6px;
  color: var(--brand);
  opacity: 0.8;
}

.stat-icon svg {
  width: 100%;
  height: 100%;
}

.stat-box-val {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  color: var(--text);
  line-height: 1.2;
}

.stat-box-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Divider */
.gameover-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-faint);
}

.gameover-divider::before,
.gameover-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
}

.gameover-divider span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 500;
  color: var(--text-dim);
}

/* Grade */
.gameover-grade {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  margin-bottom: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 115, 0.06), transparent 60%),
    var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.grade-letter {
  font-size: 36px;
  font-weight: 700;
  font-family: var(--font-display);
  background: linear-gradient(180deg, var(--brand-light), var(--brand-warm));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.grade-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  line-height: 1.3;
}

.gameover-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  flex: 1;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--brand-light), var(--brand-warm));
  border: none;
  border-radius: var(--radius);
  color: #1a1510;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow:
    0 4px 20px rgba(212, 175, 115, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.25s var(--ease-out);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 28px rgba(212, 175, 115, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-secondary {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s var(--ease-out);
}

.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.btn-secondary svg {
  width: 15px;
  height: 15px;
}

/* Staggered entrance animations */
.gameover-overlay.active .gameover-diabolo {
  animation: fadeInUp 0.6s var(--ease-out) 0.1s both;
}

.gameover-overlay.active .new-best-badge {
  animation: fadeInUp 0.6s var(--ease-out) 0.2s both, badgePulse 2s ease-in-out infinite 0.8s;
}

.gameover-overlay.active .gameover-title {
  animation: fadeInUp 0.6s var(--ease-out) 0.25s both;
}

.gameover-overlay.active .gameover-sub {
  animation: fadeInUp 0.6s var(--ease-out) 0.35s both;
}

.gameover-overlay.active .score-display-wrap {
  animation: fadeInUp 0.7s var(--ease-out) 0.4s both;
}

.gameover-overlay.active .score-label {
  animation: fadeInUp 0.6s var(--ease-out) 0.5s both;
}

.gameover-overlay.active .gameover-stats {
  animation: fadeInUp 0.6s var(--ease-out) 0.55s both;
}

.gameover-overlay.active .gameover-divider {
  animation: fadeIn 0.6s var(--ease-out) 0.65s both;
}

.gameover-overlay.active .gameover-grade {
  animation: fadeInUp 0.6s var(--ease-out) 0.7s both;
}

.gameover-overlay.active .gameover-actions {
  animation: fadeInUp 0.6s var(--ease-out) 0.8s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================
   Backdrop
   ============================================================ */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 29;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--text);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s var(--ease-out);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Responsive Design
   ============================================================ */

@media (max-width: 768px) {
  :root {
    --topbar-height: 56px;
    --trick-panel-height: 160px;
  }

  .top-bar {
    padding: 0 16px;
  }

  .top-bar::after {
    left: 16px;
    right: 16px;
  }

  .brand-logo {
    font-size: 13px;
    letter-spacing: 0.08em;
  }

  .brand-mark {
    width: 8px;
    height: 8px;
  }

  .hud-center {
    gap: 20px;
  }

  .rpm-gauge {
    min-width: 120px;
  }

  .rpm-value {
    font-size: 26px;
  }

  .score-pill {
    padding: 6px 14px;
  }

  .score-value {
    font-size: 16px;
  }

  .hud-right {
    gap: 6px;
  }

  .stat-mini {
    padding: 5px 10px;
    min-width: 56px;
  }

  .stat-mini-value {
    font-size: 12px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .start-title {
    font-size: 60px;
  }

  .start-subtitle {
    font-size: 14px;
    max-width: 320px;
    margin-bottom: 36px;
  }

  .start-instructions {
    gap: 20px;
    margin-top: 40px;
  }

  .instruction {
    max-width: 80px;
    font-size: 11px;
  }

  .instruction-icon {
    width: 44px;
    height: 44px;
  }

  .instruction-icon svg {
    width: 18px;
    height: 18px;
  }

  .start-rings {
    width: 360px;
    height: 360px;
  }

  .trick-panel-header {
    padding: 10px 16px;
  }

  .trick-list {
    padding: 4px 16px 16px;
    gap: 10px;
  }

  .trick-card {
    width: 120px;
    padding: 12px 10px;
  }

  .trick-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
  }

  .trick-icon svg {
    width: 16px;
    height: 16px;
  }

  .side-panel {
    width: 100%;
    right: -100%;
  }

  .gameover-card {
    padding: 32px 24px;
    max-width: 360px;
  }

  .score-display {
    font-size: 56px;
  }

  .gameover-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .hud-center {
    position: static;
    transform: none;
    flex: 1;
    justify-content: center;
  }

  .brand-logo span {
    display: none;
  }

  .start-title {
    font-size: 48px;
  }

  .start-cta {
    padding: 16px 40px;
    font-size: 14px;
  }

  .start-instructions {
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
  }

  .instruction {
    flex-direction: row;
    max-width: none;
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    gap: 10px;
  }

  .instruction-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .gameover-rings {
    width: 140px;
    height: 140px;
    top: 56px;
  }

  .gameover-diabolo {
    width: 36px;
    height: 46px;
    margin-bottom: 14px;
  }

  .gameover-diabolo-cup {
    width: 32px;
    height: 20px;
  }

  .gameover-title {
    font-size: 22px;
  }

  .gameover-sub {
    font-size: 12px;
    margin-bottom: 20px;
  }

  .score-glow {
    width: 150px;
    height: 70px;
  }

  .grade-letter {
    font-size: 28px;
  }

  .grade-label {
    font-size: 12px;
  }

  .gameover-grade {
    padding: 12px 16px;
    gap: 10px;
  }

  .btn-primary,
  .btn-secondary {
    padding: 13px 16px;
    font-size: 13px;
  }
}

/* Touch / mobile optimizations */
@media (hover: none) and (pointer: coarse) {
  .icon-btn,
  .btn-primary,
  .btn-secondary,
  .start-cta {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }

  .icon-btn:active,
  .btn-primary:active,
  .btn-secondary:active,
  .start-cta:active {
    transform: scale(0.97);
  }

  .game-canvas {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Prevent selection on game UI */
.game-canvas,
.top-bar,
.trick-panel,
.start-overlay,
.gameover-overlay {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   Zen Mode Button
   ============================================================ */

.start-zen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  margin-top: 12px;
  transition: all 0.3s var(--ease-out);
}

.start-zen-btn svg {
  width: 16px;
  height: 16px;
}

.start-zen-btn:hover {
  border-color: var(--border-strong);
  color: var(--brand-light);
  background: var(--brand-glow-soft);
}

/* ============================================================
   REC Indicator
   ============================================================ */

.rec-indicator {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(20, 18, 38, 0.9);
  border: 1px solid rgba(255, 80, 80, 0.3);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #ff5050;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.rec-indicator.active {
  opacity: 1;
}

.rec-dot {
  width: 7px;
  height: 7px;
  background: #ff3030;
  border-radius: 50%;
  animation: recPulse 1s ease-in-out infinite;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.rec-time {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

/* Record button recording state */
.icon-btn.recording {
  color: #ff3030;
  border-color: rgba(255, 48, 48, 0.4);
  background: rgba(255, 48, 48, 0.08);
}

.icon-btn.recording svg circle:last-child {
  animation: recBtnPulse 1s ease-in-out infinite;
}

@keyframes recBtnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   Replay Overlay
   ============================================================ */

.replay-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out);
}

.replay-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.replay-card {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 115, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-mid));
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 36px 32px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.5s var(--ease-out);
}

.replay-overlay.active .replay-card {
  transform: scale(1);
  opacity: 1;
}

.replay-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(212, 175, 115, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.replay-icon svg {
  width: 24px;
  height: 24px;
}

.replay-title {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 6px;
}

.replay-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.replay-preview {
  width: 100%;
  max-height: 280px;
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 20px;
  border: 1px solid var(--border-subtle);
}

.replay-actions {
  display: flex;
  gap: 10px;
}

/* ============================================================
   About Overlay
   ============================================================ */

.about-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 15, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 28;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease-out);
  overflow-y: auto;
  padding: 40px 20px;
}

.about-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.about-card {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 115, 0.06), transparent 50%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-mid));
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 48px 44px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.6s var(--ease-out);
}

.about-overlay.active .about-card {
  transform: translateY(0);
  opacity: 1;
}

.about-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.5;
}

.about-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.about-close:hover {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
}

.about-eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 12px;
}

.about-title {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}

.about-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
}

.about-body p {
  margin-bottom: 14px;
}

.about-body strong {
  color: var(--text);
}

.about-body em {
  color: var(--brand-light);
  font-style: italic;
}

.about-quote {
  margin-top: 28px;
  padding: 20px 24px;
  background: var(--bg-elevated);
  border-left: 2px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
  font-style: italic;
  color: var(--text);
  line-height: 1.6;
}

.about-quote-attr {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  font-style: normal;
  color: var(--text-dim);
}

.about-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
}

/* ============================================================
   Daily Challenge
   ============================================================ */

.daily-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
}

.daily-preview-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 600;
}

.daily-preview-text {
  font-weight: 500;
  color: var(--text);
}

.daily-preview-streak {
  font-size: 11px;
  padding: 2px 8px;
  background: rgba(212, 175, 115, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--brand);
  font-weight: 600;
}

.daily-preview-streak.done {
  color: #6ec07a;
  background: rgba(110, 192, 122, 0.08);
  border-color: rgba(110, 192, 122, 0.2);
}

/* Daily challenge in game over */
.daily-challenge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.daily-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daily-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.daily-status {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.daily-status.done {
  color: #6ec07a;
  font-weight: 600;
}

.daily-emoji {
  font-size: 24px;
  line-height: 1;
}

/* ============================================================
   Leaderboard
   ============================================================ */

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.leaderboard::-webkit-scrollbar {
  width: 4px;
}

.leaderboard::-webkit-scrollbar-track {
  background: transparent;
}

.leaderboard::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  font-size: 12px;
  transition: all 0.2s;
}

.lb-item.you {
  border-color: var(--border-strong);
  background: rgba(212, 175, 115, 0.06);
}

.lb-rank {
  width: 24px;
  text-align: center;
  font-weight: 700;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}

.lb-item.you .lb-rank {
  color: var(--brand);
}

.lb-name {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  color: var(--brand-light);
  font-weight: 600;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}

.lb-empty {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-dim);
}

.your-rank {
  text-align: center;
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  background: rgba(212, 175, 115, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin-top: 8px;
}

/* ============================================================
   Name Submit (Game Over)
   ============================================================ */

.name-submit {
  margin-top: 4px;
}

.name-submit-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.name-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input::placeholder {
  color: var(--text-dim);
}

.name-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(212, 175, 115, 0.12);
}

.name-submit-btn {
  flex: 0 0 auto;
  padding: 0 20px;
  height: 46px;
}

.name-submit-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.name-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  transition: color 0.2s;
}

.name-hint.error {
  color: #e5756b;
}

/* ============================================================
   Leaderboard Overlay (Top Bar Trophy)
   ============================================================ */

.lb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 15, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 28;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease-out);
  overflow-y: auto;
  padding: 40px 20px;
}

.lb-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.lb-card {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(212, 175, 115, 0.06), transparent 50%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-mid));
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.6s var(--ease-out);
}

.lb-overlay.active .lb-card {
  transform: translateY(0);
  opacity: 1;
}

.lb-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.5;
}

.lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.lb-close:hover {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
}

.lb-trophy {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(212, 175, 115, 0.08);
  border: 1px solid var(--border);
  color: var(--brand);
}

.lb-trophy svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.5;
}

.lb-modal-title {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text);
  text-align: center;
  letter-spacing: 0.02em;
}

.lb-modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin: 6px 0 20px;
}

.lb-modal-list {
  max-height: 340px;
}

.lb-modal-footer {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* ============================================================
   Utility
   ============================================================ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Smooth scrollbar for trick panel */
.trick-panel::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.trick-panel::-webkit-scrollbar-track {
  background: transparent;
}

.trick-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
