/* ===== BUFFET DASH — ALL STYLES SCOPED TO #buffet-dash-game ===== */
#buffet-dash-game {
  --bd-ocean: #0077B6;
  --bd-teal: #008080;
  --bd-sunset: #FF6B35;
  --bd-sand: #FFF1E6;
  --bd-navy: #023E73;
  --bd-gold: #f39c12;
  --bd-red: #E74C3C;
  --bd-green: #2ECC71;
  --bd-white: #ffffff;
  --bd-gray-100: #f3f4f6;
  --bd-gray-200: #e5e7eb;
  --bd-gray-500: #6b7280;
  --bd-gray-700: #374151;
  --bd-radius: 12px;

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: 500px;
  margin: 1.5rem auto;
  padding: 0 0.75rem;
  color: var(--bd-navy);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
}

#buffet-dash-game *, #buffet-dash-game *::before, #buffet-dash-game *::after {
  box-sizing: border-box;
}

/* ── Screens ── */
.bd-screen { width: 100%; }

/* ── START SCREEN ── */
.bd-start-header { text-align: center; padding-top: 1rem; }
.bd-start-emoji { font-size: 3rem; margin-bottom: 0.25rem; }
.bd-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--bd-navy);
  margin: 0;
  letter-spacing: 0.03em;
}
.bd-subtitle {
  font-size: 1rem;
  color: var(--bd-ocean);
  margin: 0.15rem 0 0;
  font-weight: 600;
}
.bd-tagline {
  text-align: center;
  font-size: 0.95rem;
  color: var(--bd-gray-700);
  margin: 1rem 0;
  line-height: 1.5;
}
.bd-instructions {
  background: var(--bd-sand);
  border-radius: var(--bd-radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.bd-instruction {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  line-height: 1.4;
}
.bd-btn-primary {
  display: block;
  width: 100%;
  padding: 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--bd-white);
  background: linear-gradient(135deg, var(--bd-ocean), var(--bd-teal));
  border: none;
  border-radius: var(--bd-radius);
  cursor: pointer;
  margin: 1rem 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,119,182,0.3);
}
.bd-btn-primary:active { transform: scale(0.97); }
.bd-high-score {
  text-align: center;
  font-size: 0.9rem;
  color: var(--bd-gray-500);
  margin-bottom: 1rem;
}
.bd-preview {
  opacity: 0.4;
  pointer-events: none;
  margin-bottom: 1rem;
}

/* ── GRID ── */
.bd-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0.5rem 0;
}
.bd-cell {
  position: relative;
  aspect-ratio: 1;
  min-height: 70px;
  background: var(--bd-gray-100);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.2s;
  border: 2px solid transparent;
}
.bd-cell-label {
  font-size: 0.55rem;
  color: var(--bd-gray-500);
  position: absolute;
  bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
  pointer-events: none;
}
.bd-cell-emoji {
  font-size: 2rem;
  line-height: 1;
  pointer-events: none;
}
.bd-cell-points {
  font-size: 0.7rem;
  font-weight: 700;
  pointer-events: none;
  margin-top: 2px;
}

/* Cell states */
.bd-cell--food { background: var(--bd-sand); border-color: rgba(0,119,182,0.15); }
.bd-cell--food .bd-cell-points { color: var(--bd-ocean); }
.bd-cell--obstacle {
  background: #fde8e8;
  border-color: rgba(231,76,60,0.3);
  animation: bd-shake 0.4s ease-in-out infinite;
}
.bd-cell--obstacle .bd-cell-points { color: var(--bd-red); font-weight: 800; }
.bd-cell--powerup {
  background: #fef9e7;
  border-color: rgba(243,156,18,0.4);
  animation: bd-glow 1.2s ease-in-out infinite;
}
.bd-cell--powerup .bd-cell-points { color: var(--bd-gold); font-weight: 800; }

/* Item animations */
.bd-cell--pop-in .bd-cell-emoji { animation: bd-pop-in 0.3s ease-out; }
.bd-cell--grabbed {
  animation: bd-grab 0.25s ease-in forwards;
  pointer-events: none;
}
.bd-cell--penalty {
  animation: bd-penalty-flash 0.3s ease-out;
}
.bd-cell--expire .bd-cell-emoji {
  animation: bd-expire 0.3s ease-in forwards;
}

/* Floating points */
.bd-float-points {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 800;
  pointer-events: none;
  animation: bd-points-float 0.8s ease-out forwards;
  z-index: 10;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.bd-float-points--positive { color: var(--bd-green); }
.bd-float-points--negative { color: var(--bd-red); }
.bd-float-points--bonus { color: var(--bd-gold); }

/* ── HUD ── */
.bd-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  gap: 0.5rem;
}
.bd-hud-item { text-align: center; }
.bd-hud-label { font-size: 0.75rem; color: var(--bd-gray-500); display: block; }
.bd-hud-value { font-size: 1.5rem; font-weight: 800; display: block; }
.bd-hud-timer { flex: 0 0 auto; }
.bd-hud-score { flex: 1 1 auto; }
.bd-hud-combo { flex: 0 0 auto; min-width: 50px; }
.bd-score-value { color: var(--bd-gold); }
#bd-timer { color: var(--bd-navy); }
#bd-timer.bd-timer-urgent { color: var(--bd-red); animation: bd-pulse-red 0.8s ease-in-out infinite; }
.bd-score-bounce { animation: bd-bounce 0.3s ease-out; }

/* Power-up bar */
.bd-powerup-bar {
  background: linear-gradient(90deg, #fef9e7, #fde68a);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--bd-navy);
  position: relative;
  overflow: hidden;
  margin-bottom: 0.25rem;
}
.bd-powerup-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  background: var(--bd-gold);
  transition: width 0.1s linear;
}

/* Stats bar */
.bd-stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--bd-gray-500);
}
.bd-stats-bar strong { color: var(--bd-navy); }

/* ── RESULTS SCREEN ── */
.bd-results-header {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--bd-navy);
  margin: 1rem 0 0.5rem;
}
.bd-results-score { text-align: center; margin: 0.75rem 0; }
.bd-results-label { font-size: 0.85rem; color: var(--bd-gray-500); }
.bd-final-score {
  font-size: 3rem;
  font-weight: 900;
  color: var(--bd-gold);
  line-height: 1.1;
}
.bd-rank-display {
  text-align: center;
  background: var(--bd-sand);
  border-radius: var(--bd-radius);
  padding: 1.25rem;
  margin: 0.75rem 0;
}
.bd-rank-emoji { font-size: 2.5rem; margin-bottom: 0.25rem; }
.bd-rank-title { font-size: 1.25rem; font-weight: 800; color: var(--bd-navy); }
.bd-rank-desc { font-size: 0.9rem; color: var(--bd-gray-700); margin-top: 0.25rem; font-style: italic; }

.bd-results-stats {
  background: var(--bd-gray-100);
  border-radius: var(--bd-radius);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}
.bd-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--bd-gray-200);
}
.bd-stat-row:last-child { border-bottom: none; }

.bd-new-high {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--bd-gold);
  padding: 0.5rem;
  background: #fef9e7;
  border-radius: 8px;
  margin: 0.5rem 0;
}
.bd-new-high span { font-weight: 400; font-size: 0.85rem; color: var(--bd-gray-500); }

/* Share */
.bd-share-section { margin: 1rem 0; text-align: center; }
.bd-share-label { font-size: 0.85rem; color: var(--bd-gray-500); margin-bottom: 0.5rem; }
.bd-share-buttons { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.bd-share-btn {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s;
}
.bd-share-btn:active { transform: scale(0.95); }
.bd-share-x { background: #000; color: #fff; }
.bd-share-fb { background: #1877F2; color: #fff; }
.bd-share-threads { background: #000; color: #fff; }
.bd-share-tiktok { background: #010101; color: #fff; }
.bd-share-ig { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.bd-share-copy { background: var(--bd-gray-200); color: var(--bd-navy); }

/* ── TOAST ── */
.bd-toast-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.bd-toast {
  background: rgba(2,62,115,0.92);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  animation: bd-toast-in 0.3s ease-out, bd-toast-out 0.3s ease-in 1.2s forwards;
}
.bd-toast--penalty { background: rgba(231,76,60,0.92); }
.bd-toast--powerup { background: rgba(243,156,18,0.92); }
.bd-toast--combo { background: rgba(46,204,113,0.92); }

/* ── CONFETTI ── */
.bd-confetti { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 50; }
.bd-confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: bd-confetti-fall 1.5s ease-out forwards;
}

/* ===== KEYFRAME ANIMATIONS ===== */
@keyframes bd-pop-in {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes bd-grab {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.2); opacity: 0; }
}
@keyframes bd-expire {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); }
  100% { transform: scale(0.8); opacity: 0; }
}
@keyframes bd-points-float {
  0% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -45px); opacity: 0; }
}
@keyframes bd-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}
@keyframes bd-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(243,156,18,0.4); }
  50% { box-shadow: 0 0 18px rgba(243,156,18,0.85); }
}
@keyframes bd-pulse-red {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
@keyframes bd-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes bd-penalty-flash {
  0% { background: #fca5a5; }
  100% { background: #fde8e8; }
}
@keyframes bd-toast-in {
  0% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes bd-toast-out {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}
@keyframes bd-confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(300px) rotate(720deg); opacity: 0; }
}
@keyframes bd-golden-flash {
  0% { opacity: 0; }
  30% { opacity: 0.3; }
  100% { opacity: 0; }
}

/* Golden flash overlay for powerup activation */
.bd-golden-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(243,156,18,0.4), transparent);
  z-index: 20;
  pointer-events: none;
  animation: bd-golden-flash 0.6s ease-out forwards;
}

/* Screen shake */
.bd-screen-shake { animation: bd-shake 0.2s ease-in-out; }

/* Score count-up on results */
.bd-score-counting { transition: none; }

/* ── RESPONSIVE ── */
@media (max-width: 380px) {
  #buffet-dash-game { padding: 0 0.5rem; }
  .bd-cell { min-height: 65px; }
  .bd-cell-emoji { font-size: 1.75rem; }
  .bd-hud-value { font-size: 1.3rem; }
  .bd-title { font-size: 1.5rem; }
}
@media (min-width: 500px) {
  .bd-cell { min-height: 90px; }
  .bd-cell-emoji { font-size: 2.25rem; }
}
