/* ============================================================================
 * ウインドランナー — ゲーム専用スタイル
 * .play-stage の中に収まる前提。色はサイト共通のCSS変数を流用。
 * ========================================================================== */

/* hidden属性を必ず優先させる（.wr-combo{display:flex} 等がUAスタイルの
   [hidden]{display:none} を上書きして、非表示のはずのコンボ表示などが
   常に見えてしまうのを防ぐ）。 */
.wr-root [hidden] { display: none !important; }

.wr-root {
    --primary: #ff5e7d;
    --primary-deep: #e8345d;
    --mint: #3ee0c8;
    --gold: #ffcf45;
    --violet: #9a7bff;
    --sky: #5ec8ff;
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.wr-viewport {
    position: relative;
    width: 100%;
}

.wr-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #0c0a22;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}

.wr-touch-controls {
    display: none;
}

/* ---------------- 上部HUD ---------------- */
.wr-hud {
    position: absolute;
    inset: 0 0 auto 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px 16px;
    pointer-events: none;
}
.wr-hud-left { display: flex; flex-direction: column; gap: 2px; }
.wr-score-box { display: flex; align-items: baseline; gap: 8px; }
.wr-score-label {
    font-family: var(--font-pixel, monospace);
    font-size: .62rem; letter-spacing: .12em;
    color: var(--mint, #3ee0c8);
    text-shadow: 0 0 8px rgba(62, 224, 200, .5);
}
.wr-score {
    font-family: var(--font-pixel, monospace);
    font-size: 1.9rem; line-height: 1;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .5), 0 0 14px rgba(255, 255, 255, .25);
}
.wr-sub {
    font-family: var(--font-pixel, monospace);
    font-size: .78rem;
    color: rgba(255, 255, 255, .8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.wr-coin-ico { color: var(--gold, #ffcf45); }

.wr-hud-right { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.wr-combo {
    display: flex; flex-direction: column; align-items: center; line-height: 1;
    font-family: var(--font-pixel, monospace);
    color: var(--gold, #ffcf45);
    text-shadow: 0 0 10px rgba(255, 207, 69, .6);
    animation: wr-combo-pop .3s ease;
}
.wr-combo span { font-size: 1.5rem; }
.wr-combo small { font-size: .55rem; letter-spacing: .15em; opacity: .85; }
@keyframes wr-combo-pop { from { transform: scale(1.5); } to { transform: scale(1); } }

.wr-pause-btn {
    pointer-events: auto;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .25);
    background: rgba(20, 16, 43, .55);
    color: #fff;
    font-size: .8rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background .15s, transform .1s;
}
.wr-pause-btn:hover { background: rgba(40, 32, 80, .75); }
.wr-pause-btn:active { transform: scale(.92); }

/* ---------------- パワーアップ残量チップ ---------------- */
.wr-powerups {
    position: absolute;
    left: 16px; top: 58px;
    display: flex; gap: 8px;
    pointer-events: none;
}
.wr-pu-chip {
    --c: var(--violet, #9a7bff);
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    font-size: 1rem;
    border-radius: 9px;
    background: rgba(20, 16, 43, .7);
    border: 1px solid var(--c);
    box-shadow: 0 0 12px color-mix(in srgb, var(--c) 40%, transparent);
    overflow: hidden;
}
.wr-pu-chip b { font-style: normal; }
.wr-pu-chip i {
    position: absolute; left: 0; bottom: 0;
    height: 3px; background: var(--c);
    transition: width .2s linear;
}

/* ---------------- オーバーレイ共通 ---------------- */
.wr-overlay {
    position: absolute; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, rgba(12, 10, 34, .55), rgba(12, 10, 34, .8));
    backdrop-filter: blur(3px);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    z-index: 5;
}
.wr-overlay.is-active { display: flex; animation: wr-fade .25s ease; }
@keyframes wr-fade { from { opacity: 0; } to { opacity: 1; } }

.wr-overlay-card {
    display: flex; flex-direction: column; align-items: center;
    gap: 14px;
    max-width: 420px; width: 100%;
}
.wr-start .wr-overlay-card { max-width: 540px; }

/* タイトル */
.wr-logo {
    display: flex; align-items: center; gap: 10px;
    font-size: 2rem;
}
.wr-logo span {
    font-family: var(--font-display, sans-serif);
    font-size: 1.7rem; letter-spacing: .02em;
    color: var(--mint, #3ee0c8);
    text-shadow: 0 0 18px rgba(62, 224, 200, .5);
}
.wr-logo b { color: #fff; }
.wr-tagline { color: rgba(255, 255, 255, .8); font-size: .95rem; margin-top: -6px; }

.wr-hint {
    display: flex; flex-direction: column; gap: 6px;
    font-size: .8rem; color: rgba(255, 255, 255, .7);
    margin-top: 4px;
}
.wr-hint kbd {
    font-family: var(--font-pixel, monospace);
    font-size: .72rem;
    padding: 2px 7px; margin: 0 2px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25);
    border-bottom-width: 2px;
    color: #fff;
}

/* 大ボタン */
.wr-big-btn {
    font-family: var(--font-display, sans-serif);
    font-size: 1.1rem;
    padding: 13px 42px;
    border: none; border-radius: 999px;
    background: linear-gradient(135deg, var(--primary, #ff5e7d), var(--primary-deep, #e8345d));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(232, 52, 93, .45);
    transition: transform .12s, box-shadow .12s, filter .12s;
}
.wr-big-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(232, 52, 93, .55); filter: brightness(1.06); }
.wr-big-btn:active { transform: translateY(0) scale(.97); }

.wr-text-btn {
    background: none; border: none;
    color: rgba(255, 255, 255, .65);
    font-size: .88rem; cursor: pointer;
    text-decoration: underline; text-underline-offset: 3px;
    padding: 4px;
}
.wr-text-btn:hover { color: #fff; }

/* ポーズ */
.wr-paused-title {
    font-family: var(--font-pixel, monospace);
    font-size: 2rem; letter-spacing: .2em;
    color: var(--sky, #5ec8ff);
    text-shadow: 0 0 16px rgba(94, 200, 255, .5);
}

/* ゲームオーバー */
.wr-over-title {
    font-family: var(--font-display, sans-serif);
    font-size: 1.6rem;
    color: var(--primary, #ff5e7d);
    text-shadow: 0 0 16px rgba(255, 94, 125, .4);
}
.wr-result { display: flex; flex-direction: column; align-items: center; gap: 0; }
.wr-result-score {
    font-family: var(--font-pixel, monospace);
    font-size: 3.4rem; line-height: 1;
    color: var(--gold, #ffcf45);
    text-shadow: 0 0 22px rgba(255, 207, 69, .5);
}
.wr-result-label {
    font-family: var(--font-pixel, monospace);
    font-size: .68rem; letter-spacing: .2em;
    color: rgba(255, 255, 255, .6);
}
.wr-result-detail {
    display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center;
    font-size: .88rem; color: rgba(255, 255, 255, .75);
}
.wr-result-detail b { color: #fff; font-family: var(--font-pixel, monospace); }

.wr-save-status {
    font-size: .85rem;
    padding: 8px 16px;
    border-radius: 10px;
    min-height: 1em;
}
.wr-save-status.muted { color: var(--ink-muted, #a59fd6); background: rgba(255, 255, 255, .06); }
.wr-save-status.ok { color: var(--mint, #3ee0c8); background: rgba(62, 224, 200, .12); }
.wr-save-status.best {
    color: var(--gold, #ffcf45); background: rgba(255, 207, 69, .14);
    font-weight: 700;
    animation: wr-best 1s ease infinite alternate;
}
@keyframes wr-best { from { box-shadow: 0 0 0 rgba(255, 207, 69, 0); } to { box-shadow: 0 0 18px rgba(255, 207, 69, .4); } }
.wr-save-status.err { color: var(--primary, #ff5e7d); background: rgba(255, 94, 125, .12); }

/* ---------------- レスポンシブ ---------------- */
@media (max-width: 560px) {
    .wr-score { font-size: 1.5rem; }
    .wr-logo span { font-size: 1.35rem; }
    .wr-result-score { font-size: 2.6rem; }
    .wr-big-btn { padding: 11px 34px; font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .wr-combo, .wr-overlay.is-active, .wr-save-status.best { animation: none; }
}

/* ---------------- バイオーム表示 ---------------- */
.wr-biome {
    display: inline-block;
    padding: 1px 8px; border-radius: 999px;
    font-size: .82rem; font-weight: 700;
    color: var(--mint, #3ee0c8);
    background: rgba(62, 224, 200, .12);
    border: 1px solid rgba(62, 224, 200, .3);
}

/* ---------------- キャラクター選択 ---------------- */
.wr-charsel {
    display: flex; align-items: center; gap: 18px;
    width: 100%; justify-content: center;
    padding: 6px 0 2px;
}
.wr-preview {
    width: 130px; height: 130px; flex: none;
    border-radius: 18px;
    background:
        radial-gradient(120px 80px at 50% 20%, rgba(154, 123, 255, .22), transparent 70%),
        linear-gradient(180deg, rgba(20, 16, 43, .6), rgba(14, 11, 32, .85));
    border: 1px solid var(--border, #322a63);
    box-shadow: inset 0 0 24px rgba(0, 0, 0, .4);
}
.wr-charsel-info { text-align: left; min-width: 150px; }
.wr-charsel-eyebrow {
    font-size: .72rem; letter-spacing: .08em;
    color: var(--ink-dim, #756f9f); text-transform: uppercase;
    margin-bottom: 4px;
}
.wr-char-name {
    font-family: var(--font-display, sans-serif);
    font-size: 1.5rem; color: #fff; line-height: 1.1;
}
.wr-char-desc { font-size: .85rem; color: rgba(255, 255, 255, .75); margin-top: 4px; }

.wr-char-picker {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
    width: 100%;
}
.wr-char-btn {
    --c: #ff5e7d;
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 13px 7px 9px; border-radius: 999px;
    background: rgba(20, 16, 43, .72);
    border: 1.5px solid rgba(255, 255, 255, .22);
    color: rgba(255, 255, 255, .82);
    font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
    transition: transform .12s, border-color .12s, background .12s, box-shadow .12s;
}
.wr-char-btn .dot {
    width: 12px; height: 12px; border-radius: 50%; flex: none;
    background: var(--c);
    box-shadow: 0 0 8px var(--c);
}
.wr-char-btn:hover { transform: translateY(-1px); border-color: var(--c); }
.wr-char-btn.is-active {
    border-color: var(--c);
    background: color-mix(in srgb, var(--c) 20%, #1b163b);
    color: #fff;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent), 0 8px 18px rgba(0, 0, 0, .3);
}

@media (max-width: 560px) {
    .wr-start .wr-overlay-card { max-width: 420px; }
    .wr-charsel { flex-direction: column; gap: 10px; }
    .wr-charsel-info { text-align: center; }
    .wr-preview { width: 110px; height: 110px; }
}

@media (max-width: 720px) {
    .wr-root {
        max-width: none;
    }
    .wr-canvas {
        /* 横幅はそのまま、スマホだけ16:9より少し縦を広くする。 */
        aspect-ratio: 3 / 2;
        border-radius: 0;
        box-shadow: none;
    }
    .wr-overlay {
        border-radius: 0;
        padding: 10px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .wr-start .wr-overlay-card,
    .wr-over .wr-overlay-card {
        gap: 6px;
    }
    .wr-start .wr-tagline,
    .wr-start .wr-hint {
        display: none;
    }
    /* スマホでも選択中キャラクターの走行プレビューは消さない。 */
    .wr-start .wr-charsel {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 9px;
        padding: 0;
    }
    .wr-start .wr-preview {
        width: 76px;
        height: 76px;
        border-radius: 12px;
    }
    .wr-start .wr-charsel-info {
        min-width: 0;
        max-width: 150px;
        text-align: left;
    }
    .wr-start .wr-charsel-eyebrow {
        font-size: .61rem;
        margin-bottom: 2px;
    }
    .wr-start .wr-char-name {
        font-size: 1.1rem;
    }
    .wr-start .wr-char-desc {
        display: none;
    }
    .wr-start .wr-logo {
        gap: 6px;
        font-size: 1.35rem;
    }
    .wr-start .wr-logo span {
        font-size: 1.15rem;
    }
    .wr-start .wr-char-picker {
        gap: 4px;
    }
    .wr-start .wr-char-btn {
        padding: 4px 8px 4px 6px;
        font-size: .72rem;
    }
    .wr-start .wr-char-btn .dot {
        width: 9px;
        height: 9px;
    }
    .wr-start .wr-big-btn,
    .wr-over .wr-big-btn {
        padding: 8px 28px;
        font-size: .9rem;
    }
    .wr-over-title {
        font-size: 1.2rem;
    }
    .wr-result-score {
        font-size: 2.1rem;
    }
    .wr-result-detail,
    .wr-save-status {
        font-size: .72rem;
    }
    .wr-touch-controls {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 64px;
        gap: 9px;
        width: 100%;
        padding: 10px 12px max(10px, env(safe-area-inset-bottom));
        background: #15102f;
        touch-action: none;
    }
    .wr-touch-btn {
        min-width: 0;
        min-height: 62px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border: 1px solid rgba(255, 255, 255, .2);
        border-radius: 15px;
        color: #fff;
        background: linear-gradient(180deg, #3a315f, #241c48);
        box-shadow: 0 5px 0 #100c25;
        cursor: pointer;
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
    }
    .wr-touch-btn span {
        font-size: 1.45rem;
        line-height: 1;
    }
    .wr-touch-btn strong {
        font-size: .95rem;
    }
    .wr-touch-btn--jump {
        border-color: rgba(62, 224, 200, .55);
        background: linear-gradient(180deg, #237f78, #185854);
    }
    .wr-touch-btn--slide {
        border-color: rgba(255, 207, 69, .55);
        background: linear-gradient(180deg, #8b6722, #654716);
    }
    .wr-touch-btn--expand {
        flex-direction: column;
        gap: 2px;
        padding-inline: 4px;
    }
    .wr-touch-btn--expand strong {
        font-size: .68rem;
    }
    .wr-touch-btn:active,
    .wr-touch-btn.is-held {
        transform: translateY(4px);
        box-shadow: 0 1px 0 #100c25;
        filter: brightness(1.12);
    }
}

body.wr-expanded-active {
    overflow: hidden;
}

.wr-root.is-expanded,
.wr-root:fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0c0a22;
}
.wr-root.is-expanded .wr-viewport,
.wr-root:fullscreen .wr-viewport {
    width: min(100vw, 177.78dvh);
}
.wr-root.is-expanded .wr-canvas,
.wr-root:fullscreen .wr-canvas,
.wr-root.is-expanded .wr-overlay,
.wr-root:fullscreen .wr-overlay {
    border-radius: 0;
}
.wr-root.is-expanded .wr-touch-controls,
.wr-root:fullscreen .wr-touch-controls {
    position: absolute;
    z-index: 40;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    padding: 0;
    background: transparent;
}
.wr-root.is-expanded .wr-touch-btn,
.wr-root:fullscreen .wr-touch-btn {
    min-height: 56px;
    opacity: .9;
}

@media (max-width: 720px) {
    .wr-root.is-expanded,
    .wr-root:fullscreen {
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        padding-top: max(6px, env(safe-area-inset-top));
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }
    .wr-root.is-expanded .wr-viewport,
    .wr-root:fullscreen .wr-viewport {
        flex: none;
        width: 100vw;
    }
    .wr-root.is-expanded .wr-canvas,
    .wr-root:fullscreen .wr-canvas {
        width: 100%;
        height: min(75vw, calc(100dvh - 94px));
        aspect-ratio: auto;
    }
    .wr-root.is-expanded .wr-touch-controls,
    .wr-root:fullscreen .wr-touch-controls {
        position: static;
        flex: none;
        width: 100%;
        padding: 10px 12px max(10px, env(safe-area-inset-bottom));
        background: #15102f;
    }
}

@media (max-width: 720px) and (orientation: landscape) and (max-height: 500px) {
    .wr-canvas {
        aspect-ratio: 16 / 9;
    }
    .wr-touch-controls {
        padding-block: 6px;
    }
    .wr-touch-btn {
        min-height: 50px;
    }
    .wr-root.is-expanded .wr-canvas,
    .wr-root:fullscreen .wr-canvas {
        width: min(100vw, calc((100dvh - 68px) * 16 / 9));
        height: auto;
        aspect-ratio: 16 / 9;
        margin-inline: auto;
    }
}
