* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #13151c;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas { display: block; touch-action: none; }

#hud {
  position: fixed;
  top: env(safe-area-inset-top, 0); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px; pointer-events: none; z-index: 5;
  color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.hud-right { display: flex; gap: 8px; }
.pill {
  background: rgba(0,0,0,.45); border-radius: 999px;
  padding: 8px 16px; font-size: 17px; font-weight: 700;
  backdrop-filter: blur(4px); line-height: 1; color: #fff;
}
.icon-btn {
  pointer-events: auto; cursor: pointer; border: none;
  font-family: inherit; padding: 8px 12px; font-size: 15px;
}
#levelbar {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
  left: 50%; transform: translateX(-50%);
  width: min(420px, 78vw); height: 13px; border-radius: 999px;
  background: rgba(0,0,0,.5); overflow: hidden; z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
#levelfill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #7c4dff, #b388ff);
  border-radius: 999px; transition: width .2s ease;
}
#leveltag {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0) + 35px);
  left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 12.5px; font-weight: 600; z-index: 5;
  text-shadow: 0 2px 4px rgba(0,0,0,.7);
}
#banner {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%) translateY(-10px);
  z-index: 6; pointer-events: none; text-align: center;
  color: #fff; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 3px 12px rgba(0,0,0,.7);
  opacity: 0; transition: opacity .3s ease, transform .3s ease;
}
#banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#banner .big { font-size: clamp(26px, 7vw, 40px); }
#banner .sub { font-size: 14px; font-weight: 600; color: #ffd54f; margin-top: 4px; }

#overlay {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: safe center; gap: 16px;
  background: rgba(12,14,20,.82); z-index: 10; color: #fff; text-align: center;
  backdrop-filter: blur(6px); padding: 24px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-top: calc(env(safe-area-inset-top, 0) + 24px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 24px);
}
.logo { display: flex; align-items: center; gap: 14px; }
.logo-hole {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #000 0%, #0a0a14 78%, #1c1233 100%);
  border: 3px solid #7c4dff; box-shadow: 0 0 22px rgba(124,77,255,.6);
}
#overlay h1 { font-size: clamp(32px, 8vw, 56px); letter-spacing: 2px; }
#overlay h1 span { color: #b388ff; }
#overlay p { font-size: 15.5px; color: #cfd3e0; max-width: 460px; line-height: 1.5; }
#overlay .stats { font-size: 21px; font-weight: 700; color: #ffd54f; }
.hint { font-size: 12.5px !important; color: #8b90a3 !important; }

.modes { display: flex; gap: 13px; flex-wrap: wrap; justify-content: center; max-width: 600px; }
.mode-card {
  width: 175px; padding: 16px 14px; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.12);
  color: #fff; font-family: inherit; text-align: center;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.mode-card:hover, .mode-card:active { transform: translateY(-3px); border-color: #b388ff; background: rgba(124,77,255,.18); }
.mode-card h3 { font-size: 18px; margin-bottom: 6px; }
.mode-card .desc { font-size: 12.5px; color: #b9bed0; line-height: 1.4; min-height: 3.8em; }
.mode-card .best { font-size: 12px; color: #ffd54f; margin-top: 8px; font-weight: 700; min-height: 1em; }
.mode-card.daily { border-color: rgba(255,213,79,.45); background: rgba(255,213,79,.07); }
.mode-card.daily:hover, .mode-card.daily:active { border-color: #ffd54f; background: rgba(255,213,79,.14); }
.mode-card.daily h3 span { color: #ffd54f; font-size: 14px; }

.btn {
  font-size: 18px; font-weight: 700; padding: 13px 38px;
  border: none; border-radius: 999px; cursor: pointer;
  background: linear-gradient(135deg, #7c4dff, #651fff); color: #fff;
  box-shadow: 0 6px 20px rgba(124,77,255,.45);
  transition: transform .12s ease; font-family: inherit;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: rgba(255,255,255,.1); box-shadow: none; }
.btn.kind { background: linear-gradient(135deg, #66bb6a, #43a047); box-shadow: 0 6px 20px rgba(67,160,71,.4); }
#niceBtn, #doubleBtn { font-size: 15px; padding: 13px 26px; }
.kind-card {
  background: rgba(102,187,106,.1); border: 1.5px solid rgba(102,187,106,.45);
  border-radius: 18px; padding: 26px 22px; width: min(440px, 92vw);
}
.kind-prompt { font-size: 22px; font-weight: 800; line-height: 1.35; color: #fff; }
.kind-sub { font-size: 13px; color: #9aa0b4; max-width: 420px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hidden { display: none !important; }

.coins {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,213,79,.14); border: 1.5px solid rgba(255,213,79,.5);
  color: #ffd54f; font-weight: 800; font-size: 16px;
  padding: 6px 16px; border-radius: 999px;
}

/* Shop + Missions panels */
.panel {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(560px, 92vw);
}
.panel h2 { font-size: 24px; letter-spacing: 1px; }
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; padding: 4px;
}
.skin-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 10px; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.12);
  color: #fff; font-family: inherit; transition: border-color .12s ease, background .12s ease;
}
.skin-card.equipped { border-color: #b388ff; background: rgba(124,77,255,.2); }
.skin-card.locked { opacity: .9; }
.skin-swatch {
  width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #000 0%, var(--inner, #1c1233) 86%, var(--inner, #1c1233) 100%);
  border: 4px solid var(--rim, #7c4dff); box-shadow: 0 0 16px var(--rim, #7c4dff);
}
.skin-card .nm { font-size: 14px; font-weight: 700; }
.skin-card .tag { font-size: 12.5px; font-weight: 700; }
.skin-card .tag.own { color: #9ccc65; }
.skin-card .tag.cost { color: #ffd54f; }
.skin-card .tag.lock { color: #ff8a80; }

.list { display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 4px; }
.mission {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.1);
}
.mission.done { border-color: rgba(156,204,101,.6); background: rgba(156,204,101,.12); }
.mission .info { flex: 1; }
.mission .info .t { font-weight: 700; font-size: 14.5px; }
.mission .info .d { font-size: 12.5px; color: #b9bed0; }
.mission .info .bar { height: 6px; border-radius: 999px; background: rgba(0,0,0,.4); margin-top: 6px; overflow: hidden; }
.mission .info .bar > i { display: block; height: 100%; background: linear-gradient(90deg,#7c4dff,#b388ff); }
.mission .rw { font-size: 13px; font-weight: 800; color: #ffd54f; white-space: nowrap; }
.mission .rw.claimed { color: #9ccc65; }

/* Leaderboard */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tabs.sub { gap: 6px; }
.tab {
  font-family: inherit; cursor: pointer; color: #cfd3e0;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.12);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700;
}
.tabs.sub .tab { padding: 5px 12px; font-size: 12px; }
.tab.active { background: rgba(124,77,255,.25); border-color: #b388ff; color: #fff; }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  border-radius: 12px; background: rgba(255,255,255,.05); border: 1.5px solid rgba(255,255,255,.08);
}
.lb-row.me { border-color: #b388ff; background: rgba(124,77,255,.15); }
.lb-row .rank { width: 28px; font-weight: 800; color: #ffd54f; }
.lb-row .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .sc { font-weight: 800; }
.lb-empty { color: #8b90a3; font-size: 14px; padding: 18px; text-align: center; }

.account {
  display: flex; flex-direction: column; gap: 8px; width: 100%;
  padding: 12px; border-radius: 14px; background: rgba(255,255,255,.05);
  border: 1.5px solid rgba(255,255,255,.1); font-size: 13px;
}
.account .row { display: flex; gap: 8px; }
.account input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 14px;
  padding: 9px 12px; border-radius: 10px; color: #fff;
  background: rgba(0,0,0,.35); border: 1.5px solid rgba(255,255,255,.15);
}
.account input::placeholder { color: #7c8295; }
.account .mini {
  font-weight: 700; font-size: 13px; padding: 9px 14px; border-radius: 10px;
  border: none; cursor: pointer; background: linear-gradient(135deg,#7c4dff,#651fff); color: #fff; font-family: inherit;
}
.account .note { color: #9aa0b4; font-size: 12px; }
.account .note a { color: #b388ff; }

/* Upgrades */
.upg {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 11px 14px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.1);
}
.upg .info { flex: 1; }
.upg .info .t { font-weight: 700; font-size: 14.5px; }
.upg .info .d { font-size: 12px; color: #b9bed0; }
.upg .pips { display: flex; gap: 4px; margin-top: 6px; }
.upg .pips i { width: 16px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); }
.upg .pips i.on { background: linear-gradient(90deg,#7c4dff,#b388ff); }
.upg .buy {
  font-family: inherit; font-weight: 800; font-size: 12.5px; white-space: nowrap;
  padding: 9px 13px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg,#7c4dff,#651fff); color: #fff;
}
.upg .buy.max { background: rgba(156,204,101,.25); color: #9ccc65; cursor: default; }
.upg .buy.cant { opacity: .5; }

/* Campaign: PLAY button + arcade label */
.btn.play {
  font-size: 24px; padding: 16px 64px; letter-spacing: 1px;
  background: linear-gradient(135deg, #b388ff, #7c4dff);
  box-shadow: 0 8px 28px rgba(124,77,255,.5);
}
.arcade-label { font-size: 12px; color: #8b90a3; margin-top: -4px; }
.btn.cash { color: #ffd54f; border: 1.5px solid rgba(255,213,79,.4); }

/* In-level goal HUD (top) */
#goalhud {
  position: fixed; top: calc(env(safe-area-inset-top, 0) + 56px); left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 5; pointer-events: none; flex-wrap: wrap; justify-content: center; max-width: 92vw;
}
.goal-bar {
  position: relative; min-width: 220px; height: 28px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.5); border: 1.5px solid rgba(255,255,255,.18); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.goal-bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg,#7c4dff,#b388ff); transition: width .2s ease; }
.goal-bar.done > i { background: linear-gradient(90deg,#66bb6a,#9ccc65); }
.goal-bar > span { position: relative; font-weight: 800; font-size: 14px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* In-level power bank (bottom) */
#bankhud {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0) + 42px); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 6;
}
.bank-btn {
  position: relative; width: 56px; height: 56px; border-radius: 16px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.25); color: #fff; font-family: inherit;
  font-weight: 800; font-size: 12px; background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
}
.bank-btn .ct {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; border-radius: 999px;
  background: #ffd54f; color: #1a1d26; font-size: 12px; font-weight: 800; line-height: 20px; padding: 0 4px;
}
.bank-btn:disabled { opacity: .35; }

/* Level select */
.bankbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 13px; color: #cfd3e0; }
.bankbar .b { background: rgba(255,255,255,.08); border-radius: 999px; padding: 5px 12px; font-weight: 700; }
.levelgrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: min(560px, 92vw); padding: 4px;
}
.lvl-cell {
  aspect-ratio: 1; border-radius: 14px; cursor: pointer; font-family: inherit; color: #fff;
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.12);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.lvl-cell .num { font-size: 20px; font-weight: 800; }
.lvl-cell .st { font-size: 11px; color: #ffd54f; letter-spacing: 1px; height: 13px; }
.lvl-cell.locked { opacity: .4; cursor: default; }
.lvl-cell.bonus { border-color: rgba(255,213,79,.5); background: rgba(255,213,79,.08); }
.lvl-cell.cleared { border-color: rgba(156,204,101,.4); }
.lvl-cell.next { border-color: #b388ff; box-shadow: 0 0 16px rgba(124,77,255,.4); }

/* Fake cash shop */
.cash-sub { font-size: 12.5px; color: #9aa0b4; margin-top: -6px; }
.cash-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.12);
}
.cash-item.best { border-color: rgba(255,213,79,.55); background: rgba(255,213,79,.08); }
.cash-item .info { flex: 1; }
.cash-item .info .t { font-weight: 800; font-size: 15px; }
.cash-item .info .d { font-size: 12.5px; color: #b9bed0; }
.cash-item .price {
  font-family: inherit; font-weight: 800; font-size: 15px; white-space: nowrap; cursor: pointer;
  padding: 10px 16px; border-radius: 10px; border: none; color: #fff;
  background: linear-gradient(135deg, #43a047, #2e7d32);
}
.cash-item .price small { display: block; font-size: 10px; opacity: .8; font-weight: 600; }

/* Settings */
.settings { display: flex; flex-direction: column; gap: 10px; width: min(420px, 92vw); }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.1);
  font-size: 15px; font-weight: 600;
}
.set-row .sub { font-size: 12px; color: #9aa0b4; font-weight: 400; }
.set-row .label { text-align: left; }
.set-row button {
  font-family: inherit; font-weight: 800; font-size: 14px; cursor: pointer;
  padding: 9px 16px; border-radius: 10px; border: none; color: #fff;
  background: rgba(255,255,255,.12); white-space: nowrap;
}
.set-row button.danger { background: linear-gradient(135deg,#ef5350,#c62828); }
.set-row button.on { background: linear-gradient(135deg,#66bb6a,#43a047); }
.set-note { font-size: 12px; color: #8b90a3; text-align: center; }

/* Stars on level complete */
.stars { font-size: 40px; letter-spacing: 6px; color: #ffd54f; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.reward-line { font-size: 15px; color: #cfd3e0; }
.reward-line b { color: #b388ff; }
