:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
    background: #070a14;
    color: #f6f6fc;
    -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; --accent: #ffd46b; --cast-accent: #ff91c9; --surface: #141d36; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
    font: inherit;
    touch-action: manipulation;
    cursor: pointer;
    color: inherit;
    border: 1px solid #7f8ea8;
    background: #1a2740;
    border-radius: 12px;
}
button:focus-visible, a:focus-visible, canvas:focus-visible {
    outline: 3px solid #ffe49c;
    outline-offset: -3px;
}
button:disabled { opacity: 0.4; cursor: default; }
button svg {
    width: 20px;
    height: 20px;
    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 #c9a760;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 0 0 1px #0009, inset 0 0 0 2px #ffe6a312;
}
.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: 6px;
    height: 46px;
    padding: 4px 8px;
    background: linear-gradient(180deg, #070d1cf5, #070d1cd8 72%, #070d1c00);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}
.mini-hud > span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 17px;
    font-weight: 800;
}
.mini-hud > span:first-child {
    min-width: 82px;
    padding: 4px 10px;
    border: 1px solid #e7c67848;
    border-radius: 10px;
    background: #0d172ce0;
    box-shadow: inset 0 1px #ffffff14;
}
.mini-hud .score-symbol { color: #ffd86b; font-size: 15px; }
.mini-hud strong { color: #fff1cc; letter-spacing: -0.02em; }
.mini-kills {
    padding: 3px 8px;
    border-radius: 9px;
    border: 1px solid #6ee7ff38;
    background: #0c1b30cc;
    color: #b8f5ff;
    font-size: 12px !important;
}
.mini-time {
    margin-left: auto;
    color: #e4ecfa;
    font-size: 12px !important;
    letter-spacing: 0.02em;
}
.mini-hud button {
    pointer-events: auto;
    width: 40px;
    height: 34px;
    display: grid;
    place-items: center;
    border-color: #d6b66f55;
    border-radius: 10px;
    background: #17253e;
    box-shadow: inset 0 1px #ffffff18, 0 2px 5px #0005;
}

.mini-buddy {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 62px;
    flex-shrink: 0;
    padding: 0 9px;
    background: linear-gradient(115deg, #1b2542, #0d1324 88%);
    border: 1px solid #c9a760;
    border-top-color: #ffe39e26;
    border-radius: 0 0 16px 16px;
}
.buddy-portrait {
    align-self: flex-end;
    flex-shrink: 0;
    width: 66px;
    height: 64px;
    object-fit: contain;
    margin-top: -4px;
    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 #ffd86b29;
    border-radius: 11px 11px 11px 3px;
    background: #121c33cc;
    color: #f3f5fc;
    font-size: 12px;
    line-height: 1.4;
}
.buddy-badge {
    color: #ffe094;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding: 5px 7px;
    border-radius: 7px;
    border: 1px solid #ffd86b30;
    background: #080d1899;
}

.mini-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 12px;
    background: #050812ba;
    backdrop-filter: blur(7px);
}
.mini-panel {
    position: relative;
    width: min(100%, 316px);
    max-height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 15px;
    border: 1px solid #e6c37399;
    border-radius: 22px;
    background: radial-gradient(ellipse at 50% 0, #25335a, #0e1526 78%);
    box-shadow: inset 0 1px #fff5, inset 0 0 0 3px #ffd86b0d, 0 18px 48px #0009;
}
.mini-panel > * { flex-shrink: 0; }
.mini-hero {
    position: relative;
    display: grid;
    place-items: center;
    width: 164px;
    height: 152px;
    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: 124px;
    height: 124px;
    border: 1.5px solid #ffd86b75;
    border-radius: 50%;
    box-shadow: 0 0 0 8px #ffd86b0d, 0 0 18px #ffd86b24;
}
.mini-hero::after {
    content: '✦';
    position: absolute;
    right: 6px;
    top: 16px;
    color: #ffe294;
    font-size: 18px;
    text-shadow: -136px 88px #ffd86b77;
}
.panel-portrait {
    width: 148px;
    height: 148px;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px #0006);
}
.mini-message {
    margin: 0;
    min-height: 28px;
    color: #ffe49c;
    font-size: 32px;
    font-weight: 850;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}
.mini-hint {
    margin: 0;
    color: #c8d3e6;
    font-size: 12px;
    text-align: center;
    line-height: 1.55;
}
.cast-picker { display: flex; gap: 10px; padding: 2px; }
.cast-choice {
    position: relative;
    width: 50px;
    height: 50px;
    padding: 3px;
    border-color: #8c9bb855;
    border-radius: 13px;
    background: linear-gradient(145deg, #273758, #0c1426);
    box-shadow: inset 0 1px #ffffff1f;
}
.cast-choice[aria-pressed="true"] {
    border-color: #ffe294;
    background: linear-gradient(145deg, #785c2d, #222942);
    box-shadow: 0 0 0 2px #ffd86b38, 0 0 12px #ffd86b33, 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: 8px;
    width: min(100%, 216px);
    min-height: 50px;
    border-color: #fff2c4;
    border-radius: 14px;
    color: #2b1f11;
    font-size: 16px;
    font-weight: 850;
    background: linear-gradient(135deg, #fff3c4, #e3b45b 68%, #b88433);
    box-shadow: inset 0 1px #fffb, 0 4px #6e4e20, 0 8px 20px #0006;
}
.mini-play svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.mini-play:active { transform: translateY(2px); box-shadow: inset 0 1px #fff8, 0 2px #6e4e20; }
.mini-best {
    margin: 0;
    color: #a9b9d4;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}
.buddy-react { animation: buddy-cheer 0.3s ease-out; }
@keyframes buddy-cheer { 50% { transform: translateY(-6px) rotate(-4deg); } }

@media (max-height: 680px) {
    .mini-buddy { height: 54px; }
    .buddy-portrait { width: 56px; height: 56px; }
    .buddy-talk { font-size: 11px; padding: 5px 8px; }
    .mini-panel { gap: 7px; padding: 12px; }
    .mini-hero { width: 124px; height: 106px; }
    .mini-hero::before { width: 90px; height: 90px; }
    .panel-portrait { width: 104px; height: 104px; }
    .cast-choice { width: 46px; height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .panel-portrait, .buddy-portrait { filter: none; }
    .mini-overlay { backdrop-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; }
