/* =========================================================
   SUGAR RUSH — escenario, HUD y pantallas (estilo golosina)
   El escenario mide 960x540 y se escala para entrar en la ventana.
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root { --pink: #ff5ab0; --pink2: #ff9ad0; --mint: #7fe0c0; --ink: #4a1a52; --cream: #fff4fb; }
html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: linear-gradient(180deg, #ffb8e0, #c9a8ff);
    font-family: 'Fredoka', 'Trebuchet MS', sans-serif; font-weight: 700;
    color: var(--ink);
    -webkit-user-select: none; user-select: none; touch-action: none;
}
button { font-family: inherit; font-weight: 700; cursor: pointer; }

#stage {
    position: absolute; left: 50%; top: 50%; width: 960px; height: 540px;
    transform-origin: 50% 50%; overflow: hidden; background: #ffe3f4;
    box-shadow: 0 0 60px rgba(255,90,176,.5); border-radius: 6px;
}
#view { position: absolute; inset: 0; width: 960px; height: 540px; }
#view.glitching { animation: glitchShake .08s linear infinite; }
@keyframes glitchShake { 25% { transform: translate(5px,-3px) skewX(2deg); } 75% { transform: translate(-6px,2px) skewX(-2deg); } }

.back-home {
    position: fixed; left: 10px; top: 8px; z-index: 50; text-decoration: none; font-size: 13px;
    color: #fff; background: rgba(255,90,176,.85); padding: 6px 12px; border-radius: 20px; border: 2px solid #fff;
}
.mute-btn {
    position: fixed; right: 10px; top: 8px; z-index: 50; width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid #fff; background: rgba(255,90,176,.85); font-size: 16px;
}
.credits { position: fixed; right: 10px; bottom: 6px; z-index: 50; font-size: 10px; color: rgba(74,26,82,.7); }

/* ---------------- HUD ---------------- */
.hud { position: absolute; inset: 0; display: none; pointer-events: none; z-index: 20; }
.hud.show { display: block; }
.hud > * { position: absolute; }
.hud-left { left: 14px; top: 12px; }
.hud-pos {
    font-family: 'Lilita One', sans-serif; font-size: 64px; line-height: 1; color: #fff;
    -webkit-text-stroke: 3px var(--pink); paint-order: stroke fill; text-shadow: 0 4px 0 rgba(120,20,90,.4);
}
.hud-pos small { font-size: 28px; }
.hud-lap {
    display: inline-block; margin-top: 4px; font-size: 14px; color: #fff; background: var(--pink);
    padding: 3px 12px; border-radius: 12px; border: 2px solid #fff;
}
.hud-time { left: 400px; top: 44px; font-family: 'Lilita One', sans-serif; font-size: 22px; color: #fff; text-shadow: 0 2px 0 #7a2a8a; }
.board { right: 14px; top: 52px; display: flex; flex-direction: column; gap: 3px; }
.b-row {
    display: flex; align-items: center; gap: 6px; padding: 2px 8px 2px 4px; border-radius: 12px; font-size: 12px; color: #fff;
    background: rgba(74,26,82,.6); min-width: 116px;
}
.b-row.me { background: var(--pink); border: 2px solid #fff; }
.b-row i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; display: block; }
.b-row b { width: 12px; text-align: center; }
.hud-speed {
    right: 14px; bottom: 14px; text-align: right; font-family: 'Lilita One', sans-serif; color: #fff;
    text-shadow: 0 2px 0 #7a2a8a; font-size: 40px; line-height: 1;
}
.hud-speed small { display: block; font-size: 12px; font-family: 'Fredoka'; }
.pause-btn {
    right: 14px; top: 10px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff;
    background: rgba(74,26,82,.7); color: #fff; pointer-events: auto; font-size: 14px; right: 60px;
}

.glitch-btn {
    left: 14px; bottom: 14px; width: 250px; height: 44px;
    border-radius: 22px; border: 3px solid #fff; overflow: hidden; pointer-events: auto;
    background: rgba(74,26,82,.75); color: #fff; font-family: 'Lilita One', sans-serif; font-size: 18px; letter-spacing: 1px;
}
.glitch-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #2ee6ff, #ff3be0); }
.glitch-btn span { position: relative; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.glitch-btn.ready { animation: readyPulse .5s ease-in-out infinite alternate; box-shadow: 0 0 20px #2ee6ff, 0 0 40px #ff3be0; }
@keyframes readyPulse { to { transform: scale(1.07); } }

.touch { left: 0; right: 0; bottom: 0; height: 0; display: none; }
.touch button {
    position: absolute; bottom: 12px; width: 78px; height: 78px; border-radius: 50%; pointer-events: auto;
    background: rgba(255,255,255,.35); border: 3px solid #fff; color: #fff; font-size: 30px; text-shadow: 0 2px 0 #7a2a8a;
}
.touch button.down { background: rgba(255,90,176,.7); }
#tLeft { left: 14px; } #tRight { left: 104px; }
#tBrake { right: 110px; font-size: 14px; width: 62px; height: 62px; bottom: 70px; }
@media (pointer: coarse) { .touch { display: block; } .glitch-btn { bottom: 100px; left: auto; right: 14px; width: 200px; } .glitch-btn.ready { animation: none; } .hud-speed { bottom: 108px; } }

.countdown {
    position: absolute; left: 0; right: 0; top: 120px; text-align: center; z-index: 30; pointer-events: none;
    font-family: 'Lilita One', sans-serif; font-size: 150px; color: #fff; -webkit-text-stroke: 6px var(--pink); paint-order: stroke fill;
    text-shadow: 0 8px 0 rgba(120,20,90,.4);
}
.countdown.pop { animation: pop .9s ease-out; }
@keyframes pop { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: .9; } }
.toast {
    position: absolute; left: 50%; top: 96px; transform: translateX(-50%); z-index: 30; pointer-events: none; display: none;
    font-family: 'Lilita One', sans-serif; font-size: 30px; color: #fff; background: rgba(255,90,176,.9);
    padding: 6px 24px; border-radius: 30px; border: 3px solid #fff; white-space: nowrap;
}
.toast.show { display: block; animation: toastIn .25s ease-out; }
@keyframes toastIn { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

/* ---------------- PANTALLAS ---------------- */
.overlay {
    position: absolute; inset: 0; z-index: 900; display: none; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; text-align: center;
    background: radial-gradient(ellipse at 50% 40%, rgba(255,214,240,.55), rgba(150,60,170,.8));
}
#selectScreen, #resultScreen, #pauseScreen { background: radial-gradient(ellipse at 50% 40%, rgba(255,190,230,.93), rgba(150,60,190,.96)); }
.overlay.show { display: flex; animation: fadeIn .3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } }

.logo-small { font-size: 13px; letter-spacing: 3px; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.logo h1 {
    font-family: 'Lilita One', sans-serif; font-weight: 400; font-size: 120px; line-height: 1; letter-spacing: 2px;
    color: #fff; -webkit-text-stroke: 8px var(--pink); paint-order: stroke fill; text-shadow: 0 10px 0 #8a2a8a;
    transform: rotate(-3deg);
}
.logo h1 span { color: #fff7a8; -webkit-text-stroke-color: #ff8a3a; }
.title-tags { font-size: 40px; display: flex; gap: 14px; }
.title-tags span { animation: bob 1s ease-in-out infinite; }
.title-tags span:nth-child(2n) { animation-delay: -.5s; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(8deg); } }
.help { font-size: 13px; color: #fff; text-shadow: 0 1px 0 var(--ink); }

.big-btn {
    font-family: 'Lilita One', sans-serif; font-size: 34px; letter-spacing: 2px; padding: 8px 40px; color: #fff;
    background: linear-gradient(180deg, #ff9ad0, var(--pink)); border: 4px solid #fff; border-radius: 40px;
    box-shadow: 0 6px 0 #a02a7a, 0 0 24px rgba(255,255,255,.6); text-shadow: 0 2px 0 rgba(120,20,90,.5);
}
.big-btn:hover { filter: brightness(1.1); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #a02a7a; }
.big-btn.small { font-size: 20px; padding: 6px 26px; }
.big-btn.ghost { background: rgba(255,255,255,.5); color: var(--ink); text-shadow: none; box-shadow: 0 5px 0 #a98ac0; }
.row-btns { display: flex; gap: 16px; }

#selectScreen { gap: 8px; padding-top: 28px; }
.sel-title {
    font-family: 'Lilita One', sans-serif; font-weight: 400; font-size: 34px; color: #fff;
    -webkit-text-stroke: 5px var(--pink); paint-order: stroke fill; letter-spacing: 2px;
}
.select-main { display: flex; gap: 12px; align-items: flex-start; }
.driver-grid { display: grid; grid-template-columns: repeat(3, 118px); gap: 8px; max-height: 288px; overflow-y: auto; padding: 4px 6px 4px 4px; touch-action: pan-y; scrollbar-width: thin; }
.card {
    position: relative; width: 118px; height: 138px; border-radius: 16px; border: 4px solid #fff;
    background: linear-gradient(180deg, #fff4fb, #ffd0ec); color: var(--ink); font-size: 14px; padding-bottom: 4px;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; overflow: hidden;
    transition: transform .15s;
}
.card canvas { position: absolute; left: 0; top: -2px; width: 112px; height: 112px; }
.card span { position: relative; }
.card em {
    position: absolute; right: 2px; top: 2px; font-style: normal; font-size: 10px; color: #fff;
    background: linear-gradient(90deg, #2ee6ff, #ff3be0); padding: 1px 6px; border-radius: 8px;
}
.card:hover { transform: translateY(-3px); }
.card.sel { border-color: #ffe93a; box-shadow: 0 0 0 3px var(--pink), 0 0 20px #ffe93a; transform: scale(1.04); }

.detail {
    width: 250px; height: 288px; border-radius: 18px; border: 4px solid #fff; background: rgba(255,244,251,.88);
    display: flex; flex-direction: column; align-items: center; padding: 2px 8px 6px; gap: 2px;
}
#dPreview { width: 200px; height: 150px; margin-top: -4px; }
.d-name { font-family: 'Lilita One', sans-serif; font-size: 20px; color: var(--pink); line-height: 1.1; }
.d-quote { font-size: 12px; opacity: .8; }
.d-stats { width: 100%; margin-top: 2px; }
.st { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 0 6px; }
.st div { display: flex; gap: 3px; }
.st i { width: 18px; height: 9px; border-radius: 5px; background: #e6cfe0; }
.st i.on { background: linear-gradient(90deg, #ff9ad0, var(--pink)); }
.d-power { font-size: 11px; margin-top: 4px; line-height: 1.2; }
.d-power b:first-child { color: #c02ad0; display: block; }

.options { width: 210px; display: flex; flex-direction: column; gap: 4px; }
.opt-title { font-family: 'Lilita One', sans-serif; color: #fff; font-size: 16px; text-shadow: 0 2px 0 var(--ink); letter-spacing: 1px; }
.track-list { display: flex; flex-direction: column; gap: 6px; }
.trk {
    display: grid; grid-template-columns: 34px 1fr; align-items: center; text-align: left; padding: 4px 8px; border-radius: 14px;
    border: 3px solid #fff; background: rgba(255,244,251,.9); color: var(--ink); font-size: 13px; line-height: 1.1;
}
.trk span { grid-row: span 2; font-size: 24px; }
.trk small { font-size: 10px; opacity: .7; }
.trk.locked { opacity: .55; filter: grayscale(.7); }
.big-btn.next { background: linear-gradient(180deg, #ffe66a, #ffb21a); box-shadow: 0 6px 0 #b86a00, 0 0 24px rgba(255,230,120,.8); animation: bob 1s ease-in-out infinite; }
.trk.sel, .diff-list button.sel { border-color: #ffe93a; box-shadow: 0 0 0 3px var(--pink); background: #fff; }
.diff-list { display: flex; gap: 6px; }
.diff-list button { flex: 1; padding: 6px 0; border-radius: 12px; border: 3px solid #fff; background: rgba(255,244,251,.9); color: var(--ink); font-size: 13px; }

.res-title {
    font-family: 'Lilita One', sans-serif; font-size: 56px; color: #fff; -webkit-text-stroke: 6px var(--pink); paint-order: stroke fill;
    text-shadow: 0 6px 0 #8a2a8a;
}
.res-sub { color: #fff; font-size: 16px; text-shadow: 0 2px 0 var(--ink); }
.res-list { display: flex; flex-direction: column; gap: 4px; width: 460px; }
.res-row {
    display: grid; grid-template-columns: 44px 56px 1fr 80px; align-items: center; gap: 6px; padding: 0 12px 0 6px; height: 40px;
    background: rgba(255,244,251,.9); border-radius: 20px; border: 3px solid #fff; font-size: 15px; text-align: left; color: var(--ink);
}
.res-row.me { background: #fff7a8; border-color: var(--pink); }
.res-row canvas { width: 40px; height: 40px; margin-top: -2px; }
.res-n { font-size: 20px; text-align: center; font-family: 'Lilita One'; }
.res-t { text-align: right; font-family: 'Lilita One'; }
.res-best { color: #fff7a8; font-size: 16px; min-height: 20px; text-shadow: 0 2px 0 var(--ink); }

#rotate-hint {
    display: none; position: fixed; inset: 0; z-index: 1000; background: #c9a8ff; color: var(--ink);
    flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 20px;
}
.rotate-phone { font-size: 70px; animation: rot 1.6s ease-in-out infinite; }
@keyframes rot { 50% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 700px) { #rotate-hint { display: flex; } }
