:root {
  --pink: #ff86bb; --pinkD: #b03f78; --mint: #7fdcbc; --lav: #c3b0ff; --butter: #ffe08a; --ink: #6b2d55;
  --o: #a8406f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; touch-action: none;
  user-select: none; -webkit-user-select: none;
  background: #f4d2e8 url(../assets/sky-bg.webp) center / cover no-repeat;
  color: #fff; font-weight: 900;
}
#gl, #hud { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#hud { pointer-events: none; z-index: 2; }
.screen { position: fixed; inset: 0; display: none; z-index: 5; }
.screen.on { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { -webkit-user-drag: none; }

.ol {
  color: #fff;
  text-shadow: 2px 0 var(--o), -2px 0 var(--o), 0 2px var(--o), 0 -2px var(--o),
    1.5px 1.5px var(--o), -1.5px 1.5px var(--o), 1.5px -1.5px var(--o), -1.5px -1.5px var(--o),
    0 4px 0 rgba(107, 45, 85, .55);
}

/* 9-slice frames. The slices are in picture pixels (set from the pictures' real size by ui.js: --pS, --bSx, --bSy, --bR),
   and every corner is drawn at the same scale across and down, so corners keep their shape; only edges and middles stretch.
   --ph / --bh: the drawn frame size of one element (CSS px). */
.panel {
  --ph: 20px;
  border-style: solid; border-color: transparent; border-width: var(--ph);
  border-image-source: url(../assets/ui-panel.webp);
  border-image-slice: var(--pS, 18%) fill;
  border-image-width: var(--ph);
  border-image-repeat: stretch;
}
.btn {
  --bh: 16px; --bw: calc(var(--bh) * var(--bR, .93));
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-style: solid; border-color: transparent; border-width: var(--bh) var(--bw);
  border-image-source: url(../assets/ui-button.webp);
  border-image-slice: var(--bSy, 42%) var(--bSx, 26%) fill;
  border-image-width: var(--bh) var(--bw);
  border-image-repeat: stretch;
  padding: 0 12px; min-height: 56px; min-width: 56px; font-size: 20px; line-height: 1.15; letter-spacing: .02em; text-align: center;
  transition: transform .12s cubic-bezier(.3,1.6,.5,1), filter .15s;
  --o: #c4632a;
}
.btn img { height: 30px; width: auto; }
.btn:active { transform: scale(.9); }
.btn.alt { filter: hue-rotate(-60deg) saturate(1.1); --o: #a8406f; }
.btn.gray { filter: grayscale(.85) brightness(1.05); --o: #6b5d68; }
.btn.small { --bh: 13px; min-height: 46px; font-size: 16px; padding: 0 8px; }
.btn.small img { height: 26px; }
.focus, .btn.focus, .boost.focus, .roundBtn.focus, .cornerBtn.focus { transform: scale(1.08); filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 3px #ff6fae); }
.btn.alt.focus { filter: hue-rotate(-60deg) drop-shadow(0 0 8px #fff); }

/* ---------- title ---------- */
#scr-title { background: #f6cfe3; overflow: hidden; }
#scr-title .cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#logo { position: absolute; left: 50%; top: 9%; width: 84%; max-height: 30%; object-fit: contain;
  transform: translateX(-50%); filter: drop-shadow(0 6px 0 rgba(120, 40, 90, .25)); }
#logo.enter { animation: logoIn .65s cubic-bezier(.25,1.6,.45,1) both, logoFloat 3.2s ease-in-out .7s infinite; }
@keyframes logoIn { from { transform: translateX(-50%) scale(.3) rotate(-8deg); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes logoFloat { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-7px); } }
#tapPrompt { position: absolute; left: 10%; right: 10%; bottom: 11%; text-align: center; font-size: 24px; animation: pulse 1.4s ease-in-out infinite; padding: 0 16px; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.07); opacity: .75; } }
.cornerBtn { position: absolute; top: max(10px, env(safe-area-inset-top)); height: 48px; display: flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .42); border-radius: 26px; padding: 0 14px 0 6px; box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 3px 8px rgba(120, 40, 90, .2);
  font-size: 15px; transition: transform .12s; }
.cornerBtn:active { transform: scale(.9); }
.cornerBtn img { width: 38px; height: 38px; object-fit: contain; }
.cornerBtn.left { left: 10px; }
.cornerBtn.right { right: 10px; }
.cornerBtn.round { width: 48px; padding: 0; justify-content: center; }
.cornerBtn .key { position: absolute; bottom: -18px; font-style: normal; font-size: 11px; color: #8a3b66; background: rgba(255,255,255,.7); border-radius: 6px; padding: 0 5px; left: 50%; transform: translateX(-50%); display: none; }
body.kb .cornerBtn .key { display: block; }

/* ---------- prep ---------- */
.topbar { position: absolute; left: 10px; right: 10px; top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; }
.roundBtn { width: 50px; height: 50px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffc2dc, #ff7fb4 70%); box-shadow: inset 0 -4px 0 rgba(160, 40, 100, .35), inset 0 3px 0 rgba(255,255,255,.6), 0 4px 10px rgba(120, 40, 90, .25); display: flex; align-items: center; justify-content: center; transition: transform .12s; flex: none; }
.roundBtn:active { transform: scale(.88); }
.roundBtn svg { width: 26px; height: 26px; }
.pill { height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 14px 0 4px; border-radius: 24px; background: rgba(255, 255, 255, .5); box-shadow: inset 0 2px 0 rgba(255,255,255,.8), 0 3px 8px rgba(120, 40, 90, .18); font-size: 20px; }
.pill img { width: 38px; height: 38px; object-fit: contain; }
#btnShop { margin-left: auto; }
#charName { position: absolute; left: 0; right: 0; top: 15%; text-align: center; font-size: 30px; }
#charName.pop { animation: pop .3s cubic-bezier(.3,1.7,.5,1); }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }
.arrow { position: absolute; top: 42%; }
.arrow.left { left: 12px; } .arrow.right { right: 12px; }
#boosts { position: absolute; left: 50%; transform: translateX(-50%); bottom: 26%; display: flex; gap: 10px; }
.boost { position: relative; width: 98px; height: 104px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px;
  background: linear-gradient(#fff9fd, #ffe1ef); box-shadow: inset 0 -5px 0 rgba(220, 120, 170, .35), inset 0 3px 0 #fff, 0 5px 12px rgba(120, 40, 90, .22); border: 3px solid #ffb2d3;
  transition: transform .12s cubic-bezier(.3,1.6,.5,1); --o: #a8406f; }
.boost:active { transform: scale(.9); }
.boost img { width: 50px; height: 50px; object-fit: contain; }
.boost .bname { font-size: 13px; line-height: 1.1; white-space: nowrap; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.boost .bstate { font-size: 12px; margin-top: 2px; opacity: .95; white-space: nowrap; display: flex; align-items: center; gap: 2px; }
.boost .bstate img { width: 16px; height: 16px; }
.boost .bcount { position: absolute; top: -8px; right: -8px; min-width: 28px; height: 28px; border-radius: 14px; background: #ff6fae; color: #fff; font-size: 15px; display: flex; align-items: center; justify-content: center; padding: 0 6px; box-shadow: 0 2px 0 #b03f78; }
.boost.on { border-color: #57d3a6; background: linear-gradient(#f2fff9, #c9f5e3); }
.boost.on::after { content: ""; position: absolute; left: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: #57d3a6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; }
.boost.hide { display: none; }
#btnRun { --bh: 22px; position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(10% + 54px); width: min(74%, 340px); min-height: 76px; font-size: 32px; }
#btnRun:active { transform: translateX(-50%) scale(.9); }
#btnRun.focus { transform: translateX(-50%) scale(1.06); }
#btnOnline2 { --bh: 14px; position: absolute; left: 50%; transform: translateX(-50%); bottom: 4%; width: min(60%, 280px); font-size: 17px; min-height: 50px; white-space: nowrap; }
#btnOnline2:active { transform: translateX(-50%) scale(.9); }
#btnOnline2.focus { transform: translateX(-50%) scale(1.06); }
.enter-up { animation: enterUp .35s cubic-bezier(.3,1.5,.5,1) both; }
@keyframes enterUp { from { opacity: 0; translate: 0 40px; } to { opacity: 1; translate: 0 0; } }

/* ---------- HUD ---------- */
#scr-hud { pointer-events: none; }
#scoreBox { --ph: 16px; position: absolute; left: 8px; top: max(8px, env(safe-area-inset-top)); min-width: 138px; padding: 2px 8px; }
#scoreNum { font-size: 30px; line-height: 1; --o: #b03f78; }
#scoreBox .row { display: flex; align-items: center; gap: 4px; font-size: 17px; margin-top: 2px; }
#scoreBox .row img { width: 24px; height: 24px; }
#distNum { margin-left: 8px; font-size: 14px; opacity: .95; }
#buffs { display: flex; gap: 6px; margin-top: 2px; }
#buffs .buff { display: flex; align-items: center; font-size: 13px; }
#buffs .buff img { width: 22px; height: 22px; }
#standings { position: absolute; left: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 110px); min-width: 138px; max-width: 200px; display: none; --ph: 14px; padding: 2px 6px; font-size: 14px; }
#standings .st { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
#standings .st span:first-child { overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
#standings .st.me { color: #fff6a0; }
#standings .st.dead { opacity: .55; }
#countdown { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: 110px; display: none; --o: #b03f78; }
#countdown.pop { animation: cd .9s ease-out both; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 20% { transform: scale(.9); opacity: 1; } 35% { transform: scale(1.05); } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
#tip { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); width: 88%; text-align: center; font-size: 17px; line-height: 1.35; display: none;
  background: rgba(176, 63, 120, .55); border-radius: 18px; padding: 8px 12px; }

#subtitle { position: fixed; left: 50%; top: 16%; transform: translateX(-50%); z-index: 30; max-width: 88%; text-align: center; font-size: 17px; line-height: 1.35;
  background: rgba(80, 30, 65, .62); border-radius: 16px; padding: 6px 14px; display: none; color: #fff; font-weight: 800; }
#banner { position: fixed; left: 0; right: 0; top: 36%; z-index: 25; text-align: center; font-size: 52px; display: none; pointer-events: none; --o: #b03f78; padding: 0 10px; }
#banner.slam { display: block; animation: slam .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes slam { from { transform: scale(3) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(-4deg); opacity: 1; } }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; background: rgba(90, 30, 70, .35); }
.modal.on { display: flex; }
.modal .card { --ph: 22px; width: min(88%, 380px); max-height: 92%; overflow: hidden; display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 10px 12px; animation: popIn .28s cubic-bezier(.3,1.6,.5,1) both; color: #6b2d55; }
@keyframes popIn { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.card .ttl { text-align: center; font-size: 28px; --o: #b03f78; }
.btn.wide { width: 100%; font-size: 18px; }
.btn .price { display: inline-flex; align-items: center; gap: 2px; font-style: normal; margin-left: 4px; }
.btn .price img { height: 22px; }
#reviveRing { position: relative; width: 92px; height: 92px; margin: 0 auto; }
#reviveRing svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#reviveRing .trk { fill: rgba(255, 255, 255, .6); stroke: #ffd2e5; stroke-width: 10; }
#reviveArc { fill: none; stroke: #ff6fae; stroke-width: 10; stroke-linecap: round; stroke-dasharray: 264; }
#reviveSec { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 36px; }
#waitList, #resList { display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .7); border-radius: 14px; padding: 6px 10px; font-size: 17px; color: #6b2d55; }
.prow .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .ok { color: #2fae7f; }
.prow .rk { width: 30px; height: 30px; border-radius: 50%; background: #ffb4d4; color: #fff; display: flex; align-items: center; justify-content: center; }
.prow.me { background: #fff3b8; }
#waitCount { text-align: center; font-size: 16px; }
.helpRow { display: flex; align-items: center; gap: 10px; }
.helpRow img { width: 46px; height: 46px; flex: none; }
.helpRow p, .helpTxt { margin: 0; font-size: 15px; line-height: 1.35; color: #6b2d55; font-weight: 800; }

/* ---------- intro ---------- */
#intro { background: #f6cfe3 url(../assets/cover-bg.webp) center / cover; z-index: 40; }
#introVid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#introSkip { position: absolute; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 15; transition: opacity .25s; }
#fade { position: fixed; inset: 0; background: #ffd7ea; opacity: 0; pointer-events: none; z-index: 50; transition: opacity .22s; }
#fade.on { opacity: 1; }
