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

* {
    box-sizing: border-box;
}

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

body {
    background:
        radial-gradient(circle at 10% 8%, rgba(255, 241, 205, 0.4), transparent 34%),
        radial-gradient(circle at 90% 16%, rgba(255, 198, 128, 0.24), transparent 26%),
        linear-gradient(165deg, #e7d4b4 0%, #ead8b8 40%, #dac39e 100%);
}

button {
    font: inherit;
}

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

.game-frame {
    position: relative;
    width: min(100vw, 640px);
    height: 100svh;
    max-width: 640px;
    max-height: none;
    background:
        linear-gradient(180deg, rgba(255, 247, 223, 0.35), rgba(248, 224, 192, 0.26)),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.08), rgba(235, 216, 179, 0.08));
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    isolation: isolate;
    border: 1px solid rgba(116, 84, 48, 0.28);
    box-shadow: 0 20px 60px rgba(84, 54, 28, 0.25);
    overflow: hidden;
}

.game-frame::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("/pref-specialty-rhythm/assets/images/japan-map.svg");
    background-repeat: no-repeat;
    background-size: 560px auto;
    background-position: center 20%;
    opacity: 0.95;
    filter: saturate(1.18) contrast(1.22);
    pointer-events: none;
    z-index: 0;
}

.panel,
.play-panel {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    gap: 16px;
    padding: 24px;
    text-align: center;
    background: linear-gradient(180deg, rgba(255, 250, 234, 0.84), rgba(255, 250, 230, 0.96));
    backdrop-filter: blur(6px);
}

.start-panel {
    align-content: stretch;
    grid-template-rows: minmax(0, 1fr) auto auto auto;
    gap: 12px;
    align-items: stretch;
    overflow: hidden;
}

.start-content {
    display: grid;
    gap: 10px;
    align-content: start;
    min-height: 0;
    overflow: auto;
}

.start-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.start-art {
    margin: 6px 0 0;
    width: min(100%, 480px);
    justify-self: center;
    border: 1px solid rgba(120, 80, 42, 0.45);
    border-radius: 16px;
    overflow: hidden;
    padding: 6px;
    background: linear-gradient(135deg, rgba(255, 237, 194, 0.95), rgba(245, 222, 176, 0.9));
    box-shadow: 0 8px 0 rgba(98, 62, 30, 0.12), inset 0 0 0 1px rgba(255, 244, 220, 0.7);
}

.start-art img {
    display: block;
    width: 100%;
    aspect-ratio: 1200 / 630;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(96, 59, 33, 0.4);
}

.start-art figcaption {
    margin: 8px 0 0;
    text-align: left;
    font-size: 12px;
    color: #6e4222;
    line-height: 1.35;
}

.start-panel h1 {
    width: min(100%, 540px);
    margin: 0 auto;
    font-size: clamp(28px, 7vw, 54px);
    line-height: 0.95;
    letter-spacing: 0.04em;
    text-wrap: balance;
    color: #5a3f2a;
    text-shadow: none;
}

.kicker {
    margin: 0;
    padding: 6px 12px;
    display: inline-block;
    border: 1px solid rgba(131, 84, 42, 0.35);
    border-radius: 999px;
    color: #8a4c17;
    background: rgba(255, 242, 220, 0.7);
    font-size: 12px;
    font-weight: 800;
}

.lead,
.hint,
.question-text {
    margin: 0;
    color: #4a3a2d;
}

.lead {
    width: min(100%, 470px);
    margin: 0 auto;
    font-size: 15px;
    line-height: 1.7;
    text-wrap: balance;
}

.hint {
    font-size: 13px;
    color: #8a4c17;
}

.start-panel .hint {
    margin-top: 4px;
    margin-bottom: 2px;
}

.start-actions {
    display: grid;
    gap: 8px;
    justify-items: stretch;
    align-items: end;
    padding-top: 2px;
    margin-top: auto;
}

.start-actions .primary-button {
    width: min(100%, 300px);
    margin: 0 auto;
    min-height: 62px;
    justify-self: center;
}

.primary-button {
    min-width: 152px;
    min-height: 54px;
    border: 0;
    border-radius: 10px;
    color: #fff9ec;
    background: linear-gradient(135deg, #c45d0a, #e08a31 54%, #5f3a1f);
    font-weight: 900;
    font-size: 19px;
    cursor: pointer;
    box-shadow: 0 10px 0 #4a2f18, 0 22px 32px rgba(84, 53, 28, 0.26);
    border: 1px solid rgba(120, 72, 30, 0.35);
}

.primary-button:active {
    transform: translateY(5px);
    box-shadow: 0 4px 0 #4a2f18, 0 14px 22px rgba(84, 53, 28, 0.22);
}

.secondary-button {
    min-width: 152px;
    min-height: 54px;
    border: 0;
    border-radius: 10px;
    color: #fff9ec;
    background: linear-gradient(135deg, #6c5a49, #8a7156 58%, #4f3a27);
    font-weight: 900;
    font-size: 19px;
    cursor: pointer;
    box-shadow: 0 10px 0 #3b2a1d, 0 22px 32px rgba(84, 53, 28, 0.26);
    border: 1px solid rgba(120, 72, 30, 0.35);
}

.secondary-button:active {
    transform: translateY(5px);
    box-shadow: 0 4px 0 #3d2b1d, 0 14px 22px rgba(84, 53, 28, 0.22);
}

.finish-actions {
    display: grid;
    gap: 8px;
    justify-items: stretch;
}

.finish-actions .primary-button,
.finish-actions .secondary-button {
    width: min(100%, 300px);
    margin: 0 auto;
}

.copyright {
    position: static;
    margin: 0;
    margin-top: 6px;
    color: rgba(72, 42, 16, 0.64);
    font-size: 12px;
}

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

.meter {
    border: 1px solid rgba(122, 85, 49, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
    background: rgba(255, 245, 225, 0.9);
    box-shadow: inset 0 -2px 0 rgba(122, 85, 49, 0.08);
}

.meter span {
    display: block;
    color: #6d4a2e;
    font-size: 10px;
    font-weight: 800;
}

.meter strong {
    display: block;
    margin-top: 2px;
    font-size: clamp(18px, 5vw, 27px);
    line-height: 1;
}

.play-panel {
    display: grid;
    align-content: start;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: linear-gradient(180deg, rgba(255, 252, 243, 0.2), rgba(255, 251, 235, 0.09));
    backdrop-filter: none;
}

.prompt-area {
    display: grid;
    gap: 8px;
    padding: 66px 0 6px;
    text-align: center;
}

.specialty-text {
    margin: 0;
    color: #5b3a22;
    font-size: clamp(36px, 11vw, 58px);
    text-shadow: 0 2px 0 rgba(255, 241, 198, 0.7);
    line-height: 1;
    letter-spacing: 0;
}

.drop-stage {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 12px;
    min-height: 0;
}

.drop-track {
    position: relative;
    width: min(100%, 360px);
    min-height: 420px;
    height: 100%;
    border: none;
    border-radius: 0;
    background: transparent;
    overflow: visible;
    box-shadow: none;
}

.judge-line {
    position: absolute;
    left: 50%;
    right: auto;
    top: 62%;
    width: min(78%, 320px);
    height: 32px;
    border-top: 2px solid rgba(182, 97, 17, 0.95);
    border-bottom: 2px solid rgba(182, 97, 17, 0.9);
    background: linear-gradient(180deg, rgba(226, 146, 42, 0.22), rgba(226, 146, 42, 0.06));
    transform: translateX(-50%) translateY(-50%);
    pointer-events: none;
    text-align: center;
    display: flex;
    justify-content: center;
}

.judge-line span {
    display: inline-block;
    margin-top: 8px;
    font-size: 10px;
    color: #613719;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.answers {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.answers::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.answer-button {
    position: absolute;
    width: 72px;
    min-height: 180px;
    border: 2px solid rgba(110, 73, 36, 0.45);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    line-height: 1.05;
    background: linear-gradient(180deg, #f8f6ef, #fffbec);
    color: #111418;
    font-size: 19px;
    text-align: center;
    padding: 12px 8px;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
    box-shadow: 0 6px 0 rgba(90, 57, 22, 0.22), inset 0 -3px 0 rgba(110, 73, 36, 0.18);
    backdrop-filter: blur(2px);
    pointer-events: auto;
    z-index: 20;
    font-size: 36px !important;
}

.answer-button:active {
    transform: translateY(3px);
}

.answer-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.choice-index {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: #6b3b16;
    color: #fff;
    font-size: 22px !important;
    font-weight: 900;
    aspect-ratio: 1 / 1;
}

.choice-name {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: calc(100% - 10px);
    min-height: 60px;
    padding: 8px 10px;
    border: 2px solid rgba(110, 73, 36, 0.32);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.84);
    box-shadow: inset 0 -2px 0 rgba(110, 73, 36, 0.24);
    overflow-wrap: anywhere;
    font-weight: 900;
    font-size: 34px !important;
    line-height: 1.2;
}

.result-text {
    min-height: 22px;
    text-align: center;
    color: #7a4e1d;
    font-weight: 900;
    font-size: 34px;
    line-height: 1.3;
    margin: 0 auto;
    max-width: min(100%, 360px);
    border: 2px solid rgba(128, 82, 31, 0.35);
    border-radius: 12px;
    background: rgba(255, 254, 236, 0.95);
    padding: 8px 10px;
    box-shadow: 0 6px 0 rgba(90, 57, 22, 0.12);
    z-index: 12;
    position: relative;
}

.result-score {
    margin: 0;
    color: #7d3f12;
    font-size: clamp(52px, 15vw, 88px);
    line-height: 1;
    text-shadow: 0 2px 0 rgba(255, 249, 226, 0.5);
}

.result-summary,
.accuracy-text,
.high-score {
    margin: 0;
    color: #4a3a2d;
}

.high-score {
    font-weight: 900;
    font-size: 18px;
}

.result-history {
    border: 1px solid rgba(128, 82, 31, 0.25);
    border-radius: 10px;
    padding: 8px;
    background: rgba(255, 247, 229, 0.95);
    display: grid;
    gap: 6px;
    overflow: hidden;
}

.result-history h3 {
    margin: 0;
    color: #5a3618;
    font-size: 14px;
    letter-spacing: 0.04em;
}

.history-list {
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 160px;
    overflow: auto;
    display: grid;
    gap: 4px;
}

.history-list li {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 6px 8px;
    align-items: baseline;
    text-align: left;
    border-bottom: 1px dashed rgba(144, 103, 52, 0.35);
    padding-bottom: 6px;
}

.history-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-number {
    grid-column: 1 / 2;
    color: #8c5428;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.history-prompt,
.history-answer,
.history-correct,
.history-status {
    grid-column: 2 / 3;
    line-height: 1.35;
    color: #4b3825;
    font-size: 12px;
}

.history-answer {
    margin-top: 2px;
}

.history-correct {
    margin-top: 2px;
}

.history-status {
    margin-top: 2px;
    font-weight: 900;
}

.status-correct {
    color: #196f36;
}

.status-incorrect {
    color: #8e3410;
}

#finishPanel h2 {
    margin: 0;
    color: #532f14;
}

#finishPanel {
    justify-content: center;
}

.play-panel[hidden],
.hud[hidden],
.start-panel[hidden],
#finishPanel[hidden] {
    display: none;
}

@media (max-width: 430px) {
    .panel,
    .play-panel {
        padding: 16px;
    }

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

    .prompt-area {
        padding-top: 56px;
    }

    .specialty-text {
        font-size: clamp(30px, 11vw, 50px);
    }

    .answer-button {
        min-height: 210px;
        font-size: 40px !important;
    }

    .choice-name {
        font-size: 38px !important;
    }

    .choice-index {
        width: 52px;
        height: 52px;
        font-size: 24px !important;
    }

    .start-art {
        width: min(100%, 320px);
    }

    .start-panel h1 {
        font-size: clamp(26px, 8vw, 40px);
    }
}

@media (min-width: 641px) {
    .page-shell {
        padding-top: 20px;
    }

    .game-frame {
        border-radius: 12px;
    }
}
