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

:root {
    color-scheme: dark;

    --black: #08090b;
    --panel: #171a1e;
    --red: #c9282e;
    --red-light: #ed4b51;
    --red-dark: #681419;
    --white: #f6f3ed;
    --gray: #aaa6a0;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
}

body {
    min-height: 100svh;
    overflow-x: hidden;

    color: var(--white);
    background: var(--black);

    font-family:
        "Zen Old Mincho",
        "Yu Mincho",
        "Hiragino Mincho ProN",
        serif;
}

button {
    font-family: inherit;
}


/* =====================================
   ゲーム画面
===================================== */

.game-screen {
    position: relative;

    width: 100%;
    min-height: 100svh;

    overflow: hidden;

    padding:
        max(22px, env(safe-area-inset-top))
        7px
        max(18px, env(safe-area-inset-bottom));

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background:
        linear-gradient(
            rgba(8, 9, 11, 0.8),
            rgba(8, 9, 11, 0.95)
        ),
        url("images/ui/background.webp"),
        radial-gradient(
            circle at 50% 25%,
            #30343a,
            #131619 45%,
            #060708
        );

    background-size: cover;
    background-position: center;
}

.background-slash {
    position: absolute;

    width: 48px;
    height: 650px;

    background: var(--red);
    opacity: 0.18;

    transform: rotate(28deg);

    pointer-events: none;
}

.slash-a {
    top: -280px;
    right: 0;
}

.slash-b {
    bottom: -330px;
    left: 20px;
}


/* =====================================
   ヘッダー
===================================== */

.game-header {
    position: relative;
    z-index: 2;

    margin-bottom: 17px;

    text-align: center;
}

.header-line {
    width: 55px;
    height: 4px;

    margin: 0 auto 9px;

    background: var(--red);

    transform: skewX(-28deg);
}

.eyebrow {
    margin: 0 0 4px;

    color: #bbb7b2;

    font-size: 11px;
}

.game-header h1 {
    margin: 0;

    font-size: clamp(35px, 10vw, 62px);
    line-height: 1;

    font-weight: 700;
    letter-spacing: 0.06em;
}

.instruction {
    margin: 9px 0 0;

    color: #e5e1da;

    font-size: 13px;
}


/* =====================================
   リール配置
===================================== */

.reels {
    position: relative;
    z-index: 2;

    width: 100%;
    max-width: 680px;

    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 5px;
}

.character-panel {
    min-width: 0;
    text-align: center;
}

.character-panel h2 {
    height: 29px;

    margin: 0 0 5px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    border-top: 1px solid #74777b;
    border-bottom: 1px solid #292c30;

    color: #f0ede7;

    background:
        linear-gradient(
            90deg,
            #111315,
            #292d32,
            #111315
        );

    font-size: clamp(9px, 2.7vw, 13px);
    font-weight: 600;

    white-space: nowrap;
}


/* =====================================
   縦スクロール式リール
===================================== */

.reel {
    position: relative;

    width: 100%;
    aspect-ratio: 3 / 5;

    overflow: hidden;

    border: 1px solid #767a7e;

    background:
        linear-gradient(
            180deg,
            #363a40,
            #111315
        );

    box-shadow:
        inset 0 0 22px #000,
        0 8px 20px rgba(0, 0, 0, 0.6);
}

.reel-track {
    position: absolute;

    top: 0;
    left: 0;

    width: 100%;

    will-change: transform;
}

.reel-item {
    position: relative;

    width: 100%;
    aspect-ratio: 3 / 5;

    display: flex;
    align-items: flex-end;
    justify-content: center;

    overflow: hidden;

    background:
        linear-gradient(
            180deg,
            #34383d,
            #111315
        );
}

.reel-item img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;
    object-position: center bottom;

    pointer-events: none;
    user-select: none;
}


/* 上下の影 */

.reel::before {
    content: "";

    position: absolute;
    inset: 0;

    z-index: 3;

    pointer-events: none;

    background:
        linear-gradient(
            180deg,
            rgba(0, 0, 0, 0.68) 0%,
            rgba(0, 0, 0, 0.08) 20%,
            transparent 40%,
            transparent 60%,
            rgba(0, 0, 0, 0.10) 80%,
            rgba(0, 0, 0, 0.64) 100%
        );
}


/* 中央ライン */

.reel::after {
    content: "";

    position: absolute;

    z-index: 4;

    left: 5px;
    right: 5px;
    top: 50%;

    height: 1px;

    background:
        rgba(255, 255, 255, 0.16);

    pointer-events: none;
}


/* コーナー装飾 */

.corner {
    position: absolute;

    z-index: 6;

    width: 18px;
    height: 18px;

    pointer-events: none;
}

.corner-left {
    top: 0;
    left: 0;

    border-top: 3px solid var(--red);
    border-left: 3px solid var(--red);
}

.corner-right {
    right: 0;
    bottom: 0;

    border-right: 3px solid var(--red);
    border-bottom: 3px solid var(--red);
}


/* 衣装番号 */

.costume-number {
    position: absolute;

    right: 4px;
    bottom: 4px;

    z-index: 8;

    min-width: 28px;

    padding: 3px 5px;

    color: #fff;

    border-left: 2px solid var(--red);

    background:
        rgba(0, 0, 0, 0.82);

    font-size: 13px;
    font-weight: 700;
}


/* =====================================
   ボタン
===================================== */

.stop-button {
    width: 100%;
    min-height: 50px;

    margin-top: 8px;

    border: 1px solid var(--red-light);

    color: #fff;

    background:
        linear-gradient(
            135deg,
            var(--red-dark),
            var(--red),
            #85171b
        );

    font-size: clamp(14px, 4vw, 18px);
    font-weight: 700;

    cursor: pointer;

    clip-path:
        polygon(
            7px 0,
            100% 0,
            100% calc(100% - 7px),
            calc(100% - 7px) 100%,
            0 100%,
            0 7px
        );

    touch-action: manipulation;
}

.stop-button:active:not(:disabled) {
    transform: scale(0.95);
}

.stop-button:disabled {
    color: #696b6e;

    border-color: #36383c;

    background:
        linear-gradient(
            #25282c,
            #17191c
        );
}

.start-button {
    position: relative;
    z-index: 2;

    width: min(440px, 93%);
    min-height: 65px;

    margin-top: 27px;

    border: 1px solid var(--red-light);

    color: #fff;

    background:
        linear-gradient(
            135deg,
            var(--red-dark),
            var(--red),
            #801519
        );

    font-size: 24px;
    font-weight: 700;

    cursor: pointer;

    clip-path:
        polygon(
            20px 0,
            100% 0,
            calc(100% - 20px) 100%,
            0 100%
        );
}

.start-button span {
    margin-right: 10px;
}

.start-button:disabled {
    color: #696c70;

    border-color: #383b40;

    background: #24272b;
}

.footer-copy {
    position: relative;
    z-index: 2;

    margin: 14px 0 0;

    color: #aaa59e;

    font-size: 11px;
}


/* =====================================
   結果画面
===================================== */

.result-screen {
    position: fixed;

    inset: 0;
    z-index: 1000;

    display: none;

    width: 100%;
    height: 100svh;

    overflow-y: auto;

    padding:
        max(20px, env(safe-area-inset-top))
        10px
        max(20px, env(safe-area-inset-bottom));

    background:
        linear-gradient(
            rgba(8, 9, 11, 0.8),
            rgba(8, 9, 11, 0.95)
        ),
        url("images/ui/result-background.webp"),
        radial-gradient(
            circle at 50% 35%,
            #4a171a,
            #171a1d 45%,
            #070809
        );

    background-size: cover;
    background-position: center;
}

.result-screen.show {
    display: block;
}

.result-light {
    position: fixed;

    top: 15%;
    left: 50%;

    width: 450px;
    height: 450px;

    border-radius: 50%;

    background:
        rgba(201, 40, 46, 0.14);

    filter: blur(95px);

    transform: translateX(-50%);

    pointer-events: none;
}

.result-content {
    position: relative;
    z-index: 2;

    width: min(100%, 500px);

    margin: auto;

    text-align: center;
}

.result-eyebrow {
    margin: 0 0 5px;

    color: #bbb7b2;

    font-size: 12px;
}

.result-content > h2 {
    margin: 0;

    font-size: clamp(36px, 10vw, 58px);
    line-height: 1;

    font-weight: 700;
}

.result-description {
    margin: 10px 0 0;

    color: #d9d5ce;

    font-size: 12px;
}

.result-title-line {
    width: 95px;
    height: 4px;

    margin: 13px auto 16px;

    background: var(--red);

    transform: skewX(-28deg);
}


/* Canvas */

.canvas-frame {
    position: relative;

    width: min(100%, 430px);

    margin: auto;

    overflow: hidden;

    border: 1px solid #707378;

    background: #111315;

    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.68);
}

#resultCanvas {
    width: 100%;
    height: auto;

    display: block;

    aspect-ratio: 4 / 5;
}

.canvas-loading {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #eeeae4;

    background:
        rgba(5, 6, 7, 0.92);

    font-size: 13px;
}

.canvas-loading.hidden {
    display: none;
}


/* 結果コード */

.coordinate-code {
    width: min(420px, 94%);
    margin: 13px auto 0;
    padding: 12px 14px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 5px;

    border-left: 3px solid var(--red);
    border-right: 3px solid var(--red);

    background:
        rgba(0, 0, 0, 0.58);
}

.coordinate-code span {
    color: #aaa6a0;
    font-size: 10px;
}

.coordinate-code strong {
    width: 100%;

    color: #fff;

    font-size: clamp(
        12px,
        3.5vw,
        15px
    );

    line-height: 1.7;
    font-weight: 700;

    text-align: center;

    white-space: pre-line;
    overflow-wrap: anywhere;
}


/* =====================================
   結果ボタン
===================================== */
.download-button,
.retry-button {
    display: block;
    width: min(360px, 90%);
    margin-left: auto;
    margin-right: auto;
    cursor: pointer;
}

.download-button {
    min-height: 47px;
    margin-top: 9px;
    border: 1px solid #73777c;
    color: #eeeae4;
    background: #202327;
}

.retry-button {
    min-height: 44px;
    margin-top: 9px;
    border: 0;
    color: #bdb9b2;
    background: transparent;
    text-decoration: underline;
}

.download-button:disabled {
    opacity: 0.4;
}

.share-button {
    min-height: 59px;

    margin-top: 14px;

    border: 1px solid var(--red-light);

    color: #fff;

    background:
        linear-gradient(
            135deg,
            #711519,
            var(--red),
            #85171b
        );

    font-size: 17px;
    font-weight: 700;
}

.download-button {
    min-height: 47px;

    margin-top: 9px;

    border: 1px solid #73777c;

    color: #eeeae4;
    background: #202327;
}

.retry-button {
    min-height: 44px;

    margin-top: 9px;

    border: 0;

    color: #bdb9b2;
    background: transparent;

    text-decoration: underline;
}

.share-button:disabled,
.download-button:disabled {
    opacity: 0.4;
}

.share-message {
    min-height: 18px;

    margin: 8px 0 0;

    color: #d4d0c9;

    font-size: 11px;
}


/* 小型スマホ */

@media (max-width: 380px) {
    .game-screen {
        padding-left: 4px;
        padding-right: 4px;
    }

    .reels {
        gap: 3px;
    }

    .game-header h1 {
        font-size: 32px;
    }

    .stop-button {
        min-height: 46px;
    }
}

