:root{
  --bg:#0b1020;
  --card:#121a33;
  --card2:#0f1730;
  --text:#e8eefc;
  --muted:#a6b1d6;
  --accent:#2d7dff;
  --accent2:#00ffe0;
  --danger:#ff3b3b;
}

*{ box-sizing:border-box; }
html,body{
  margin:0;
  padding:0;
  background:var(--bg);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  height:100%;
  overscroll-behavior:none;
}

body{
  /* prevents double-tap zoom issues better than JS alone */
  touch-action: manipulation;
}

.stage{
  display:flex;
  justify-content:center;
  align-items:center;
  padding: 86px 12px 12px;
}

#gameCanvas{
  width: min(92vw, 420px);
  height: auto;
  border-radius: 18px;
  background:#000;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  touch-action: none; /* IMPORTANT: canvas should not scroll/zoom */
}

.topHud{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 12px;
  display:flex;
  gap:12px;
  align-items:flex-start;
  justify-content:space-between;
  background: linear-gradient(to bottom, rgba(11,16,32,0.95), rgba(11,16,32,0.55));
  backdrop-filter: blur(8px);
  z-index: 20;
}

.hudLeft{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.hudRow{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  font-size: 13px;
}

.label{ color: var(--muted); }
.sep{ color: rgba(255,255,255,0.25); }

.hudRight{ display:flex; gap:8px; }

.btn{
  border:0;
  color: var(--text);
  background: var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor:pointer;
}
.btn.secondary{ background: rgba(255,255,255,0.10); }
.btn.big{ width: 100%; padding: 12px 14px; font-size: 16px; }
.btn.small{ padding: 9px 10px; border-radius: 10px; }
.btn.tiny{ padding: 6px 8px; border-radius: 10px; font-size: 12px; }

.menu{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 90px 14px 14px;
  z-index: 30;
}

.card{
  width: min(520px, 96vw);
  background: linear-gradient(180deg, rgba(18,26,51,0.95), rgba(15,23,48,0.95));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.45);
}

.title{ font-size: 28px; font-weight: 900; letter-spacing: 0.2px; }
.subtitle{ color: var(--muted); margin-top: 4px; }

.menuButtons{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.miniInfo{ margin-top: 14px; }
.miniBox{
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 12px;
}
.miniLabel{ color: var(--muted); font-weight:700; margin-bottom: 8px; }

.leaderboard{
  margin:0;
  padding-left: 18px;
  color: var(--text);
}

.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px;
  z-index: 60;
  font-weight:700;
}
.hidden{ display:none !important; }

/* Panels */
.panel{
  position: fixed;
  inset: 0;
  padding: 90px 14px 14px;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  z-index: 40;
}

.panelCard{
  width: min(560px, 96vw);
  background: rgba(18,26,51,0.96);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.45);
  overflow: hidden;
}

.panelHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 12px;
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.panelTitle{ font-weight: 900; font-size: 18px; }

.panelBody{
  padding: 12px;
  max-height: calc(100vh - 140px);
  overflow: auto; /* FIX: settings can scroll now */
  -webkit-overflow-scrolling: touch;
}

.group{
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 12px;
  margin-top: 10px;
}
.groupTitle{
  font-weight: 900;
  margin-bottom: 10px;
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.col{ flex:1; min-width: 120px; }

.select{
  width:100%;
  padding: 10px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  font-weight: 700;
}

.color{
  width:100%;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.25);
}

.preview{
  width:100%;
  height:auto;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.25);
}

.switch{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.switchText{ font-weight: 800; color: var(--text); }

.shopList{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
@media (max-width: 480px){
  .shopList{ grid-template-columns: 1fr; }
}

.hint{
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

/* Overlay */
.overlay{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 90px 14px 14px;
  background: rgba(0,0,0,0.35);
  z-index: 70;
}
.overlayCard{
  width: min(520px, 96vw);
  background: rgba(18,26,51,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 12px 60px rgba(0,0,0,0.6);
}
.overlayTitle{ font-size: 22px; font-weight: 900; }
.overlaySubtitle{ margin-top: 6px; color: var(--muted); }
.overlayButtons{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

/* Splash */
.splash{
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(45,125,255,0.35), transparent 45%),
              radial-gradient(circle at 70% 80%, rgba(0,255,224,0.18), transparent 45%),
              var(--bg);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 20px;
  z-index: 999;
}
.splashCard{
  width: min(480px, 95vw);
  background: rgba(18,26,51,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 18px 70px rgba(0,0,0,0.65);
}
.splashTitle{ font-size: 26px; font-weight: 900; }
.splashSub{ margin-top: 6px; color: var(--muted); }
.splashBar{
  margin-top: 12px;
  height: 10px;
  border-radius: 99px;
  background: rgba(255,255,255,0.10);
  overflow:hidden;
}
.splashFill{
  height:100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.splashVersion{
  margin-top: 10px;
  color: rgba(255,255,255,0.7);
  font-weight: 800;
  font-size: 12px;
}
