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

:root {
  --bg: #0e0718;
  --neon-pink: #ff2d78;
  --neon-yellow: #ffe600;
  --neon-cyan: #00f5ff;
  --neon-green: #39ff14;
  --neon-orange: #ff8c00;
  --panel: rgba(255,255,255,0.06);
  --radius: 18px;
}

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

html, body {
  width:100%; height:100%;
  background: var(--bg);
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  overflow:hidden;
  touch-action: none;
}
body.lang-en { font-family: 'Boogaloo', cursive; }
body.lang-ko { font-family: 'Nunito', sans-serif; }

/* Override default fonts if they conflict with language choice */
body.lang-ko .stat-value,
body.lang-ko #logo,
body.lang-ko #level-label,
body.lang-ko .ov-title,
body.lang-ko .btn,
body.lang-ko #lvlup {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
}
body.lang-en .stat-label,
body.lang-en #hint {
  font-family: 'Boogaloo', cursive;
  letter-spacing: 1px;
}

/* ── LANGUAGE SWITCHER ── */
#lang-wrap {
  position: fixed; top: 16px; right: 16px;
  display: flex; gap: 4px; z-index: 100;
}
.lang-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  font-size: 11px; padding: 4px 8px; border-radius: 6px;
  cursor: pointer; transition: all 0.2s;
  font-weight: 700;
}
.lang-btn.active {
  background: var(--neon-cyan);
  color: var(--bg);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
}
.lang-btn:hover { border-color: var(--neon-cyan); color: white; }

/* BG aurora */
body::before {
  content:'';
  position:fixed; inset:0;
  background:
    radial-gradient(ellipse at 15% 25%, rgba(255,45,120,0.18) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 75%, rgba(0,245,255,0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 100%, rgba(160,32,240,0.15) 0%, transparent 40%);
  pointer-events:none; z-index:0;
  animation: auroraPulse 8s ease-in-out infinite alternate;
}
@keyframes auroraPulse {
  0%   { opacity:.7; }
  100% { opacity:1; }
}

#stars { position:fixed; inset:0; pointer-events:none; z-index:0; }
.star {
  position:absolute; border-radius:50%; background:white;
  animation: twinkle var(--d) ease-in-out infinite;
}
@keyframes twinkle {
  0%,100%{ opacity:.08; transform:scale(1); }
  50%    { opacity:.6;  transform:scale(1.6); }
}

/* ── WRAPPER ── */
#wrap {
  position:relative; z-index:1;
  display:flex; flex-direction:column; align-items:center;
  gap:10px;
  /* scale to fit smaller screens */
  transform-origin: top center;
}

/* ── HEADER ── */
#header {
  width: var(--cw);
  display:grid; grid-template-columns:1fr auto 1fr;
  align-items:center;
  padding:8px 16px;
  background:var(--panel);
  border:1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  backdrop-filter:blur(12px);
  gap:20px;
}
.stat-group { display:flex; gap:16px; }
.stat-group.right { justify-content:flex-end; }
.stat-box { text-align:center; }
.stat-label {
  font-size:9px; letter-spacing:2px;
  text-transform:uppercase; color:rgba(255,255,255,0.45);
}
.stat-value {
  font-family:'Boogaloo',cursive; font-size:26px; line-height:1;
  color:var(--neon-yellow);
  text-shadow:0 0 10px rgba(255,230,0,0.6);
  transition: transform .15s;
}
.stat-value.pop { animation: statPop .3s ease; }
@keyframes statPop {
  0%  { transform:scale(1); }
  50% { transform:scale(1.4); }
  100%{ transform:scale(1); }
}
.stat-value.cyan  { color:var(W--neon-cyan);   text-shadow:0 0 10px rgba(0,245,255,0.6); }
.stat-value.green { color:var(--neon-green);  text-shadow:0 0 10px rgba(57,255,20,0.6); }

#logo {
  font-family:'Boogaloo',cursive; font-size:13px; letter-spacing:3px;
  color:white; text-shadow:0 0 15px var(--neon-pink);
  text-align:center; white-space:nowrap;
}

/* ── CANVAS AREA ── */
#canvas-wrap { position:relative; }

#gameCanvas {
  display:block;
  border-radius:var(--radius);
  border:2px solid rgba(255,255,255,0.1);
  box-shadow: 0 0 50px rgba(255,45,120,0.25), 0 0 100px rgba(0,245,255,0.08);
  touch-action:none;
}

/* ── LEVEL BAR ── */
#level-bar-wrap {
  width:var(--cw);
  display:flex; align-items:center; gap:10px;
}
#level-label {
  font-family:'Boogaloo',cursive; font-size:14px;
  color:var(--neon-cyan); white-space:nowrap;
  text-shadow:0 0 8px var(--neon-cyan);
  min-width:60px;
}
#level-track {
  flex:1; height:8px;
  background:rgba(255,255,255,0.08);
  border-radius:99px; overflow:hidden;
}
#level-fill {
  height:100%; border-radius:99px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  box-shadow:0 0 8px rgba(0,245,255,0.5);
  transition: width .3s ease;
  width:0%;
}

/* ── LIVES ── */
#lives-row {
  display:flex; gap:6px; align-items:center;
}
.hrt {
  font-size:20px;
  filter:drop-shadow(0 0 5px rgba(255,45,120,0.9));
  transition:all .3s;
}
.hrt.lost {
  filter:grayscale(1) opacity(.25);
  transform:scale(.75);
}

/* ── OVERLAY ── */
#overlay {
  position:absolute; inset:0;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:14px;
  background:rgba(8,3,18,0.93);
  border-radius:var(--radius);
  backdrop-filter:blur(6px);
  z-index:20;
  animation:fadeIn .4s ease;
  padding:20px;
}
@keyframes fadeIn { from{opacity:0;transform:scale(.94)} to{opacity:1;transform:scale(1)} }

.ov-emoji { font-size:60px; animation:floatBig 2.5s ease-in-out infinite alternate; }
@keyframes floatBig {
  from{transform:translateY(0) rotate(-6deg)}
  to  {transform:translateY(-14px) rotate(6deg)}
}

.ov-title {
  font-family:'Boogaloo',cursive;
  font-size:clamp(36px,10vw,54px);
  color:white;
  text-shadow:0 0 30px var(--neon-pink), 0 0 70px var(--neon-pink);
  line-height:1; text-align:center;
}
.ov-sub {
  font-size:clamp(13px,3.5vw,16px);
  color:rgba(255,255,255,0.6);
  text-align:center; line-height:1.65;
}
.ov-score {
  font-family:'Boogaloo',cursive;
  font-size:clamp(28px,8vw,40px);
  color:var(--neon-yellow);
  text-shadow:0 0 20px var(--neon-yellow);
}
.ov-best {
  font-size:14px; color:rgba(255,255,255,0.45);
  display:flex; align-items:center; gap:6px;
}
.ov-best span { color:var(--neon-cyan); font-weight:700; }

/* score breakdown */
.score-grid {
  display:grid; grid-template-columns:1fr 1fr;
  gap:6px 20px; font-size:13px;
  color:rgba(255,255,255,0.5);
  background:rgba(255,255,255,0.04);
  padding:12px 20px; border-radius:12px;
  border:1px solid rgba(255,255,255,0.07);
}
.score-grid .sg-val { color:white; font-weight:700; text-align:right; }

/* NEW BEST banner */
.new-best {
  font-family:'Boogaloo',cursive; font-size:20px;
  color:var(--neon-yellow);
  background:rgba(255,230,0,0.12);
  padding:6px 18px; border-radius:99px;
  border:1px solid rgba(255,230,0,0.3);
  animation:pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from{opacity:.7} to{opacity:1} }

.btn {
  padding:13px 38px;
  font-family:'Boogaloo',cursive; font-size:13px; letter-spacing:2px;
  border:none; border-radius:50px; cursor:pointer;
  background:linear-gradient(135deg, var(--neon-pink), #8020d0);
  color:white;
  box-shadow:0 0 22px rgba(255,45,120,0.5), 0 5px 18px rgba(0,0,0,0.4);
  transition:all .18s;
  position:relative; overflow:hidden;
  -webkit-tap-highlight-color:transparent;
}
.btn::after {
  content:''; position:absolute; inset:0;
  background:linear-gradient(135deg,transparent 40%,rgba(255,255,255,0.18));
  border-radius:50px;
}
.btn:hover   { transform:translateY(-3px) scale(1.05); box-shadow:0 0 40px rgba(255,45,120,.7),0 8px 24px rgba(0,0,0,.4); }
.btn:active  { transform:scale(.97); }
.btn.secondary {
  background:rgba(255,255,255,0.07);
  box-shadow:none; border:1px solid rgba(255,255,255,0.15);
  font-size:16px; padding:10px 24px;
}
.btn.secondary:hover { background:rgba(255,255,255,0.12); box-shadow:none; }

/* ── FLOATING TEXTS ── */
#floaters { position:absolute; inset:0; pointer-events:none; z-index:15; }

/* ── LEVEL UP BANNER ── */
#lvlup {
  position:absolute; top:40%; left:50%;
  transform:translate(-50%,-50%) scale(.5);
  font-family:'Boogaloo',cursive; font-size:40px;
  color:var(--neon-yellow);
  text-shadow:0 0 30px var(--neon-yellow);
  pointer-events:none; opacity:0; z-index:15;
  white-space:nowrap;
  transition: none;
}

/* ── ACHIEVEMENT NOTIFICATION ── */
#achievement-toast {
  position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 7, 24, 0.9);
  border: 2px solid var(--neon-yellow);
  border-radius: 12px; padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 0 20px rgba(255, 230, 0, 0.4);
  z-index: 200; transition: top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none; backdrop-filter: blur(10px);
}
#achievement-toast.show { top: 20px; }
.ac-icon { font-size: 24px; }
.ac-info { display: flex; flex-direction: column; }
.ac-title { font-family: 'Boogaloo', cursive; color: var(--neon-yellow); font-size: 18px; line-height: 1; }
.ac-desc { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 4px; }

/* ── ACHIEVEMENT LIST ── */
.ac-list {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-height: 240px; overflow-y: auto;
  padding-right: 6px; margin: 10px 0;
}
.ac-list::-webkit-scrollbar { width: 4px; }
.ac-list::-webkit-scrollbar-thumb { background: var(--neon-cyan); border-radius: 10px; }

.ac-counter {
  font-size: 13px; color: var(--neon-cyan);
  background: rgba(0,245,255,0.1);
  padding: 4px 12px; border-radius: 20px;
  margin-bottom: 8px; font-weight: 700;
  border: 1px solid rgba(0,245,255,0.2);
  display: inline-block;
}

.ac-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.05);
  padding: 10px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.3s;
}
.ac-item.locked { opacity: 0.3; filter: grayscale(1); }
.ac-item.unlocked { border-color: var(--neon-yellow); background: rgba(255,230,0,0.05); }

.ac-item-icon { font-size: 20px; width: 32px; text-align: center; }
.ac-item-info { display: flex; flex-direction: column; gap: 2px; }
.ac-item-title { font-size: 14px; font-weight: 700; color: white; }
.ac-item-desc { font-size: 11px; color: rgba(255,255,255,0.5); }

.btn-row { display: flex; gap: 8px; width: 100%; justify-content: center; }
.btn-icon { padding: 13px 20px; }

/* ── BOTTOM INFO ── */
#bottom-row {
  width:var(--cw);
  display:flex; align-items:center; justify-content:space-between;
  gap:8px;
}
#hint {
  font-size:11px; color:rgba(255,255,255,0.3);
  letter-spacing:.5px;
}
#sound-btn {
  background:none; border:1px solid rgba(255,255,255,0.15);
  color:rgba(255,255,255,0.5); font-size:16px;
  padding:4px 10px; border-radius:8px; cursor:pointer;
  transition:all .2s;
}
#sound-btn:hover { border-color:var(--neon-cyan); color:var(--neon-cyan); }