@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

/* ── Bubble Blaster — warm candy theme ─────────────────────────────────────── */
:root {
  --bubble1:  #ff6b9d;   /* pink */
  --bubble2:  #ffd166;   /* yellow */
  --bubble3:  #06d6a0;   /* mint */
  --bubble4:  #4cc9f0;   /* sky */
  --bg-top:   #1a0533;   /* deep purple */
  --bg-mid:   #2d0a5e;
  --bg-bot:   #0d1b4b;   /* deep blue */
  --surface:  rgba(255,255,255,0.08);
  --surface2: rgba(255,255,255,0.14);
  --border:   rgba(255,255,255,0.18);
  --text:     #fff;
  --text-dim: rgba(255,255,255,0.55);
  --gold:     #ffd166;
  --green:    #06d6a0;
  --red:      #ff6b6b;
  --shadow:   rgba(0,0,0,0.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Nunito', sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
body {
  display: flex; align-items: center; justify-content: center;
  background: #3a7d20;
  min-height: 100vh;
}

/* During gameplay body bg matches landscape — canvas draws it */
body.in-game {
  background: #2a5c14;
}
body.in-game::before { display: none; }

/* Floating bubbles background decoration */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 15% 25%, rgba(255,107,157,0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(76,201,240,0.10) 0%, transparent 35%),
    radial-gradient(circle at 50% 75%, rgba(6,214,160,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,209,102,0.09) 0%, transparent 35%);
}

/* ── SCREENS ── */
.screen { display: none; position: relative; z-index: 1; width: 100%; max-width: 420px; align-items: center; flex-direction: column; padding: 60px 20px 32px; min-height: 100vh; min-height: 100dvh; overflow-y: auto; }
.screen.active { display: flex; }
#menu-screen {
  max-width: none; width: 100%; padding: 0;
  justify-content: center; align-items: center;
  height: 100vh; height: 100dvh;
  min-height: 0 !important; max-height: 100vh; max-height: 100dvh;
  overflow: hidden !important;
  position: relative;
}
/* Background image contained inside the menu screen, not bleeding out */
#menu-screen .menu-bg {
  position: absolute; inset: 0; z-index: 0;
  background-image: url('bg.png');
  background-size: auto 100%;   /* fit full height, let width overflow = characters visible on sides */
  background-position: center top;
  background-repeat: no-repeat;
  background-color: #3a7d20;    /* matches landscape grass for any side gaps */
}
#menu-screen .menu-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(5, 2, 16, 0.18);
}
#menu-screen > * { position: relative; z-index: 1; }
/* Glass card wraps all the menu content */
.menu-card {
  background: transparent;
  padding: 28px 28px 22px;
  width: min(380px, 88vw);
  display: flex; flex-direction: column; align-items: center;
}
#roadmap-screen { padding: 0; overflow: hidden; max-width: none; width: 100%; min-height: 100vh; min-height: 100dvh; }
#game-screen { padding: 0; flex-direction: column; justify-content: flex-start; align-items: center; background: transparent; width: 100%; max-width: none; position: relative; }
#game-canvas  { display: block; width: 100%; max-width: 100vw; touch-action: none; cursor: crosshair; }

/* ── LOGO ── */
.logo {
  font-family: 'Fredoka One', sans-serif;
  font-size: clamp(28px, 8vw, 44px);
  text-align: center; line-height: 1.0; letter-spacing: 2px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ff6b9d, #ffd166, #06d6a0, #4cc9f0);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.8)) drop-shadow(0 4px 16px rgba(0,0,0,0.6));
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ── STATS ── */
.stats-row { display: flex; gap: 8px; width: 100%; margin-bottom: 10px; }
.stat-box {
  flex: 1; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px; padding: 10px 6px; text-align: center;
  backdrop-filter: blur(12px); box-shadow: 0 4px 16px var(--shadow);
}
.stat-label { font-size: 9px; letter-spacing: 2px; color: var(--text-dim); text-transform: uppercase; font-weight: 700; margin-bottom: 3px; }
.stat-value { font-family: 'Fredoka One', sans-serif; font-size: 22px; color: #fff; }
.stat-value.gold { color: var(--gold); }
.stat-value.mint { color: var(--green); }
.xp-bar-wrap { width: 100%; background: rgba(255,255,255,0.1); border-radius: 999px; height: 8px; margin-bottom: 4px; overflow: hidden; border: 1px solid var(--border); }
.xp-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ff6b9d, #ffd166); transition: width .5s ease; }
.xp-label { font-size: 10px; color: var(--text-dim); text-align: right; margin-bottom: 14px; font-weight: 600; }

/* ── BUTTONS ── */
.btn {
  width: 100%; padding: 15px; border-radius: 50px; border: none;
  font-family: 'Fredoka One', sans-serif; font-size: 16px; letter-spacing: 1px;
  cursor: pointer; margin-bottom: 10px; transition: all .2s;
  box-shadow: 0 6px 20px var(--shadow);
}
.btn-primary {
  background: linear-gradient(135deg, #ff6b9d, #ff8cc3);
  color: #fff;
}
.btn-primary:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 8px 24px rgba(255,107,157,0.5); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--surface2); color: rgba(255,255,255,0.8);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.18); }
.btn-daily {
  background: linear-gradient(135deg, #06d6a0, #0bcfa0);
  color: #fff; display: none;
}
.btn-daily.visible { display: block; }
.btn-daily:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(6,214,160,0.5); }
.btn-map {
  background: linear-gradient(135deg, #4cc9f0, #7b2fff);
  color: #fff;
}
.btn-map:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(76,201,240,0.45); }

#kgames-collection-btn { display: block; margin-top: 8px; font-size: 11px; color: var(--text-dim); text-decoration: none; text-align: center; font-weight: 600; }
#kgames-collection-btn:hover { color: #fff; }

/* ── TOP BARS ── */
#top-btn-bar { position: fixed; top: 12px; right: 12px; z-index: 1000; display: none; align-items: center; gap: 8px; }
#top-btn-bar.visible { display: flex; }
#shop-btn {
  background: linear-gradient(135deg, var(--gold), #ffaa00);
  color: #3d2000; border: none; padding: 8px 14px; border-radius: 20px;
  font-family: 'Fredoka One', sans-serif; font-size: 13px; cursor: pointer;
  transition: all .2s; box-shadow: 0 4px 14px rgba(255,209,102,0.4); white-space: nowrap;
}
#shop-btn:hover { transform: scale(1.05); }
#auth-top-btn {
  background: var(--surface2); color: #fff; border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 20px; font-family: 'Fredoka One', sans-serif;
  font-size: 13px; cursor: pointer; transition: all .2s; white-space: nowrap;
  backdrop-filter: blur(8px);
}
#auth-top-btn.logged-in { font-size: 11px; color: var(--text-dim); }
#top-left-bar { position: fixed; top: 12px; left: 12px; z-index: 1000; display: none; align-items: center; gap: 8px; }
#top-left-bar.visible { display: flex; }
.top-left-btn {
  background: var(--surface2); color: rgba(255,255,255,0.75); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 20px; font-family: 'Fredoka One', sans-serif;
  font-size: 12px; cursor: pointer; transition: all .2s; white-space: nowrap;
  backdrop-filter: blur(8px);
}
.top-left-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ── ROADMAP ── */
#roadmap-canvas { display: block; width: 100%; touch-action: none; }
.roadmap-back-btn {
  position: fixed; top: 12px; left: 12px;
  background: rgba(255,255,255,0.12); border: 1px solid var(--border);
  color: #fff; padding: 8px 16px; border-radius: 20px;
  font-family: 'Fredoka One', sans-serif; font-size: 13px; cursor: pointer;
  z-index: 100; backdrop-filter: blur(10px); white-space: nowrap;
}
.roadmap-back-btn:hover { background: rgba(255,255,255,0.22); }

/* ── GAME SCREEN ── */
#hud {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px; background: rgba(0,0,0,0.4); border-bottom: 1px solid var(--border);
  flex-shrink: 0; width: 100%; max-width: none; backdrop-filter: blur(10px);
}
.hud-back, .hud-pause {
  background: none; border: none; color: rgba(255,255,255,0.6);
  font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 10px; transition: all .2s;
}
.hud-back:hover, .hud-pause:hover { color: #fff; background: rgba(255,255,255,0.1); }
.hud-center { text-align: center; flex: 1; }

/* ── POWERUP BAR ── */
#powerup-bar {
  width: 100%; max-width: none; display: flex; gap: 3px;
  padding: 4px 6px; background: rgba(0,0,0,0.4); border-top: 1px solid var(--border);
  justify-content: center; align-items: center; flex-shrink: 0;
  backdrop-filter: blur(10px); flex-wrap: wrap; min-height: 36px;
}
.powerup-slot {
  display: none;  /* hidden by default — only shown when count > 0 */
  align-items: center; gap: 2px;
  background: rgba(255,255,255,0.06); border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 4px 6px; opacity: .35; transition: all .2s;
  cursor: pointer; user-select: none;
}
.powerup-slot.has-items {
  display: flex;   /* shown when > 0 */
  opacity: 1; border-color: rgba(255,255,255,0.3);
}
.powerup-slot.has-items:hover { background: rgba(255,255,255,0.15); transform: scale(1.06); }
.pu-icon  { font-size: 14px; line-height: 1; }
.pu-count { font-family: 'Fredoka One', sans-serif; font-size: 10px; color: #fff; min-width: 7px; }
.pu-mute {
  padding: 4px 8px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); cursor: pointer;
  font-size: 13px; transition: all .2s; flex-shrink: 0;
}
.pu-mute:hover  { background: rgba(255,255,255,0.15); }
.pu-mute.muted  { color: var(--red); border-color: rgba(255,107,107,0.4); }

/* ── OVERLAYS ── */
.overlay {
  position: fixed; inset: 0; background: rgba(13,5,30,0.85); backdrop-filter: blur(16px);
  display: none; align-items: center; justify-content: center; z-index: 500;
  flex-direction: column; padding: 20px;
}
.overlay.active { display: flex; }
.overlay-panel {
  background: linear-gradient(160deg, rgba(45,10,94,0.95), rgba(13,27,75,0.95));
  border: 1px solid var(--border); border-radius: 24px;
  padding: 30px 24px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.overlay-title {
  font-family: 'Fredoka One', sans-serif; font-size: 26px; letter-spacing: 2px;
  text-align: center; margin-bottom: 4px;
}
.overlay-title.pink   { color: #ff6b9d; text-shadow: 0 0 20px rgba(255,107,157,0.6); }
.overlay-title.mint   { color: #06d6a0; text-shadow: 0 0 20px rgba(6,214,160,0.5); }
.overlay-title.sky    { color: #4cc9f0; text-shadow: 0 0 20px rgba(76,201,240,0.5); }
.overlay-title.gold   { color: var(--gold); text-shadow: 0 0 20px rgba(255,209,102,0.4); }
.overlay-sub { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 6px; font-weight: 600; }
.overlay-score {
  font-family: 'Fredoka One', sans-serif; font-size: 48px;
  color: #fff; text-shadow: 0 0 30px rgba(255,209,102,0.6); margin: 8px 0;
}
.overlay-score.red { color: var(--red); text-shadow: 0 0 30px rgba(255,107,107,0.5); }
.level-clear-badge {
  font-family: 'Fredoka One', sans-serif; font-size: 13px; color: var(--gold);
  letter-spacing: 1px; margin-bottom: 4px;
}
.close-btn {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: rgba(255,255,255,0.4); font-size: 22px; cursor: pointer;
  padding: 4px 8px; border-radius: 8px; transition: all .2s;
}
.close-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* ── SHOP ── */
.shop-tabs { display: flex; gap: 6px; width: 100%; margin-bottom: 12px; }
.shop-tab {
  flex: 1; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-family: 'Fredoka One', sans-serif; font-size: 11px;
  letter-spacing: .5px; cursor: pointer; text-align: center; color: var(--text-dim); transition: all .2s;
}
.shop-tab:hover  { background: var(--surface2); color: #fff; }
.shop-tab.active { border-color: #ff6b9d; color: #ff6b9d; background: rgba(255,107,157,0.1); }
.coins-tab.active { border-color: var(--gold) !important; color: var(--gold) !important; background: rgba(255,209,102,0.1) !important; }
.shop-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; width: 100%; }
.shop-grid.coinpack-grid { grid-template-columns: repeat(2,1fr); }
.shop-item {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 16px;
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; transition: all .2s; position: relative;
}
.shop-item:hover { border-color: #ff6b9d; background: rgba(255,107,157,0.1); transform: translateY(-2px); }
.shop-item.selected { border-color: #06d6a0; background: rgba(6,214,160,0.1); }
.si-icon  { font-size: 26px; }
.si-name  { font-family: 'Fredoka One', sans-serif; font-size: 12px; text-align: center; }
.si-desc  { font-size: 9px; color: var(--text-dim); text-align: center; line-height: 1.3; }
.si-price { font-family: 'Fredoka One', sans-serif; font-size: 11px; color: var(--gold); display: flex; align-items: center; justify-content: center; gap: 3px; }
.si-price.free { color: var(--green); }
.si-price.sel  { color: #06d6a0; }
.shop-section-header {
  grid-column: 1 / -1; font-family: 'Fredoka One', sans-serif;
  font-size: 12px; color: rgba(255,255,255,0.5);
  padding: 8px 2px 3px; letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 4px;
}
.si-badge { position: absolute; top: 6px; right: 6px; background: #ff6b9d; color: #fff; font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 8px; }

/* ── LEADERBOARD ── */
.lb-tabs { display: flex; gap: 8px; width: 100%; margin-bottom: 12px; }
.lb-tab {
  flex: 1; padding: 8px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font-family: 'Fredoka One', sans-serif; font-size: 11px;
  cursor: pointer; text-align: center; color: var(--text-dim); transition: all .2s;
}
.lb-tab.active { border-color: var(--gold); color: var(--gold); background: rgba(255,209,102,0.08); }
.lb-entry { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.05); width: 100%; }
.lb-entry.top1 { background: rgba(255,209,102,0.08); border-radius: 10px; }
.lb-rank { font-family: 'Fredoka One', sans-serif; font-size: 14px; min-width: 28px; text-align: center; }
.lb-rank.gold { color: var(--gold); }
.lb-name  { flex: 1; font-size: 13px; font-weight: 700; }
.lb-score { font-family: 'Fredoka One', sans-serif; font-size: 13px; color: #4cc9f0; }

/* ── ACHIEVEMENTS ── */
.ach-grid { width: 100%; display: flex; flex-direction: column; gap: 5px; }
.ach-cat-header { font-family: 'Fredoka One', sans-serif; font-size: 11px; letter-spacing: 1px; color: var(--text-dim); text-transform: uppercase; padding: 8px 4px 3px; border-bottom: 1px solid var(--border); margin-top: 6px; }
.ach-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface); border: 1px solid transparent; border-radius: 12px; opacity: .4; }
.ach-item.unlocked { opacity: 1; border-color: rgba(6,214,160,0.3); background: rgba(6,214,160,0.06); }
.ach-icon  { font-size: 22px; min-width: 28px; text-align: center; }
.ach-name  { font-family: 'Fredoka One', sans-serif; font-size: 11px; margin-bottom: 1px; }
.ach-desc  { font-size: 10px; color: var(--text-dim); }
.ach-check { color: #06d6a0; font-size: 16px; opacity: 0; margin-left: auto; }
.ach-item.unlocked .ach-check { opacity: 1; }

/* ── TOAST ── */
#toast {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: rgba(45,10,94,0.95); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 24px; padding: 10px 20px; font-size: 14px; font-weight: 700;
  color: #fff; z-index: 9999; opacity: 0; transition: all .28s;
  pointer-events: none; white-space: nowrap; max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── PARTICLES ── */
#particle-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

/* ── COIN ICON ── */
.coin-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; }
.coin-icon svg { width: 100%; height: 100%; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
