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

html, body {
  height: 100%;
  background: #14161c;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#wrap {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  touch-action: none;
  border-radius: 10px;
  box-shadow: 0 0 60px rgba(0,0,0,.6);
  background: #3a3f4a;
}

#muteBtn, #pauseBtn {
  position: absolute;
  right: 12px;
  z-index: 30;
  width: 44px;
  height: 44px;
  font-size: 20px;
  border: none;
  border-radius: 10px;
  background: rgba(0,0,0,.45);
  color: #fff;
  cursor: pointer;
}
#muteBtn { bottom: 12px; }
#pauseBtn { bottom: 64px; }
#muteBtn, #pauseBtn { display: flex; align-items: center; justify-content: center; }
#muteBtn:hover, #pauseBtn:hover { background: rgba(0,0,0,.7); }
.tips li svg { vertical-align: -3px; margin-right: 2px; }
.buyBtn svg, .miniBtn svg, .diffBtn svg { vertical-align: -2px; }

/* ---------- toasts (achievement unlocks) ---------- */
#toasts {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2a3040, #1c212e);
  border: 1px solid rgba(255,209,102,.6);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: toastIn .3s ease-out, toastOut .4s ease-in 2.8s forwards;
}
.toast small { display: block; font-weight: 600; color: #b9c3d6; font-size: 11px; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, .72);
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
#lbOverlay, #achOverlay { z-index: 25; }

.panel {
  text-align: center;
  color: #fff;
  padding: 24px 24px;
  border-radius: 18px;
  background: rgba(24, 28, 40, .95);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  max-width: 360px;
  max-height: 92vh;
  max-height: calc(100dvh - 24px);   /* respects mobile browser chrome */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;                          /* Firefox */
  scrollbar-color: rgba(255,255,255,.22) transparent;
}

/* slim custom scrollbars everywhere — no default chrome */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.32); }
::-webkit-scrollbar-corner { background: transparent; }
.panel.wide { width: 350px; }

.panel h1 {
  font-size: 32px;
  letter-spacing: 2px;
  font-weight: 900;
  background: linear-gradient(180deg, #7ecbff, #2f7bff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.panel h1.dead {
  background: linear-gradient(180deg, #ff9d7e, #ff2f2f);
  -webkit-background-clip: text;
  background-clip: text;
}
.panel h2 { font-size: 20px; font-weight: 900; margin-bottom: 12px; letter-spacing: 1px; }

.panel .tag { color: #b9c3d6; font-size: 14px; margin-bottom: 12px; line-height: 1.4; }

.tips {
  list-style: none;
  text-align: left;
  font-size: 12.5px;
  color: #cdd6e6;
  margin: 0 0 14px;
  line-height: 1.8;
}
.tips .good { color: #6db4ff; }
.tips .bad  { color: #ff6d6d; }

.bigBtn {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 13px 36px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #35c163, #1e9948);
  box-shadow: 0 6px 0 #14713366, 0 10px 24px rgba(0,0,0,.4);
  transition: transform .06s;
}
.bigBtn:hover { filter: brightness(1.08); }
.bigBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 #14713366; }

.btnRow { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.miniBtn {
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  cursor: pointer;
  color: #dfe6f2;
  background: rgba(255,255,255,.07);
}
.miniBtn:hover { background: rgba(255,255,255,.15); }
.closeBtn { margin-top: 14px; }

.hint { margin-top: 12px; font-size: 11.5px; color: #7a8499; line-height: 1.6; }
.legalLinks { margin-top: 6px; }
.legalLinks a { color: #7a8499; text-decoration: underline; }
.legalLinks a:hover { color: #b9c3d6; }

/* ---------- difficulty ---------- */
#diffRow { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.diffBtn {
  flex: 1;
  padding: 7px 2px;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: #cdd6e6;
  cursor: pointer;
  line-height: 1.3;
}
.diffBtn small { display: block; font-weight: 600; font-size: 8.5px; color: #8f9ab0; }
.diffBtn.sel { border-color: #35c163; background: rgba(53,193,99,.18); color: #fff; }
.diffBtn:hover { background: rgba(255,255,255,.14); }

/* ---------- skins ---------- */
.skinLabel { font-size: 10px; font-weight: 800; letter-spacing: 2px; color: #7a8499; margin-bottom: 6px; }
#skinRow {
  display: flex;
  flex-wrap: wrap;            /* wrap into rows — never overflow the panel */
  gap: 9px;
  justify-content: center;
  margin-bottom: 16px;
  max-width: 100%;
}
.skinDot {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.skinDot.sel { border-color: #fff; box-shadow: 0 0 10px rgba(255,255,255,.5); }
.skinDot.locked { opacity: .38; cursor: default; }

/* ---------- tables ---------- */
.lbTable { width: 100%; border-collapse: collapse; font-size: 13px; }
.lbTable th {
  font-size: 10px; letter-spacing: 1px; color: #7a8499;
  padding: 4px 6px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.1);
}
.lbTable td { padding: 6px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.05); }
.lbTable td.num, .lbTable th.num { text-align: right; }
.lbTable tr.me td { background: rgba(53,193,99,.15); font-weight: 800; }
.lbTable .rank { color: #ffd166; font-weight: 900; }
.empty { color: #7a8499; font-size: 13px; padding: 16px 0; }

.achRow {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-align: left;
}
.achRow .ico { font-size: 20px; width: 28px; text-align: center; }
.achRow .nm { font-weight: 800; font-size: 13px; }
.achRow .ds { font-size: 11px; color: #9aa5ba; }
.achRow.locked { opacity: .45; }
.achRow .st { margin-left: auto; font-size: 15px; }

/* ---------- shop ---------- */
#walletLine { font-size: 17px; font-weight: 800; margin-bottom: 10px; color: #ffd166; }
.shopSec {
  font-size: 10px; font-weight: 800; letter-spacing: 2px; color: #7a8499;
  text-align: left; margin: 12px 0 4px; border-bottom: 1px solid rgba(255,255,255,.08); padding-bottom: 4px;
}
.shopSec small { letter-spacing: 0; font-weight: 600; }
.shopRow {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.shopRow .ico { font-size: 19px; width: 26px; text-align: center; }
.shopRow .dot {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px;
  border: 2px solid rgba(255,255,255,.25);
}
.shopRow .nm { font-size: 13px; font-weight: 700; text-align: left; flex: 1; }
.buyBtn {
  font-size: 12px; font-weight: 800;
  padding: 6px 12px;
  border: none; border-radius: 8px; cursor: pointer;
  color: #fff; background: linear-gradient(180deg, #35c163, #1e9948);
  min-width: 74px;
}
.buyBtn:disabled { opacity: .4; cursor: default; }
.buyBtn.armed { background: rgba(255,255,255,.12); }

#nameInput {
  width: 170px;
  margin: 6px 0 2px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  color: #fff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px;
  outline: none;
}
#nameInput:focus { border-color: #35c163; }

#overStats { margin: 2px 0 12px; color: #dfe6f2; }
.bigDist { font-size: 44px; font-weight: 900; color: #fff; line-height: 1; margin: 2px 0 12px; }
.bigDist span { font-size: 20px; color: #7a8499; font-weight: 800; margin-left: 2px; }
.chipRow { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 11px; font-weight: 800; color: #dfe6f2;
  white-space: nowrap;
}
.statGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 12px; }
.statCard {
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 9px 2px 7px;
}
.statCard svg { display: block; margin: 0 auto 4px; }
.statCard .v { font-size: 17px; font-weight: 900; color: #fff; line-height: 1.1; }
.statCard .l { font-size: 8.5px; font-weight: 800; letter-spacing: 1px; color: #7a8499; margin-top: 2px; }
.bestLine { font-size: 12px; color: #aab4c8; }
#overStats .newbest {
  display: inline-block;
  margin-bottom: 4px;
  padding: 4px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb300, #ff6a00);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  animation: pulse 1s infinite alternate;
}
#overLb { margin: 14px 0 4px; }
.bigBtn.fullW { width: 100%; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* ---------- mobile ---------- */
button, .skinDot, .diffBtn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (max-width: 430px), (max-height: 780px) {
  .panel { padding: 16px 14px; max-width: 94vw; }
  .panel h1 { font-size: 25px; margin-bottom: 5px; }
  .panel .tag { font-size: 12.5px; margin-bottom: 8px; }
  .tips { font-size: 11px; line-height: 1.55; margin-bottom: 10px; }
  .bigBtn { padding: 12px 24px; font-size: 17px; }
  .bigDist { font-size: 34px; margin-bottom: 8px; }
  .statCard .v { font-size: 15px; }
  .hint { margin-top: 8px; }
  #skinRow { margin-bottom: 10px; }
  #diffRow { margin-bottom: 10px; }
  .btnRow { margin-top: 8px; }
}
