/* ============================================================
   STYLES.CSS — ACAB Ball Collector v3
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #FF6B35;
  --secondary: #FFD700;
  --accent:    #4ECDC4;
  --dark:      #1a1a2e;
  --darker:    #0f0f1a;
  --text:      #F5F5F5;
  --muted:     #aaaacc;
  --panel-bg:  rgba(20, 20, 40, 0.93);
  --radius:    16px;
  --shadow:    0 8px 32px rgba(0,0,0,0.55);
}

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  background: var(--darker);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
}

/* ============================================================ SCREENS */
.screen {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  z-index: 10;
}
.screen.active  { display: flex; }
.screen.overlay {
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(5px);
  z-index: 30;
  align-items: center;
  overflow-y: auto;
  padding: 1rem 0;
}

/* ============================================================ PANELS */
.panel {
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 2rem 2.4rem;
  min-width: 300px; max-width: 480px; width: 90vw;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative; overflow: visible;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}
.panel.wide { max-width: 720px; }
.panel h2 {
  font-size: 1.8rem; font-weight: 800; margin-bottom: 1.2rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================ START SCREEN */
#screen-start {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255,107,53,0.14) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(78,205,196,0.11) 0%, transparent 60%),
    var(--darker);
  flex-direction: column;
}
.start-inner { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.logo {
  width: 120px; height: 120px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--primary);
  box-shadow: 0 0 32px rgba(255,107,53,0.5); margin-bottom: 0.5rem;
}
.game-title {
  font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 900; letter-spacing: -1px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { font-size: 1rem; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }
.tagline  { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }

/* ============================================================ BUTTONS */
.menu-buttons { display: flex; flex-direction: column; gap: 0.65rem; margin-top: 1.2rem; width: 100%; max-width: 260px; }
.btn {
  padding: 0.75rem 1.5rem; border: none; border-radius: 50px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.5px; width: 100%;
}
.btn:hover  { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,0,0,0.4); }
.btn:active { transform: translateY(0); }
.btn-primary  { background: linear-gradient(135deg, var(--primary), #ff8c00); color: #fff; box-shadow: 0 4px 16px rgba(255,107,53,0.35); }
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text); border: 1px solid rgba(255,255,255,0.2); }
.btn-secondary:hover { background: rgba(255,255,255,0.17); }
.btn-danger { background: linear-gradient(135deg, #c62828, #e53935); color: #fff; }
.btn-sm {
  padding: 0.3rem 0.85rem; font-size: 0.78rem;
  background: linear-gradient(135deg, var(--primary), #ff8c00);
  color: #fff; border: none; border-radius: 50px;
  cursor: pointer; font-weight: 700; margin-top: 0.4rem; width: auto;
}
.btn-mute {
  position: absolute; top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%; width: 40px; height: 40px;
  font-size: 1.1rem; cursor: pointer; color: var(--text);
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================ MUSIC BUTTON */
.music-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(20, 20, 40, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 22px;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.45);
  transition: transform 0.2s ease;
  color: white;
}
.music-btn:hover  { transform: scale(1.12); }
.music-btn.playing { animation: musicPulse 2.4s ease-in-out infinite; }
@keyframes musicPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.45); }
  50%       { box-shadow: 0 4px 28px rgba(138,43,226,0.55), 0 0 0 3px rgba(138,43,226,0.18); }
}

/* ============================================================ NAME INPUT */
.name-input {
  width: 100%; padding: 0.75rem 1rem; border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.07);
  color: var(--text); font-size: 1.1rem; font-weight: 600;
  text-align: center; margin-bottom: 0.5rem; outline: none;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: var(--primary); }
.name-input::placeholder { color: var(--muted); }

/* ============================================================ LEVEL SELECT */
.level-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.8rem;
  max-height: 60vh; overflow-y: auto;
  padding: 0.3rem;
  margin-bottom: 0.5rem;
}
.level-card {
  border-radius: 14px; padding: 0;
  text-align: center; border: 2px solid transparent;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  position: relative; overflow: hidden;
  min-height: 160px; display: flex; flex-direction: column;
  justify-content: flex-end;
  animation: cardFadeIn 0.3s ease both;
}
@keyframes cardFadeIn {
  from { opacity:0; transform: translateY(8px); }
  to   { opacity:1; transform: translateY(0); }
}
.level-card .lc-court-icon {
  position: absolute; top: 8px; right: 10px;
  font-size: 1.5rem; opacity: 0.85; text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}
.level-card .lc-content {
  position: relative; z-index: 2;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.20) 100%);
  padding: 0.5rem 0.5rem 0.6rem;
  border-radius: 0 0 12px 12px;
}
.level-card.lc-unlocked {
  border-color: rgba(255,255,255,0.20);
  cursor: pointer;
}
.level-card.lc-unlocked:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(255,107,53,0.4);
}
.level-card.lc-locked { opacity: 0.50; cursor: not-allowed; }
.lc-num   { font-size: 1.5rem; font-weight: 900; color: #FFFFFF; text-shadow: 0 2px 6px rgba(0,0,0,0.8); line-height: 1; }
.lc-name  { font-size: 0.72rem; font-weight: 600; margin: 0.15rem 0; line-height: 1.2; min-height: 2em; color: rgba(255,255,255,0.9); }
.lc-stars { font-size: 0.9rem; margin: 0.15rem 0; letter-spacing: 1px; }
.lc-best  { font-size: 0.65rem; color: rgba(255,255,255,0.65); }
.lc-lock  { font-size: 1.2rem; margin-top: 0.2rem; }

/* Court-themed card backgrounds */
.lc-court-1  { background: linear-gradient(160deg, #C4822A 0%, #8B5A1C 100%); }
.lc-court-2  { background: linear-gradient(160deg, #3A3A3A 0%, #1A1A1A 100%); }
.lc-court-3  { background: linear-gradient(160deg, #7A7A80 0%, #555558 100%); }
.lc-court-4  { background: linear-gradient(160deg, #E0B87A 0%, #B88A4A 100%); }
.lc-court-5  { background: linear-gradient(160deg, #4A7A30 0%, #2A4A18 100%); }
.lc-court-6  { background: linear-gradient(160deg, #C0D8F0 0%, #88B4D8 100%); }
.lc-court-7  { background: linear-gradient(160deg, #3A1000 0%, #1A0500 100%); }
.lc-court-8  { background: linear-gradient(160deg, #0A0A20 0%, #050510 100%); }
.lc-court-9  { background: linear-gradient(160deg, #3A2A10 0%, #1A100A 100%); }
.lc-court-10 { background: linear-gradient(160deg, #E0E0FF 0%, #C0C0F0 100%); }
.lc-court-11 { background: linear-gradient(160deg, #3A0555 0%, #1A0533 100%); }
.lc-court-12 { background: linear-gradient(160deg, #2A5010 0%, #1A2E0A 100%); }
.lc-court-13 { background: linear-gradient(160deg, #050530 0%, #020220 100%); }
.lc-court-14 { background: linear-gradient(160deg, #2A2A45 0%, #1A1A2E 100%); }
.lc-court-15 { background: linear-gradient(160deg, #6A3800 0%, #3A2000 100%); }
.lc-court-16 { background: linear-gradient(160deg, #3A1060 0%, #1A0A2E 100%); }
.lc-court-17 { background: linear-gradient(160deg, #001030 0%, #000010 100%); }
.lc-court-18 { background: linear-gradient(160deg, #200050 0%, #0A0020 100%); }
.lc-court-19 { background: linear-gradient(160deg, #2A0000 0%, #0A0000 100%); }
.lc-court-20 { background: linear-gradient(160deg, #3A2A00 0%, #1A1200 100%); }
.lc-court-21 { background: linear-gradient(160deg, #042A04 0%, #001A00 100%); }
.lc-court-22 { background: linear-gradient(160deg, #2A0800 0%, #100000 100%); }
.lc-court-23 { background: linear-gradient(160deg, #080010 0%, #000005 100%); }
.lc-court-24 { background: linear-gradient(160deg, #200010 0%, #0A0005 100%); }
.lc-court-25 { background: linear-gradient(160deg, #001A30 0%, #000A15 100%); }
.lc-court-26 { background: linear-gradient(160deg, #252525 0%, #101010 100%); }
.lc-court-27 { background: linear-gradient(160deg, #280800 0%, #150000 100%); }
.lc-court-28 { background: linear-gradient(160deg, #101010 0%, #050505 100%); }
.lc-court-29 { background: linear-gradient(160deg, #08080F 0%, #020205 100%); }
.lc-court-30 { background: linear-gradient(160deg, #2A2000 0%, #100800 100%); }

/* Court accent lines on cards */
.lc-court-1::before,  .lc-court-2::before,  .lc-court-3::before,
.lc-court-4::before,  .lc-court-5::before,  .lc-court-6::before,
.lc-court-7::before,  .lc-court-8::before,  .lc-court-9::before,
.lc-court-10::before, .lc-court-11::before, .lc-court-12::before,
.lc-court-13::before, .lc-court-14::before, .lc-court-15::before,
.lc-court-16::before, .lc-court-17::before, .lc-court-18::before,
.lc-court-19::before, .lc-court-20::before, .lc-court-21::before,
.lc-court-22::before, .lc-court-23::before, .lc-court-24::before,
.lc-court-25::before, .lc-court-26::before, .lc-court-27::before,
.lc-court-28::before, .lc-court-29::before, .lc-court-30::before {
  content: '';
  position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.20);
  pointer-events: none;
}
.lc-court-6  .lc-num, .lc-court-6  .lc-name { color: #1A3A5A; text-shadow: none; }
.lc-court-10 .lc-num, .lc-court-10 .lc-name { color: #1A1A3A; text-shadow: none; }

/* ============================================================ HOW TO PLAY */
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-bottom: 0.75rem; }
.howto-item { background: rgba(255,255,255,0.05); border-radius: 12px; padding: 0.7rem; display: flex; align-items: center; gap: 0.55rem; text-align: left; font-size: 0.82rem; }
.howto-item .icon { font-size: 1.4rem; flex-shrink: 0; }
.controls-box { background: rgba(78,205,196,0.1); border: 1px solid rgba(78,205,196,0.25); border-radius: 10px; padding: 0.7rem 1rem; margin-bottom: 1rem; font-size: 0.88rem; line-height: 1.8; }

/* ============================================================ GAME SCREEN & HUD */
#screen-game { flex-direction: column; background: var(--darker); display: none; overflow: hidden; }
#screen-game.active { display: flex; }

#hud {
  width: 100%; max-width: 800px;
  display: flex; align-items: center;
  padding: 0.45rem 0.75rem;
  background: rgba(8,8,18,0.95);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  gap: 0.5rem; flex-shrink: 0;
}
.hud-section { display: flex; flex-direction: column; gap: 0.25rem; }
.hud-left  { align-items: flex-start; min-width: 130px; }
.hud-center { flex: 1; align-items: center; }
.hud-right { align-items: flex-end; min-width: 130px; }

.hud-item { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 7px; padding: 0.2rem 0.55rem; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.hud-level-item { display: flex; align-items: center; gap: 0.4rem; }
.hud-level-name { font-size: 0.65rem; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.hud-ball-item  { font-size: 0.72rem; }

.hud-score-row { display: flex; align-items: baseline; gap: 0.3rem; }
.hud-score-icon { font-size: 0.9rem; }
.hud-score-num  { font-size: 1.4rem; font-weight: 900; color: var(--secondary); line-height: 1; }

.hud-goal-wrap { display: flex; align-items: center; gap: 0.4rem; }
.hud-goal-bar  { height: 5px; width: 120px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.hud-goal-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 3px; transition: width 0.3s ease; }
.hud-goal-text { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.hud-timer     { font-size: 0.68rem; color: var(--accent); white-space: nowrap; margin-left: 0.4rem; font-weight: 700; }

.hud-combo-badge {
  display: flex; align-items: center; gap: 0.3rem;
  background: linear-gradient(135deg, rgba(255,107,53,0.25), rgba(255,215,0,0.2));
  border: 1px solid rgba(255,107,53,0.5);
  border-radius: 20px; padding: 0.15rem 0.6rem;
  font-size: 0.75rem; font-weight: 800;
  animation: comboPulse 0.6s ease-out;
}
.combo-mult { color: var(--secondary); font-size: 0.85rem; }

@keyframes comboPulse {
  0%   { transform: scale(0.9); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.hud-btn { margin-left: 0.3rem; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 7px; padding: 0.2rem 0.55rem; cursor: pointer; font-size: 1rem; color: var(--text); }

/* Power-up pills */
.powerup-hud { display: flex; flex-direction: column; gap: 3px; }
.powerup-pill {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px; padding: 0.15rem 0.45rem;
  font-size: 0.72rem; border-left: 2px solid var(--pu-color, #fff);
}
.pu-icon { font-size: 0.85rem; }
.pu-bar  { width: 48px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.pu-fill { height: 100%; border-radius: 2px; transition: width 0.3s linear; }

/* ============================================================ GAME AREA WRAPPER */
#game-area {
  position: relative;
  width: 100%;
  max-width: 800px;
  flex: 1;
  min-height: 0;           /* lets flex child shrink below content size */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 800px;
  max-height: 100%;        /* constrain by height on landscape mobile */
  aspect-ratio: 800 / 560;
  touch-action: none;
}

/* ============================================================ SCORE / COMBO POPUPS */
#score-popup-container { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.score-popup {
  position: absolute;
  transform: translateX(-50%) translateY(-50%);
  background: rgba(255,255,255,0.92); color: #1a1a2e;
  font-size: 0.95rem; font-weight: 800;
  padding: 0.18rem 0.65rem; border-radius: 50px;
  white-space: nowrap; pointer-events: none;
  animation: popupAnim 0.95s ease-out forwards;
}
.score-popup-dmg { background: rgba(220,30,30,0.92); color: #fff; font-size: 1rem; }

@keyframes popupAnim {
  0%   { opacity: 1; transform: translateX(-50%) translateY(-50%); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-140%); }
}

.combo-announce {
  position: fixed; top: 30%; left: 50%; transform: translateX(-50%);
  font-size: 1.5rem; font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  pointer-events: none; z-index: 50;
  animation: comboAnnounce 1.3s ease-out forwards;
}
@keyframes comboAnnounce {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.7); }
  20%  { opacity: 1; transform: translateX(-50%) scale(1.15); }
  70%  { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.95) translateY(-20px); }
}

/* ============================================================ LEVEL COMPLETE STARS */
.star-row { display: flex; gap: 0.6rem; justify-content: center; margin: 0.5rem 0 0.1rem; }
.star-icon { font-size: 2.2rem; display: inline-block; }
.star-labels { display: flex; gap: 0; justify-content: center; font-size: 0.65rem; color: var(--muted); margin-bottom: 0.8rem; }
.star-labels span { width: 50px; text-align: center; }

@keyframes starPop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.star-pop { animation: starPop 0.45s cubic-bezier(0.34,1.56,0.64,1) forwards; }

/* ============================================================ LEVEL STATS */
.level-stats { background: rgba(255,255,255,0.05); border-radius: 12px; padding: 0.9rem 1rem; margin: 0.75rem 0; line-height: 2; font-size: 1rem; }
.unlock-msg       { color: var(--secondary); font-weight: 700; font-size: 0.9rem; margin-top: 0.2rem; }
.speed-bonus-val  { color: #4ECDC4; }

/* ============================================================ CONFETTI */
.celebration { overflow: hidden; }
.confetti-container { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; animation: confettiFall linear forwards; }
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 1; }
  100% { transform: translateY(360px) rotate(720deg); opacity: 0; }
}

/* ============================================================ UNLOCKS */
.unlocks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 0.7rem; margin-bottom: 0.85rem; max-height: 55vh; overflow-y: auto; padding-right: 4px; }
.skin-card { background: rgba(255,255,255,0.06); border: 2px solid rgba(255,255,255,0.1); border-radius: 13px; padding: 0.9rem 0.65rem; text-align: center; transition: border-color 0.18s, background 0.18s; }
.skin-card.unlocked { border-color: rgba(255,255,255,0.2); }
.skin-card.equipped { border-color: var(--primary); background: rgba(255,107,53,0.14); }
.skin-card.locked   { opacity: 0.52; }
.skin-emoji { font-size: 1.9rem; margin-bottom: 0.25rem; }
.skin-img   { width: 52px; height: 52px; object-fit: contain; margin-bottom: 0.25rem; display: block; margin-left: auto; margin-right: auto; }
.skin-name  { font-weight: 700; font-size: 0.82rem; margin-bottom: 0.18rem; }
.skin-desc  { font-size: 0.7rem; color: var(--muted); line-height: 1.3; }
.equipped-badge { display: inline-block; background: var(--primary); color: #fff; font-size: 0.68rem; font-weight: 700; padding: 0.12rem 0.55rem; border-radius: 50px; margin-top: 0.35rem; }
.equip-msg { font-size: 0.88rem; color: var(--accent); min-height: 1.4em; margin-bottom: 0.5rem; }

/* ============================================================ LEADERBOARD */
.leaderboard-list { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.9rem; max-height: 60vh; overflow-y: auto; }
.lb-row { display: grid; grid-template-columns: 2.2rem 1fr auto auto auto auto; gap: 0.45rem; align-items: center; background: rgba(255,255,255,0.05); border-radius: 9px; padding: 0.55rem 0.7rem; font-size: 0.86rem; }
.lb-gold   { background: rgba(255,215,0,0.12); border: 1px solid rgba(255,215,0,0.3); }
.lb-silver { background: rgba(192,192,192,0.1); border: 1px solid rgba(192,192,192,0.2); }
.lb-bronze { background: rgba(205,127,50,0.1);  border: 1px solid rgba(205,127,50,0.2); }
.lb-rank  { font-size: 1rem; text-align: center; }
.lb-name  { font-weight: 700; }
.lb-score { color: var(--secondary); font-weight: 700; }
.lb-level { color: var(--accent); }
.lb-tokens { color: #FFD700; }
.lb-date  { color: var(--muted); font-size: 0.72rem; }
.empty-msg { color: var(--muted); padding: 2rem; font-size: 0.92rem; }

/* ============================================================ SCROLLBARS */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

/* ============================================================ VIRTUAL JOYSTICK */
#joystick-zone {
  position: absolute;
  inset: 0;
  pointer-events: none;        /* hidden on desktop */
  z-index: 20;
  touch-action: none;
}
.is-touch #joystick-zone {
  pointer-events: auto;        /* active on touch devices */
}

#joystick-base {
  position: absolute;
  width: 112px; height: 112px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.22);
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}

#joystick-knob {
  position: absolute;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.6), rgba(255,107,53,0.8));
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}


/* ============================================================ RESPONSIVE */
@media (max-width: 600px) {
  .panel { padding: 1.3rem 1.1rem; }
  .howto-grid { grid-template-columns: 1fr; }
  .lb-row { grid-template-columns: 2rem 1fr auto auto; font-size: 0.76rem; }
  .lb-tokens, .lb-date { display: none; }
  #hud { padding: 0.3rem 0.4rem; gap: 0.3rem; }
  .hud-item { font-size: 0.7rem; padding: 0.18rem 0.4rem; }
  .hud-score-num { font-size: 1.1rem; }
  .hud-goal-bar { width: 80px; }
  .hud-left, .hud-right { min-width: 90px; }
  .level-select-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ============================================================ TOUCH/MOBILE BODY CLASS OVERRIDES */
/* Larger tap targets on touch devices */
.is-touch .btn { min-height: 52px; }
.is-touch .btn-sm { min-height: 36px; padding: 0.4rem 1rem; }
.is-touch .hud-btn { min-width: 42px; min-height: 42px; font-size: 1.2rem; }

/* Mobile: compact HUD to leave more room for canvas + joystick */
.is-mobile #hud {
  padding: 0.25rem 0.4rem;
  gap: 0.25rem;
}
.is-mobile .hud-item     { font-size: 0.65rem; padding: 0.15rem 0.35rem; }
.is-mobile .hud-score-num { font-size: 1rem; }
.is-mobile .hud-goal-bar  { width: 70px; }
.is-mobile .hud-left, .is-mobile .hud-right { min-width: 80px; }
.is-mobile .hud-level-name { display: none; }  /* save space */

/* Safe-area insets for notched iPhones */
body {
  padding-top:    env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
}

/* ============================================================ WALLET UI */
.wallet-row {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; margin: 0.3rem 0 0.6rem;
  min-height: 36px;
}

/* "Connect Wallet" button */
.btn-wallet-connect {
  display: flex; align-items: center; gap: 0.4rem;
  background: linear-gradient(135deg, rgba(124,77,255,0.25), rgba(78,205,196,0.18));
  border: 1px solid rgba(124,77,255,0.45);
  border-radius: 50px; padding: 0.42rem 1rem;
  font-size: 0.85rem; font-weight: 700; cursor: pointer; color: var(--text);
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-wallet-connect:hover {
  background: linear-gradient(135deg, rgba(124,77,255,0.4), rgba(78,205,196,0.3));
  transform: translateY(-1px);
}

/* Connected wallet pill */
.wallet-pill {
  display: flex; align-items: center; gap: 0.45rem;
  background: rgba(78,205,196,0.1);
  border: 1px solid rgba(78,205,196,0.35);
  border-radius: 50px; padding: 0.38rem 0.85rem;
  font-size: 0.82rem; font-weight: 700; color: var(--text);
}
.wallet-dot  { color: #4ECDC4; font-size: 0.65rem; }
.wallet-addr { font-family: monospace; letter-spacing: 0.5px; }
.wallet-label{ font-size: 0.68rem; color: var(--accent); opacity: 0.85; }
.btn-wallet-x {
  background: none; border: none; color: var(--muted);
  font-size: 0.78rem; cursor: pointer; padding: 0 0.1rem;
  line-height: 1;
}
.btn-wallet-x:hover { color: var(--text); }
.wallet-error { font-size: 0.78rem; color: #ff6b6b; text-align: center; margin-top: 0.2rem; }

/* Force Pera Wallet modal above all game overlays.
   Targets: official docs class (.pera-wallet-modal) + Web Component
   tags (<pera-wallet-connect-modal>) + wrapper divs. */
.pera-wallet-modal,
pera-wallet-connect-modal,
pera-wallet-redirect-modal,
.pera-wallet-connect-modal-wrapper,
.pera-wallet-redirect-modal-wrapper,
#pera-wallet-connect-modal-wrapper,
#pera-wallet-redirect-modal-wrapper {
  z-index: 2147483647 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: all !important;
}

/* ============================================================ ONLINE SUBMIT BUTTON */
.btn-online {
  background: linear-gradient(135deg, #7C4DFF, #4ECDC4);
  color: #fff; border: none; border-radius: 50px;
  padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 700;
  cursor: pointer; width: 100%; letter-spacing: 0.5px;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 18px rgba(124,77,255,0.35);
}
.btn-online:hover  { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(124,77,255,0.5); }
.btn-online:active { transform: translateY(0); }

/* ============================================================ LEADERBOARD TABS */
.lb-tabs {
  display: flex; gap: 0.4rem; margin-bottom: 0.75rem; justify-content: center;
}
.lb-tab {
  flex: 1; max-width: 160px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50px; padding: 0.4rem 1rem;
  font-size: 0.82rem; font-weight: 700; color: var(--muted);
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lb-tab-active {
  background: linear-gradient(135deg, rgba(124,77,255,0.3), rgba(78,205,196,0.2));
  border-color: rgba(124,77,255,0.5);
  color: var(--text);
}
.lb-me   { background: rgba(78,205,196,0.1) !important; border: 1px solid rgba(78,205,196,0.35) !important; }
.lb-you  { background: var(--accent); color: #000; font-size: 0.62rem; font-weight: 800; padding: 0.1rem 0.4rem; border-radius: 50px; vertical-align: middle; }
.lb-loading { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.45} }

/* ============================================================ LEVEL SELECT TABS */
.level-tab-bar {
  display: flex; gap: 0.5rem; margin-bottom: 0.8rem; justify-content: center;
}
.ls-tab {
  flex: 1; max-width: 120px;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 0.45rem 0.8rem;
  color: var(--muted); font-size: 0.88rem; font-weight: 700;
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ls-tab-active {
  background: linear-gradient(135deg, rgba(255,107,53,0.3), rgba(78,205,196,0.2));
  border-color: rgba(255,107,53,0.6);
  color: var(--text);
}
.ls-tab:hover:not(.ls-tab-active) { background: rgba(255,255,255,0.1); color: var(--text); }

/* ============================================================ POWER-UP EXPIRY FLASH */
@keyframes puExpiry { 0%,100%{opacity:1} 50%{opacity:0.35} }
.pu-expiring { animation: puExpiry 0.45s ease-in-out infinite; }

/* ============================================================ PAUSE HINT */
.pause-hint {
  position: fixed;
  bottom: 90px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,40,0.85);
  color: rgba(255,255,255,0.85);
  font-size: 0.82rem; font-weight: 600;
  padding: 0.45rem 1.2rem; border-radius: 30px;
  border: 1px solid rgba(255,255,255,0.15);
  pointer-events: none; z-index: 9998;
  animation: fadeInUp 0.4s ease both, fadeOut 0.5s ease 3s both;
}
@keyframes fadeInUp  { from { opacity:0; transform: translateX(-50%) translateY(10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
@keyframes fadeOut   { from { opacity:1; } to { opacity:0; } }

/* ============================================================ ONLINE SUBMIT SCREEN */
.osub-hint {
  font-size: 0.88rem; color: var(--muted); text-align: center;
  margin-bottom: 0.5rem; line-height: 1.5;
}
.osub-pill { justify-content: center; margin: 0 auto 0.5rem; width: fit-content; }

/* ============================================================ MOBILE: wallet row */
@media (max-width: 600px) {
  .wallet-row { flex-wrap: wrap; }
  .btn-wallet-connect { font-size: 0.78rem; padding: 0.38rem 0.85rem; }
  .wallet-pill { font-size: 0.75rem; padding: 0.32rem 0.7rem; }
}

/* ============================================================ GOALS FANFARE */
.goals-fanfare {
  position: fixed;
  top: 38%; left: 50%; transform: translate(-50%, -50%);
  font-size: 1.9rem; font-weight: 900;
  color: #00FF88;
  text-shadow: 0 0 24px #00FF88, 0 0 48px #00FF88;
  pointer-events: none; z-index: 9995;
  animation: goalsPopIn 0.4s cubic-bezier(0.175,0.885,0.32,1.275) both,
             goalsFadeOut 0.5s ease 1.7s both;
}
@keyframes goalsPopIn    { from { transform: translate(-50%,-50%) scale(0.2); opacity:0; } to { transform: translate(-50%,-50%) scale(1); opacity:1; } }
@keyframes goalsFadeOut  { from { opacity:1; } to { opacity:0; } }

/* ============================================================ MILESTONE BANNER */
.milestone-banner {
  position: fixed;
  top: 22%; left: 50%; transform: translate(-50%, 0);
  font-size: 1.45rem; font-weight: 900; letter-spacing: 0.08em;
  color: #FFD700;
  text-shadow: 0 0 18px #FFD700, 0 2px 0 rgba(0,0,0,0.6);
  pointer-events: none; z-index: 9994;
  animation: msBannerIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275) both,
             msBannerOut 0.4s ease 1.4s both;
}
@keyframes msBannerIn  { from { transform: translate(-50%,-16px) scale(0.7); opacity:0; } to { transform: translate(-50%,0) scale(1); opacity:1; } }
@keyframes msBannerOut { from { opacity:1; } to { opacity:0; transform: translate(-50%,-12px); } }

/* ============================================================ LEVEL WIPE TRANSITION */
.level-wipe {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0a0a1a 40%, #1a0a2e);
  z-index: 9990; pointer-events: none;
  animation: wipeSweep 0.85s ease both;
}
@keyframes wipeSweep {
  0%   { clip-path: inset(0 100% 0 0); }
  40%  { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 0 100%); }
}

/* ============================================================ COMBO STREAK BAR */
.hud-combo-bar-wrap {
  width: 100%; height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px; overflow: hidden;
  margin-top: 2px;
}
.hud-combo-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.12s linear, background 0.3s;
  box-shadow: 0 0 6px currentColor;
}
