
        @font-face { font-family:Jua; src:url('/fonts/Jua-Regular.ttf') format('truetype'); font-display:swap; }

        :root {
            --bg-gradient: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
            --text-color: #4A4A4A;
            --accent-color: #845ec2;
            --font-main: "Jua", sans-serif;
            --card-radius: 30px;
        }

        body {
            margin: 0; padding: 0; height: 100vh;
            background: var(--bg-gradient);
            color: var(--text-color);
            font-family: var(--font-main);
            display: flex; justify-content: center; align-items: center;
            user-select: none;
        }

        #app { width: 100%; max-width: 500px; padding: 20px; text-align: center; position: relative; }

        .screen { display: none; }
        .screen.active { display: block; animation: fadeUp 0.5s ease; }
        @keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

        h1 { font-size: 2.5rem; color: #fff; text-shadow: 2px 2px 0 rgba(0,0,0,0.1); margin: 0; }
        h2 { color: #fff; font-size: 1.2rem; margin-bottom: 20px; opacity: 0.9; }

        /* Menu */
        .menu-container { height: 65vh; overflow-y: auto; padding: 10px; }
        .menu-btn {
            width: 100%; padding: 20px; margin: 10px 0;
            background: white; border: 4px solid white; border-radius: 25px;
            color: var(--text-color); font-family: var(--font-main); font-size: 1.3rem;
            cursor: pointer; display: flex; align-items: center;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1); transition: 0.2s;
        }
        .menu-btn:hover { transform: translateY(-3px); border-color: var(--accent-color); }
        .icon-circle {
            background: var(--accent-color); width: 40px; height: 40px; border-radius: 50%;
            display: flex; justify-content: center; align-items: center;
            margin-right: 15px; color: white; font-size: 1rem; font-weight: bold;
        }

        /* Flashcard */
        .scene {
            width: 100%; height: 480px;
            perspective: 1000px; cursor: pointer;
        }
        .card {
            width: 100%; height: 100%; position: relative;
            transition: transform 0.6s; transform-style: preserve-3d;
            border-radius: var(--card-radius);
            box-shadow: 0 20px 50px rgba(0,0,0,0.15);
        }
        .card.is-flipped { transform: rotateY(180deg); }

        .card-face {
            position: absolute; width: 100%; height: 100%;
            -webkit-backface-visibility: hidden; backface-visibility: hidden;
            display: flex; flex-direction: column;
            justify-content: center; align-items: center;
            border-radius: var(--card-radius);
            background: white; border: 5px solid white;
            padding: 20px; box-sizing: border-box;
        }
        .card-face.card-back { background: #f9f9f9; transform: rotateY(180deg); border-color: #eee; }

        /* Badges */
        .mode-badge {
            position: absolute; top: 5px;
            padding: 5px 15px; border-radius: 15px;
            color: white; font-size: 0.9rem; font-weight: bold;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        .bg-read { background: #4facfe; }
        .bg-listen { background: #f093fb; }
        .bg-speak { background: #fa709a; }

        /* Text Styles */
        .big-text { font-size: 1.8rem; margin: 15px 0; color: #333; line-height: 1.3; transition: 0.3s; word-break: keep-all; }
        .big-text.korean { color: var(--accent-color); }
        .big-text.german { color: #4A4A4A; }
        .big-text.blurred { filter: blur(12px); opacity: 0.6; }

        .sub-text { font-size: 1rem; color: #888; margin-top: 5px; }

        /* Audio Btn */
        .play-btn {
            width: 60px; height: 60px; border-radius: 50%; border: none;
            background: #f0f0f0; cursor: pointer;
            display: flex; justify-content: center; align-items: center;
            margin-top: 10px; transition: 0.2s;
        }
        .play-btn:active { transform: scale(0.9); }
        .play-btn svg { width: 28px; height: 28px; fill: #555; }
        .play-btn.highlight { background: var(--accent-color); }
        .play-btn.highlight svg { fill: white; }

        /* Mic Button */
        .mic-container { display: none; flex-direction: column; align-items: center; margin-top: 20px; }
        .mic-btn {
            width: 80px; height: 80px; border-radius: 50%; border: none;
            background: #fa709a; color: white; font-size: 2rem;
            cursor: pointer; box-shadow: 0 10px 20px rgba(250, 112, 154, 0.4);
            transition: all 0.3s; display: flex; justify-content: center; align-items: center;
        }
        .mic-btn.listening { background: #ff4b1f; animation: pulse 1.5s infinite; }
        @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 75, 31, 0.7); } 70% { box-shadow: 0 0 0 20px rgba(255, 75, 31, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 75, 31, 0); } }

        .speech-feedback { margin-top: 15px; font-size: 1rem; color: #555; font-style: italic; min-height: 1.5em; }
        .match-success { color: #28a745; font-weight: bold; }
        .match-fail { color: #dc3545; }

        .controls { display: flex; gap: 10px; width: 100%; margin-top: 25px; }
        .ctrl-btn { flex: 1; padding: 15px; border-radius: 20px; border: none; font-family: var(--font-main); font-size: 1.2rem; cursor: pointer; }
        .btn-no { background: #fad0c4; color: #822727; }
        .btn-yes { background: #a8edea; color: #2c7a7b; }

        .stats-bar { display: flex; justify-content: space-between; color: white; font-size: 1.2rem; margin-bottom: 10px; text-shadow: 1px 1px 1px rgba(0,0,0,0.1); }

        #error-box { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #8b0000; color: white; padding: 15px; text-align: left; z-index: 9999; font-size: 12px; }

* { box-sizing: border-box; }
body { min-height:100svh; height:auto; padding:16px 0; flex-direction:column; }
#app { margin:auto; }
.trainer-nav { margin-bottom:16px; }
.trainer-nav a { color:#493766; }
#level-search { width:100%; padding:12px 16px; border:2px solid white; border-radius:20px; font:inherit; background:#ffffffdd; color:var(--text-color); }
.menu-btn .icon-circle { flex-shrink:0; }
.menu-btn { text-align:left; }
.menu-container { height:55vh; }
#access-message { padding:24px; background:white; border-radius:25px; }
#access-message a { color:#68429f; }
#level-title { color:white; margin:0 0 14px; }
button:focus-visible, a:focus-visible, input:focus-visible { outline:3px solid #453063; outline-offset:3px; }
#mic-hint { font-size:.8rem; color:#666; }
@media(max-width:420px) { #app{padding:12px;} h1{font-size:2rem;} .scene{height:460px;} .big-text{font-size:1.5rem;} }
[hidden] { display:none !important; }
*, *::before, *::after { box-sizing:border-box; }
#error-box { max-height:25vh; overflow:auto; }
#finish-screen { color:white; }
#finish-screen .menu-btn { justify-content:center; width:100%; margin:18px 0; }
#level-ratings fieldset { margin:16px 0; border:2px solid #fff9; border-radius:20px; padding:12px; display:flex; justify-content:space-around; }
#level-ratings label { display:flex; flex-direction:column; align-items:center; gap:8px; cursor:pointer; min-width:36px; padding:8px 0; }
#level-ratings input { width:20px; height:20px; accent-color:var(--accent-color); }
.trainer-exit { background:none; border:0; font:inherit; color:#493766; cursor:pointer; padding:14px; }
button:disabled { opacity:.55; cursor:wait; }
.trainer-reveal { min-height:44px; padding:10px 20px; margin:8px auto 16px; border:2px solid #493766; border-radius:16px; background:#fff; color:#493766; font:inherit; cursor:pointer; }
#game-screen > .speech-feedback { min-height:2.8em; padding:8px 12px; border-radius:12px; background:#fff; color:#493766; overflow-wrap:anywhere; }
.scene { height:clamp(260px,calc(100svh - 360px),460px); }
.controls { margin-top:10px; }
.card-face { overflow:auto; }
@media (max-height:650px) and (min-width:600px) { .scene { height:360px; } }
@media (prefers-reduced-motion:reduce) { .card,.screen.active { transition:none; animation:none; } }

/* Keep essential text legible on both ends of the pastel background. */
h1,h2,#level-title,.stats-bar,#finish-screen,.trainer-nav a,.trainer-exit { color:#352643; text-shadow:none; }
h2 { opacity:1; }
.bg-read { background:#175d91; }
.bg-listen { background:#793b87; }
.bg-speak { background:#963754; }
.sub-text { color:#666; }
button:disabled { cursor:not-allowed; }
#level-ratings fieldset { border-color:#78658b; flex-wrap:wrap; gap:4px; }
#level-ratings label { min-width:44px; min-height:44px; }
@media (prefers-reduced-motion:reduce) { .mic-btn.listening { animation:none; } }
@media (max-width:360px) { #level-ratings fieldset { display:grid; grid-template-columns:repeat(3,minmax(44px,1fr)); } }

.hangul-reading #front-text { font-size:clamp(2.4rem,10vw,4rem); overflow-wrap:anywhere; }
.hangul-reading #back-korean { font-size:1.5rem; margin:8px 0; }
.hangul-reading #back-german { font-size:clamp(1.8rem,7vw,2.8rem) !important; margin:8px 0; overflow-wrap:anywhere; }
.hangul-reading #back-hint,.hangul-reading #audio-source { font-family:system-ui,sans-serif; font-size:.8rem; line-height:1.4; }
.hangul-reading #audio-source { margin-top:8px; }
.hangul-reading .play-btn { flex-shrink:0; }

.hangul-reading .card-front > div:last-child { position:absolute; bottom:16px; left:12px; right:12px; margin:0 !important; }
.hangul-reading .card-front { padding-top:50px; padding-bottom:56px; }

.answer-content{display:contents}.hangul-reading .card-back{display:block;overscroll-behavior:contain;scrollbar-gutter:stable}.hangul-reading .answer-content{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100%;gap:8px}.hangul-reading .answer-content>*{flex-shrink:0;max-width:100%;overflow-wrap:anywhere}.hangul-reading #back-german{white-space:pre-wrap}.hangul-reading #back-explanation{width:100%;font-family:system-ui,sans-serif;font-size:1rem;line-height:1.65;text-align:left;white-space:pre-wrap;overflow-wrap:anywhere;user-select:text;padding:14px;background:#eee8f6;border-radius:12px;margin:4px 0}.hangul-reading #back-hint{white-space:pre-wrap}.card-back:focus-visible{outline:3px solid #453063;outline-offset:-4px}

.answer-scroll-hint{font-family:system-ui,sans-serif;font-size:.8rem;line-height:1.4;color:#352643;margin:8px 0 0}
