@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --bg-base: #0d0d0b;
    --bg-mid: #1a1712;
    --bg-end: #12100d;
    --glow-red: rgba(167, 40, 28, 0.25);
    --glow-gold: rgba(200, 169, 106, 0.22);
    --panel: rgba(19, 16, 12, 0.86);
    --panel-soft: rgba(255, 255, 255, 0.03);
    --panel-border: rgba(200, 169, 106, 0.45);
    --panel-border-soft: rgba(230, 210, 170, 0.24);
    --paper: #f2ece1;
    --paper-soft: #ddd1bd;
    --text-main: #f5f1ea;
    --text-dark: #15120e;
    --accent-red: #a3261b;
    --accent-red-soft: #c74130;
    --accent-gold: #c8a96a;
    --button-bg: rgba(24, 20, 15, 0.92);
    --button-text: #f2ece1;
    --hero-overlay: rgba(0, 0, 0, 0.62);
    --app-overlay: rgba(8, 8, 7, 0.8);
    --mon-line: rgba(220, 193, 141, 0.34);
    --mon-core: rgba(220, 193, 141, 0.2);
    --theme-toggle-bg: rgba(17, 14, 11, 0.88);
    --theme-toggle-text: #f2ece1;
    --reading-width: 58ch;
}

body[data-theme='tatami'] {
    --bg-base: #e5dccd;
    --bg-mid: #d7ccb8;
    --bg-end: #cfc4b0;
    --glow-red: rgba(150, 45, 27, 0.18);
    --glow-gold: rgba(154, 122, 59, 0.22);
    --panel: rgba(244, 236, 224, 0.9);
    --panel-soft: rgba(255, 255, 255, 0.46);
    --panel-border: rgba(126, 90, 45, 0.4);
    --panel-border-soft: rgba(126, 90, 45, 0.3);
    --paper: #fbf7ef;
    --paper-soft: #efe5d4;
    --text-main: #2c2318;
    --text-dark: #2a2015;
    --accent-red: #8d2618;
    --accent-red-soft: #a33222;
    --accent-gold: #8f6634;
    --button-bg: rgba(234, 220, 196, 0.92);
    --button-text: #241c13;
    --hero-overlay: rgba(248, 236, 216, 0.55);
    --app-overlay: rgba(244, 232, 212, 0.57);
    --mon-line: rgba(110, 79, 40, 0.35);
    --mon-core: rgba(110, 79, 40, 0.2);
    --theme-toggle-bg: rgba(245, 236, 220, 0.92);
    --theme-toggle-text: #2a2015;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at 12% 10%, var(--glow-red), transparent 34%),
        radial-gradient(circle at 90% 18%, var(--glow-gold), transparent 32%),
        linear-gradient(140deg, var(--bg-base), var(--bg-mid) 52%, var(--bg-end));
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

#WelcomeApp,
#App {
    width: 100%;
    min-height: 100dvh;
    position: relative;
    overflow: hidden;
}

#WelcomeApp {
    display: grid;
    place-items: center;
    padding: 1.2rem;
}

#WelcomeApp::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--hero-overlay), var(--hero-overlay)),
        url('../data/samurai.png');
    background-size: cover;
    background-position: center;
    filter: saturate(0.72) contrast(1.06);
    z-index: 0;
}

#WelcomeApp::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(110deg, rgba(210, 197, 170, 0.04) 0 2px, transparent 2px 12px);
    opacity: 0.5;
    z-index: 1;
}

.theme-toggle {
    position: fixed;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 40;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: var(--theme-toggle-bg);
    color: var(--theme-toggle-text);
    padding: 0.5rem 0.9rem;
    font-size: clamp(0.76rem, 2vw, 0.88rem);
    letter-spacing: 0.03em;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    background: var(--paper-soft);
    color: var(--text-dark);
}

.scene-mons {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.mon {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--mon-line);
    background:
        radial-gradient(circle, transparent 31%, var(--mon-line) 31% 36%, transparent 36%),
        radial-gradient(circle at center, var(--mon-core) 0 22%, transparent 22%),
        conic-gradient(from 0deg, transparent 0 12%, var(--mon-line) 12% 15%, transparent 15% 29%, var(--mon-line) 29% 32%, transparent 32% 46%, var(--mon-line) 46% 49%, transparent 49% 63%, var(--mon-line) 63% 66%, transparent 66% 80%, var(--mon-line) 80% 83%, transparent 83% 97%, var(--mon-line) 97% 100%);
    opacity: 0.74;
}

.mon-a {
    width: clamp(120px, 19vw, 230px);
    height: clamp(120px, 19vw, 230px);
    top: 8%;
    left: -3%;
}

.mon-b {
    width: clamp(95px, 14vw, 170px);
    height: clamp(95px, 14vw, 170px);
    bottom: 10%;
    right: 3%;
}

.mon-c {
    width: clamp(75px, 11vw, 130px);
    height: clamp(75px, 11vw, 130px);
    top: 22%;
    right: 14%;
    opacity: 0.5;
}

#Welcome,
#StartText {
    position: relative;
    z-index: 3;
}

#Welcome {
    width: min(92vw, 900px);
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: clamp(1.75rem, 4.7vw, 3.15rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.7rem;
    color: var(--paper);
    text-shadow: 0 0 24px rgba(0, 0, 0, 0.75);
}

body[data-theme='tatami'] #Welcome {
    color: #2a1f12;
    text-shadow:
        0 1px 0 rgba(255, 247, 231, 0.55),
        0 0 2px rgba(20, 12, 5, 0.45),
        0 0 10px rgba(20, 12, 5, 0.35);
}

#StartText {
    width: min(92vw, 920px);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: clamp(1.2rem, 3.3vw, 2.4rem);
    font-size: clamp(1rem, 2.7vw, 1.45rem);
    line-height: 1.6;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(5px);
    color: var(--text-main);
}

#questionRange,
#startQuiz {
    width: min(88vw, 430px);
    display: block;
    margin: 0.95rem auto;
    border-radius: 11px;
    border: 1px solid var(--panel-border);
    font-family: 'Noto Sans JP', sans-serif;
}

#questionRange {
    padding: 0.9rem;
    font-size: clamp(1rem, 2.7vw, 1.15rem);
    background: rgba(243, 236, 225, 0.95);
    color: var(--text-dark);
}

#startQuiz {
    padding: 0.95rem 1.1rem;
    font-size: clamp(1.02rem, 2.8vw, 1.2rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--paper);
    cursor: pointer;
    background: linear-gradient(140deg, var(--accent-red), #7f1d13);
    border: 1px solid rgba(255, 238, 212, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#startQuiz:hover,
#startQuiz:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(153, 37, 24, 0.45);
    background: linear-gradient(140deg, var(--accent-red-soft), #8f2418);
}

#QuestionArea {
    position: relative;
    z-index: 3;
    width: min(94vw, 980px);
    margin: min(3.8vh, 2rem) auto;
    padding: clamp(0.9rem, 3vw, 1.5rem);
    border-radius: 20px;
    background: linear-gradient(165deg, var(--panel), rgba(9, 8, 7, 0.95));
    border: 1px solid var(--panel-border);
    box-shadow: 0 22px 45px rgba(0, 0, 0, 0.42);
    display: grid;
    grid-template-rows: auto auto auto auto;
    gap: clamp(0.7rem, 2vw, 1rem);
}

#KitsuneRunner {
    --kitsune-run-distance: 1200px;
    --kitsune-track-bottom: 0px;
    position: absolute;
    left: -180px;
    bottom: var(--kitsune-track-bottom);
    width: clamp(78px, 20vw, 116px);
    z-index: 28;
    opacity: 0;
    pointer-events: none;
    transform: translateX(0);
    will-change: transform, opacity;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
}

#KitsuneRunner img {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
}

#KitsuneRunner.is-running {
    animation: kitsune-run 2.5s ease-in-out 1;
}

@keyframes kitsune-run {
    0% {
        transform: translateX(0);
        opacity: 0;
    }
    8% {
        opacity: 0.95;
    }
    90% {
        opacity: 0.9;
    }
    100% {
        transform: translateX(var(--kitsune-run-distance));
        opacity: 0;
    }
}

#App::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(var(--app-overlay), var(--app-overlay)),
        url('../data/katana.jpg');
    background-size: cover;
    background-position: center;
    filter: saturate(0.66) brightness(0.76);
}

#Intro {
    --intro-logo-size: min(66vmin, 520px);
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at center, rgba(13, 11, 8, 0.14) 0 40%, rgba(5, 4, 3, 0.76) 100%),
        linear-gradient(var(--app-overlay), var(--app-overlay)),
        url('../data/index.png') center/var(--intro-logo-size) var(--intro-logo-size) no-repeat;
    background-color: #090807;
    z-index: 9;
}

#Intro::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--intro-logo-size);
    height: var(--intro-logo-size);
    transform: translate(-50%, -50%);
    border: 1.5px solid rgba(214, 177, 106, 0.85);
    outline: 1.5px solid rgba(106, 78, 36, 0.72);
    outline-offset: 12px;
    border-radius: 16px;
    box-shadow:
        0 0 26px rgba(200, 154, 67, 0.35),
        0 18px 40px rgba(0, 0, 0, 0.52);
    pointer-events: none;
}

#Intro::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at center, transparent 42%, rgba(6, 5, 4, 0.52) 82%);
    pointer-events: none;
}

@media (max-width: 760px) {
    #Intro::before {
        outline-offset: 8px;
        border-radius: 12px;
    }
}

#abdecker,
#picture,
.entry,
#typeDropdown,
#searchField,
#Titel {
    display: none;
}

#QuestionNr {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.18rem, 3.7vw, 1.6rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-gold);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(3.1rem, 6vh, 3.6rem);
    padding: 0.5rem 0.8rem;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid rgba(200, 169, 106, 0.32);
    background: rgba(255, 255, 255, 0.03);
}

body[data-theme='tatami'] #QuestionNr {
    color: #5e431f;
}

#Question {
    background: var(--panel-soft);
    border: 1px solid var(--panel-border-soft);
    border-radius: 15px;
    padding: clamp(0.95rem, 2.8vw, 1.25rem);
}

#QuestionText {
    margin: 0 auto;
    width: min(100%, var(--reading-width));
    font-size: clamp(1.1rem, 3.2vw, 1.75rem);
    line-height: 1.5;
    text-align: left;
    color: var(--text-main);
}

#Antworten {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.7rem;
    min-height: clamp(7.5rem, 22vh, 12rem);
    max-height: clamp(8rem, 26vh, 14rem);
    overflow: auto;
    align-content: start;
}

#Antworten.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

#QuestionInfoBox {
    margin-top: 0.1rem;
    border-radius: 12px;
    border: 1px solid rgba(200, 169, 106, 0.25);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.7rem 0.85rem;
}

#QuestionInfoBox.is-hidden {
    display: none;
}

#QuestionInfoLabel {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: clamp(0.78rem, 2vw, 0.9rem);
    color: var(--accent-gold);
    margin-bottom: 0.35rem;
}

#QuestionInfo {
    margin: 0 auto;
    width: min(100%, var(--reading-width));
    font-size: clamp(0.9rem, 2.3vw, 1.02rem);
    line-height: 1.45;
    color: #dfd2bc;
    opacity: 0.92;
}

body[data-theme='tatami'] #QuestionInfoBox {
    border: 1px solid rgba(126, 90, 45, 0.3);
    background: rgba(250, 243, 229, 0.58);
}

body[data-theme='tatami'] #QuestionInfo {
    color: #4a3821;
}

body[data-theme='tatami'] #QuestionInfoLabel {
    color: #7c5726;
}

.antwort {
    margin: 0;
    padding: clamp(0.85rem, 2.8vw, 1.1rem);
    font-size: clamp(1rem, 2.8vw, 1.35rem);
    line-height: 1.45;
    text-align: left;
    display: flex;
    align-items: center;
    border-radius: 12px;
    border: 1px solid rgba(200, 169, 106, 0.34);
    background: linear-gradient(150deg, rgba(242, 236, 225, 0.94), rgba(212, 198, 171, 0.92));
    color: var(--text-dark);
    min-height: 3rem;
}

.antwort > [class^='antworttext'] {
    width: min(100%, var(--reading-width));
    margin: 0 auto;
}

body[data-theme='tatami'] .antwort {
    background: linear-gradient(150deg, #f7f0e2, #eadcc2);
}

#Navigation {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.62rem;
}

.jo_btn {
    position: static;
    width: 100%;
    min-height: 3.25rem;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    background: var(--button-bg);
    color: var(--button-text);
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
}

.jo_btn:hover,
.jo_btn:focus-visible {
    transform: translateY(-1px);
    background: var(--accent-red);
    color: var(--paper);
}

.material-symbols-outlined {
    font-size: clamp(1.5rem, 4.8vw, 2.1rem);
}

#closeBtn,
#nextBtn,
#prevBtn {
    position: static;
}

.reward-card {
    position: relative;
    z-index: 4;
    width: min(92vw, 820px);
    margin-top: 0.9rem;
    padding: clamp(0.9rem, 2.5vw, 1.25rem);
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    background: linear-gradient(165deg, rgba(24, 18, 13, 0.9), rgba(12, 10, 8, 0.88));
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.33);
    text-align: center;
}

body[data-theme='tatami'] .reward-card {
    background: linear-gradient(165deg, rgba(243, 233, 212, 0.9), rgba(234, 222, 196, 0.9));
}

.reward-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
    font-size: clamp(0.72rem, 1.9vw, 0.82rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid rgba(200, 169, 106, 0.55);
    color: var(--accent-gold);
    background: rgba(17, 14, 11, 0.45);
}

body[data-theme='tatami'] .reward-badge {
    background: rgba(255, 247, 232, 0.7);
    color: #6d4d22;
}

#RewardTitle {
    margin: 0.7rem 0 0.35rem;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.04em;
    font-size: clamp(1.15rem, 3vw, 1.55rem);
    color: var(--paper);
}

body[data-theme='tatami'] #RewardTitle {
    color: #2a1f12;
}

#RewardProgress,
#RewardQuote {
    margin: 0.3rem 0;
    font-size: clamp(0.95rem, 2.2vw, 1.08rem);
    color: var(--text-main);
}

#RewardQuote {
    opacity: 0.92;
}

.reward-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
}

.confetti-piece {
    position: absolute;
    top: -7%;
    width: 9px;
    height: 14px;
    border-radius: 2px;
    background: linear-gradient(180deg, #e4c179, #b12e20);
    opacity: 0.85;
    transform: rotate(10deg);
    animation-name: confetti-fall;
    animation-timing-function: linear;
    animation-iteration-count: 1;
}

body[data-theme='tatami'] .confetti-piece {
    background: linear-gradient(180deg, #b78944, #8a2b1e);
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.85;
    }
    100% {
        transform: translateY(110dvh) rotate(540deg);
        opacity: 0;
    }
}

@media (max-width: 760px) {
    .theme-toggle {
        top: 0.65rem;
        right: 0.65rem;
        padding: 0.45rem 0.75rem;
    }

    #Welcome {
        margin-bottom: 0.5rem;
    }

    body[data-theme='tatami'] #Welcome {
        width: min(94vw, 560px);
        padding: 0.35rem 0.7rem;
        border-radius: 10px;
        background: rgba(246, 237, 220, 0.78);
        border: 1px solid rgba(95, 69, 35, 0.34);
        color: #1f160d;
        text-shadow:
            0 1px 0 rgba(255, 248, 235, 0.75),
            0 0 1px rgba(19, 11, 4, 0.7),
            0 2px 8px rgba(19, 11, 4, 0.35);
    }

    #WelcomeApp {
        align-content: center;
        gap: 0.35rem;
        padding:
            calc(0.7rem + env(safe-area-inset-top))
            0.85rem
            calc(0.9rem + env(safe-area-inset-bottom));
    }

    .reward-card {
        margin-top: 0.5rem;
        padding: 0.8rem;
    }

    #QuestionArea {
        width: min(95vw, 95vw);
        margin: 0.75rem auto;
        border-radius: 16px;
        padding-bottom: calc(4.8rem + env(safe-area-inset-bottom));
        min-height: calc(100dvh - (1.5rem + 5.6rem + env(safe-area-inset-bottom)));
    }

    #KitsuneRunner {
        width: clamp(78px, 20vw, 116px);
    }

    #QuestionText,
    #QuestionInfo,
    .antwort > [class^='antworttext'] {
        width: 100%;
    }

    .mon-b,
    .mon-c {
        opacity: 0.42;
    }

    .jo_btn {
        min-height: 3.1rem;
    }

    #Navigation {
        position: fixed;
        left: 0.55rem;
        right: 0.55rem;
        bottom: calc(0.5rem + env(safe-area-inset-bottom));
        z-index: 30;
        padding: 0.35rem;
        border-radius: 12px;
        background: rgba(13, 11, 9, 0.9);
        border: 1px solid rgba(200, 169, 106, 0.35);
        box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
    }

    body[data-theme='tatami'] #Navigation {
        background: rgba(243, 232, 210, 0.95);
        border: 1px solid rgba(126, 90, 45, 0.35);
    }
}

@media (max-width: 430px) {
    #Welcome {
        width: min(94vw, 94vw);
        font-size: clamp(1.35rem, 7vw, 1.9rem);
        margin-bottom: 0.35rem;
    }

    #StartText {
        width: min(94vw, 94vw);
        font-size: clamp(0.92rem, 4.2vw, 1.05rem);
        line-height: 1.45;
        padding: 0.85rem 0.8rem;
        max-height: calc(100dvh - (6.9rem + env(safe-area-inset-top) + env(safe-area-inset-bottom)));
        overflow: auto;
    }

    #questionRange,
    #startQuiz {
        width: 100%;
        margin: 0.6rem auto;
    }

    #questionRange {
        padding: 0.72rem;
        font-size: 1rem;
    }

    #startQuiz {
        padding: 0.8rem 0.95rem;
        font-size: 1rem;
    }

    .mon-a,
    .mon-b,
    .mon-c {
        opacity: 0.3;
    }
}

@media (min-width: 880px) {
    #Antworten {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 761px) and (max-width: 1023px) {
    #QuestionArea {
        width: min(92vw, 760px);
        min-height: calc(100dvh - 1.8rem);
        margin: 0.9rem auto;
        padding-bottom: 5.2rem;
        grid-template-rows: auto auto 1fr auto;
    }

    #Antworten {
        min-height: 0;
        max-height: none;
        overflow: auto;
    }

    #Navigation {
        position: fixed;
        left: max(1rem, calc((100vw - min(92vw, 760px)) / 2));
        right: max(1rem, calc((100vw - min(92vw, 760px)) / 2));
        bottom: 0.65rem;
        z-index: 30;
        padding: 0.35rem;
        border-radius: 12px;
        background: rgba(13, 11, 9, 0.9);
        border: 1px solid rgba(200, 169, 106, 0.35);
        box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
    }

    body[data-theme='tatami'] #Navigation {
        background: rgba(243, 232, 210, 0.95);
        border: 1px solid rgba(126, 90, 45, 0.35);
    }
}

@media (min-width: 1024px) and (min-height: 640px) {
    #QuestionArea {
        width: min(460px, calc((100dvh - 2.4rem) * 9 / 19.5));
        min-height: calc(100dvh - 2.4rem);
        max-height: calc(100dvh - 2.4rem);
        margin: 1.2rem auto;
        padding: 1rem 0.95rem;
        border-radius: 22px;
        overflow: hidden;
        grid-template-rows: auto auto 1fr auto;
    }

    #QuestionText {
        width: 100%;
        font-size: clamp(1.06rem, 1.18vw, 1.35rem);
    }

    #Antworten {
        min-height: 0;
        max-height: none;
        overflow: auto;
    }

    .antwort > [class^='antworttext'] {
        width: 100%;
    }

}
