* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: #1f1008;
    font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
    background-color: #07142d;
    overflow-x: hidden;
}

body.is-dialog-open {
    overflow: hidden;
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.one-oracle-page {
    min-height: 100vh;
    padding: 16px;
    background-color: #07142d;
    background-image: url("../images/menu/menu-stage1-space-bg.png");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

.oracle-panel {
    position: relative;
    width: min(100%, 720px);
    margin: 0 auto;
    padding: 170px 28px 28px;
    text-align: center;
    background-color: #fffdf7;
    background-image:
        linear-gradient(
            rgba(255, 253, 247, 0.78),
            rgba(255, 250, 238, 0.78)
        ),
        url("../images/menu/menu-stage1-parchment.png");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    border: 4px solid #c89b3c;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(72, 48, 20, 0.2);
}

.oracle-panel::before {
    position: absolute;
    inset: 14px;
    border: 1px solid #d7b45b;
    border-radius: 10px;
    content: "";
    pointer-events: none;
}

.oracle-heading {
    position: absolute;
    top: 22px;
    left: 50%;
    z-index: 2;
    width: min(88%, 520px);
    padding: 14px 24px 16px;
    color: #fffdf7;
    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.32) 0%,
            rgba(255, 255, 255, 0.08) 20%,
            rgba(255, 255, 255, 0) 48%
        ),
        linear-gradient(
            180deg,
            #ffd15f 0%,
            #f3ad35 46%,
            #d98216 100%
        );
    border: 2px solid #f9d982;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.74),
        inset 0 -2px 0 rgba(125, 66, 18, 0.28),
        0 4px 0 #a95b10;
    transform: translateX(-50%);
}

#page-title {
    margin: 0 0 6px;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    letter-spacing: 0.08em;
    text-shadow: 0 1px 2px rgba(88, 56, 8, 0.4);
}

.oracle-heading-lead {
    margin: 0;
    color: #fffdf7;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.7;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(88, 56, 8, 0.35);
}

.top-menu-navigation {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    margin: 16px 0 16px;
}

.top-menu-link,
.top-menu-link:visited {
    display: inline-flex;
    min-width: 190px;
    padding: 10px 20px;
    align-items: center;
    justify-content: center;
    color: #211008;
    font-size: 1.02rem;
    font-weight: bold;
    text-decoration: none;
    background-color: #fffaf0;
    border: 2px solid #b9894e;
    border-radius: 9px;
    box-shadow: 0 2px 0 #d7b580;
    transition:
        transform 0.2s,
        background-color 0.2s,
        box-shadow 0.2s;
}

.top-menu-link:hover {
    background-color: #fff0cf;
    box-shadow: 0 4px 0 #d7b580;
    transform: translateY(-2px);
}

.top-menu-link:active {
    box-shadow: 0 1px 0 #d7b580;
    transform: translateY(2px);
}

.top-menu-link:focus-visible {
    outline: 3px solid #4b7d9e;
    outline-offset: 3px;
}

.theme-form {
    position: relative;
    z-index: 2;
    width: min(100%, 560px);
    margin: 0 auto;
}

.theme-selector {
    width: min(100%, 560px);
    margin: 0 auto 10px;
    padding: 8px 16px 11px;
    text-align: center;
    border: 1px solid rgba(192, 142, 47, 0.58);
}

.theme-selector legend {
    padding: 0 6px;
    color: #1f1008;
    font-size: 1.04rem;
    font-weight: bold;
}

.theme-options {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.theme-option {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    color: #241107;
    cursor: pointer;
}

.theme-option input {
    position: static;
    width: 1rem;
    height: 1rem;
    margin: 0 7px 0 0;
    flex: 0 0 auto;
    cursor: pointer;
    opacity: 1;
    pointer-events: auto;
    accent-color: auto;
}

.theme-option-label {
    display: inline;
    min-height: 0;
    padding: 0;
    color: #241107;
    font-size: 1.02rem;
    font-weight: 500;
    line-height: 1.45;
    white-space: nowrap;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transition: color 0.2s;
}

.theme-option:hover .theme-option-label {
    color: #804003;
    background: none;
    box-shadow: none;
    transform: none;
}

.theme-option input:checked + .theme-option-label {
    color: #804003;
    font-weight: bold;
    background: none;
    border: 0;
    box-shadow: none;
}

.theme-option input:focus-visible {
    outline: 3px solid #4b7d9e;
    outline-offset: 3px;
}

.theme-option input:disabled {
    cursor: not-allowed;
}

.theme-option input:disabled + .theme-option-label {
    cursor: not-allowed;
    opacity: 0.7;
}

.oracle-lead {
    position: relative;
    z-index: 6;
    min-height: 56px;
    margin: 14px auto 8px;
    padding: 0 8px;
    color: #241107;
    font-size: 1.08rem;
    font-weight: 500;
    line-height: 1.8;
    letter-spacing: 0.015em;
    text-align: center;
    background-color: #fffdf7;
}

.oracle-lead-action {
    display: inline-block;
    margin-top: 2px;
    color: #804003;
    font-weight: bold;
}

.mobile-line-break {
    display: none;
}

.card-stage {
    position: relative;
    z-index: 1;
    min-height: 246px;
    margin: 0 auto;
}

#oracle-lead[hidden] + .card-stage {
    margin-top: 18px;
}

#deck-stack {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(108px, 13vw, 128px);
    aspect-ratio: var(--tarot-card-ratio, 1109 / 1920);
    isolation: isolate;
    transform: translate(-50%, -50%);
}

#drawn-card {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

.deck-card {
    position: absolute;
    inset: 0;
    z-index: var(--deck-z);
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 5px 12px rgba(72, 48, 20, 0.22);
    transform:
        translate(var(--rest-x), var(--rest-y))
        rotate(var(--rest-rotate));
    transition:
        opacity 0.25s,
        transform 0.25s;
    transform-origin: center;
}

#deck-stack.is-shuffling .deck-card {
    animation: tarot-deck-shuffle var(--shuffle-duration) ease-in-out infinite;
    animation-delay: var(--shuffle-delay);
}

@keyframes tarot-deck-shuffle {
    0%,
    100% {
        transform:
            translate(var(--rest-x), var(--rest-y))
            rotate(var(--rest-rotate));
    }

    25% {
        transform:
            translate(var(--move-1-x), var(--move-1-y))
            rotate(var(--move-1-rotate))
            scale(var(--shuffle-card-scale));
    }

    50% {
        transform:
            translate(var(--move-2-x), var(--move-2-y))
            rotate(var(--move-2-rotate))
            scale(var(--shuffle-card-scale));
    }

    75% {
        transform:
            translate(var(--move-3-x), var(--move-3-y))
            rotate(var(--move-3-rotate))
            scale(var(--shuffle-card-scale));
    }
}

#deck-stack.is-card-decided .deck-card {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.96);
}

#deck-stack.is-card-decided .deck-card:first-child {
    z-index: 30;
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
}

#tarot-card-image {
    width: clamp(108px, 13vw, 128px);
    max-width: 100%;
    height: auto;
    aspect-ratio: var(--tarot-card-ratio, 1109 / 1920);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(72, 48, 20, 0.25);
}

.is-reversed {
    transform: rotate(180deg);
}

.button-area {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    min-height: 52px;
    margin-top: 10px;
}

.button-area button,
#repeat-button,
.replay-modal-buttons button {
    min-width: 150px;
    padding: 12px 24px;
    color: #211008;
    font-size: 1.05rem;
    font-weight: bold;
    cursor: pointer;
    background: linear-gradient(180deg, #ffd7b9, #f2b785);
    border: 2px solid #70401f;
    border-radius: 10px;
    box-shadow: 0 3px 0 #a9673b;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.button-area button:not(:disabled):hover,
#repeat-button:hover,
.replay-modal-buttons button:hover {
    box-shadow: 0 5px 0 #a9673b;
    transform: translateY(-2px);
}

.button-area button:not(:disabled):active,
#repeat-button:active,
.replay-modal-buttons button:active {
    box-shadow: 0 1px 0 #a9673b;
    transform: translateY(2px);
}

.button-area button:disabled {
    color: #907866;
    cursor: not-allowed;
    background: #ead9cc;
    border-color: #b9a18d;
    box-shadow: 0 3px 0 #a88c75;
}

.button-area button:focus-visible,
#repeat-button:focus-visible,
.replay-modal-buttons button:focus-visible {
    outline: 3px solid #4b7d9e;
    outline-offset: 3px;
}

.oracle-panel.is-result-view .card-stage {
    min-height: 236px;
}

.oracle-panel.is-result-view .button-area {
    min-height: 0;
    margin-top: 2px;
}

#result-area {
    position: relative;
    z-index: 2;
    margin: 20px auto 0;
    padding: 22px;
    color: #1f1008;
    text-align: left;
    background-color: #fffaf0;
    border: 2px solid #9f7442;
    border-radius: 10px;
}

#result-area .reading-result-title {
    margin: 0;
    padding-bottom: 14px;
    color: #1f1008;
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    text-align: center;
    border-bottom: 2px solid #d7b45b;
}

.result-theme-label {
    margin: 16px 0 24px;
    color: #804003;
    font-size: 1.04rem;
    font-weight: bold;
    text-align: center;
}

#result-card-name {
    margin: 0;
    color: #1f1008;
    font-size: 1.42rem;
    font-weight: bold;
}

#result-area .reading-keyword-label {
    margin: 18px 0 6px;
    color: #804003;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.03em;
}

#result-card-keywords {
    margin: 0;
    color: #4d2a12;
    font-size: 1.02rem;
    font-weight: 500;
}

#result-card-meaning {
    margin: 0;
    color: #241107;
    font-size: 1.02rem;
    font-weight: 500;
    line-height: 1.9;
}

#result-area .reading-section-title {
    margin: 20px 0 8px;
    color: #804003;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.03em;
}

.result-detail-block {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(199, 150, 65, 0.5);
}

.result-detail-block h4 {
    margin: 0 0 8px;
    color: #804003;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.03em;
}

#result-interpretation {
    margin: 0;
    color: #241107;
    font-size: 1.02rem;
    font-weight: 500;
    line-height: 1.9;
}

#repeat-button {
    display: block;
    margin: 24px auto 0;
}

.replay-modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    padding: 16px;
    place-items: center;
}

.replay-modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(54, 34, 18, 0.58);
}

.replay-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    padding: 28px 24px 24px;
    text-align: center;
    background-color: #fffdf7;
    border: 3px solid #c89b3c;
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(35, 20, 8, 0.35);
}

.replay-modal-dialog h2 {
    margin: 0 0 14px;
    color: #1f1008;
    font-size: 1.35rem;
}

.replay-modal-dialog p {
    margin: 0;
    color: #241107;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.8;
}

.replay-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.replay-modal-buttons button {
    min-width: 130px;
}

.cancel-replay-button {
    background: #fffaf0 !important;
}

/* PC版だけ、山札と通常時のスタートボタンの間を広げる */
@media (min-width: 768px) {
    .one-oracle-page {
        background-attachment: fixed;
    }

    .button-area {
        margin-top: 24px;
    }
}

@media (max-width: 767px) {
    .one-oracle-page {
        padding: 16px 10px;
        background-image: none;
        background-color: #07142d;
    }

    .oracle-panel {
        padding: 166px 20px 28px;
    }

    .oracle-heading {
        width: min(90%, 420px);
        padding: 13px 14px 15px;
    }

    .oracle-heading-lead {
        font-size: 0.94rem;
        letter-spacing: 0;
    }

    .top-menu-navigation {
        margin-top: 10px;
    }

    .top-menu-link,
    .top-menu-link:visited {
        font-size: 1rem;
    }

    .theme-selector {
        padding-right: 8px;
        padding-left: 8px;
    }

    .theme-selector legend {
        font-size: 1rem;
    }

    .theme-options {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: normal;
        gap: 12px 14px;
    }

    .theme-option {
        justify-content: flex-start;
        padding-left: 12px;
    }

    .theme-option input {
        width: 1.08rem;
        height: 1.08rem;
        margin-right: 6px;
    }

    .theme-option-label {
        font-size: 1rem;
    }

    .oracle-lead {
        min-height: 76px;
        margin-top: 18px;
        font-size: 1rem;
        letter-spacing: 0;
        text-align: center;
    }

    .oracle-lead-action {
        display: block;
        text-align: center;
    }

    .mobile-line-break {
        display: inline;
    }

    .card-stage {
        min-height: 268px;
    }

    #oracle-lead[hidden] + .card-stage {
        margin-top: 10px;
    }

    #deck-stack {
        width: min(31vw, 110px);
    }

    #deck-stack.is-shuffling {
        transform: translate(-50%, -50%) scale(0.9);
    }

    #tarot-card-image {
        width: min(34vw, 122px);
    }

    .button-area button {
        min-width: 140px;
        font-size: 1rem;
    }

    .oracle-panel.is-result-view .card-stage {
        min-height: 250px;
    }

    #result-area {
        padding: 18px;
    }

    #result-area .reading-result-title {
        font-size: 1.45rem;
    }

    .result-theme-label,
    #result-card-keywords,
    #result-interpretation,
    #result-area .reading-section-title,
    .result-detail-block h4 {
        font-size: 1rem;
    }

    #result-card-name {
        font-size: 1.32rem;
    }

    .replay-modal-dialog {
        padding: 24px 18px 20px;
    }

    .replay-modal-dialog h2 {
        font-size: 1.28rem;
    }

    .replay-modal-dialog p {
        text-align: left;
    }

    .replay-modal-buttons {
        flex-direction: column;
        align-items: center;
    }

    .replay-modal-buttons button {
        width: min(100%, 240px);
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #deck-stack.is-shuffling .deck-card {
        animation: none;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto;
        transition-duration: 0.01ms !important;
    }
}