:root {
    color-scheme: light;
    --flap-bg: #f8fbff;
    --flap-side-bg: #eef7ff;
    --flap-board-bg: linear-gradient(180deg, #50c8ff 0%, #8ce6ff 52%, #86d972 52%, #43a853 100%);
    --flap-ink: #231f25;
    --flap-muted: #6f6570;
    --flap-line: #e5dce5;
    --flap-panel: rgba(255, 255, 255, 0.9);
    --flap-pink: #f657b5;
    --flap-blue: #2878f0;
    --flap-green: #14a86a;
    --flap-gold: #ffb82e;
    --flap-violet: #7d59e8;
    --game-header-side-bg: var(--flap-side-bg);
    --game-header-center-bg: #fff;
    --game-header-accent: var(--flap-pink);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    touch-action: manipulation;
}

body {
    color: var(--flap-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    letter-spacing: 0;
    -webkit-text-size-adjust: 100%;
    background:
        linear-gradient(
            to right,
            var(--flap-side-bg) 0,
            var(--flap-side-bg) calc((100% - 500px) / 2),
            var(--flap-bg) calc((100% - 500px) / 2),
            var(--flap-bg) calc((100% + 500px) / 2),
            var(--flap-side-bg) calc((100% + 500px) / 2),
            var(--flap-side-bg) 100%
        );
}

button,
a {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.flap-shell {
    display: grid;
    place-items: start center;
    min-height: 100vh;
    padding: 6px 10px max(14px, env(safe-area-inset-bottom));
}

.flap-stage {
    width: min(100%, clamp(310px, calc((100svh - 132px) * 0.62903226), 470px));
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.flap-hud {
    position: absolute;
    top: 16px;
    right: 16px;
    left: 78px;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(60px, 1fr) minmax(48px, 0.75fr) minmax(56px, 0.9fr) minmax(44px, 0.62fr);
    gap: 7px;
    pointer-events: none;
}

.flap-hud > div,
.flap-global-panel {
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.64);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 10px 24px rgba(40, 120, 240, 0.08);
    backdrop-filter: blur(14px) saturate(1.08);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
}

.flap-hud > div {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 42px;
    padding: 7px 6px;
    border-color: rgba(255, 255, 255, 0.72);
    color: #fff;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.12) 46%, rgba(112, 197, 255, 0.24)),
        rgba(22, 116, 218, 0.3);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        inset 0 -10px 18px rgba(20, 86, 171, 0.16),
        0 8px 20px rgba(8, 64, 154, 0.14);
}

.flap-hud > div::before {
    content: "";
    position: absolute;
    inset: 1px 1px auto;
    height: 44%;
    border-radius: 7px 7px 16px 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.flap-hud > div:first-child {
    padding-left: 7px;
}

.flap-hud-icon {
    position: relative;
    flex: 0 0 auto;
    color: rgba(222, 246, 255, 0.92);
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(5, 55, 126, 0.42);
}

.flap-hud strong {
    position: relative;
    min-width: 0;
    color: #fff;
    font-size: 20px;
    line-height: 1.03;
    white-space: nowrap;
    text-shadow:
        0 1px 0 rgba(5, 36, 98, 0.72),
        0 2px 8px rgba(4, 60, 144, 0.28),
        0 0 12px rgba(255, 255, 255, 0.42);
}

.flap-hud > div:not(:first-child) strong {
    font-size: 16px;
}

.flap-hud strong.flap-hud-composite {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 1px;
}

.flap-hud-number {
    line-height: 1;
}

.flap-hud-affix {
    flex: 0 0 auto;
    font-size: 0.8em;
    font-weight: 800;
    line-height: 1;
    opacity: 0.92;
}

.flap-hud-unit {
    margin-left: 1px;
    font-size: 0.78em;
}

.flap-hud-prefix {
    margin-right: 1px;
}

.flap-board-wrap {
    position: relative;
    overflow: hidden;
    padding: 8px;
    border-radius: 8px;
    background: var(--flap-board-bg);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.4),
        0 16px 34px rgba(26, 95, 150, 0.2);
}

.flap-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 0.62903226;
    border-radius: 8px;
    background: #69d5ff;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.flap-item-tray {
    position: absolute;
    right: 0;
    bottom: 82px;
    left: 0;
    z-index: 4;
    display: flex;
    justify-content: center;
    gap: 8px;
    pointer-events: none;
}

.flap-item-slot {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 8px;
    color: #fff;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.08)),
        rgba(35, 31, 37, 0.28);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.56),
        0 8px 18px rgba(20, 36, 82, 0.18);
    opacity: 0.82;
    pointer-events: auto;
    cursor: pointer;
    touch-action: manipulation;
}

.flap-item-slot::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px dashed rgba(255, 255, 255, 0.54);
    border-radius: 7px;
}

.flap-item-slot.is-filled {
    border-color: rgba(139, 240, 255, 0.92);
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.86), rgba(139, 240, 255, 0.26) 42%, rgba(40, 120, 240, 0.48)),
        rgba(40, 120, 240, 0.52);
    opacity: 1;
}

.flap-item-slot.is-slow {
    border-color: rgba(255, 244, 165, 0.92);
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.88), rgba(255, 244, 165, 0.36) 44%, rgba(255, 184, 46, 0.52)),
        rgba(196, 124, 16, 0.5);
}

.flap-item-slot.is-magnet {
    border-color: rgba(255, 138, 200, 0.92);
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.9), rgba(255, 138, 200, 0.32) 44%, rgba(246, 87, 181, 0.56)),
        rgba(216, 100, 142, 0.5);
}

.flap-item-slot.is-filled::before {
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.42);
}

.flap-item-slot.is-active {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 0 0 3px rgba(139, 240, 255, 0.24),
        0 8px 18px rgba(20, 36, 82, 0.18);
}

.flap-item-slot:disabled {
    cursor: default;
}

.flap-item-emoji {
    position: relative;
    z-index: 1;
    font-size: 23px;
    line-height: 1;
    filter: drop-shadow(0 2px 5px rgba(5, 55, 126, 0.28));
}

.flap-overlay {
    position: absolute;
    inset: 8px;
    z-index: 5;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(26, 38, 78, 0.22);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.flap-overlay[hidden] {
    display: none;
}

.flap-overlay-panel {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(82%, 288px);
    padding: 20px 18px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 18px 42px rgba(30, 60, 120, 0.22);
}

.start-hero {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
}

.start-hero img {
    display: block;
    width: 78px;
    height: 78px;
    object-fit: contain;
}

.flap-overlay-panel > strong {
    color: var(--flap-ink);
    font-size: 24px;
    line-height: 1.15;
}

.flap-overlay-panel > span {
    color: var(--flap-blue);
    font-size: 11px;
    font-weight: 900;
}

#resultKicker {
    display: none;
}

.result-panel > strong {
    font-size: 20px;
    line-height: 1.18;
}

.flap-overlay-panel button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 900;
    text-decoration: none;
    background: var(--flap-pink);
    box-shadow: 0 7px 16px rgba(216, 100, 142, 0.18);
    cursor: pointer;
}

.flap-overlay-panel button {
    min-width: 112px;
    padding-right: 22px;
    padding-left: 22px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    margin: 0;
}

.result-stats > div {
    min-width: 0;
    padding: 9px 10px;
    border-radius: 8px;
    background: #f8fbff;
}

.result-stats dt {
    margin: 0 0 2px;
    color: var(--flap-muted);
    font-size: 10px;
    font-weight: 900;
}

.result-stats dd {
    margin: 0;
    color: var(--flap-ink);
    font-size: 16px;
    font-weight: 900;
    line-height: 1.15;
}

.current-cast-button {
    position: absolute;
    top: 16px;
    left: 14px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 50px;
    height: 42px;
    padding: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    color: var(--flap-ink);
    font: inherit;
    font-size: 13px;
    font-weight: 900;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.12) 46%, rgba(112, 197, 255, 0.24)),
        rgba(22, 116, 218, 0.3);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        inset 0 -10px 18px rgba(20, 86, 171, 0.16),
        0 8px 20px rgba(8, 64, 154, 0.14);
    cursor: pointer;
}

.current-cast-button::before {
    content: "";
    position: absolute;
    inset: 1px 1px auto;
    height: 44%;
    border-radius: 7px 7px 16px 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.current-cast-button img {
    position: relative;
    flex: 0 0 auto;
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
    filter: drop-shadow(0 1px 3px rgba(5, 55, 126, 0.18));
}

.current-cast-button span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cast-picker {
    display: flex;
    gap: 7px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.cast-picker::-webkit-scrollbar {
    display: none;
}

.cast-button {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.cast-button[aria-pressed="true"] {
    border-color: var(--flap-green);
    background: rgba(238, 253, 245, 0.34);
}

.cast-button img {
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.flap-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    align-items: end;
    justify-items: center;
    padding: 16px 10px max(16px, env(safe-area-inset-bottom));
}

.flap-modal[hidden] {
    display: none;
}

.flap-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(20, 24, 42, 0.34);
    cursor: pointer;
}

.flap-modal-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 430px);
    max-height: 72vh;
    max-height: min(72svh, 420px);
    overflow: auto;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 18px 44px rgba(30, 60, 120, 0.24);
    backdrop-filter: blur(16px) saturate(1.08);
    -webkit-backdrop-filter: blur(16px) saturate(1.08);
}

.flap-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.flap-modal-head h2 {
    margin: 0;
    color: var(--flap-ink);
    font-size: 15px;
    line-height: 1.2;
}

.flap-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--flap-ink);
    background: #f3f4f6;
    cursor: pointer;
}

.flap-modal-close .material-icons {
    font-size: 20px;
}

.cast-picker--modal {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
    overflow: visible;
}

.cast-picker--modal .cast-button {
    display: flex;
    width: auto;
    height: auto;
    min-height: 58px;
    gap: 7px;
    justify-content: flex-start;
    padding: 8px;
    border-radius: 8px;
    color: var(--flap-ink);
    font: inherit;
    font-size: 12px;
    font-weight: 900;
    background: rgba(248, 251, 255, 0.86);
}

.cast-picker--modal .cast-button img {
    width: 38px;
    height: 38px;
}

.cast-picker--modal .cast-button span {
    min-width: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flap-global-panel {
    margin-top: 8px;
    padding: 10px;
}

.flap-global-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.flap-global-panel-head span {
    color: var(--flap-ink);
    font-size: 13px;
    font-weight: 900;
}

.flap-global-panel-head small {
    min-width: 0;
    color: var(--flap-muted);
    font-size: 10px;
    font-weight: 800;
    text-align: right;
}

.flap-global-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 0;
}

.flap-global-grid > div {
    min-width: 0;
    padding: 8px 9px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
}

.flap-global-grid dt {
    margin: 0 0 2px;
    color: var(--flap-muted);
    font-size: 10px;
    font-weight: 900;
}

.flap-global-grid dd {
    margin: 0;
    color: var(--flap-ink);
    font-size: 16px;
    font-weight: 900;
    line-height: 1.15;
}

@media (max-width: 374px) {
    .flap-stage {
        width: min(100%, clamp(292px, calc((100svh - 126px) * 0.62903226), 470px));
    }

    .flap-hud {
        top: 14px;
        right: 14px;
        left: 72px;
        grid-template-columns: minmax(52px, 1fr) minmax(40px, 0.75fr) minmax(46px, 0.88fr) minmax(40px, 0.62fr);
        gap: 5px;
    }

    .flap-hud > div {
        min-height: 40px;
        gap: 3px;
        padding-right: 5px;
        padding-left: 5px;
    }

    .flap-hud > div:first-child {
        padding-left: 5px;
    }

    .flap-hud-icon {
        font-size: 14px;
    }

    .flap-hud strong {
        font-size: 16px;
    }

    .flap-hud > div:not(:first-child) strong {
        font-size: 13px;
    }

    .flap-item-tray {
        bottom: 74px;
        gap: 7px;
    }

    .flap-item-slot {
        width: 40px;
        height: 40px;
    }

    .current-cast-button {
        top: 14px;
        left: 13px;
        width: 46px;
        height: 40px;
    }

    .current-cast-button img {
        width: 32px;
        height: 32px;
    }

    .flap-global-grid dd {
        font-size: 15px;
    }
}

@media (max-height: 680px) {
    .flap-stage {
        width: min(100%, clamp(278px, calc((100svh - 124px) * 0.62903226), 470px));
    }

    .flap-board-wrap {
        padding: 6px;
    }

    .flap-overlay {
        inset: 6px;
    }

    .flap-item-tray {
        bottom: 70px;
    }
}
