* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; position: fixed; inset: 0;
  background: #14102a; color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#hud {
  position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 28px);
  text-align: center; pointer-events: none; transition: opacity .2s;
}
#score { font-size: 72px; font-weight: 800; line-height: 1; text-shadow: 0 4px 20px rgba(0,0,0,.3); font-variant-numeric: tabular-nums; }
#combo { font-size: 18px; font-weight: 700; margin-top: 6px; min-height: 22px; color: #ffe27a; letter-spacing: 1px; }
#mode-tag { font-size: 12px; font-weight: 700; letter-spacing: 2px; opacity: .7; min-height: 16px; margin-bottom: 4px; }

#flash {
  position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none;
  font-size: 44px; font-weight: 900; letter-spacing: 4px; color: #fff;
  text-shadow: 0 0 18px rgba(255,255,255,.8), 0 0 40px rgba(255,220,120,.7);
  opacity: 0; transform: scale(.6);
}
#flash.go { animation: flash .7s ease-out; }
@keyframes flash {
  0% { opacity: 0; transform: scale(.6); }
  20% { opacity: 1; transform: scale(1.15); }
  45% { transform: scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(1); }
}

#toolbar {
  position: absolute; z-index: 5;
  top: calc(env(safe-area-inset-top) + 10px); right: calc(env(safe-area-inset-right) + 10px);
  display: flex; gap: 8px;
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; font-size: 20px;
  background: rgba(255,255,255,.14); color: #fff; backdrop-filter: blur(6px);
}
.icon-btn.off { opacity: .45; filter: grayscale(1); }

.panel {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(env(safe-area-inset-top) + 20px) 24px calc(env(safe-area-inset-bottom) + 20px);
  text-align: center; opacity: 0; pointer-events: none; transition: opacity .18s;
  background: radial-gradient(ellipse at center, rgba(10,6,30,.25), rgba(10,6,30,.65));
}
.panel.show { opacity: 1; pointer-events: auto; }
h1 { font-size: 56px; font-weight: 900; line-height: .95; letter-spacing: 3px; text-shadow: 0 6px 30px rgba(0,0,0,.35); }
.sub { opacity: .8; font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.modes { display: flex; flex-direction: column; gap: 12px; width: min(320px, 100%); }
.btn {
  border: 0; border-radius: 16px; padding: 16px 20px; font-size: 18px; font-weight: 800;
  background: rgba(255,255,255,.15); color: #fff; backdrop-filter: blur(6px);
  transition: transform .08s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: #fff; color: #1b1440; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.btn.small { padding: 10px 16px; font-size: 15px; }
.bests { display: flex; gap: 22px; justify-content: center; }
.bests > div { display: flex; flex-direction: column; gap: 2px; }
.bests span:last-child { font-size: 24px; font-weight: 800; }
.lbl { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .7; }
.hint { font-size: 13px; opacity: .6; }
.tiny { color: #fff; opacity: .7; font-size: 13px; }

#over-score { font-size: 110px; font-weight: 900; line-height: 1; text-shadow: 0 8px 40px rgba(0,0,0,.35); }
#over-new { font-weight: 900; letter-spacing: 3px; color: #ffe27a; animation: pulse .8s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }
.again { font-size: 16px; font-weight: 700; opacity: .9; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .4; } }

#toast {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 40px); z-index: 10;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: rgba(0,0,0,.75); padding: 10px 18px; border-radius: 20px; font-weight: 600; transition: .25s;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
body.playing #hud { opacity: 1; }
.link-btn { background: none; border: 0; color: #fff; opacity: .6; font-size: 13px; padding: 6px 10px; }
#challenge-banner {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 62px); max-width: calc(100% - 24px);
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 999px;
  background: rgba(255, 226, 122, .95); color: #2a1d00; font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25); pointer-events: none; white-space: nowrap;
  animation: cb-in .35s ease-out;
}
#challenge-banner[hidden] { display: none; }
#cb-text { overflow: hidden; text-overflow: ellipsis; }
#cb-close { pointer-events: auto; border: 0; background: rgba(0,0,0,.12); color: inherit; width: 26px; height: 26px; border-radius: 50%; font-size: 12px; flex: none; }
@keyframes cb-in { from { opacity: 0; transform: translate(-50%, -10px); } }
#over-challenge { font-weight: 800; font-size: 17px; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.12); }
#over-challenge.won { background: rgba(255, 226, 122, .95); color: #2a1d00; }
#lb { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px); background: rgba(8,5,24,.6); }
#lb[hidden] { display: none; }
.lb-card { width: min(420px, 100%); max-height: 100%; display: flex; flex-direction: column; background: #1d1640; border-radius: 20px; padding: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lb-head { display: flex; align-items: center; justify-content: space-between; font-size: 20px; padding: 2px 4px 10px; }
#lb-close { border: 0; background: rgba(255,255,255,.12); color: #fff; width: 34px; height: 34px; border-radius: 50%; font-size: 14px; }
.lb-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.lb-tabs button { flex: 1; border: 0; border-radius: 12px; padding: 9px 6px; font-weight: 700; font-size: 13px; background: rgba(255,255,255,.08); color: #fff; opacity: .7; }
.lb-tabs button.on { background: #fff; color: #1b1440; opacity: 1; }
#lb-list { list-style: none; overflow-y: auto; touch-action: pan-y; flex: 1; min-height: 120px; margin: 0; padding: 0; }
#lb-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,.07); font-variant-numeric: tabular-nums; }
#lb-list li.me { background: rgba(255,226,122,.18); border-radius: 10px; }
#lb-list li.empty { justify-content: center; opacity: .7; border: 0; padding: 24px 0; }
#lb-list .rk { width: 28px; text-align: right; opacity: .6; font-size: 13px; }
#lb-list .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lb-list .sc { font-weight: 800; }
#lb-you { font-size: 13px; opacity: .8; padding: 10px 4px 2px; text-align: center; }
#btn-lb[hidden], #btn-lb-over[hidden], #btn-nick[hidden] { display: none; }
#zone { font-size: 13px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; margin-top: 6px; opacity: 0; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
#zone.go { animation: zone 2.2s ease-out; }
@keyframes zone { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: .95; transform: none; } 70% { opacity: .95; } 100% { opacity: 0; } }
/* skins */
.menu-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#btn-skins[hidden] { display: none; }
#skins { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 16px) 12px calc(env(safe-area-inset-bottom) + 16px); background: rgba(8,5,24,.6); }
#skins[hidden] { display: none; }
.skins-card { width: min(480px, 100%); }
#skins-count { margin-left: auto; margin-right: 10px; font-size: 12px; font-weight: 600; opacity: .7; }
#skins-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; overflow-y: auto; touch-action: pan-y; padding: 2px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border-radius: 14px; border: 2px solid transparent; background: rgba(255,255,255,.07); color: #fff; font: inherit; text-align: center; }
.skin canvas { position: static; inset: auto; width: 84px; height: 84px; display: block; }
.skin.on { border-color: #ffe27a; background: rgba(255,226,122,.12); }
.skin.locked canvas { filter: grayscale(.85) brightness(.7); opacity: .75; }
.skin.nope { animation: nope .35s; }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.sk-name { font-weight: 800; font-size: 14px; }
.sk-status { font-size: 11px; opacity: .85; line-height: 1.3; width: 100%; }
.skin.on .sk-status { color: #ffe27a; font-weight: 700; opacity: 1; }
.sk-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.15); margin: 5px 4px 2px; overflow: hidden; }
.sk-bar i { display: block; height: 100%; background: #ffe27a; border-radius: 3px; }
.sk-prog { font-variant-numeric: tabular-nums; opacity: .8; }
#over-unlock { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; padding: 10px 12px 10px 16px; border-radius: 16px; background: linear-gradient(135deg, #ffe27a, #ff9ecb); color: #2a1240; font-weight: 800; box-shadow: 0 8px 30px rgba(255,180,200,.35); max-width: min(360px, 100%); }
#over-unlock[hidden] { display: none; }
#over-unlock .btn.small { background: #2a1240; color: #fff; padding: 8px 12px; font-size: 13px; }
#over-unlock.pop { animation: unlock-pop .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes unlock-pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
