@charset "utf-8";

:root {
    --paper: #f8f1df;
    --paper-deep: #ecdfc3;
    --paper-light: #fffdf6;
    --ink: #272923;
    --ink-soft: #626157;
    --green: #173f3a;
    --green-light: #2f665b;
    --vermilion: #b83a2d;
    --vermilion-dark: #7d241d;
    --indigo: #31536d;
    --gold: #c49a42;
    --line: rgba(53, 48, 36, 0.17);
    --shadow: 0 14px 36px rgba(48, 40, 25, 0.13);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: #d5ccba;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background-color: #d5ccba;
    font-family: "Kosugi Maru", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: repeating-linear-gradient(115deg, transparent 0 8px, rgba(87, 71, 42, 0.025) 8px 9px);
    content: "";
}

button,
summary,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible {
    outline: 3px solid #087fda;
    outline-offset: 4px;
}

[hidden] {
    display: none !important;
}

.app-shell {
    position: relative;
    width: 100%;
    max-width: 520px;
    min-height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    background:
        linear-gradient(rgba(255, 253, 246, 0.82), rgba(248, 241, 223, 0.94)),
        repeating-linear-gradient(87deg, transparent 0 4px, rgba(66, 55, 35, 0.025) 4px 5px);
}

main {
    min-height: calc(100dvh - 54px);
}

.screen {
    padding: max(22px, env(safe-area-inset-top)) 18px 48px;
}

footer {
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    color: rgba(255, 255, 255, 0.8);
    background: var(--green);
    text-align: center;
}

footer p {
    margin: 0;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
}

.eyebrow,
.result-kicker {
    margin: 4px 0 8px;
    color: var(--vermilion);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-align: center;
}

.noren-stage {
    width: min(100%, 380px);
    margin: -12px auto -8px;
}

.noren-stage svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.noren-roof {
    fill: #422f22;
}

.noren-beam {
    fill: #6f4c32;
}

.noren-panel {
    fill: var(--green);
    transform-box: fill-box;
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
}

.noren-panel text {
    fill: var(--paper-light);
    font-size: 37px;
    text-anchor: middle;
}

.noren-panel-left {
    transform-origin: left center;
}

.noren-panel-center {
    transform-origin: center center;
}

.noren-panel-right {
    transform-origin: right center;
}

.is-starting .noren-panel-left {
    transform: translateX(-40px) rotate(-3deg);
}

.is-starting .noren-panel-center {
    opacity: 0;
    transform: scaleX(0.15);
}

.is-starting .noren-panel-right {
    transform: translateX(40px) rotate(3deg);
}

.noren-ground {
    fill: none;
    stroke: rgba(48, 42, 31, 0.18);
    stroke-linecap: round;
    stroke-width: 2;
}

.start-screen h1 {
    margin: 0;
    color: var(--green);
    font-size: clamp(2rem, 9vw, 2.65rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.25;
    text-align: center;
}

.start-screen h1 span {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-soft);
    font-size: 0.38em;
    font-weight: 400;
    letter-spacing: 0.12em;
}

.start-lead {
    margin: 14px auto 8px;
    color: var(--ink-soft);
    font-size: 0.92rem;
    line-height: 1.8;
    text-align: center;
}

.journey-preview {
    margin: 4px 0 8px;
}

.journey-preview svg {
    display: block;
    width: 100%;
}

.journey-preview path {
    fill: none;
    stroke: rgba(49, 83, 109, 0.34);
    stroke-dasharray: 2 7;
    stroke-linecap: round;
    stroke-width: 3;
}

.journey-preview circle {
    fill: var(--paper-light);
    stroke: var(--indigo);
    stroke-width: 2;
}

.journey-preview g:last-child circle {
    fill: var(--vermilion);
    stroke: var(--vermilion-dark);
}

.journey-preview text {
    fill: var(--indigo);
    font-size: 10px;
    text-anchor: middle;
}

.journey-preview g:last-child text {
    fill: #fff;
}

.start-card {
    padding: 18px;
    border: 1px solid rgba(118, 90, 41, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 253, 246, 0.82);
    box-shadow: var(--shadow);
}

.start-facts {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
    color: var(--ink-soft);
    font-size: 0.8rem;
}

.start-facts span {
    display: flex;
    align-items: baseline;
    gap: 2px;
    padding: 0 15px;
    border-right: 1px solid var(--line);
}

.start-facts span:last-child {
    border-right: 0;
}

.start-facts b {
    color: var(--green);
    font-size: 1.35rem;
}

.primary-button,
.secondary-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 58px;
    padding: 13px 18px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.primary-button {
    color: #fff;
    background: var(--vermilion);
    box-shadow: 0 6px 0 var(--vermilion-dark), 0 11px 22px rgba(125, 36, 29, 0.17);
}

.primary-button svg,
.puzzle-link > svg {
    position: absolute;
    right: 20px;
    width: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.primary-button:active {
    box-shadow: 0 2px 0 var(--vermilion-dark);
    transform: translateY(4px);
}

.primary-button:disabled,
.secondary-button:disabled {
    cursor: wait;
    opacity: 0.78;
}

.prize-note {
    margin: 16px 0 0;
    color: var(--vermilion-dark);
    font-size: 0.78rem;
    text-align: center;
}

.how-to {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.8rem;
}

.how-to summary {
    padding: 14px 4px 8px;
    color: var(--indigo);
    cursor: pointer;
    text-align: center;
}

.how-to ol {
    margin: 8px 4px 6px 1.7em;
    padding: 0;
    list-style: decimal;
}

.how-to li {
    margin: 5px 0;
}

.how-to p {
    margin: 8px 4px 0;
    font-size: 0.74rem;
    text-align: center;
}

.quiz-screen {
    padding-top: max(14px, env(safe-area-inset-top));
}

.quiz-header {
    margin: 0 -4px 10px;
}

.quiz-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
}

.quiz-number,
.quiz-score {
    margin: 0;
    font-weight: 700;
}

.quiz-number {
    color: var(--green);
    font-size: 1.05rem;
    letter-spacing: 0.08em;
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--vermilion-dark);
    font-size: 0.78rem;
}

.mini-stamp {
    display: inline-grid;
    width: 25px;
    height: 25px;
    border: 2px solid var(--vermilion);
    border-radius: 50%;
    place-items: center;
    color: var(--vermilion);
    font-size: 0.65rem;
    transform: rotate(-8deg);
}

.route-map {
    margin-top: -2px;
}

.route-map svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.route-line {
    fill: none;
    stroke: rgba(49, 83, 109, 0.2);
    stroke-linecap: round;
    stroke-width: 4;
}

.route-line-done {
    stroke: var(--vermilion);
    stroke-dasharray: 0 100;
    transition: stroke-dasharray 0.65s ease;
}

.route-stop circle {
    fill: var(--paper-light);
    stroke: #9f9b8e;
    stroke-width: 2;
    transition: fill 0.25s ease, stroke 0.25s ease, transform 0.25s ease;
}

.route-stop text {
    fill: #7f7c72;
    font-size: 11px;
    text-anchor: middle;
}

.route-stop.is-current circle {
    fill: var(--indigo);
    stroke: var(--indigo);
    transform: scale(1.13);
}

.route-stop.is-current text,
.route-stop.is-visited text {
    fill: #fff;
}

.route-stop.is-visited circle {
    fill: var(--green-light);
    stroke: var(--green);
}

.route-stop.is-correct circle {
    fill: var(--vermilion);
    stroke: var(--vermilion-dark);
}

.route-traveler {
    color: var(--green);
    fill: currentColor;
    transform: translate(22px, 44px);
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-card {
    padding: 16px;
    border: 1px solid rgba(94, 77, 47, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 253, 246, 0.9);
    box-shadow: var(--shadow);
}

.category-chip {
    display: inline-block;
    margin: 0 0 10px;
    padding: 4px 11px;
    border: 1px solid rgba(49, 83, 109, 0.25);
    border-radius: 999px;
    color: var(--indigo);
    background: #eef3f2;
    font-size: 0.7rem;
}

.quiz-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: 15px;
    background: var(--paper-deep);
}

.quiz-image::after {
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(255, 255, 255, 0.43);
    border-radius: 11px;
    content: "";
    pointer-events: none;
}

.quiz-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.quiz-question {
    margin: 17px 2px 13px;
}

.quiz-question p {
    margin: 0 0 9px;
    font-size: 0.96rem;
    line-height: 1.75;
}

.quiz-question p:last-child {
    margin-bottom: 0;
    color: var(--ink);
    font-size: 1.07rem;
    font-weight: 700;
}

.quiz-options {
    display: grid;
    gap: 11px;
    margin-top: 15px;
}

.option-button {
    position: relative;
    display: grid;
    grid-template-columns: 36px 1fr 28px;
    align-items: center;
    width: 100%;
    min-height: 58px;
    padding: 9px 10px;
    border: 2px solid rgba(49, 83, 109, 0.28);
    border-radius: 15px;
    color: var(--ink);
    background: #fffefa;
    cursor: pointer;
    line-height: 1.45;
    text-align: left;
    transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.option-button:active:not(:disabled) {
    transform: scale(0.985);
}

.option-button:disabled {
    opacity: 1;
    cursor: default;
}

.option-mark {
    display: grid;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(49, 83, 109, 0.3);
    border-radius: 50%;
    place-items: center;
    color: var(--indigo);
    font-size: 0.78rem;
}

.option-text {
    padding: 2px 6px;
    font-size: 0.88rem;
}

.option-status {
    color: transparent;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.option-button.is-correct {
    border-color: var(--green-light);
    background: #eaf3eb;
}

.option-button.is-correct .option-mark {
    border-color: var(--green);
    color: #fff;
    background: var(--green);
}

.option-button.is-correct .option-status {
    color: var(--green);
}

.option-button.is-wrong {
    border-color: var(--vermilion);
    background: #fae9e5;
}

.option-button.is-wrong .option-mark {
    border-color: var(--vermilion);
    color: #fff;
    background: var(--vermilion);
}

.option-button.is-wrong .option-status {
    color: var(--vermilion);
}

.answer-panel {
    margin: 18px -4px -4px;
    padding: 18px 14px 14px;
    border-top: 1px dashed rgba(77, 64, 42, 0.28);
}

.answer-panel.is-revealed {
    animation: revealPanel 0.42s ease both;
}

.feedback-heading {
    display: grid;
    grid-template-columns: 94px 1fr;
    align-items: center;
    gap: 13px;
}

.answer-stamp {
    display: block;
    width: 94px;
    height: 94px;
    color: var(--vermilion);
    overflow: visible;
}

.is-revealed .answer-stamp {
    animation: stampIn 1.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.answer-stamp.is-wrong {
    color: var(--indigo);
}

.answer-stamp.is-wrong text {
    font-size: 23px;
    letter-spacing: 0;
}

.stamp-ring,
.stamp-accent {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 3;
}

.stamp-ring-outer {
    stroke-width: 5;
    stroke-dasharray: 8 3 18 2;
}

.stamp-accent {
    opacity: 0.7;
    stroke-width: 2;
}

.answer-stamp text {
    fill: currentColor;
    font-size: 29px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-anchor: middle;
}

.quiz-result {
    margin: 0 0 6px;
    color: var(--vermilion);
    font-size: 1.45rem;
    font-weight: 700;
}

.answer-panel.is-incorrect .quiz-result {
    color: var(--indigo);
}

.correct-answer {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.78rem;
    line-height: 1.55;
}

.correct-answer strong {
    display: block;
    margin-top: 3px;
    color: var(--ink);
    font-size: 0.9rem;
}

.quiz-explanation {
    margin-top: 12px;
    padding: 13px;
    border-left: 4px solid var(--gold);
    border-radius: 4px 12px 12px 4px;
    background: rgba(236, 223, 195, 0.48);
}

.quiz-explanation > p,
.explanation-more p,
.explanation-more li {
    margin: 0 0 8px;
    color: #4f4d45;
    font-size: 0.82rem;
    line-height: 1.7;
}

.quiz-explanation p:last-child,
.explanation-more li:last-child {
    margin-bottom: 0;
}

.explanation-more {
    margin-top: 8px;
}

.explanation-more summary {
    color: var(--indigo);
    cursor: pointer;
    font-size: 0.78rem;
}

.explanation-more-content {
    margin-top: 9px;
}

.explanation-more-content .explanation-list-title {
    margin-bottom: 4px;
    color: var(--ink);
    font-weight: 700;
}

.explanation-more ul {
    margin: 0 0 10px 1.25em;
    padding: 0;
    list-style: disc;
}

.quiz-explanation a {
    display: inline-block;
    margin-top: 4px;
    color: var(--indigo);
    overflow-wrap: anywhere;
}

.next-button {
    margin-top: 17px;
}

.end-screen {
    padding-top: max(22px, env(safe-area-inset-top));
}

.result-card {
    position: relative;
    overflow: hidden;
    padding: 16px 18px 22px;
    border: 1px solid rgba(128, 94, 39, 0.28);
    border-radius: 8px 8px 30px 8px;
    background:
        linear-gradient(rgba(255, 253, 246, 0.9), rgba(248, 241, 223, 0.97)),
        repeating-linear-gradient(95deg, transparent 0 4px, rgba(77, 61, 34, 0.03) 4px 5px);
    box-shadow: var(--shadow);
    text-align: center;
}

.result-decoration {
    display: block;
    width: 100%;
    max-height: 220px;
    margin: -4px auto -20px;
    overflow: visible;
}

.celebration-rays {
    fill: none;
    stroke: var(--gold);
    stroke-linecap: round;
    stroke-width: 4;
}

.result-card.is-master .celebration-rays path {
    animation: rayPulse 1.6s ease-in-out infinite alternate;
}

.floating-leaves {
    fill: var(--green-light);
    opacity: 0.7;
}

.result-card.is-master .floating-leaves path {
    transform-box: fill-box;
    transform-origin: center;
    animation: leafFloat 2.2s ease-in-out infinite alternate;
}

.result-card.is-master .floating-leaves path:nth-child(2) {
    animation-delay: -0.8s;
}

.result-card.is-master .floating-leaves path:nth-child(3) {
    animation-delay: -1.3s;
}

.result-card.is-master .floating-leaves path:nth-child(4) {
    animation-delay: -0.35s;
}

.result-seal {
    color: var(--vermilion);
}

.result-card:not(.is-master) .result-seal {
    color: var(--indigo);
}

.result-seal circle {
    fill: rgba(255, 253, 246, 0.85);
    stroke: currentColor;
    stroke-width: 5;
}

.result-seal circle:nth-child(2) {
    fill: none;
    stroke-width: 2;
    stroke-dasharray: 10 4;
}

.result-kicker {
    margin-top: 0;
}

.result-card h1 {
    margin: 2px 0 4px;
    color: var(--green);
    font-size: clamp(1.8rem, 8vw, 2.45rem);
    letter-spacing: 0.08em;
    line-height: 1.35;
}

.result-score-text {
    margin: 0;
    color: var(--vermilion);
    font-size: 1.05rem;
    font-weight: 700;
}

.result-message {
    margin: 10px auto 0;
    color: var(--ink-soft);
    font-size: 0.88rem;
    line-height: 1.75;
}

.prize-panel {
    position: relative;
    margin-top: 18px;
    padding: 23px 12px 15px;
    border: 2px solid var(--vermilion);
    border-radius: 15px;
    background: rgba(255, 248, 225, 0.72);
}

.prize-label {
    position: absolute;
    top: -13px;
    left: 50%;
    padding: 3px 14px;
    border-radius: 999px;
    color: #fff;
    background: var(--vermilion);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    transform: translateX(-50%);
}

.prize-panel p {
    margin: 0;
    font-size: 0.92rem;
}

.prize-panel strong {
    color: var(--vermilion-dark);
    font-size: 1.15rem;
}

.prize-panel .prize-instruction {
    margin-top: 10px;
    color: var(--ink-soft);
    font-size: 0.75rem;
    line-height: 1.6;
}

.end-time {
    margin: 16px 0 0;
    color: var(--ink-soft);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.secondary-button {
    margin-top: 20px;
    border: 2px solid var(--green);
    color: var(--green);
    background: transparent;
}

.secondary-button:active {
    color: #fff;
    background: var(--green);
    transform: scale(0.985);
}

.puzzle-link {
    position: relative;
    display: grid;
    grid-template-columns: 44px 1fr 22px;
    align-items: center;
    gap: 11px;
    margin-top: 22px;
    padding: 14px;
    border-radius: 16px;
    color: var(--ink);
    background: rgba(255, 253, 246, 0.75);
    box-shadow: 0 8px 24px rgba(48, 40, 25, 0.08);
    text-decoration: none;
}

.puzzle-link-icon {
    display: grid;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    place-items: center;
    color: #fff;
    background: var(--indigo);
    font-size: 1.15rem;
}

.puzzle-link small {
    display: block;
    color: var(--ink-soft);
    font-size: 0.68rem;
}

.puzzle-link > svg {
    position: static;
    width: 20px;
    color: var(--indigo);
}

@keyframes stampIn {
    0% {
        opacity: 0;
        transform: scale(1.7) rotate(-16deg);
    }
    38% {
        opacity: 1;
        transform: scale(0.86) rotate(5deg);
    }
    62% {
        opacity: 1;
        transform: scale(1.07) rotate(-5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(-3deg);
    }
}

@keyframes revealPanel {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rayPulse {
    from {
        opacity: 0.35;
        stroke-dasharray: 4 7;
    }
    to {
        opacity: 1;
        stroke-dasharray: 16 2;
    }
}

@keyframes leafFloat {
    from {
        transform: translateY(-4px) rotate(-8deg);
    }
    to {
        transform: translateY(7px) rotate(8deg);
    }
}

@media (hover: hover) {
    .primary-button:hover {
        background: #c64739;
        transform: translateY(-1px);
    }

    .secondary-button:hover {
        color: #fff;
        background: var(--green);
    }

    .option-button:hover:not(:disabled) {
        border-color: var(--indigo);
        background: #f4f7f5;
    }
}

@media (min-width: 560px) {
    .app-shell {
        min-height: calc(100dvh - 32px);
        margin-top: 16px;
        margin-bottom: 16px;
        border-radius: 26px;
        box-shadow: 0 22px 60px rgba(45, 37, 24, 0.22);
    }
}

@media (max-width: 359px) {
    .screen {
        padding-right: 13px;
        padding-left: 13px;
    }

    .quiz-card {
        padding: 13px;
    }

    .feedback-heading {
        grid-template-columns: 78px 1fr;
    }

    .answer-stamp {
        width: 78px;
        height: 78px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

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