:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #16161e;
  --bg-card: #1c1c28;
  --accent: #00e0c6;
  --accent2: #7b61ff;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --danger: #ff4757;
  --gold: #ffd700;
  --blue: #3498db;
  --purple: #9b59b6;
  --orange: #e67e22;
  --fever: #ff9800;
  --ghost: #00d4ff;
  --canvas-bg: #050508;
}

body.theme-light {
  --bg-dark: #f0f2f5;
  --bg-panel: #fff;
  --bg-card: #f1f3f6;
  --accent: #00b894;
  --accent2: #6c5ce7;
  --text: #1a1a1d;
  --text-dim: #777;
  --canvas-bg: #f8f9fa;
}

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

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .3s ease, color .3s ease
}

.menu-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.95);
  background: var(--bg-panel);
  padding: 2rem 2.5rem;
  border-radius: 16px;
  text-align: center;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .7);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, transform .35s cubic-bezier(.18, .89, .32, 1.28), background .3s ease;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  border: 1px solid rgba(255, 255, 255, .06);
  max-height: 90vh;
  overflow-y: auto;
  z-index: 5
}

.menu-screen.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1)
}

.logo h1 {
  font-size: 2.6rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow: 0 0 24px rgba(0, 224, 198, .5)
}

.version {
  color: var(--accent2);
  font-size: .85rem;
  letter-spacing: 2px;
  margin-top: -4px
}

h2 {
  font-size: 1.5rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px
}

.confirm-text {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-bottom: 4px
}

.coins-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 152, 0, 0.15));
  border: 1px solid rgba(255, 215, 0, 0.4);
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
  margin: 0 auto;
}

.coin-icon {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}

.hud-coins {
  color: var(--gold) !important;
}

.hud-coins b {
  color: var(--gold) !important;
}

.coins-earned {
  color: var(--gold) !important;
  font-size: 1.1rem;
}

.stats-bar {
  display: flex;
  justify-content: space-around;
  background: var(--bg-card);
  border-radius: 10px;
  padding: 12px 8px;
  gap: 8px
}

.stats-bar>div {
  display: flex;
  flex-direction: column;
  gap: 2px
}

.stat-label {
  font-size: .72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px
}

.stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent)
}

.leaderboard-panel {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 12px;
  text-align: left
}

.leaderboard-panel h3 {
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px
}

.leaderboard {
  list-style: none;
  padding: 0;
  margin: 0
}

.leaderboard li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .06)
}

.leaderboard li:last-child {
  border-bottom: none
}

.leaderboard .rank {
  font-weight: 700;
  color: var(--text-dim);
  min-width: 24px
}

.leaderboard .score-val {
  color: var(--gold);
  font-weight: 700
}

.about-content {
  text-align: left;
  margin-bottom: 8px
}

.about-content p {
  margin: 6px 0;
  color: var(--text-dim)
}

.about-content p:first-child {
  color: var(--accent);
  font-size: 1.1rem
}

.about-text {
  font-size: .92rem;
  line-height: 1.5
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: transform .12s, box-shadow .2s, background .2s
}

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

.btn:active {
  transform: scale(.96)
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00b894);
  color: #000;
  box-shadow: 0 4px 16px rgba(0, 224, 198, .35)
}

body.mobile-controls-compact .direction-btn {
  width: 48px;
  height: 40px;
  border-radius: 11px;
  font-size: 1rem;
}

body.mobile-controls-large .direction-btn {
  width: 70px;
  height: 58px;
  border-radius: 16px;
  font-size: 1.35rem;
}

body.mobile-controls-large .direction-row {
  gap: 9px;
}

body.mobile-controls-left .mobile-controls {
  align-items: flex-start;
  margin-left: 0;
  margin-right: auto;
}

body.mobile-controls-left .mobile-hint {
  text-align: left;
}

body.mobile-control-swipe .mobile-controls {
  display: none !important;
}

body.high-contrast .menu-screen,
body.high-contrast .hud,
body.high-contrast canvas {
  border-width: 2px;
  border-color: currentColor;
}

body.high-contrast .btn-secondary,
body.high-contrast .btn-small,
body.high-contrast select {
  border-width: 2px;
}

body.high-contrast:not(.theme-light) .menu-screen,
body.high-contrast:not(.theme-light) .hud,
body.high-contrast:not(.theme-light) .overlay {
  color: #ffffff;
}

body.high-contrast:not(.theme-light) .stat-label,
body.high-contrast:not(.theme-light) .hud-item,
body.high-contrast:not(.theme-light) .text-dim,
body.high-contrast:not(.theme-light) .about-text {
  color: #e8e8f0;
}

body.theme-light.high-contrast .menu-screen,
body.theme-light.high-contrast .hud,
body.theme-light.high-contrast .overlay {
  color: #111318;
}

body.high-contrast .mobile-hint {
  font-weight: 700;
}

body.performance-performance .logo h1,
body.performance-performance .toast-notification {
  animation: none !important;
}

body.performance-performance *,
body.performance-performance *::before,
body.performance-performance *::after {
  transition-duration: .08s !important;
}

body.reduced-motion,
body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
}

.fullscreen-control {
  border-color: rgba(125, 249, 255, .28);
  color: var(--accent);
}

.fullscreen-control.fullscreen-active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #081014;
  border-color: transparent;
}

.share-score-control {
  min-width: 190px;
  border-color: rgba(123, 97, 255, .45);
  color: var(--accent2);
}

.share-score-control:hover {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  border-color: transparent;
}

#btn-continue {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent2) 35%, transparent);
}

@media (max-width: 600px) {
  .desktop-only {
      display: none !important;
  }
}

.btn-primary:hover {
  box-shadow: 0 8px 28px rgba(0, 224, 198, .5)
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .08)
}

.btn-secondary:hover {
  background: #262636
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c0392b);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 71, 87, .3)
}

.btn-small {
  padding: 7px 14px;
  font-size: .82rem;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .08);
  cursor: pointer;
  transition: background .2s
}

.btn-small:hover {
  background: #2a2a3c
}

button,
.btn,
.btn-small,
select,
input[type="checkbox"],
input[type="range"],
input[type="color"] {
  cursor: pointer
}

.game-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
  z-index: 5
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  font-size: .95rem
}

.hud-left,
.hud-right {
  display: flex;
  gap: 16px
}

.hud-item {
  color: var(--text-dim)
}

.hud-item b {
  color: var(--text);
  font-size: 1.1rem
}

#combo-display {
  color: var(--gold) !important;
  animation: comboPulse .4s ease
}

@keyframes comboPulse {
  0% {
      transform: scale(1)
  }

  50% {
      transform: scale(1.3)
  }

  100% {
      transform: scale(1)
  }
}

.powerup-bar {
  display: flex;
  gap: 8px;
  padding: 0 6px;
  min-height: 28px;
  flex-wrap: wrap
}

.powerup-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
  }

.powerup-chip.fading {
opacity: 0;
transform: translateY(-8px);
}

.powerup-chip.shield {
  background: rgba(155, 89, 182, .2);
  color: #c39bf3;
  border: 1px solid #9b59b6
}

.powerup-chip.slow {
  background: rgba(52, 152, 219, .2);
  color: #74b9ff;
  border: 1px solid #3498db
}

.powerup-chip.magnet {
  background: rgba(230, 126, 34, .2);
  color: #fab36c;
  border: 1px solid #e67e22
}

.powerup-chip.fever {
  background: rgba(255, 152, 0, .2);
  color: #ffd54f;
  border: 1px solid #ff9800;
  animation: feverGlow 0.8s ease-in-out infinite alternate;
}

@keyframes feverGlow {
  from { box-shadow: 0 0 8px rgba(255, 152, 0, 0.4); }
  to   { box-shadow: 0 0 20px rgba(255, 152, 0, 0.8); }
}

.powerup-chip.ghost {
  background: rgba(0, 212, 255, .2);
  color: #7fe9ff;
  border: 1px solid #00d4ff;
  animation: ghostGlow 1s ease-in-out infinite alternate;
}

@keyframes ghostGlow {
  from { box-shadow: 0 0 8px rgba(0, 212, 255, 0.4); }
  to   { box-shadow: 0 0 20px rgba(0, 212, 255, 0.85); }
}

.powerup-chip .timer-bar {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .15);
  overflow: hidden
}

.powerup-chip .timer-fill {
height: 100%;
border-radius: 2px;
transition: width .1s linear;
background: #fff;
}

.powerup-chip.shield .timer-fill { background: #c39bf3; }
.powerup-chip.slow .timer-fill   { background: #74b9ff; }
.powerup-chip.magnet .timer-fill { background: #fab36c; }
.powerup-chip.fever .timer-fill  { background: #ffd54f; }
.powerup-chip.ghost .timer-fill  { background: #7fe9ff; }

.canvas-container {
  position: relative;
  display: inline-block;
  transition: transform .08s ease
}

canvas {
  border: 1px solid rgba(255, 255, 255, .1);
  background: var(--canvas-bg);
  display: block;
  border-radius: 8px;
  image-rendering: pixelated
}

.fever-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  box-shadow: inset 0 0 40px rgba(255, 152, 0, 0.6), inset 0 0 80px rgba(255, 215, 0, 0.3);
  animation: feverPulse 0.6s ease-in-out infinite alternate;
  z-index: 10;
}

@keyframes feverPulse {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 10, .9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: 8px;
  gap: 14px;
  animation: fadeIn .3s ease
}

.overlay.hidden {
  display: none
}

@keyframes fadeIn {
  from {
      opacity: 0
  }

  to {
      opacity: 1
  }
}

.end-stats {
  text-align: center;
  margin-bottom: 8px
}

.end-stats p {
  margin: 4px 0;
  color: var(--text-dim)
}

.end-stats b {
  color: var(--text)
}

.level-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(0, 224, 198, .6);
  z-index: 15;
  animation: levelUp 1.2s ease forwards;
  pointer-events: none
}

.level-banner.hidden {
  display: none
}

@keyframes levelUp {
  0% {
      opacity: 0;
      transform: translate(-50%, -50%) scale(.5)
  }

  30% {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1.1)
  }

  70% {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1)
  }

  100% {
      opacity: 0;
      transform: translate(-50%, -50%) scale(1.2)
  }
}

.game-controls {
  display: flex;
  gap: 8px;
  justify-content: center
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0
}

.setting-row>span:first-child {
  flex-shrink: 0
}

@media (max-width: 600px) {
  #settings-screen .setting-row-mobile-wrap {
    align-items: flex-start;
    flex-wrap: wrap
  }

  #settings-screen .setting-row-mobile-wrap>span:first-child {
    flex: 1 1 100%;
    white-space: normal
  }

  #settings-screen .setting-row-mobile-wrap>select {
    width: 100%;
    max-width: 100%
  }
}

.settings-section-title {
  align-self: stretch;
  margin-top: .35rem;
  padding-top: .7rem;
  border-top: 1px solid rgba(255, 255, 255, .12);
  color: var(--accent2);
  font-size: .95rem;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase
}

.keybindings-setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
  text-align: left
}

.key-bindings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px
}

.key-bind-button {
  min-width: 0;
  padding: 9px 6px;
  border: 1px solid rgba(0, 224, 198, .25);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  cursor: pointer
}

.key-bind-button:focus-visible,
.key-bind-button.is-listening {
  outline: 2px solid var(--accent);
  outline-offset: 2px
}

.key-bind-button.is-listening {
  color: var(--accent)
}

.key-bind-reset {
  align-self: flex-start
}

.setting-help {
  color: var(--text-dim);
  font-size: .78rem;
  line-height: 1.4
}

select {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, .1);
  font-size: .9rem
}

input[type="range"] {
  width: 110px;
  accent-color: var(--accent)
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent)
}

input[type="color"] {
  border: none;
  padding: 4px;
  width: 40px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-card)
}

.vol-label {
  font-size: .85rem;
  min-width: 36px;
  text-align: right;
  color: var(--text-dim)
}

.info-list {
  text-align: left;
  margin: 0 0 8px 1.2rem;
  list-style: disc;
  line-height: 1.6
}

.info-list b {
  color: var(--accent)
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 2px;
  vertical-align: middle
}

.dot.red { background: #e74c3c }
.dot.gold { background: var(--gold) }
.dot.blue { background: var(--blue) }
.dot.purple { background: var(--purple) }
.dot.orange { background: var(--orange) }
.dot.fever {
  background: linear-gradient(135deg, #ffeb3b, #ff9800);
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.6);
  animation: feverDotPulse 1s ease-in-out infinite alternate;
}

@keyframes feverDotPulse {
  from { box-shadow: 0 0 4px rgba(255, 152, 0, 0.4); }
  to   { box-shadow: 0 0 10px rgba(255, 152, 0, 0.9); }
}

.dot.ghost {
  background: var(--ghost);
  box-shadow: 0 0 6px rgba(0, 212, 255, 0.6);
  animation: ghostDotPulse 1.2s ease-in-out infinite alternate;
}

@keyframes ghostDotPulse {
  from { opacity: 0.6; box-shadow: 0 0 4px rgba(0, 212, 255, 0.4); }
  to   { opacity: 1;   box-shadow: 0 0 12px rgba(0, 212, 255, 0.9); }
}

.hidden {
  display: none !important
}

.menu-screen::-webkit-scrollbar {
  width: 6px
}

.menu-screen::-webkit-scrollbar-track {
  background: transparent
}

.menu-screen::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 3px
}

body {
  background: linear-gradient(-45deg, #0a0a0f, #16161e, #1a1a2e, #0f0f1a);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite
}

@keyframes gradientShift {
  0%   { background-position: 0% 50% }
  50%  { background-position: 100% 50% }
  100% { background-position: 0% 50% }
}

body.theme-light {
  background: linear-gradient(-45deg, #f0f2f5, #fff, #f1f3f6, #e8eaf0);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite
}

.toast-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(20, 20, 30, 0.95);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  box-shadow: 0 0 20px rgba(0, 224, 198, 0.3);
  max-width: 300px
}

.toast-notification.show {
  transform: translateX(0)
}

.toast-icon {
  font-size: 28px;
  flex-shrink: 0
}

.toast-text b {
  color: var(--accent);
  font-size: 15px;
  display: block
}

.toast-text small {
  color: var(--text-dim);
  font-size: 12px
}

.leaderboard .score-val.highlight {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(0, 224, 198, 0.6);
  font-weight: bold
}

.skin-selector-title {
  margin-top: 20px;
  margin-bottom: 10px;
  font-weight: bold;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: .85rem
}

.skin-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 20px
}

.skin-option {
  padding: 12px 8px;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  background: var(--bg-card);
  gap: 6px;
  position: relative;
}

.skin-option:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3)
}

.skin-option.active {
  border-color: var(--accent);
  background: rgba(0, 224, 198, 0.1);
  box-shadow: 0 0 20px rgba(0, 224, 198, 0.3)
}

.skin-option.locked {
  opacity: 0.55;
  filter: grayscale(0.6);
}

.skin-option.locked:hover {
  opacity: 0.8;
  filter: grayscale(0.3);
}

.skin-option .lock-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 14px;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.8));
}

.skin-option .dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-bottom: 2px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2)
}

.skin-option .dot.rainbow-dot {
  background: linear-gradient(135deg, #ff0000, #ff9900, #ffff00, #00ff00, #0099ff, #9900ff);
  background-size: 200% 200%;
  animation: rainbowShift 3s linear infinite;
}

.skin-option .dot.flame-dot {
  background: radial-gradient(circle at 50% 70%, 
    #fff59d 0%, 
    #ffb300 25%, 
    #ff6f00 55%, 
    #d84315 80%, 
    #8b0000 100%);
  background-size: 100% 100%;
  animation: flameFlicker 0.4s ease-in-out infinite alternate;
  box-shadow: 
    0 0 12px rgba(255, 100, 0, 0.8),
    0 0 24px rgba(255, 60, 0, 0.5),
    inset 0 -4px 8px rgba(139, 0, 0, 0.6);
}

@keyframes flameFlicker {
  0% {
    background: radial-gradient(circle at 50% 75%, 
      #fff59d 0%, #ffb300 25%, #ff6f00 55%, #d84315 80%, #8b0000 100%);
    filter: brightness(1);
    transform: scaleY(1);
  }
  50% {
    background: radial-gradient(circle at 50% 65%, 
      #fffde7 0%, #ffc107 25%, #ff8f00 55%, #e64a19 80%, #b71c1c 100%);
    filter: brightness(1.2);
    transform: scaleY(1.05);
  }
  100% {
    background: radial-gradient(circle at 50% 70%, 
      #fff9c4 0%, #ffa000 25%, #ff5722 55%, #d84315 80%, #8b0000 100%);
    filter: brightness(1.1);
    transform: scaleY(0.98);
  }
}

@keyframes rainbowShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.skin-option span:last-child {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px
}

.skin-option.active span:last-child {
  color: var(--text);
  font-weight: bold
}

.progress-container {
  margin: 10px 0;
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: 8px
}

.progress-label {
  font-size: .72rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden
}

.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 224, 198, 0.4)
}

#btn-continue {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  box-shadow: 0 4px 16px rgba(123, 97, 255, 0.35)
}

#btn-continue:hover {
  box-shadow: 0 8px 28px rgba(123, 97, 255, 0.5)
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 15px;
  margin-bottom: 15px
}

.achievement-card {
  padding: 12px 10px;
  border-radius: 10px;
  text-align: center;
  font-size: .72rem;
  line-height: 1.4;
  transition: transform 0.2s
}

.achievement-card:hover {
  transform: translateY(-2px)
}

.achievement-card.unlocked {
  background: rgba(0, 224, 198, 0.15);
  border: 1px solid var(--accent);
  color: var(--text)
}

.achievement-card.locked {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  opacity: 0.5
}

.achievement-card .icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px
}

.achievement-card.unlocked .icon {
  filter: drop-shadow(0 0 6px rgba(0, 224, 198, 0.5))
}

.achievement-card.locked .icon {
  filter: grayscale(1)
}

.tutorial-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--text-dim);
  margin-top: -4px
}

.tutorial-hint a {
  color: var(--accent2);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent2)
}

.tutorial-hint a:hover {
  color: var(--accent)
}

.stat-label,
.stat-val,
.hud-item,
.end-stats p,
.about-text,
.leaderboard .rank {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5)
}

.logo h1 {
  animation: logoPulse 4s ease-in-out infinite
}

@keyframes logoPulse {
  0%, 100% { text-shadow: 0 0 24px rgba(0, 224, 198, 0.5) }
  50%      { text-shadow: 0 0 36px rgba(0, 224, 198, 0.8), 0 0 12px rgba(123, 97, 255, 0.4) }
}

.btn-primary:hover {
  box-shadow: 0 8px 28px rgba(0, 224, 198, 0.5), 0 0 15px rgba(0, 224, 198, 0.3)
}

.btn-secondary:hover {
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1)
}

.btn-danger:hover {
  box-shadow: 0 8px 28px rgba(255, 71, 87, 0.5), 0 0 15px rgba(255, 71, 87, 0.3)
}

.btn:active {
  transform: scale(0.95)
}

.quests-panel {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 12px;
  text-align: left;
  border: 1px solid rgba(255, 215, 0, 0.15);
}

.quests-panel h3 {
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.quests-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quest-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent2);
  transition: all 0.2s;
}

.quest-item.done {
  border-left-color: var(--gold);
  background: rgba(255, 215, 0, 0.08);
}

.quest-text {
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 4px;
}

.quest-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
}

.quest-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.quest-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
  border-radius: 3px;
}

.quest-item.done .quest-fill {
  background: linear-gradient(90deg, var(--gold), #ff9800);
}

.quest-reward {
  color: var(--gold);
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

.quest-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 10px;
}

.shop-coins {
  color: var(--gold);
  font-size: 1.1rem;
  margin-bottom: 10px;
  text-align: center;
}

.shop-coins b {
  font-size: 1.3rem;
  color: var(--gold);
}

.shop-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-card);
  border-radius: 12px;
}

.shop-item {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.shop-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.shop-item.active {
  border-color: var(--gold);
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.shop-item.owned {
  border-color: rgba(0, 224, 198, 0.3);
}

.shop-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.shop-dot.rainbow-dot {
  background: linear-gradient(135deg, #ff0000, #ff9900, #ffff00, #00ff00, #0099ff, #9900ff);
  background-size: 200% 200%;
  animation: rainbowShift 3s linear infinite;
}

.shop-dot.flame-dot {
  background: radial-gradient(circle at 50% 70%, 
    #fff59d 0%, 
    #ffb300 25%, 
    #ff6f00 55%, 
    #d84315 80%, 
    #8b0000 100%);
  animation: flameFlicker 0.4s ease-in-out infinite alternate;
  box-shadow: 
    0 0 16px rgba(255, 100, 0, 0.9),
    0 0 32px rgba(255, 60, 0, 0.6),
    inset 0 -6px 10px rgba(139, 0, 0, 0.7);
}

.shop-name {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
}

.shop-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: none;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.buy-btn {
  background: linear-gradient(135deg, var(--gold), #ff9800);
  color: #1a0a00;
}

.buy-btn:hover {
  filter: brightness(1.15);
}

.free-btn {
  background: linear-gradient(135deg, var(--accent), #00b894);
  color: #000;
}

.select-btn {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
}

.shop-status {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  width: 100%;
}

.active-status {
  color: var(--gold);
  background: rgba(255, 215, 0, 0.15);
  border-radius: 6px;
}

:root {
  --panel-border: rgba(255, 255, 255, .1);
  --soft-shadow: 0 20px 60px rgba(0, 0, 0, .38);
}

html {
  min-height: 100%;
  background: var(--bg-dark);
}

body {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overscroll-behavior: none;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 28vw;
  height: 28vw;
  min-width: 180px;
  min-height: 180px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .18;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background: var(--accent);
  top: -12vw;
  left: -8vw;
}

body::after {
  background: var(--accent2);
  right: -10vw;
  bottom: -14vw;
}

.menu-screen {
  width: min(460px, calc(100vw - 24px));
  max-height: min(90dvh, 760px);
  padding: clamp(1.25rem, 4vw, 2.25rem) clamp(1rem, 5vw, 2.5rem);
  border-color: var(--panel-border);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 5;
}

.logo h1 {
  font-size: clamp(2.25rem, 10vw, 3.25rem);
  line-height: 1;
}

.version span {
  color: var(--text-dim);
  font-size: .78em;
}

.tagline {
  color: var(--text-dim);
  font-size: .82rem;
  letter-spacing: .04em;
  margin-top: 4px;
}

button,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(0, 224, 198, .5);
  outline-offset: 3px;
}

.btn {
  min-height: 46px;
  touch-action: manipulation;
}

.game-wrapper {
  width: min(100%, 560px);
  align-items: stretch;
  gap: 10px;
  z-index: 5;
}

.hud {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(22, 22, 30, .72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hud-left,
.hud-right {
  gap: clamp(8px, 3vw, 18px);
  flex-wrap: wrap;
}

.hud-item {
  font-size: .8rem;
  white-space: nowrap;
}

.hud-item b {
  font-size: 1rem;
}

.powerup-bar {
  min-height: 24px;
  padding: 0 4px;
}

.canvas-container {
  align-self: center;
  width: fit-content;
  max-width: 100%;
  border-radius: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  max-width: 100%;
  height: auto;
  border: 2px solid rgba(0, 224, 198, .18);
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 14px 45px rgba(0, 0, 0, .35), 0 0 28px rgba(0, 224, 198, .08);
  touch-action: none;
}

.game-controls {
  gap: 8px;
}

.game-controls .btn-small {
  flex: 1;
  min-height: 40px;
}

.mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 2px auto 0;
  touch-action: manipulation;
}

.direction-row {
  display: flex;
  gap: 7px;
}

.direction-btn {
  width: 58px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(0, 224, 198, .24);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(38, 44, 62, .96), rgba(25, 28, 42, .96));
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: 0 5px 12px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .08);
  touch-action: manipulation;
  user-select: none;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}

.direction-btn:active,
.direction-btn.pressed {
  transform: scale(.9);
  background: linear-gradient(145deg, var(--accent), #00a98f);
  border-color: transparent;
  color: #061313;
}

.direction-center {
  color: var(--accent);
  font-size: 1rem;
}

.mobile-hint {
  color: var(--text-dim);
  font-size: .72rem;
  letter-spacing: .03em;
}

.info-list {
  padding-right: 4px;
}

@media (max-width: 600px) {
  .mobile-controls {
      display: flex;
  }

  .game-wrapper {
      width: min(100%, 480px);
  }

  .game-controls {
      order: 5;
  }

  .mobile-controls {
      order: 6;
  }

  .overlay {
      padding: 20px;
  }

  .powerup-chip {
      font-size: .72rem;
  }

  .shop-items {
      grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  .mobile-controls {
      display: none;
  }

  .game-wrapper {
      gap: 5px;
  }

  .hud {
      padding: 5px 10px;
  }

  .powerup-bar {
      min-height: 18px;
  }
}

@media (max-width: 380px) {
  .hud {
      padding: 8px;
  }

  .hud-item {
      font-size: .72rem;
  }

  .direction-btn {
      width: 52px;
      height: 44px;
  }
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn-primary:hover {
  box-shadow: 0 8px 28px color-mix(in srgb, var(--accent) 50%, transparent);
}

.start-countdown {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 18;
  pointer-events: none;
  font-size: clamp(3rem, 14vw, 6rem);
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow:
    0 0 24px rgba(0, 224, 198, .8),
    0 0 60px rgba(0, 224, 198, .4);
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
  line-height: 1;
  overflow: hidden;
}

.start-countdown.hidden {
  display: none;
}

.start-countdown .countdown-tick {
  display: inline-block;
  animation: countdownPop .9s cubic-bezier(.25, .1, .25, 1) both;
  will-change: opacity, transform;
}

.start-countdown.go .countdown-tick {
  color: var(--gold);
  text-shadow:
    0 0 24px rgba(255, 215, 0, .9),
    0 0 60px rgba(255, 152, 0, .5);
  font-size: .72em;
  letter-spacing: 2px;
}

@keyframes countdownPop {
  0% {
    opacity: 0;
    transform: scale(.4);
  }
  35% {
    opacity: 1;
    transform: scale(1.15);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  .start-countdown .countdown-tick {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

body.performance-performance .start-countdown .countdown-tick {
  animation: none !important;
  opacity: 1 !important;
}

select:focus,
input[type="range"]:focus {
  outline-color: var(--accent);
}

#btn-install-pwa {
  background: linear-gradient(135deg, #ffd700, #ff9800);
  color: #0b1020;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
  animation: pulse-install 2s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

#btn-install-pwa::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shine 3s ease-in-out infinite;
}

#btn-install-pwa:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 215, 0, 0.6);
  background: linear-gradient(135deg, #ffeb3b, #ffb300);
}

#btn-install-pwa:active {
  transform: scale(0.96);
}

@keyframes pulse-install {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
  }
  50% {
    box-shadow: 0 4px 30px rgba(255, 215, 0, 0.8), 0 0 0 8px rgba(255, 215, 0, 0.1);
  }
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  #btn-install-pwa {
    animation: none;
  }
  #btn-install-pwa::before {
    animation: none;
  }
}
