:root {
  --bg-primary: #0a0c12;
  --bg-secondary: #121622;
  --gold-primary: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.45);
  --cyan-primary: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.4);
  --glass-bg: rgba(18, 22, 34, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --cell-bg: rgba(255, 255, 255, 0.04);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --board-size: min(92vw, 440px);
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ambient-bg-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
}

.glow-1 {
  width: 450px;
  height: 450px;
  background: var(--gold-primary);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: var(--cyan-primary);
  bottom: -150px;
  right: -150px;
}

/* Navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  background: rgba(10, 12, 18, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-back-link:hover {
  color: #fff;
}

.back-arrow {
  font-size: 1.4rem;
  line-height: 1;
}

.nav-divider {
  color: var(--text-muted);
  opacity: 0.35;
}

.game-badge {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--gold-primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 12px;
}

.nav-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

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

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold-primary);
  text-decoration: none;
  font-family: 'Cinzel', serif;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 1.5px;
}

/* Main Container */
.game-container {
  position: relative;
  z-index: 10;
  margin: 68px auto 20px auto;
  max-width: 520px;
  width: 100%;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header */
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.main-title {
  font-family: 'Cinzel', serif;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.highlight-gold {
  color: var(--gold-primary);
  text-shadow: 0 0 16px var(--gold-glow);
}

.tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stats-bar {
  display: flex;
  gap: 8px;
}

.stat-box {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 64px;
  text-align: center;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.stat-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-weight: 700;
}

.stat-val {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
}

.pulse-box .stat-val {
  color: var(--gold-primary);
}

/* Powerups */
.powerup-bar {
  width: 100%;
  max-width: var(--board-size);
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.powerup-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 8px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.powerup-btn:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
}

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

.pu-badge {
  background: var(--gold-primary);
  color: #000;
  font-size: 0.65rem;
  font-weight: 900;
  border-radius: 10px;
  padding: 1px 5px;
}

/* Board */
.board-wrapper {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  margin: 0 auto;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(14, 18, 28, 0.85);
  border: 2px solid rgba(245, 158, 11, 0.2);
  border-radius: 16px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0,0,0,0.5);
  touch-action: none;
  user-select: none;
}

.grid-cell {
  background: var(--cell-bg);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Tile container & tiles */
.tile-container {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  pointer-events: none;
}

.tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  border-radius: 10px;
  user-select: none;
  transition: transform 110ms ease-in-out, opacity 100ms;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.tile-new {
  animation: tileSpawn 160ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tile-merged {
  animation: tileMerge 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}

@keyframes tileSpawn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes tileMerge {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Tile Levels */
.tile-2 { background: #1e293b; color: #94a3b8; border: 1px solid #334155; font-size: 1.8rem; }
.tile-4 { background: #0f3952; color: #38bdf8; border: 1px solid #0284c7; font-size: 1.8rem; }
.tile-8 { background: #084c47; color: #2dd4bf; border: 1px solid #0d9488; font-size: 1.8rem; }
.tile-16 { background: #134e2f; color: #4ade80; border: 1px solid #16a34a; font-size: 1.7rem; }
.tile-32 { background: #5c4108; color: #fbbf24; border: 1px solid #d97706; font-size: 1.7rem; }
.tile-64 { background: #7c2d12; color: #fb923c; border: 1px solid #ea580c; font-size: 1.6rem; }
.tile-128 { background: #831843; color: #f472b6; border: 1px solid #db2777; font-size: 1.5rem; box-shadow: 0 0 16px rgba(219, 39, 119, 0.3); }
.tile-256 { background: #581c87; color: #c084fc; border: 1px solid #9333ea; font-size: 1.5rem; box-shadow: 0 0 18px rgba(147, 51, 234, 0.35); }
.tile-512 { background: #312e81; color: #818cf8; border: 1px solid #4f46e5; font-size: 1.4rem; box-shadow: 0 0 20px rgba(79, 70, 229, 0.4); }
.tile-1024 { background: #1e1b4b; color: #a5b4fc; border: 1px solid #6366f1; font-size: 1.25rem; box-shadow: 0 0 22px rgba(99, 102, 241, 0.5); }
.tile-2048 {
  background: linear-gradient(135deg, #b45309 0%, #f59e0b 50%, #fbbf24 100%);
  color: #000;
  border: 1px solid #fff;
  font-size: 1.25rem;
  box-shadow: 0 0 30px var(--gold-glow), 0 0 15px rgba(255,255,255,0.6);
  animation: pulseGold 2s infinite alternate;
}
.tile-4096 {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 50%, #10b981 100%);
  color: #fff;
  border: 1px solid #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 35px var(--cyan-glow);
}

@keyframes pulseGold {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.03); filter: brightness(1.2); }
}

/* Overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 18, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 100;
}

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

.overlay-modal {
  text-align: center;
  padding: 24px;
}

.overlay-title {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  color: #f87171;
  margin-bottom: 8px;
}

.overlay-msg {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.overlay-score-summary {
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.cta-btn {
  background: linear-gradient(135deg, var(--gold-primary) 0%, #d97706 100%);
  color: #000;
  border: none;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--gold-glow);
  transition: transform 0.2s;
}

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

/* Guides & Dpad */
.controls-guide {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.mobile-guide { display: none; }

/* Virtual D-pad */
.virtual-dpad {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad-middle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dpad-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  width: 50px;
  height: 44px;
  border-radius: 10px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.1s;
}

.dpad-btn:active {
  background: rgba(245, 158, 11, 0.35);
  transform: scale(0.95);
}

.dpad-center {
  width: 32px;
  height: 32px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .pc-guide { display: none; }
  .mobile-guide { display: inline; }
  .main-title { font-size: 1.5rem; }
  .stat-box { min-width: 58px; padding: 4px 8px; }
  .stat-val { font-size: 0.95rem; }
  .powerup-btn { font-size: 0.72rem; padding: 6px 4px; }
}

/* Auth Bar Start Styles */
.auth-bar-start {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  min-height: 40px;
}
.auth-bar-start .skibidi-logged-out {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.auth-bar-start .skibidi-google-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  width: 100%;
}
.skibidi-google-custom-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  background: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 9999px !important;
  padding: 7px 16px !important;
  font-family: 'Outfit', sans-serif !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35) !important;
  width: auto !important;
  line-height: normal !important;
  text-decoration: none !important;
  transition: all 0.2s ease !important;
}
.skibidi-google-custom-btn:hover {
  background: #f3f4f6 !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45) !important;
  transform: translateY(-1px) !important;
}
.skibidi-google-custom-btn:active {
  transform: translateY(1px) !important;
}
.skibidi-user-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  background: rgba(245, 158, 11, 0.18) !important;
  border: 1.5px solid #f59e0b !important;
  color: #fef08a !important;
  padding: 5px 12px !important;
  border-radius: 9999px !important;
  font-size: 0.85rem !important;
  font-weight: 800 !important;
}
.skibidi-logout-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  padding: 5px 12px !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  background: rgba(239, 68, 68, 0.2) !important;
  color: #fca5a5 !important;
  border: 1.5px solid #ef4444 !important;
  border-radius: 9999px !important;
  box-shadow: none !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
}
.skibidi-logout-btn:hover {
  background: rgba(239, 68, 68, 0.35) !important;
  color: #ffffff !important;
}

