@font-face {
  font-family: "Titan One";
  src: url("/fonts/TitanOne-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #e0e5ec;
  --dark: #b8bec9;
  --light: #ffffff;
  --ink: #3d4457;
  --purple: #9945ff;
  --green: #14f195;
  --red: #ff4d6d;
  --out: 9px 9px 18px var(--dark), -9px -9px 18px var(--light);
  --out-sm: 5px 5px 10px var(--dark), -5px -5px 10px var(--light);
  --in: inset 6px 6px 12px var(--dark), inset -6px -6px 12px var(--light);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "Titan One", "Arial Black", sans-serif;
  color: var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ---------- shared bits ---------- */

.pill {
  background: var(--bg);
  box-shadow: var(--out-sm);
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: 1px;
}

.panel {
  background: var(--bg);
  box-shadow: var(--out);
  border-radius: 28px;
  padding: 22px;
}

.btn {
  background: var(--bg);
  box-shadow: var(--out-sm);
  border: none;
  border-radius: 20px;
  font-family: inherit;
  font-size: 22px;
  color: var(--ink);
  padding: 14px 34px;
  letter-spacing: 2px;
}

.clicky { cursor: pointer; transition: transform 0.06s; }
.clicky:active { box-shadow: var(--in); transform: scale(0.97); }

.tag { font-size: 14px; letter-spacing: 2px; opacity: 0.55; }
.bignum { font-size: 44px; letter-spacing: 1px; margin: 10px 0 16px; }
.green { color: #0cab69; }
.dim { opacity: 0.6; }
.row { display: flex; gap: 16px; justify-content: center; }
.hint { min-height: 22px; font-size: 13px; opacity: 0.5; letter-spacing: 1px; }

/* ---------- menu ---------- */

#menu {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px 18px;
  gap: 22px;
  background: radial-gradient(circle at 50% 30%, #e8edf4cc, #e0e5ecee);
}

#logo {
  margin-top: 4vh;
  font-size: clamp(44px, 11vw, 84px);
  letter-spacing: 3px;
  background: linear-gradient(100deg, var(--purple) 15%, #5fd0f5 50%, var(--green) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(3px 5px 0px #b9bfca) drop-shadow(-2px -2px 0 #ffffffaa);
}

#walletBtn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  font-size: 14px;
  color: var(--purple);
}

#tabs {
  display: flex;
  gap: 14px;
  background: var(--bg);
  box-shadow: var(--in);
  border-radius: 999px;
  padding: 8px;
}

.tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: clamp(14px, 4vw, 18px);
  letter-spacing: 1.5px;
  color: var(--ink);
  opacity: 0.45;
  border-radius: 999px;
  padding: 10px 22px;
}

.tab.on {
  opacity: 1;
  background: var(--bg);
  box-shadow: var(--out-sm);
  color: var(--purple);
}

.page { display: none; flex-direction: column; align-items: center; gap: 20px; }
.page.on { display: flex; }

#playBtn {
  width: clamp(180px, 46vw, 230px);
  height: clamp(180px, 46vw, 230px);
  border-radius: 50%;
  border: none;
  background: var(--bg);
  box-shadow: var(--out);
  font-family: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 2vh;
}

#playLabel {
  font-size: clamp(34px, 9vw, 44px);
  letter-spacing: 2px;
  background: linear-gradient(100deg, var(--purple), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.fee {
  font-size: 18px;
  color: var(--ink);
  opacity: 0.55;
}

/* rewards */
.reward { text-align: center; min-width: min(320px, 84vw); }
.statrow { display: flex; gap: 12px; }
.statrow .pill b { color: var(--purple); }

/* leaderboard */
.board {
  min-width: min(360px, 88vw);
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lbrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: var(--out-sm);
}

.lbrow .rank { width: 34px; font-size: 18px; }
.lbrow .name { flex: 1; letter-spacing: 1px; }
.lbrow .profit { color: #0cab69; }
.lbrow .profit.neg { color: var(--red); }
.lbrow .kills { opacity: 0.5; font-size: 13px; }

/* ---------- HUD ---------- */

#hud { display: none; pointer-events: none; }

#hudBal {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  font-size: 20px;
  color: var(--purple);
}

#hudLb {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0.9;
  min-width: 130px;
}

#hudLb .r { display: flex; justify-content: space-between; gap: 10px; margin: 3px 0; }
#hudLb .r.me { color: var(--purple); }

#boostBtn {
  display: none;
  position: fixed;
  right: 26px;
  bottom: max(26px, env(safe-area-inset-bottom));
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  box-shadow: var(--out);
  font-size: 34px;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

#boostBtn:active { box-shadow: var(--in); }

#joystick {
  display: none;
  position: fixed;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  box-shadow: var(--in);
  background: #dde3ec88;
  z-index: 4;
  pointer-events: none;
}

#joyknob {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--out-sm);
}

/* ---------- modals ---------- */

.modalWrap {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #e0e5ecbb;
  backdrop-filter: blur(4px);
  z-index: 10;
}

.modalWrap.on { display: flex; }

.modal {
  text-align: center;
  min-width: min(300px, 80vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.modal .btn { font-size: 28px; width: 84px; }

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 6px solid #c9d0dc;
  border-top-color: var(--purple);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--bg);
  box-shadow: var(--out);
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 15px;
  letter-spacing: 1px;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  z-index: 20;
  max-width: 86vw;
  text-align: center;
}

#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { color: var(--red); }
#toast.good { color: #0cab69; }
