:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
    background: #080c15;
    color: #f5f5fb;
    -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; --accent: #ffd659; --cast-accent: #ff91c9; --surface: #141e36; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; touch-action: manipulation; cursor: pointer; color: inherit; border: 1px solid #77879b; background: #1c293d; border-radius: 12px; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid #ffe4a7; outline-offset: -3px; }
button:disabled { opacity: .4; cursor: default; }
button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.mini-shell {
    max-width: 450px;
    margin: 0 auto;
    height: calc(100svh - var(--nav-height, 88px));
    height: calc(100dvh - var(--nav-height, 88px));
    min-height: 360px;
    padding: 3px 5px max(4px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
}
.mini-stage {
    position: relative;
    min-height: 0;
    flex: 1;
    border: 1px solid #d4af37;
    border-radius: 18px 18px 0 0;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 0 0 1px #0008, inset 0 0 0 3px #ffd65914;
}
.mini-canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }
.mini-hud {
    position: absolute;
    z-index: 2;
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 43px;
    padding: 4px 7px;
    background: linear-gradient(180deg, #0b1124f5, #0b1124d9 70%, #0b112400);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}
.mini-hud > span { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 800; }
.mini-hud > span:first-child { min-width: 82px; padding: 4px 10px; border: 1px solid #f2cc6b55; border-radius: 10px; background: #121c33d9; box-shadow: inset 0 1px #ffffff14; }
.mini-hud .score-symbol { color: #ffd659; font-size: 16px; }
.mini-hud strong { color: #fff1c2; letter-spacing: -.03em; }
.mini-time { margin-left: auto; color: #ffe699; font-size: 12px !important; letter-spacing: .02em; }
.mini-hud button { pointer-events: auto; width: 42px; height: 38px; display: grid; place-items: center; border-color: #ffd65944; border-radius: 10px; background: #192642; box-shadow: inset 0 1px #ffffff18, 0 2px 4px #0004; }
.mini-buddy {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 58px;
    flex-shrink: 0;
    padding: 0 9px;
    background: linear-gradient(115deg, #1b2440, #0f1629 88%);
    border: 1px solid #d4af3788;
    border-top-color: #ffd65933;
    border-radius: 0 0 16px 16px;
}
.buddy-portrait { align-self: flex-end; flex-shrink: 0; width: 64px; height: 64px; object-fit: contain; margin-top: -6px; pointer-events: none; filter: drop-shadow(0 2px 4px #0006); }
.buddy-talk { min-width: 0; margin-right: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 6px 10px; border: 1px solid #ffd65928; border-radius: 11px 11px 11px 3px; background: #ffffff08; color: #fff6d6; font-size: 12px; line-height: 1.4; }
.buddy-badge { color: #ffd659; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 5px 6px; border-radius: 7px; background: #080d1688; }
.mini-overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 10px; background: #060a17b8; }
.mini-panel {
    position: relative;
    width: min(100%, 312px);
    max-height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 15px 14px;
    border: 1px solid #ffd65999;
    border-radius: 24px;
    background: radial-gradient(ellipse at 50% 0, #281e46, #10172b 78%);
    box-shadow: inset 0 1px #fff5, 0 18px 48px #0009;
}
.mini-panel > * { flex-shrink: 0; }
.mini-hero {
    position: relative;
    display: grid;
    place-items: center;
    width: 162px;
    height: 146px;
    isolation: isolate;
    background: radial-gradient(ellipse, color-mix(in srgb, var(--cast-accent) 24%, transparent), transparent 68%);
}
.mini-hero::before { content: ''; position: absolute; z-index: -1; width: 122px; height: 122px; border: 1px solid #ffd65988; border-radius: 50%; box-shadow: 0 0 0 8px #ffd65912, 0 0 0 10px #ffd65924; }
.mini-hero::after { content: '🪙'; position: absolute; right: 4px; top: 16px; font-size: 18px; }
.panel-portrait { width: 144px; height: 144px; object-fit: contain; filter: drop-shadow(0 6px 8px #0006); }
.mini-message { margin: 0; min-height: 28px; color: #ffe580; font-size: 31px; font-weight: 850; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.mini-hint { margin: 0; color: #d8e1f0; font-size: 12px; text-align: center; line-height: 1.5; }
.cast-picker { display: flex; gap: 10px; padding: 3px; }
.cast-choice { position: relative; width: 50px; height: 50px; padding: 3px; border-color: #8390aa50; border-radius: 14px; background: linear-gradient(145deg, #ffffff14, #0d162b); }
.cast-choice[aria-pressed=true] { border-color: #ffd659; background: linear-gradient(145deg, #9a742266, #322536); box-shadow: 0 0 0 2px #ffd65933, inset 0 1px #fff6; }
.cast-choice img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mini-play { display: flex; align-items: center; justify-content: center; gap: 9px; width: 172px; min-height: 52px; border-color: #fff2bd; border-radius: 15px; color: #2b1d08; font-size: 15px; font-weight: 850; background: linear-gradient(145deg, #fff0b8, #e0a838); box-shadow: inset 0 1px #fff9, 0 4px #7c5614, 0 8px 18px #0005; }
.mini-play svg { width: 19px; height: 19px; fill: currentColor; stroke: none; }
.mini-play:active { transform: translateY(2px); box-shadow: inset 0 1px #fff7, 0 2px #7c5614; }
.mini-best { margin: 0; color: #c7d4e6; font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.mini-next { display: grid; place-items: center; min-height: 40px; padding: 0 12px; color: #ffe8a3; font-size: 12px; text-decoration: none; border-bottom: 1px solid #ffe8a344; }
.buddy-react { animation: buddy-cheer .3s ease-out; }
@keyframes buddy-cheer { 50% { transform: translateY(-6px) rotate(-4deg); } }
@media(max-height:650px) {
    .mini-buddy { height: 50px; }
    .buddy-portrait { width: 54px; height: 54px; }
    .buddy-talk { font-size: 11px; padding: 5px 7px; }
    .mini-panel { gap: 7px; padding: 10px 12px; }
    .mini-hero { width: 110px; height: 86px; }
    .mini-hero::before { width: 74px; height: 74px; }
    .mini-hero::after { content: none; }
    .panel-portrait { width: 84px; height: 84px; }
    .mini-message { font-size: 26px; }
    .cast-choice { width: 45px; height: 45px; }
}
@media(prefers-reduced-motion:reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .panel-portrait, .buddy-portrait { filter: none; }
    .mini-play:active { transform: none; }
}

/* Keep the expanded cast roster within the play panel. */
.cast-picker { min-width: 0; max-width: 100%; overflow-x: auto; padding-bottom: 10px; }
.cast-picker > button { flex-shrink: 0; }
