:root {
    color-scheme: light;
    font-family: "Arial", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    color: #17201d;
}

* {
    box-sizing: border-box;
}

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

body {
    background: linear-gradient(150deg, #dfe9e3 0%, #f1e4c5 52%, #cddfe8 100%);
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.page-shell {
    width: 100%;
    min-height: 100svh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 0 24px;
}

.game-frame {
    position: relative;
    width: min(100vw, 640px);
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
    background: linear-gradient(90deg, rgba(38, 75, 83, 0.05) 1px, transparent 1px), linear-gradient(180deg, rgba(38, 75, 83, 0.05) 1px, transparent 1px), linear-gradient(180deg, #f9f5ea 0%, #e8f0ec 100%);
    background-size:
        28px 28px,
        28px 28px,
        auto;
    border: 1px solid rgba(34, 57, 55, 0.2);
    box-shadow: 0 20px 70px rgba(39, 57, 55, 0.22);
}

.game-frame::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(170deg, rgba(244, 243, 232, 0.9), rgba(226, 243, 238, 0.95)), url("/timeline-dash/assets/images/mascot.png");
    background-size:
        auto,
        160px auto;
    background-position:
        center,
        center top;
    background-repeat: no-repeat, no-repeat;
    background-blend-mode: multiply;
    opacity: 0.9;
    pointer-events: none;
}

.mascot-character {
    position: absolute;
    right: clamp(10px, 5vw, 22px);
    bottom: clamp(84px, 15vh, 156px);
    width: clamp(120px, 30vw, 220px);
    height: auto;
    z-index: 2;
    pointer-events: none;
    filter: drop-shadow(0 8px 16px rgba(36, 49, 47, 0.28));
    animation: mascot-float 2.8s ease-in-out infinite;
}

.mascot-message {
    position: absolute;
    right: clamp(8px, 5vw, 24px);
    bottom: calc(clamp(84px, 15vh, 156px) + clamp(150px, 38vh, 280px));
    max-width: clamp(180px, 45vw, 250px);
    z-index: 3;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid rgba(34, 57, 55, 0.22);
    border-radius: 12px 12px 12px 2px;
    background: rgba(255, 251, 239, 0.94);
    box-shadow: 0 8px 18px rgba(34, 57, 55, 0.16);
    color: #1f3a3d;
    font-size: 12px;
    line-height: 1.45;
    text-align: left;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
    pointer-events: none;
    min-height: 1.6em;
}

.mascot-message.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.time-rail {
    position: absolute;
    top: 92px;
    bottom: 84px;
    left: 28px;
    z-index: 1;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, #2f6f73, #d7a83f, #9d5742);
    opacity: 0.36;
}

.rail-dot {
    position: absolute;
    left: 50%;
    width: 18px;
    height: 18px;
    border: 3px solid #fbf7ee;
    border-radius: 50%;
    background: #2f6f73;
    box-shadow: 0 4px 10px rgba(31, 45, 43, 0.2);
    transform: translateX(-50%);
}

.dot-one {
    top: 6%;
}

.dot-two {
    top: 33%;
    background: #d7a83f;
}

.dot-three {
    top: 62%;
    background: #b85f4b;
}

.dot-four {
    top: 91%;
    background: #25485f;
}

.panel,
.play-panel {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    padding: max(24px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom));
    text-align: center;
}

.panel {
    align-content: center;
    gap: 18px;
    background: linear-gradient(180deg, rgba(252, 248, 238, 0.92), rgba(235, 244, 240, 0.96));
    backdrop-filter: blur(5px);
}

.start-panel {
    grid-template-rows: auto auto minmax(130px, 1fr) auto auto auto auto;
}

.kicker {
    justify-self: center;
    margin: 0;
    padding: 6px 12px;
    border: 1px solid rgba(47, 111, 115, 0.32);
    border-radius: 999px;
    color: #24555b;
    background: rgba(244, 250, 245, 0.72);
    font-size: 12px;
    font-weight: 900;
}

h1,
h2,
p {
    margin: 0;
}

.start-panel h1 {
    font-size: clamp(34px, 9vw, 58px);
    line-height: 0.96;
    letter-spacing: 0;
    color: #1d383d;
}

.start-visual {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 28px 1fr;
    align-items: center;
    width: min(100%, 430px);
    min-height: 168px;
    justify-self: center;
}

.timeline-line {
    width: 8px;
    height: 148px;
    justify-self: center;
    border-radius: 999px;
    background: linear-gradient(180deg, #2f6f73, #d7a83f, #9d5742);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

.era-card {
    display: grid;
    gap: 7px;
    align-content: center;
    min-height: 112px;
    padding: 16px 14px;
    border: 1px solid rgba(34, 57, 55, 0.22);
    border-radius: 8px;
    background: rgba(255, 251, 239, 0.86);
    box-shadow:
        0 8px 0 rgba(34, 57, 55, 0.1),
        0 18px 30px rgba(34, 57, 55, 0.12);
}

.era-card span {
    font-size: 30px;
    font-weight: 950;
    color: #a95643;
}

.era-card strong {
    color: #263d3e;
}

.era-card-left {
    transform: rotate(-3deg);
}

.era-card-right {
    transform: rotate(3deg);
}

.lead {
    width: min(100%, 420px);
    justify-self: center;
    color: #344743;
    font-size: 16px;
    line-height: 1.7;
}

.hint,
.copyright {
    color: #5e746d;
    font-size: 13px;
}

.copyright {
    font-size: 12px;
}

.primary-button,
.secondary-button {
    width: min(100%, 300px);
    min-height: 58px;
    justify-self: center;
    border: 1px solid rgba(27, 54, 58, 0.28);
    border-radius: 10px;
    color: #fffdf4;
    font-size: 19px;
    font-weight: 900;
    cursor: pointer;
    touch-action: manipulation;
}

.primary-button {
    background: linear-gradient(135deg, #2d6f73, #418b83 58%, #243d4d);
    box-shadow:
        0 10px 0 #1d3338,
        0 18px 28px rgba(34, 57, 55, 0.22);
}

.secondary-button {
    background: linear-gradient(135deg, #7a6651, #9c7b55 58%, #4d4238);
    box-shadow:
        0 10px 0 #3d322b,
        0 18px 28px rgba(34, 57, 55, 0.18);
}

.primary-button:active,
.secondary-button:active {
    transform: translateY(5px);
    box-shadow:
        0 4px 0 #1d3338,
        0 12px 20px rgba(34, 57, 55, 0.2);
}

.hud {
    position: absolute;
    z-index: 4;
    top: max(10px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.meter {
    min-width: 0;
    padding: 7px 6px;
    border: 1px solid rgba(34, 57, 55, 0.18);
    border-radius: 8px;
    background: rgba(255, 252, 242, 0.9);
    box-shadow: inset 0 -2px 0 rgba(34, 57, 55, 0.07);
}

.meter span {
    display: block;
    color: #55706c;
    font-size: 10px;
    font-weight: 900;
}

.meter strong {
    display: block;
    margin-top: 2px;
    color: #1e373b;
    font-size: clamp(15px, 4vw, 22px);
    line-height: 1.1;
}

.play-panel {
    z-index: 3;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 14px;
    align-content: end;
    padding-top: max(78px, calc(env(safe-area-inset-top) + 78px));
}

.question-card {
    align-self: end;
    display: grid;
    gap: 12px;
    width: min(100%, 500px);
    justify-self: center;
    padding: 22px 18px;
    border: 1px solid rgba(34, 57, 55, 0.2);
    border-radius: 8px;
    background: rgba(255, 251, 239, 0.88);
    box-shadow:
        0 12px 0 rgba(47, 111, 115, 0.1),
        0 22px 42px rgba(34, 57, 55, 0.14);
}

.era-text {
    justify-self: center;
    padding: 5px 10px;
    border-radius: 999px;
    color: #fffdf5;
    background: #a95643;
    font-size: 12px;
    font-weight: 900;
}

.question-card h2 {
    color: #172f34;
    font-size: clamp(26px, 7vw, 42px);
    line-height: 1.2;
    letter-spacing: 0;
    text-wrap: balance;
}

.note-text {
    color: #58706c;
    font-size: 14px;
    line-height: 1.5;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: min(100%, 500px);
    justify-self: center;
}

.choice-button {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    min-height: 78px;
    padding: 12px;
    border: 1px solid rgba(34, 57, 55, 0.22);
    border-radius: 8px;
    color: #172f34;
    background: rgba(255, 253, 246, 0.95);
    box-shadow:
        0 7px 0 rgba(34, 57, 55, 0.18),
        0 12px 22px rgba(34, 57, 55, 0.1);
    cursor: pointer;
    touch-action: manipulation;
}

.choice-button:active {
    transform: translateY(4px);
    box-shadow:
        0 3px 0 rgba(34, 57, 55, 0.18),
        0 9px 16px rgba(34, 57, 55, 0.08);
}

.choice-button.correct {
    color: #0f3b2e;
    background: #e2f5df;
    border-color: rgba(40, 126, 74, 0.45);
}

.choice-button.wrong {
    color: #5c201e;
    background: #f8e3dc;
    border-color: rgba(167, 70, 53, 0.42);
}

.choice-button:disabled {
    cursor: default;
}

.choice-index {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fffdf5;
    background: #2f6f73;
    font-size: 14px;
    font-weight: 900;
}

.choice-year {
    font-size: clamp(27px, 8vw, 42px);
    letter-spacing: 0;
    line-height: 1;
}

.judge-text {
    min-height: 48px;
    color: #263d3e;
    font-weight: 900;
    line-height: 1.4;
}

.finish-panel {
    overflow-y: auto;
    align-content: start;
    padding-top: max(28px, env(safe-area-inset-top));
}

.finish-panel h2 {
    color: #1d383d;
    font-size: 32px;
}

.result-score {
    color: #a95643;
    font-size: clamp(48px, 16vw, 78px);
    font-weight: 950;
    line-height: 1;
}

.result-summary,
.high-score {
    color: #344743;
    font-weight: 800;
}

.review-box {
    display: grid;
    gap: 8px;
    width: min(100%, 500px);
    justify-self: center;
    padding: 14px;
    border: 1px solid rgba(34, 57, 55, 0.18);
    border-radius: 8px;
    background: rgba(255, 253, 246, 0.72);
    text-align: left;
}

.review-box h3 {
    margin: 0;
    color: #1d383d;
    font-size: 16px;
}

.review-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 22px;
    color: #344743;
    font-size: 13px;
    line-height: 1.5;
}

.review-list li::marker {
    font-weight: 900;
    color: #a95643;
}

.finish-actions {
    display: grid;
    gap: 10px;
    width: min(100%, 500px);
    justify-self: center;
}

@media (max-width: 380px) {
    .panel,
    .play-panel {
        padding-left: 14px;
        padding-right: 14px;
    }

    .choice-button {
        min-height: 70px;
        grid-template-columns: 28px 1fr;
        padding: 10px 8px;
    }

    .choice-index {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

@media (min-height: 760px) {
    .play-panel {
        gap: 20px;
    }

    .choice-button {
        min-height: 88px;
    }
}

@keyframes mascot-float {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}
