/* 2048 CUPCAKE - Master Stylesheet */
:root {
  --bg-primary: #fdf6ee;
  --bg-secondary: #faede0;
  --bg-card: #ffffff;
  --bg-board: #e9d5c3;
  --bg-cell: #debfa7;
  
  --primary: #f26a8d;
  --primary-hover: #e55378;
  --primary-light: #fde8ee;
  --primary-dark: #c84364;
  
  --secondary: #9c6644;
  --secondary-light: #b08968;
  --accent-gold: #f5b041;
  --accent-gold-glow: rgba(245, 176, 65, 0.6);
  --accent-mint: #52b788;
  --accent-blue: #4ea8de;
  --accent-purple: #9d4edd;
  
  --text-dark: #4a2e18;
  --text-medium: #7f5539;
  --text-light: #9c6644;
  --text-muted: #b08968;
  --text-white: #ffffff;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 6px rgba(74, 46, 24, 0.08);
  --shadow-md: 0 6px 16px rgba(74, 46, 24, 0.12);
  --shadow-lg: 0 12px 28px rgba(74, 46, 24, 0.16);
  --shadow-glow: 0 0 20px rgba(242, 106, 141, 0.4);
  
  --font-display: 'Fredoka', 'Quicksand', system-ui, -apple-system, sans-serif;
  --font-body: 'Quicksand', system-ui, -apple-system, sans-serif;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Safe-area insets (notches / home-indicator / gesture bars) with 0px fallback */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* Dark / Night Bakery Theme */
body.theme-night {
  --bg-primary: #1f1a24;
  --bg-secondary: #2a2232;
  --bg-card: #2f2738;
  --bg-board: #3b3047;
  --bg-cell: #483b56;
  
  --text-dark: #f8edeb;
  --text-medium: #e8d7cf;
  --text-light: #d8c3b8;
  --text-muted: #9f8899;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  background-color: var(--bg-primary);
  color: var(--text-dark);
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.4;
  touch-action: manipulation;
}

/* App Container */
#app-container {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 10%, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  box-sizing: border-box;
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: scale(0.98);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  z-index: 10;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  z-index: 20;
}

/* Buttons & UI Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #f26a8d 0%, #d83a56 100%);
  color: var(--text-white);
  border-bottom: 3px solid #b82b43;
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(242, 106, 141, 0.45);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-dark);
  border: 2px solid var(--bg-cell);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-accent {
  background: linear-gradient(135deg, #f5b041 0%, #e67e22 100%);
  color: var(--text-white);
  border-bottom: 3px solid #b95f10;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--bg-card);
  color: var(--text-dark);
  border: 1px solid rgba(74, 46, 24, 0.08);
  box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
  background: var(--bg-secondary);
}

/* Badge / Currency Pill */
.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(74, 46, 24, 0.08);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
}

.coin-icon {
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #ffd166 0%, #f77f00 100%);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 2px 4px rgba(247, 127, 0, 0.35);
  border: 1.5px solid #ffea79;
}

/* Particle Canvas */
#particles-canvas, #confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

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

.toast {
  padding: 10px 20px;
  background: rgba(47, 39, 56, 0.94);
  color: #fff;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), toastOut 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) 2.4s forwards;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-16px) scale(0.9); }
}

/* Shimmer & Glow Effects */
@keyframes goldenPulse {
  0% { box-shadow: 0 0 10px rgba(245, 176, 65, 0.5), inset 0 0 8px rgba(255, 255, 255, 0.6); }
  50% { box-shadow: 0 0 25px rgba(245, 176, 65, 0.9), inset 0 0 16px rgba(255, 255, 255, 0.9); }
  100% { box-shadow: 0 0 10px rgba(245, 176, 65, 0.5), inset 0 0 8px rgba(255, 255, 255, 0.6); }
}

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

.animate-float {
  animation: floatAnim 3s ease-in-out infinite;
}
