:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: #070b14;
    color: #f8f5ec;
    -webkit-text-size-adjust: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    --cast-accent: #ff91c9;
    --gold-bright: #fff0b8;
    --gold-main: #f3c868;
    --surface-dark: #0e1628;
    background: radial-gradient(circle at 50% 18%, #1a2442 0%, #070b14 75%);
    overflow: hidden;
}

button, a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
    touch-action: manipulation;
    cursor: pointer;
    color: inherit;
    border: 1px solid #d9b66c88;
    background: #1b2842;
    border-radius: 12px;
}

button:focus-visible, a:focus-visible, canvas:focus-visible {
    outline: 3px solid #ffe49e;
    outline-offset: -2px;
}

button:disabled {
    opacity: 0.4;
    cursor: default;
}

[hidden] {
    display: none !important;
}

.break-shell {
    max-width: 450px;
    margin: 0 auto;
    height: calc(100svh - var(--nav-height, 86px));
    height: calc(100dvh - var(--nav-height, 86px));
    min-height: 360px;
    padding: 2px 5px max(4px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
}

.break-stage {
    position: relative;
    min-height: 0;
    flex: 1;
    border: 1.5px solid #dab56a;
    border-radius: 18px 18px 0 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 35%, #1c2947 0%, #09101f 85%);
    box-shadow:
        0 0 0 1px #000a,
        inset 0 0 22px #f6cf771f,
        inset 0 1px 0 #fff4;
}

.break-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
}

.break-hud {
    position: absolute;
    z-index: 2;
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 48px;
    padding: 2px 6px;
    background: linear-gradient(180deg, #070d1cf0 0%, #070d1cb8 70%, #070d1c00 100%);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.hud-pill {
    display: inline-flex;
    flex-shrink: 0;
    white-space: nowrap;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border: 1px solid #f0cd7e45;
    border-radius: 999px;
    background: #0e182dd9;
    box-shadow: inset 0 1px #ffffff1a;
    font-size: 13px;
    font-weight: 800;
}

.hud-score {
    min-width: 68px;
}

.hud-icon {
    color: var(--gold-main);
    font-size: 11px;
}

.hud-pill strong {
    color: var(--gold-bright);
    letter-spacing: -0.02em;
}

.hud-reveal strong {
    color: #ffdf8e;
}

.hud-balls strong {
    color: #84f2ff;
}

.hud-lives {
    margin-left: auto;
    color: #ff79b0;
    font-size: 12px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px #ff5ca188;
}

.hud-pause {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 9px;
    border-color: #ebd08e59;
    background: linear-gradient(180deg, #243554, #142036);
    box-shadow: inset 0 1px #ffffff24;
}

.hud-pause svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--gold-bright);
    stroke-width: 2.3;
    stroke-linecap: round;
}

.break-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 12px;
    background: radial-gradient(circle at 50% 35%, #10192ecc, #050913e6);
    backdrop-filter: blur(6px);
}

.break-panel {
    position: relative;
    width: min(100%, 306px);
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 14px 14px;
    border: 1.5px solid #f2cf7e;
    border-radius: 24px;
    background:
        radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--cast-accent) 28%, #2a2114), transparent 64%),
        linear-gradient(165deg, #1b2742 0%, #0d1424 58%, #161120 100%);
    box-shadow:
        0 18px 46px #000c,
        0 0 24px #f3c8682e,
        inset 0 1px 0 #fff6,
        inset 0 0 0 3px #f3c86812;
}

.break-overlay[data-won="true"] .break-panel {
    border-color: #ffe89e;
    box-shadow:
        0 18px 48px #000d,
        0 0 36px #ffd46b66,
        inset 0 1px 0 #fff9,
        inset 0 0 0 3px #ffe28a33;
}

.hero-frame {
    position: relative;
    width: 180px;
    height: 180px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    border: 2px solid #f4cf7b;
    background:
        radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--cast-accent) 44%, #fff2c2), #151e34 76%);
    box-shadow:
        0 0 24px color-mix(in srgb, var(--cast-accent) 45%, #f3c868),
        inset 0 0 16px #ffe6a344;
    overflow: hidden;
}

.break-overlay[data-won="true"] .hero-frame {
    width: 198px;
    height: 198px;
    border-width: 2.5px;
    border-color: #fff0b3;
    box-shadow:
        0 0 32px #ffd86f99,
        0 0 14px var(--cast-accent),
        inset 0 0 22px #ffefba66;
}

.hero-crown {
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    padding: 2px 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, #b87e1f, #ffe89c, #b87e1f);
    color: #261704;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    white-space: nowrap;
    box-shadow: 0 2px 8px #0008;
}

.panel-portrait {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: drop-shadow(0 6px 10px #0007);
}

.panel-status {
    margin: 0;
    color: var(--gold-bright);
    font-size: 13px;
    font-weight: 800;
}

.panel-score {
    margin: -4px 0 -2px;
    color: #fff3c4;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 14px #f5c45388;
}

.reward-box {
    width: 100%;
    padding: 8px 11px;
    border-radius: 14px;
    border: 1px solid #ffe49c99;
    background: linear-gradient(145deg, #352616e6, #1f172ce6);
    box-shadow: inset 0 1px #fff4, 0 0 14px #f3c8682e;
    text-align: center;
}

.reward-line {
    margin: 0;
    color: #fff9eb;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.42;
}

.result-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.result-stats > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #e7c67844;
    background: #0d1526cc;
    color: #d6e0f2;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.result-stats strong {
    color: var(--gold-bright);
    font-size: 13px;
    font-weight: 800;
}

.cast-picker {
    display: flex;
    gap: 9px;
    padding: 2px;
}

.cast-choice {
    position: relative;
    width: 52px;
    height: 52px;
    padding: 3px;
    border: 1.5px solid #8a99b555;
    border-radius: 15px;
    background: linear-gradient(145deg, #233252, #0e1628);
    box-shadow: inset 0 1px #ffffff1f;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.cast-choice[aria-pressed="true"] {
    border-color: #ffe599;
    background: linear-gradient(145deg, #6b4e22, #2b2129);
    box-shadow:
        0 0 14px #f5c86266,
        0 0 0 2px #ffe59944,
        inset 0 1px #fff8;
    transform: translateY(-2px);
}

.cast-choice img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 11px;
    object-fit: cover;
}

.panel-hint {
    margin: 0;
    color: #b7c4dc;
    font-size: 11px;
}

.play-button {
    display: grid;
    place-items: center;
    width: 86px;
    height: 52px;
    border: 1.5px solid #fff3c4;
    border-radius: 18px;
    color: #281905;
    background: linear-gradient(180deg, #fff2be 0%, #f4c459 52%, #cf8f24 100%);
    box-shadow:
        inset 0 1px 0 #fffc,
        0 4px 0 #6e4810,
        0 8px 20px #f4c45955;
}

.play-button svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.play-button:active {
    transform: translateY(2px);
    box-shadow:
        inset 0 1px 0 #fffc,
        0 2px 0 #6e4810,
        0 4px 12px #f4c45944;
}

.panel-best {
    margin: 0;
    color: #96a8c0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.break-buddy {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    flex-shrink: 0;
    padding: 0 9px;
    background: linear-gradient(115deg, #1b2845 0%, #0e1526 60%, #1c1528 100%);
    border: 1.5px solid #dab56a;
    border-top: 1px solid #ffe49e33;
    border-radius: 0 0 18px 18px;
}

.buddy-portrait {
    align-self: flex-end;
    flex-shrink: 0;
    width: 58px;
    height: 58px;
    border-radius: 12px;
    object-fit: cover;
    margin-top: -4px;
    border: 1.5px solid #f4cf7b88;
    box-shadow: 0 2px 8px #0008;
    pointer-events: none;
}

.buddy-talk {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 6px 10px;
    border: 1px solid #ffffff14;
    border-radius: 11px 11px 11px 3px;
    background: #ffffff08;
    color: #f4f6fb;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.buddy-badge {
    flex-shrink: 0;
    color: #ffe39c;
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding: 4px 7px;
    border-radius: 7px;
    border: 1px solid #f3c86838;
    background: #09101ecc;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 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; }

/* Keep every game statistic and the pause target available on narrow phones. */
@media (max-width: 380px) {
    .break-hud { gap: 3px; padding-inline: 4px; }
    .hud-pill { gap: 3px; padding-inline: 5px; font-size: 12px; }
    .hud-score { min-width: 0; }
    .hud-lives { font-size: 11px; letter-spacing: 0; }
}

/* Give short portrait screens more room between the bricks and the paddle. */
@media (max-height: 740px) and (orientation: portrait) {
    .break-buddy { height: 38px; gap: 6px; padding-inline: 6px; }
    .buddy-portrait { width: 36px; height: 36px; margin-top: 0; border-radius: 8px; }
    .buddy-talk { padding: 3px 6px; font-size: 11px; }
    .buddy-badge { display: none; }
}
