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

:root {
    --frame-bottom: 0px;
    --frame-left: 0px;
    --frame-right: 0px;
    --ink: #0b1a2b;
    --orange: #f28c00;
    --card: rgba(6, 14, 30, .62);
}
html, body { height: 100%; }
/* Inside the site iframe a fixed footer bar (~40px) covers the bottom; the site hides it when height <= 400px. */
html.in-frame { --frame-bottom: 44px; }
@media (max-height: 400px) { html.in-frame { --frame-bottom: 0px; } }

body {
    font-family: Arial, Helvetica, sans-serif; color: #fff; overflow: hidden; user-select: none; -webkit-user-select: none;
    background: radial-gradient(1200px 700px at 50% 25%, #1b3158 0%, #0a1430 55%, #050a18 100%);
}
#app {
    position: relative; z-index: 1;
    height: calc(100vh - var(--frame-bottom));
    height: calc(100dvh - var(--frame-bottom));
    padding: 0 var(--frame-right) 0 var(--frame-left);
    display: flex; justify-content: center;
}
#stage {
    position: relative; width: 100%; max-width: 480px; height: 100%; overflow: hidden; background: #0b1a2b;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .18), 0 20px 70px rgba(0, 0, 0, .6);
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen { display: none; position: absolute; inset: 0; flex-direction: column; z-index: 2; }
.screen.active { display: flex; }

/* ---------- Buttons ---------- */
.btn {
    display: block; width: 290px; max-width: 100%; border: none; padding: 13px 18px; margin: 6px auto;
    font-size: 18px; font-weight: bold; border-radius: 50px; cursor: pointer; font-family: inherit; min-height: 46px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .25); transition: transform .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: #fff; color: var(--ink); }
.btn-secondary { background: rgba(255, 255, 255, .14); color: #fff; border: 2px solid rgba(255, 255, 255, .75); }
.btn-secondary small { display: block; font-size: 12px; font-weight: normal; opacity: .85; margin-top: 2px; }
.btn-ghost { background: transparent; color: #fff; box-shadow: none; text-decoration: underline; font-size: 15px; padding: 8px 6px; min-height: 40px; }
.btn-orange { background: linear-gradient(#ffb020, #f28c00); color: #3a2200; box-shadow: 0 4px 0 #a65d00, 0 8px 18px rgba(0, 0, 0, .35); font-size: 21px; letter-spacing: .5px; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .12);
    color: #fff; font-size: 17px; font-weight: bold; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.icon-btn.dark { background: var(--card); border-color: rgba(255, 255, 255, .25); }
.icon-spacer { width: 40px; flex-shrink: 0; }

/* ---------- Start ---------- */
#start-screen { background: linear-gradient(180deg, rgba(3, 8, 22, .55) 0%, rgba(3, 8, 22, .05) 30%, rgba(3, 8, 22, 0) 48%, rgba(3, 8, 22, .55) 70%, rgba(3, 8, 22, .85) 100%); }
.sound-start { position: absolute; top: 15px; left: 15px; z-index: 3; background: rgba(6, 14, 30, .5); }
.title-wrap { margin-top: calc(70px + 2vh); text-align: center; padding: 0 18px; }
#start-screen h1 {
    font-size: clamp(38px, 12vw, 54px); letter-spacing: 2px; font-weight: 900; line-height: 1;
    color: #fff; -webkit-text-stroke: 1.5px #0b1a2b; paint-order: stroke fill;
    text-shadow: 0 0 18px rgba(80, 230, 170, .55), 0 4px 0 #0b1a2b, 0 8px 20px rgba(0, 0, 0, .5);
}
#start-screen .desc { font-size: 15px; line-height: 1.45; max-width: 360px; margin: 10px auto 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.start-inner { position: relative; z-index: 2; margin-top: auto; padding: 0 18px 16px; text-align: center; }
.profile { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; min-height: 22px; }
.profile span { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .3); border-radius: 14px; padding: 4px 10px; }
.profile b { color: #ffd166; }
.row3 { display: flex; justify-content: center; gap: 10px; }
.row3 .btn { width: auto; margin: 2px 0; }

/* ---------- List screens ---------- */
.list-screen { background: linear-gradient(170deg, #12305a 0%, #0b1a2b 60%, #050d18 100%); }
.topbar {
    height: 54px; display: flex; align-items: center; gap: 8px; padding: 0 10px; flex-shrink: 0; z-index: 5;
    background: linear-gradient(#1c3557, #132845); box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.topbar .title { flex: 1; text-align: center; font-weight: bold; font-size: 18px; }
.scroll { flex: 1; overflow-y: auto; padding: 10px 10px 24px; -webkit-overflow-scrolling: touch; }
.sled-card {
    display: flex; gap: 12px; align-items: center; background: rgba(255, 255, 255, .08); border: 2px solid rgba(255, 255, 255, .14);
    border-radius: 14px; padding: 10px; margin-bottom: 10px; cursor: pointer; width: 100%; color: #fff; text-align: left; font-family: inherit;
}
.sled-card.sel { border-color: #ffd166; background: rgba(255, 209, 102, .12); }
.sled-card.locked { cursor: default; opacity: .75; }
.sled-card canvas { width: 84px; height: 84px; flex-shrink: 0; border-radius: 10px; background: radial-gradient(circle at 50% 70%, #dfe9f6, #8aa3c6); }
.sled-card .info { flex: 1; min-width: 0; }
.sled-card b { font-size: 17px; display: block; }
.sled-card p { font-size: 13px; opacity: .85; margin: 3px 0 6px; line-height: 1.35; }
.sled-card .tag { display: inline-block; font-size: 12px; font-weight: bold; padding: 3px 9px; border-radius: 10px; background: #ffd166; color: #3a2200; }
.sled-card .tag.choose { background: rgba(255, 255, 255, .2); color: #fff; }
.sled-card .bar { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; margin-top: 5px; }
.sled-card .bar i { display: block; height: 100%; background: linear-gradient(90deg, #6ee7b7, #22c55e); }
.sled-card small { font-size: 12px; opacity: .8; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.stat { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; padding: 10px; }
.stat small { display: block; font-size: 12px; opacity: .75; }
.stat b { font-size: 20px; color: #ffd166; }
.section-title { font-size: 14px; font-weight: bold; opacity: .8; margin: 6px 2px 8px; text-transform: uppercase; letter-spacing: .5px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); margin-bottom: 6px; }
.ach .ico { font-size: 24px; width: 32px; text-align: center; filter: grayscale(1); opacity: .45; }
.ach.on .ico { filter: none; opacity: 1; }
.ach b { display: block; font-size: 14px; } .ach small { font-size: 12px; opacity: .75; }
.ach.on b { color: #ffd166; }

/* ---------- Game HUD ---------- */
#game-screen { background: transparent; }
.touch { position: absolute; inset: 0; touch-action: none; z-index: 1; }
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.hud-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.hud-top .right { display: flex; gap: 8px; align-items: center; }
.pill {
    background: var(--card); border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; padding: 6px 13px; min-height: 40px;
    font-weight: 800; font-size: 20px; letter-spacing: .3px; text-shadow: 0 1px 2px #000; display: flex; align-items: center; gap: 3px;
    font-variant-numeric: tabular-nums;
}
.pill small { font-weight: 600; font-size: 13px; opacity: .8; margin-left: 2px; }
.pill.pip { padding-left: 8px; gap: 6px; }
.pill canvas { width: 26px; height: 26px; }
#btn-pause { pointer-events: auto; width: 42px; height: 42px; }
#btn-pause i { display: block; width: 4px; height: 15px; background: #fff; margin: 0 2px; border-radius: 1px; }
.daily-badge {
    position: absolute; left: 50%; top: 52px; transform: translateX(-50%); white-space: nowrap; display: none;
    font-size: 12px; font-weight: bold; background: rgba(255, 200, 80, .2); border: 1px solid rgba(255, 200, 80, .55); border-radius: 999px; padding: 4px 10px; color: #ffe3a3;
}
.daily-badge.show { display: block; }
.hud-sub { position: absolute; top: 60px; left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; }
.life { display: none; width: 38px; height: 38px; border-radius: 50%; background: var(--card); border: 1px solid rgba(255, 255, 255, .25); align-items: center; justify-content: center; }
.life.show { display: flex; animation: pop .4s ease; }
.life canvas { width: 28px; height: 28px; }
.shield { display: none; align-items: center; gap: 6px; background: rgba(120, 40, 10, .55); border: 1px solid rgba(255, 170, 90, .6); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: bold; color: #ffd9b0; }
.shield.show { display: flex; }
.shield b { display: block; width: 60px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.shield i { display: block; height: 100%; background: linear-gradient(90deg, #ffb347, #ff6a2a); }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.banner {
    position: absolute; left: 0; right: 0; top: 33%; text-align: center; font-weight: 900; font-size: clamp(28px, 9vw, 40px); letter-spacing: 1px;
    color: #fff; text-shadow: 0 0 18px #4bd5a0, 0 2px 0 #0b2a3f, 0 3px 10px #000; opacity: 0; transform: translateY(10px); transition: opacity .35s, transform .35s;
}
.banner small { display: block; font-size: 15px; font-weight: 700; letter-spacing: 3px; opacity: .9; margin-top: 4px; }
.banner.show { opacity: 1; transform: none; }
.toast {
    position: absolute; left: 50%; top: 45%; transform: translate(-50%, 0) scale(.8); font-weight: 900; font-size: 26px; white-space: nowrap;
    color: #ffe8b0; text-shadow: 0 2px 0 #5a2a00, 0 0 14px rgba(255, 150, 60, .8); opacity: 0; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.hint {
    position: absolute; left: 12px; right: 12px; bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    opacity: 0; transition: opacity .4s;
}
.hint.show { opacity: 1; }
.hint .arr { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .18); border: 2px solid rgba(255, 255, 255, .6); display: flex; align-items: center; justify-content: center; font-size: 22px; animation: nudge 1s ease-in-out infinite; }
.hint .arr.r { animation-delay: .5s; }
.hint .txt { text-align: center; font-size: 14px; background: var(--card); border-radius: 12px; padding: 7px 10px; line-height: 1.35; }
.hint .txt small { display: block; font-size: 12px; opacity: .75; }
@keyframes nudge { 50% { transform: scale(1.12); background: rgba(255, 255, 255, .32); } }
.ach-toast {
    position: absolute; left: 50%; top: 104px; transform: translate(-50%, -20px); opacity: 0; transition: opacity .3s, transform .3s;
    background: #fff; color: var(--ink); border-radius: 14px; padding: 8px 14px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 22px rgba(0, 0, 0, .35); white-space: nowrap; z-index: 5;
}
.ach-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ach-toast .ico { font-size: 24px; } .ach-toast small { display: block; font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: .5px; } .ach-toast b { font-size: 14px; }

/* ---------- Modals ---------- */
.modal-overlay { position: absolute; inset: 0; background: rgba(2, 6, 16, .62); display: none; align-items: center; justify-content: center; z-index: 400; padding: 12px; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; color: #374151; border-radius: 18px; padding: 18px 16px 0; width: 100%; max-width: 400px; max-height: 100%; overflow-y: auto; text-align: center; box-shadow: 0 15px 35px rgba(0, 0, 0, .45); animation: modalIn .25s ease; }
@keyframes modalIn { from { transform: scale(.92); opacity: 0; } }
.modal h2 { font-size: 24px; margin-bottom: 6px; color: var(--ink); }
.modal p { font-size: 14px; line-height: 1.45; margin: 4px 0; }
.modal .btn { width: 100%; max-width: 280px; }
.modal .btn-primary { background: var(--orange); color: #3a2200; }
.modal .btn-secondary { background: #fff; color: var(--ink); border-color: var(--ink); }
.modal .btn-ghost.dark { color: var(--ink); }
.modal-buttons { padding: 8px 0 14px; }
.results .modal-buttons { position: sticky; bottom: 0; background: #fff; margin-top: 8px; box-shadow: 0 -8px 12px -8px rgba(0, 0, 0, .18); }
.modal.help { text-align: left; } .modal.help h2 { text-align: center; } .modal.help p { margin: 8px 0; font-size: 14px; }
.cause { font-size: 15px; color: #4b5563; margin-bottom: 8px !important; }
.record { display: inline-block; background: linear-gradient(#ffd166, #f5a524); color: #3a2200; font-weight: 900; padding: 5px 14px; border-radius: 14px; margin: 2px 0 8px; animation: pop .5s ease; }
.res-table { width: 100%; border-collapse: collapse; font-size: 15px; color: #1f2937; margin: 4px 0 6px; }
.res-table td { padding: 6px 4px; border-bottom: 1px solid #eef0f3; text-align: left; }
.res-table td:last-child { text-align: right; font-weight: bold; }
.res-table tr.total td { border-bottom: none; font-size: 19px; color: var(--ink); padding-top: 9px; }
.res-table .pts { color: #6b7280; font-weight: normal; font-size: 12px; margin-left: 4px; }
.daily-info { font-size: 13px !important; background: #fff7e6; border-radius: 10px; padding: 7px 8px; color: #7a4a00; }
.unlock { font-size: 14px !important; background: #ecfdf5; color: #065f46; border-radius: 10px; padding: 7px 8px; font-weight: bold; }
.big-dist { font-size: 44px; font-weight: 900; color: var(--ink); line-height: 1.05; }
.big-dist small { font-size: 18px; color: #6b7280; margin-left: 2px; }
