/* ゲーム読み込み状態 */
.gida-btn.is-loading {
    background: #eeeeee;
    border-color: #777777;
}

.gida-btn.is-loading .btn-text {
    color: #777777;
}

.gida-btn.is-error {
    background: #fff1f1;
    border-color: #b42318;
}

.gida-btn.is-error .btn-text {
    color: #b42318;
}

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

.back-btn {
    min-height: 76px;
}

.back-btn .btn-text {
    font-size: 1.5rem;
}

.back-arrow {
    position: absolute;
    left: 28px;

    color: #ff9800;

    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}


/* ========================================
   stage-select.html：タイトル
======================================== */

.stage-title {
    margin-bottom: 30px;
    padding: 20px;

    background: #ffffff;

    border: 5px solid #000000;
    border-radius: 25px;
}

.stage-title h1 {
    color: #ff9800;
    font-size: 2rem;
    letter-spacing: 1px;
}


/* ========================================
   stage-select.html：ステージ一覧
======================================== */

.stage-list {
    margin-bottom: 40px;

    display: flex;
    flex-direction: column;
    gap: 40px;
}

.stage-card {
    display: block;
    overflow: hidden;

    background: #ffffff;
    color: #000000;

    border: 5px solid #000000;
    border-radius: 25px;

    text-decoration: none;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.stage-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 0 #ff9800;
}

.stage-card:focus-visible {
    outline: 5px solid #ffd28a;
    outline-offset: 5px;
}

.stage-card:active {
    transform: translateY(2px);
    box-shadow: 0 3px 0 #ff9800;
}

.stage-image {
    width: 100%;
    height: 200px;

    background: #eeeeee;
    color: #888888;

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

    font-size: 1.5rem;
    font-weight: 800;
}

.stage-name {
    padding: 20px;

    color: #ff9800;

    border-top: 3px solid #000000;

    font-size: 1.5rem;
    font-weight: 800;
}


@media (max-width: 500px) {
    .stage-title h1 {
        font-size: 1.7rem;
    }

    .back-arrow {
        left: 20px;
        font-size: 1.7rem;
    }

    .stage-list {
        gap: 30px;
    }

    .stage-image {
        height: 170px;
        font-size: 1.2rem;
    }

}

/* =========================
   全ステージ共通の漫画・ゲーム画面
========================= */

.stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.stage-header h1 {
    color: #222222;
    font-size: 1.5rem;
}

.manga-box {
    /* The same panel occupies (142, 566)–(1394, 1482) in all 1536 × 2048 images. */
    --panel-left: 142;
    --panel-top: 566;
    --panel-width: 1252;
    --panel-height: 916;
    position: relative;
    box-sizing: content-box;
    width: calc(100% - 10px);
    aspect-ratio: var(--panel-width) / var(--panel-height);
    overflow: hidden;
    background: #ffffff;
    border: 5px solid #000000;
    border-radius: 16px;
}

.manga-image {
    position: absolute;
    display: block;
    width: calc(100% * 1536 / var(--panel-width));
    height: auto;
    left: calc(-100% * var(--panel-left) / var(--panel-width));
    top: calc(-100% * var(--panel-top) / var(--panel-height));
}

.manga-page {
    margin: 12px 0;
    color: #333333;
    font-size: 1rem;
    font-weight: 800;
}

.manga-navigation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.manga-navigation .gida-btn {
    min-width: 0;
    max-width: none;
    min-height: 60px;
    padding: 12px 8px;
    border-width: 4px;
    border-radius: 16px;
    touch-action: manipulation;
}

.manga-navigation .btn-text {
    color: #222222;
    font-size: clamp(0.9rem, 4.5vw, 1.25rem);
    letter-spacing: 0.03em;
    white-space: normal;
}

.manga-navigation #nextBtn:not(:disabled):not(.is-error) {
    background: #ff9800;
}

.manga-navigation .gida-btn:disabled {
    background: #eeeeee;
    border-color: #999999;
    cursor: not-allowed;
}

.manga-navigation .gida-btn:disabled .btn-text {
    color: #666666;
}

.manga-navigation .gida-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 0 #ff9800;
}

.unity-container {
    width: 100%;
    max-width: 480px;
    aspect-ratio: 9 / 16;

    margin: 20px auto 30px;

    overflow: hidden;

    background: #000000;

    border: 5px solid #000000;
    border-radius: 25px;
}

/* Unityにゼロではない描画サイズを与えたまま、PLAYまでは画面外で待機させる。 */
.unity-container.is-preloading {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;

    width: min(100vw, 480px);
    margin: 0;

    opacity: 0;
    pointer-events: none;
}

.unity-container.is-visible {
    position: relative;
    z-index: auto;
    opacity: 1;
}

.unity-status {
    max-width: 380px;
    margin: 12px auto 20px;
    color: #555555;
    font-size: 0.95rem;
    line-height: 1.6;
}

.unity-frame {
    display: block;

    width: 100%;
    height: 100%;

    border: none;

    background: #000000;
}

img.manga-image[hidden],
.manga-retry[hidden] {
    display: none;
}

.stage-note {
    display: inline-block;
    margin-left: 12px;
    color: #555555;
    font-size: 1rem;
}

.stage-unavailable {
    padding: 32px 20px;
    margin-bottom: 30px;
    border: 5px solid #000000;
    border-radius: 25px;
    background: #ffffff;
    line-height: 1.8;
}
