/* ===== Sweet Crush — Modern Candy Match-3 Styles ===== */

:root {
  --bg-deep: #1a0a2e;
  --bg-mid: #2d1b4e;
  --accent-pink: #ff6b9d;
  --accent-purple: #c44dff;
  --accent-gold: #ffd93d;
  --accent-cyan: #6ee7ff;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --text: #fff8fc;
  --text-muted: rgba(255, 248, 252, 0.65);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 16px;
  --board-gap: 3px;
  --site-footer-h: 36px;
  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;

  /* Default cell size — overridden on game screen via container query */
  --cell-size: clamp(38px, 11vmin, 72px);

  /* Candy colors */
  --candy-red: #ff4757;
  --candy-orange: #ff9f43;
  --candy-yellow: #ffd93d;
  --candy-green: #2ed573;
  --candy-blue: #3742fa;
  --candy-purple: #a55eea;
}

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

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--bg-deep) 0%, #16213e 40%, var(--bg-mid) 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

/* Animated background orbs */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: float 12s ease-in-out infinite;
}

.orb-1 { width: 400px; height: 400px; background: var(--accent-pink); top: -10%; left: -5%; }
.orb-2 { width: 350px; height: 350px; background: var(--accent-purple); top: 50%; right: -10%; animation-delay: -4s; }
.orb-3 { width: 300px; height: 300px; background: var(--accent-cyan); bottom: -5%; left: 30%; animation-delay: -8s; }
.orb-4 { width: 250px; height: 250px; background: var(--accent-gold); top: 20%; left: 60%; animation-delay: -2s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* Twinkling starfield */
.bg-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 30% 65%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, rgba(255,217,61,0.6), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 85% 35%, rgba(110,231,255,0.5), transparent),
    radial-gradient(1px 1px at 15% 85%, rgba(255,107,157,0.5), transparent),
    radial-gradient(1px 1px at 45% 45%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 90% 60%, rgba(255,255,255,0.6), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}

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

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  background-image:
    linear-gradient(rgba(255,255,255,0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.5) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* Start screen floating decor */
.floating-candies {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.fc {
  position: absolute;
  font-size: 2rem;
  opacity: 0.35;
  animation: fcFloat 6s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.fc-1 { top: 8%; left: 5%; animation-delay: 0s; font-size: 2.4rem; }
.fc-2 { top: 15%; right: 8%; animation-delay: -1.5s; }
.fc-3 { bottom: 20%; left: 10%; animation-delay: -3s; font-size: 1.8rem; }
.fc-4 { bottom: 12%; right: 6%; animation-delay: -2s; font-size: 2.2rem; }
.fc-5 { top: 45%; left: -2%; animation-delay: -4s; font-size: 1.6rem; }

@keyframes fcFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-18px) rotate(8deg); }
}

#start-screen {
  position: relative;
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== Screens ===== */
.screen {
  display: none;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#start-screen.active {
  align-items: center;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--site-footer-h) + 8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#game-screen.active {
  max-width: none;
  padding: 4px 6px 2px;
  justify-content: flex-start;
  gap: 4px;
}

/* ===== Compact in-game HUD ===== */
#game-screen .game-header {
  gap: 4px;
  margin-bottom: 0;
}

#game-screen .stat-card {
  padding: 4px 3px;
  border-radius: 8px;
}

#game-screen .stat-label {
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

#game-screen .stat-value {
  font-size: 0.9rem;
  line-height: 1.15;
}

#game-screen .level-name {
  display: none;
}

#game-screen .stat-sub {
  font-size: 0.55rem;
  line-height: 1;
}

#game-screen .progress-bar {
  height: 3px;
  margin: 2px 2px 1px;
}

#game-screen .sugar-rush-wrap {
  margin-bottom: 0;
  padding: 3px 8px 4px;
  border-radius: 8px;
}

#game-screen .sugar-rush-label {
  font-size: 0.55rem;
  margin-bottom: 3px;
  letter-spacing: 0.03em;
}

#game-screen .sugar-rush-bar {
  height: 4px;
}

#game-screen #sugar-rush-status {
  font-size: 0.55rem;
}

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

.screen-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
  width: 100%;
  text-align: center;
}

.logo-candy {
  font-size: 4rem;
  display: block;
  position: relative;
  z-index: 1;
  animation: bounce 2s ease infinite;
  filter: drop-shadow(0 4px 12px rgba(255, 107, 157, 0.5));
}

.logo-badge {
  position: relative;
  display: inline-block;
  margin-bottom: 4px;
}

.logo-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 107, 157, 0.35);
  animation: logoRing 3s ease-in-out infinite;
}

.logo-ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 217, 61, 0.25);
  animation: logoRing 4s ease-in-out infinite reverse;
}

@keyframes logoRing {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.6; }
  50% { transform: scale(1.08) rotate(180deg); opacity: 1; }
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.feature-pills span {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.logo h1 {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 8px 0;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 28px;
}

.level-select label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.level-picker-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.level-nav {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

.level-nav:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}

#level-display {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  min-width: 100px;
}

.level-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.level-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.level-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px 8px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-display);
  color: var(--text);
}

.level-node:hover:not(.locked) {
  transform: translateY(-2px);
  border-color: var(--node-accent, var(--accent-pink));
}

.level-node.selected {
  border-color: var(--node-accent, var(--accent-gold));
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 16px rgba(255,217,61,0.2);
}

.level-node.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.node-num { font-size: 1.1rem; font-weight: 700; }
.node-emoji { font-size: 1.2rem; }
.node-stars { font-size: 0.55rem; letter-spacing: 1px; color: var(--accent-gold); min-height: 10px; }

.how-to {
  margin-top: 28px;
  text-align: left;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.how-to h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--accent-gold);
}

.how-to ul {
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.how-to li::before {
  content: '🍭 ';
}

/* ===== Buttons ===== */
.btn-primary {
  position: relative;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  padding: 14px 48px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(196, 77, 255, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 28px rgba(196, 77, 255, 0.55);
}

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

.start-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.start-actions .btn-primary {
  width: min(100%, 280px);
}

.btn-auto-menu {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 32px;
  border-radius: 50px;
  border: 1px solid rgba(110, 231, 255, 0.45);
  background: rgba(110, 231, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(100%, 280px);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: 0 2px 12px rgba(110, 231, 255, 0.15);
}

.btn-auto-menu:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(110, 231, 255, 0.2);
  box-shadow: 0 4px 20px rgba(110, 231, 255, 0.28);
}

.btn-auto-menu:active:not(:disabled) {
  transform: translateY(0);
}

.btn-auto-menu.btn-disabled,
.btn-auto-menu:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-help {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  padding: 10px 24px;
  border-radius: 50px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  transition: all 0.2s;
}

.btn-help:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
  color: var(--accent-cyan);
}

.btn-help-link {
  text-decoration: none;
}

.btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shine 3s infinite;
  pointer-events: none;
}

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

.btn-secondary {
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 10px 28px;
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  margin-top: 10px;
  width: 100%;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-action {
  font-family: var(--font-display);
  font-size: clamp(0.75rem, 2.4vmin, 0.85rem);
  padding: clamp(8px, 2vmin, 10px) clamp(10px, 2.5vmin, 16px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-action.auto-on {
  background: rgba(110, 231, 255, 0.2);
  border-color: rgba(110, 231, 255, 0.55);
  box-shadow: 0 0 16px rgba(110, 231, 255, 0.25);
  animation: autoPulse 1.6s ease-in-out infinite;
}

@keyframes autoPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(110, 231, 255, 0.2); }
  50% { box-shadow: 0 0 22px rgba(110, 231, 255, 0.45); }
}

.board-frame.auto-active {
  box-shadow:
    var(--shadow),
    0 0 28px rgba(110, 231, 255, 0.2),
    inset 0 0 0 1px rgba(110, 231, 255, 0.15);
}

.candy.auto-pick {
  animation: autoPickGlow 0.32s ease-in-out infinite alternate;
}

@keyframes autoPickGlow {
  from { box-shadow: 0 0 12px rgba(110, 231, 255, 0.5); }
  to { box-shadow: 0 0 20px rgba(110, 231, 255, 0.85); }
}

.toast-auto {
  color: var(--accent-cyan);
}

/* ===== Game Header ===== */
.game-header {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.stat-card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 8px 6px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.2vmin, 1.3rem);
  font-weight: 700;
  display: block;
}

.level-name {
  display: block;
  font-size: 0.58rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.moves-card.moves-low {
  border-color: rgba(255, 159, 67, 0.5);
  animation: movesWarn 1s ease infinite;
}

.moves-card.moves-low .stat-value {
  color: var(--candy-orange);
}

.moves-card.moves-critical {
  border-color: rgba(255, 71, 87, 0.6);
  animation: movesCritical 0.6s ease infinite;
}

.moves-card.moves-critical .stat-value {
  color: var(--candy-red);
}

@keyframes movesWarn {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 12px rgba(255, 159, 67, 0.3); }
}

@keyframes movesCritical {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); box-shadow: 0 0 16px rgba(255, 71, 87, 0.4); }
}

.score-card {
  grid-column: span 1;
  position: relative;
}

.stat-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 4px 4px 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-gold));
  border-radius: 2px;
  transition: width 0.4s ease;
  position: relative;
}

.progress-fill.complete {
  background: linear-gradient(90deg, var(--accent-gold), #fff, var(--accent-gold));
  background-size: 200% 100%;
  animation: progressShine 1.5s ease infinite;
}

@keyframes progressShine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.stat-value.bump {
  animation: scoreBump 0.35s cubic-bezier(0.34, 1.5, 0.64, 1);
}

@keyframes scoreBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); color: var(--accent-gold); }
  100% { transform: scale(1); }
}

.combo-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.combo-card.active {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255, 217, 61, 0.4);
  border-color: var(--accent-gold);
}

.combo-card.active .stat-value {
  color: var(--accent-gold);
  animation: pulse 0.5s ease;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ===== Game Board ===== */
.game-main {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.board-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.03));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s;
}

.board-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 2px;
  background: linear-gradient(135deg, rgba(255,107,157,0.2), transparent, rgba(110,231,255,0.15));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.board-glow {
  position: absolute;
  inset: 6px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s;
}

.board-glow.active {
  opacity: 1;
  animation: glowPulse 0.6s ease forwards;
}

.board-glow.tier-2 { box-shadow: inset 0 0 30px rgba(255, 217, 61, 0.3); }
.board-glow.tier-3 { box-shadow: inset 0 0 40px rgba(255, 107, 157, 0.35); }
.board-glow.tier-4 { box-shadow: inset 0 0 50px rgba(196, 77, 255, 0.4); }
.board-glow.tier-5 { box-shadow: inset 0 0 60px rgba(110, 231, 255, 0.45); }

@keyframes glowPulse {
  0% { opacity: 0; transform: scale(0.98); }
  50% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

.board-frame.board-pulse {
  animation: boardPulse 0.5s ease;
}

@keyframes boardPulse {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.02); box-shadow: var(--shadow), 0 0 40px rgba(255, 107, 157, 0.3); }
}

.board-frame.board-shake {
  animation: shake 0.45s ease;
}

#particle-canvas {
  position: absolute;
  inset: 6px;
  pointer-events: none;
  z-index: 10;
  border-radius: 10px;
}

.sweep-layer {
  position: absolute;
  inset: 6px;
  pointer-events: none;
  z-index: 9;
  border-radius: 10px;
  overflow: hidden;
}

.sweep {
  position: absolute;
  pointer-events: none;
  border-radius: 4px;
}

.sweep-h {
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.7), transparent);
  animation: sweepH 0.4s ease forwards;
}

.sweep-v {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  animation: sweepV 0.4s ease forwards;
}

.wrapped-burst {
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,217,61,0.6), transparent 70%);
  animation: wrappedBurst 0.5s ease forwards;
}

@keyframes sweepH {
  0% { opacity: 0; transform: scaleY(0.3); }
  50% { opacity: 1; transform: scaleY(1.2); }
  100% { opacity: 0; transform: scaleY(1); }
}

@keyframes sweepV {
  0% { opacity: 0; transform: scaleX(0.3); }
  50% { opacity: 1; transform: scaleX(1.2); }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes wrappedBurst {
  0% { opacity: 0; transform: scale(0.3); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.4); }
}

.game-board {
  --board-pad: 4px;
  display: grid;
  gap: var(--board-gap);
  padding: var(--board-pad);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  position: relative;
  flex-shrink: 0;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  position: relative;
}

.cell-alt {
  background: rgba(255, 255, 255, 0.07);
}

.candy {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 2;
  will-change: transform, top, left;
  touch-action: none;
  animation: candyIdle 3s ease-in-out infinite;
}

.candy-face {
  font-size: calc(var(--cell-size) * 0.46);
  line-height: 1;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
  pointer-events: none;
  transition: transform 0.15s;
}

.candy-shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.45) 0%,
    transparent 40%,
    transparent 60%,
    rgba(255,255,255,0.08) 100%
  );
  pointer-events: none;
  z-index: 1;
  animation: candyShimmer 3s ease-in-out infinite;
}

@keyframes candyShimmer {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.candy.dragging {
  transform: scale(1.18);
  z-index: 20;
  animation: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: grabbing;
}

.candy.match-glow {
  animation: matchGlow 0.12s ease forwards;
  z-index: 8;
}

@keyframes matchGlow {
  0% { filter: brightness(1); box-shadow: 0 0 0 0 rgba(255,255,255,0); }
  100% { filter: brightness(1.6); box-shadow: 0 0 20px 4px rgba(255,255,255,0.6); }
}

.candy.landed {
  animation: landSquish 0.3s ease;
}

@keyframes landSquish {
  0% { transform: scaleY(1.15) scaleX(0.9); }
  60% { transform: scaleY(0.92) scaleX(1.06); }
  100% { transform: scaleY(1) scaleX(1); }
}

.candy:nth-child(odd) { animation-delay: -1s; }
.candy:nth-child(3n) { animation-delay: -2s; }

@keyframes candyIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.candy.enter {
  animation: candyEnter 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) backwards;
}

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

.candy:active {
  cursor: grabbing;
}

.candy::before {
  content: '';
  position: absolute;
  top: 15%;
  left: 20%;
  width: 30%;
  height: 20%;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  transform: rotate(-30deg);
}

.candy::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.25);
}

.candy.selected {
  transform: scale(1.15);
  z-index: 5;
  animation: wiggle 0.4s ease infinite;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.candy.selected .candy-face {
  transform: scale(1.1);
}

.candy.drag-target {
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(110, 231, 255, 0.6);
  animation: none;
}

.candy.hint {
  animation: hintPulse 0.8s ease infinite;
}

@keyframes wiggle {
  0%, 100% { transform: scale(1.12) rotate(-2deg); }
  50% { transform: scale(1.12) rotate(2deg); }
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-gold); }
  50% { box-shadow: 0 0 0 6px rgba(255, 217, 61, 0.4); }
}

.candy.matching {
  animation: pop 0.4s ease forwards;
  z-index: 10;
}

.candy.falling {
  transition: top 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
  animation: none;
}

.candy.swapping {
  transition: top 0.2s ease, left 0.2s ease;
  z-index: 6;
  animation: none;
}

.candy.shuffle-spin {
  animation: shuffleSpin 0.5s ease-in-out;
}

@keyframes shuffleSpin {
  0% { transform: rotate(0) scale(1); }
  50% { transform: rotate(180deg) scale(0.5); opacity: 0.3; }
  100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  30% { transform: scale(1.35); opacity: 1; filter: brightness(1.5); }
  100% { transform: scale(0) rotate(20deg); opacity: 0; filter: brightness(2); }
}

.special-flash {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,217,61,0.8), transparent 70%);
  animation: specialFlash 0.6s ease forwards;
  pointer-events: none;
  z-index: 8;
}

@keyframes specialFlash {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

/* Candy type colors — gem jelly look */
.candy[data-type="0"] {
  background: radial-gradient(circle at 32% 28%, #ff8a96 0%, var(--candy-red) 45%, #c0392b 100%);
  box-shadow: 0 4px 12px rgba(255, 71, 87, 0.55), inset 0 -3px 6px rgba(0,0,0,0.2);
}
.candy[data-type="1"] {
  background: radial-gradient(circle at 32% 28%, #ffc285 0%, var(--candy-orange) 45%, #e67e22 100%);
  box-shadow: 0 4px 12px rgba(255, 159, 67, 0.55), inset 0 -3px 6px rgba(0,0,0,0.2);
}
.candy[data-type="2"] {
  background: radial-gradient(circle at 32% 28%, #fff176 0%, var(--candy-yellow) 45%, #f39c12 100%);
  box-shadow: 0 4px 12px rgba(255, 217, 61, 0.55), inset 0 -3px 6px rgba(0,0,0,0.2);
}
.candy[data-type="3"] {
  background: radial-gradient(circle at 32% 28%, #7bed9f 0%, var(--candy-green) 45%, #27ae60 100%);
  box-shadow: 0 4px 12px rgba(46, 213, 115, 0.55), inset 0 -3px 6px rgba(0,0,0,0.2);
}
.candy[data-type="4"] {
  background: radial-gradient(circle at 32% 28%, #7b83ff 0%, var(--candy-blue) 45%, #2c3e99 100%);
  box-shadow: 0 4px 12px rgba(55, 66, 250, 0.55), inset 0 -3px 6px rgba(0,0,0,0.2);
}
.candy[data-type="5"] {
  background: radial-gradient(circle at 32% 28%, #d4a5ff 0%, var(--candy-purple) 45%, #8e44ad 100%);
  box-shadow: 0 4px 12px rgba(165, 94, 234, 0.55), inset 0 -3px 6px rgba(0,0,0,0.2);
}

/* Special candies */
.candy[data-special="striped-h"]::after {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 4px,
    rgba(255,255,255,0.5) 4px,
    rgba(255,255,255,0.5) 8px
  );
  inset: 20% 10%;
  border-radius: 4px;
}

.candy[data-special="striped-v"]::after {
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 4px,
    rgba(255,255,255,0.5) 4px,
    rgba(255,255,255,0.5) 8px
  );
  inset: 10% 20%;
  border-radius: 4px;
}

.candy[data-special="wrapped"] {
  border-radius: 18%;
  animation: wrappedGlow 1.5s ease infinite;
}

.candy[data-special="wrapped"]::before {
  width: 50%;
  height: 50%;
  top: 10%;
  left: 10%;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 20%;
}

@keyframes wrappedGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

.candy[data-special="rainbow"] {
  background: conic-gradient(
    var(--candy-red), var(--candy-orange), var(--candy-yellow),
    var(--candy-green), var(--candy-blue), var(--candy-purple), var(--candy-red)
  ) !important;
  animation: rainbowSpin 3s linear infinite;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.4) !important;
}

@keyframes rainbowSpin {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

.board-overlay {
  position: absolute;
  inset: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.board-overlay.hidden {
  display: none;
}

.overlay-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.overlay-spinner.spin-fast {
  animation: spin 0.35s linear infinite;
  width: 48px;
  height: 48px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.game-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 6px;
  width: 100%;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
  flex-shrink: 0;
}

.btn-icon {
  aspect-ratio: 1;
  padding: 0;
  justify-content: center;
  min-height: 0;
  border-radius: 10px;
}

#game-screen .btn-icon {
  font-size: 1.15rem;
  line-height: 1;
}

#game-screen .btn-icon span {
  pointer-events: none;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: linear-gradient(145deg, rgba(45, 27, 78, 0.95), rgba(26, 10, 46, 0.98));
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px 28px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.pause-card .settings-row {
  margin: 16px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toggle-btn {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 50px;
  border: 1px solid rgba(255, 71, 87, 0.4);
  background: rgba(255, 71, 87, 0.15);
  color: #ff6b7a;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 52px;
}

.toggle-btn.on {
  border-color: rgba(46, 213, 115, 0.4);
  background: rgba(46, 213, 115, 0.15);
  color: var(--candy-green);
}

.end-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
  animation: bounce 1s ease infinite;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
}

.end-stats span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.end-stats strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--accent-gold);
}

.star {
  display: inline-block;
  font-size: 1.4rem;
  color: rgba(255,255,255,0.2);
  transition: transform 0.3s;
}

.star.earned {
  color: var(--accent-gold);
  animation: starPop 0.5s cubic-bezier(0.34, 1.5, 0.64, 1) backwards;
}

.star.earned:nth-child(1) { animation-delay: 0.2s; }
.star.earned:nth-child(2) { animation-delay: 0.4s; }
.star.earned:nth-child(3) { animation-delay: 0.6s; }

@keyframes starPop {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.end-card .btn-primary,
.end-card .btn-secondary {
  width: 100%;
}

#end-message {
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ===== Floating score text ===== */
#float-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.float-score {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent-gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  animation: floatUp 0.9s ease forwards;
  pointer-events: none;
}

.float-combo {
  font-size: 1.8rem;
  color: var(--accent-pink);
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-70px) scale(1.4); }
}

/* Level intro splash */
.level-intro {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.level-intro.hidden {
  display: none;
}

.level-intro-card {
  text-align: center;
  animation: introPop 1.8s cubic-bezier(0.34, 1.3, 0.64, 1) forwards;
}

.level-intro-num {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.level-intro-name {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.level-intro-goal {
  display: block;
  font-size: 1rem;
  color: var(--text-muted);
}

@keyframes introPop {
  0% { transform: scale(0.5); opacity: 0; }
  15% { transform: scale(1.08); opacity: 1; }
  70% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0; }
}

/* Combo banner */
.combo-banner {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 700;
  color: var(--accent-gold);
  text-shadow:
    0 0 20px rgba(255, 217, 61, 0.6),
    0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

.combo-banner.show {
  animation: comboBanner 0.9s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.combo-banner.tier-3 { color: var(--accent-pink); text-shadow: 0 0 24px rgba(255, 107, 157, 0.7), 0 4px 12px rgba(0,0,0,0.5); }
.combo-banner.tier-4 { color: var(--accent-cyan); font-size: clamp(2rem, 7vw, 3.2rem); }
.combo-banner.tier-5 { color: #fff; font-size: clamp(2.2rem, 8vw, 3.5rem); animation: comboBannerMega 0.9s cubic-bezier(0.34, 1.4, 0.64, 1) forwards; }

@keyframes comboBanner {
  0% { opacity: 0; transform: translateX(-50%) scale(0.3) rotate(-5deg); }
  20% { opacity: 1; transform: translateX(-50%) scale(1.15) rotate(2deg); }
  70% { opacity: 1; transform: translateX(-50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.3) translateY(-20px); }
}

@keyframes comboBannerMega {
  0% { opacity: 0; transform: translateX(-50%) scale(0.2); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.25); }
  30% { transform: translateX(-50%) scale(1.1); }
  70% { opacity: 1; transform: translateX(-50%) scale(1.05); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.4) translateY(-30px); }
}

.float-score.float-special {
  font-size: 1.6rem;
  color: var(--accent-cyan);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 50px;
  background: rgba(26, 10, 46, 0.92);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  color: var(--text);
  opacity: 0;
  transform: translateY(-12px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
  box-shadow: var(--shadow);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.toast-success {
  border-color: rgba(255, 217, 61, 0.4);
  box-shadow: 0 4px 20px rgba(255, 217, 61, 0.2);
}

.toast.toast-rush {
  border-color: rgba(255, 107, 157, 0.5);
  box-shadow: 0 4px 24px rgba(255, 107, 157, 0.35);
  color: var(--accent-gold);
  font-size: 1rem;
}

.toast.toast-achievement {
  border-color: rgba(196, 77, 255, 0.5);
  box-shadow: 0 4px 24px rgba(196, 77, 255, 0.35);
  color: var(--accent-cyan);
  font-size: 0.95rem;
}

.float-bonus {
  color: var(--accent-cyan) !important;
  font-size: 1.6rem !important;
}

.intro-stars {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.intro-stars span {
  color: var(--accent-gold);
}

.end-bonus {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  margin-bottom: 12px;
  font-weight: 600;
}

/* Per-level theme accents */
body[data-theme="0"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(255,107,157,0.15); }
body[data-theme="1"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(255,159,67,0.15); }
body[data-theme="2"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(255,217,61,0.15); }
body[data-theme="3"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(46,213,115,0.15); }
body[data-theme="4"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(110,231,255,0.15); }
body[data-theme="5"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(165,94,234,0.15); }
body[data-theme="6"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(255,179,71,0.15); }
body[data-theme="7"] .board-frame { box-shadow: var(--shadow), 0 0 30px rgba(196,77,255,0.15); }

#game-screen .stat-card.level-card .stat-value {
  color: var(--theme-accent, var(--accent-pink));
}

/* ===== Splash screen ===== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-deep), #16213e, var(--bg-mid));
  transition: opacity 0.5s ease, visibility 0.5s;
}

.splash.splash-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
}

.splash-logo {
  font-size: 5rem;
  display: block;
  animation: bounce 1.5s ease infinite;
  filter: drop-shadow(0 4px 20px rgba(255, 107, 157, 0.6));
}

.splash-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 12px 0 24px;
}

.splash-bar {
  width: 180px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin: 0 auto 12px;
  overflow: hidden;
}

.splash-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-gold));
  border-radius: 2px;
  animation: splashLoad 1.2s ease forwards;
}

@keyframes splashLoad {
  to { width: 100%; }
}

.splash-tag {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Player stats & level stars ===== */
.level-stars-display {
  font-size: 1.3rem;
  letter-spacing: 4px;
  color: var(--accent-gold);
  margin-top: 6px;
}

.player-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 20px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
}

.player-stat {
  text-align: center;
}

.ps-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ps-value {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}

.btn-primary.btn-disabled,
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

.rank-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 50px;
  background: linear-gradient(135deg, rgba(255,107,157,0.2), rgba(255,217,61,0.15));
  border: 1px solid rgba(255, 217, 61, 0.3);
  color: var(--accent-gold);
  margin-bottom: 16px;
}

/* ===== Sugar Rush meter ===== */
.sugar-rush-wrap {
  width: 100%;
  margin-bottom: 6px;
  padding: 6px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  transition: all 0.3s;
  flex-shrink: 0;
}

.sugar-rush-wrap.rush-ready {
  border-color: rgba(255, 217, 61, 0.5);
  animation: rushReady 1s ease infinite;
}

.sugar-rush-wrap.rush-active {
  border-color: rgba(255, 107, 157, 0.6);
  box-shadow: 0 0 20px rgba(255, 107, 157, 0.25);
  background: rgba(255, 107, 157, 0.08);
}

@keyframes rushReady {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 217, 61, 0.2); }
  50% { box-shadow: 0 0 20px rgba(255, 217, 61, 0.45); }
}

.sugar-rush-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sugar-rush-label span:first-child {
  color: var(--accent-gold);
}

#sugar-rush-status {
  color: var(--accent-pink);
  font-size: 0.7rem;
  animation: pulse 0.8s ease infinite;
}

.sugar-rush-bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.sugar-rush-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink), var(--accent-gold));
  background-size: 200% 100%;
  border-radius: 4px;
  transition: width 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
  animation: rushGradient 2s linear infinite;
}

.sugar-rush-wrap.rush-active .sugar-rush-fill {
  animation: rushGradient 0.5s linear infinite, rushPulse 0.6s ease infinite;
}

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

@keyframes rushPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4); }
}

/* Screen flash */
.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.screen-flash.active {
  opacity: 1;
  animation: screenFlash 0.35s ease forwards;
}

.screen-flash.flash-gold { background: radial-gradient(circle, rgba(255,217,61,0.25), transparent 70%); }
.screen-flash.flash-pink { background: radial-gradient(circle, rgba(255,107,157,0.2), transparent 70%); }

@keyframes screenFlash {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

/* Hide footer during gameplay to maximize board */
body:has(#game-screen.active) .site-footer {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 400px) {
  #game-screen .game-header {
    grid-template-columns: repeat(4, 1fr);
  }

  .logo h1 {
    font-size: 2.2rem;
  }

  #game-screen.active {
    padding-left: 4px;
    padding-right: 4px;
  }

  #game-screen .stat-value {
    font-size: 0.82rem;
  }
}

@media (min-width: 520px) {
  #game-screen .game-actions {
    max-width: 280px;
  }
}

@media (min-height: 800px) {
  .screen-card {
    padding: 44px 32px;
  }
}

/* ===== Site footer ===== */
.site-footer {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0);
  left: 0;
  right: 0;
  z-index: 5;
  text-align: center;
  padding: 8px 16px;
  pointer-events: none;
  height: var(--site-footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-footer a {
  pointer-events: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s, color 0.2s;
}

.site-footer a:hover {
  opacity: 1;
  color: var(--accent-cyan);
}
