:root {
    --font-main: "Comfortaa", "Nunito", cursive, sans-serif;
    --color-parchment: #fcf6e8;
    --color-parchment-border: #8b5a2b;
    --color-gold: #f39c12;
    --color-gold-dark: #d68910;
    --color-forest: #27ae60;
    --color-crimson: #c0392b;
    --color-royal-blue: #2980b9;
    --shadow-storybook: 0 8px 24px rgba(0, 0, 0, 0.25);
}

* {
    box-sizing: border-box;
    user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden !important;
    font-family: var(--font-main);
    background: #2c3e50;
    background: radial-gradient(circle, #34495e 0%, #1a252f 100%);
    color: #2c3e50;
}

#app {
    width: 100vw;
    height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-viewport {
    width: 100%;
    max-width: 1024px;
    height: 100vh;
    max-height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(6px, 1.5vh, 14px);
    box-sizing: border-box;
    overflow: hidden;
}

.viewport-fullscreen {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* ========================================================
   PC GAME MAIN MENU SCREEN (100% VIEWPORT FIT)
   ======================================================== */
.main-menu-fullscreen {
    height: 100vh;
    max-height: 100dvh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.main-menu-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-height: 100dvh;
    padding: clamp(14px, 3vh, 32px) 20px;
    z-index: 2;
    box-sizing: border-box;
}

.title-logo-box {
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.title-crown {
    font-size: clamp(2rem, 5vh, 3.2rem);
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
    animation: bounce 1.5s infinite alternate;
}

.main-game-title {
    font-size: clamp(2rem, 5.5vh, 3.4rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 
        3px 3px 0px #8b5a2b,
        -3px -3px 0px #8b5a2b,
        3px -3px 0px #8b5a2b,
        -3px 3px 0px #8b5a2b,
        0 8px 16px rgba(0,0,0,0.6);
    margin: 0;
    letter-spacing: 2px;
}

.title-banner {
    display: inline-block;
    background: linear-gradient(135deg, #f39c12, #d68910);
    color: white;
    font-size: clamp(0.9rem, 2vh, 1.2rem);
    font-weight: 700;
    padding: 4px 22px;
    border-radius: 20px;
    border: 3px solid #fff;
    box-shadow: 0 6px 14px rgba(0,0,0,0.3);
    margin-top: 4px;
}

.menu-actions-parchment {
    background: rgba(252, 246, 232, 0.95);
    border: 4px solid var(--color-parchment-border);
    border-radius: 20px;
    padding: clamp(16px, 3vh, 28px) clamp(18px, 4vw, 36px);
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vh, 14px);
    width: 100%;
    max-width: 440px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
}

.pc-menu-btn {
    background: #fff;
    border: 3px solid #bdc3c7;
    border-radius: 14px;
    padding: clamp(8px, 1.8vh, 14px) 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.2s ease;
    text-align: left;
    box-shadow: 0 4px 0 #bdc3c7;
}

.pc-menu-btn:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: var(--color-gold);
}

.pc-menu-btn.new-game-btn { background: #e8f8f5; border-color: #27ae60; box-shadow: 0 4px 0 #1e8449; }
.pc-menu-btn.continue-btn { background: #fef9e7; border-color: var(--color-gold); box-shadow: 0 4px 0 var(--color-gold-dark); }
.pc-menu-btn.reset-btn { background: transparent; border: 2px dashed #e74c3c; color: #c0392b; box-shadow: none; padding: 6px 12px; justify-content: center; }

.btn-icon { font-size: clamp(1.4rem, 3.5vh, 2rem); }
.btn-title { font-size: clamp(1.1rem, 2.5vh, 1.3rem); font-weight: 800; color: #2c3e50; }
.btn-subtitle { font-size: clamp(0.75rem, 1.6vh, 0.85rem); color: #7f8c8d; }
.btn-title-small { font-size: 0.85rem; font-weight: 700; }

.main-menu-footer {
    color: white;
    font-weight: 600;
    font-size: clamp(0.75rem, 1.6vh, 0.95rem);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 14px;
    border-radius: 10px;
}

/* ========================================================
   WIZARD NEW GAME FLOW (GRADE -> HERO -> NAME & START)
   ======================================================== */
.wizard-screen {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: clamp(6px, 1.5vh, 16px);
}

.wizard-container {
    background: var(--color-parchment);
    border: 4px solid var(--color-parchment-border);
    border-radius: 20px;
    box-shadow: var(--shadow-storybook);
    padding: clamp(10px, 1.8vh, 20px);
    width: 100%;
    max-width: 980px;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.wizard-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(4px, 1vh, 10px);
    flex: 0 0 auto;
}

.btn-wizard-back {
    background: #fff;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    padding: 4px 12px;
    font-weight: 700;
    font-family: var(--font-main);
    font-size: clamp(0.75rem, 1.6vh, 0.9rem);
    cursor: pointer;
    transition: all 0.15s ease;
    color: #2c3e50;
}

.btn-wizard-back:hover {
    background: #ecf0f1;
    border-color: #95a5a6;
}

.wizard-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: clamp(0.75rem, 1.6vh, 0.9rem);
    font-weight: 700;
}

.step-badge {
    padding: 3px 10px;
    border-radius: 12px;
    background: #e2dcd0;
    color: #7f8c8d;
    transition: all 0.2s ease;
}

.step-badge.active {
    background: var(--color-gold);
    color: white;
    box-shadow: 0 2px 6px rgba(243, 156, 18, 0.4);
}

.step-badge.completed {
    background: #d4efdf;
    color: #1e8449;
    cursor: pointer;
}

.step-divider {
    color: #bdc3c7;
    font-size: 0.8rem;
}

.wizard-header {
    text-align: center;
    margin-bottom: clamp(6px, 1.2vh, 14px);
    flex: 0 0 auto;
}

.wizard-title {
    font-size: clamp(1.4rem, 3.2vh, 2rem);
    color: var(--color-parchment-border);
    margin: 0;
    font-weight: 800;
}

.wizard-subtitle {
    font-size: clamp(0.8rem, 1.6vh, 0.95rem);
    color: #7f8c8d;
    margin: 2px 0 0 0;
}

/* --- STEP 1: GRADES GRID --- */
.grades-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(10px, 1.5vw, 18px);
    flex: 1 1 auto;
    align-items: stretch;
    min-height: 0;
}

.grade-card {
    background: white;
    border: 3px solid #d5dbdb;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    overflow: hidden;
}

.grade-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(0,0,0,0.15);
}

.grade-1-card { border-color: #3498db; }
.grade-1-card:hover, .grade-1-card.selected { border-color: #2980b9; box-shadow: 0 8px 22px rgba(52, 152, 219, 0.35); }

.grade-2-card { border-color: #e67e22; }
.grade-2-card:hover, .grade-2-card.selected { border-color: #d35400; box-shadow: 0 8px 22px rgba(230, 126, 34, 0.35); }

.grade-3-card { border-color: #9b59b6; }
.grade-3-card:hover, .grade-3-card.selected { border-color: #8e44ad; box-shadow: 0 8px 22px rgba(155, 89, 182, 0.35); }

.grade-banner-stage {
    width: 100%;
    height: clamp(75px, 14vh, 105px);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grade-banner-overlay {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.5) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

.grade-card-icon {
    font-size: clamp(1.4rem, 3vh, 2rem);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.grade-card-badge {
    font-size: clamp(0.7rem, 1.4vh, 0.8rem);
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 8px;
    color: white;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.grade-1-badge { background: #3498db; }
.grade-2-badge { background: #e67e22; }
.grade-3-badge { background: #9b59b6; }

.grade-card-content {
    padding: clamp(8px, 1.4vh, 14px);
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    align-items: center;
}

.grade-card-title {
    margin: 0 0 2px 0;
    font-size: clamp(1.1rem, 2.3vh, 1.3rem);
    color: #2c3e50;
    font-weight: 800;
}

.grade-card-desc {
    font-size: clamp(0.72rem, 1.4vh, 0.82rem);
    color: #7f8c8d;
    margin: 0 0 clamp(6px, 1vh, 8px) 0;
    min-height: 2.4em;
    line-height: 1.2;
}

.grade-topics-list {
    list-style: none;
    padding: 0;
    margin: 0 0 clamp(8px, 1.4vh, 12px) 0;
    text-align: left;
    font-size: clamp(0.72rem, 1.35vh, 0.82rem);
    color: #34495e;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    width: 100%;
}

.grade-topics-list li {
    background: #f8f9f9;
    padding: 3px 8px;
    border-radius: 6px;
    border-left: 3px solid #bdc3c7;
}

.grade-1-card .grade-topics-list li { border-left-color: #3498db; }
.grade-2-card .grade-topics-list li { border-left-color: #e67e22; }
.grade-3-card .grade-topics-list li { border-left-color: #9b59b6; }

.btn-grade-select {
    width: 100%;
    color: white;
    border: none;
    border-radius: 10px;
    padding: clamp(6px, 1.2vh, 10px) 12px;
    font-weight: 800;
    font-family: var(--font-main);
    font-size: clamp(0.85rem, 1.7vh, 0.95rem);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: auto;
}

.btn-grade-1 { background: #3498db; box-shadow: 0 3px 0 #2471a3; }
.btn-grade-1:hover { background: #2980b9; transform: translateY(-1px); }

.btn-grade-2 { background: #e67e22; box-shadow: 0 3px 0 #b95c00; }
.btn-grade-2:hover { background: #d35400; transform: translateY(-1px); }

.btn-grade-3 { background: #9b59b6; box-shadow: 0 3px 0 #6c3483; }
.btn-grade-3:hover { background: #8e44ad; transform: translateY(-1px); }

/* --- STEP 2: HERO SHOWCASE GRID --- */
.hero-showcase-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(10px, 1.5vw, 18px);
    flex: 1 1 auto;
    align-items: stretch;
    min-height: 0;
}

.hero-showcase-card {
    background: white;
    border: 3px solid #d5dbdb;
    border-radius: 16px;
    padding: clamp(8px, 1.4vh, 14px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}

.hero-showcase-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.hero-theme-knight { border-color: #f39c12; }
.hero-theme-knight:hover, .hero-theme-knight.selected { border-color: #d35400; background: #fef9e7; }

.hero-theme-mage { border-color: #9b59b6; }
.hero-theme-mage:hover, .hero-theme-mage.selected { border-color: #8e44ad; background: #fbf6fd; }

.hero-theme-archer { border-color: #27ae60; }
.hero-theme-archer:hover, .hero-theme-archer.selected { border-color: #229954; background: #eafaf1; }

.hero-card-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.hero-crest-icon { font-size: clamp(1.2rem, 2.5vh, 1.5rem); }
.hero-class-label { font-size: 0.75rem; font-weight: 700; color: #7f8c8d; text-transform: uppercase; }

.hero-portrait-stage {
    width: 100%;
    height: clamp(90px, 18vh, 140px);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin: 2px 0 6px 0;
}

.hero-portrait-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.25));
}

.hero-info-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    width: 100%;
}

.hero-title-name {
    margin: 0;
    font-size: clamp(1rem, 2.2vh, 1.25rem);
    color: #2c3e50;
    font-weight: 800;
}

.hero-lore-desc {
    font-size: clamp(0.7rem, 1.4vh, 0.8rem);
    color: #7f8c8d;
    margin: 0;
    min-height: 2.4em;
    line-height: 1.25;
}

.hero-skill-pill {
    background: #f4f6f6;
    border: 1px dashed #bdc3c7;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: clamp(0.7rem, 1.3vh, 0.8rem);
    color: #34495e;
    margin: 2px 0;
}

.hero-stats-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.stat-tag {
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    color: #2c3e50;
}

.btn-hero-select {
    width: 100%;
    background: var(--color-forest);
    color: white;
    border: none;
    border-radius: 10px;
    padding: clamp(6px, 1.2vh, 10px) 12px;
    font-weight: 800;
    font-family: var(--font-main);
    font-size: clamp(0.85rem, 1.7vh, 0.95rem);
    cursor: pointer;
    box-shadow: 0 3px 0 #1e8449;
    transition: all 0.15s ease;
}

.btn-hero-select:hover {
    background: #2ecc71;
    transform: translateY(-1px);
}

/* --- STEP 3: NAMING & START QUEST --- */
.wizard-name-container {
    max-width: 860px;
}

.naming-content-stage {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: clamp(14px, 2.5vw, 24px);
    align-items: center;
    flex: 1 1 auto;
    min-height: 0;
}

.naming-hero-preview {
    background: white;
    border: 3px solid var(--color-parchment-border);
    border-radius: 16px;
    padding: clamp(12px, 2vh, 18px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.hero-stage-pedestal {
    width: 100%;
    height: clamp(110px, 22vh, 160px);
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, rgba(243, 156, 18, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 12px;
    margin-bottom: 6px;
}

.naming-hero-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 14px rgba(0,0,0,0.3));
}

.naming-badges-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.grade-pill-badge {
    background: var(--color-gold);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
}

.hero-pill-badge {
    background: #34495e;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
}

.naming-stat-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: clamp(0.7rem, 1.4vh, 0.8rem);
    color: #566573;
    font-weight: 600;
}

.naming-form-box {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vh, 14px);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: clamp(0.95rem, 2vh, 1.15rem);
    font-weight: 800;
    color: #2c3e50;
}

.name-input-with-dice {
    display: flex;
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.hero-name-big-input {
    flex: 1;
    padding: clamp(8px, 1.5vh, 12px) 14px;
    font-size: clamp(1rem, 2.2vh, 1.25rem);
    font-family: var(--font-main);
    font-weight: 700;
    border: 3px solid var(--color-gold);
    border-radius: 12px;
    background: white;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
    color: #2c3e50;
}

.hero-name-big-input:focus {
    border-color: #d35400;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.4);
}

.btn-dice-randomizer {
    background: #fef9e7;
    border: 2px solid var(--color-gold);
    border-radius: 12px;
    padding: clamp(6px, 1vh, 10px) 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-main);
    font-weight: 800;
    font-size: clamp(0.8rem, 1.6vh, 0.95rem);
    color: #b7950b;
    box-shadow: 0 3px 0 var(--color-gold-dark);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-dice-randomizer:hover {
    background: #fcf3cf;
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--color-gold-dark);
}

.btn-dice-randomizer:active, .btn-dice-randomizer.rolling {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--color-gold-dark);
}

.dice-icon {
    font-size: clamp(1.3rem, 2.8vh, 1.7rem);
    display: inline-block;
    transition: transform 0.3s ease;
}

.btn-dice-randomizer.rolling .dice-icon {
    animation: diceSpin 0.35s ease-in-out;
}

@keyframes diceSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.3); }
    100% { transform: rotate(360deg) scale(1); }
}

.quick-names-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quick-names-title {
    font-size: 0.8rem;
    color: #7f8c8d;
    font-weight: 600;
}

.quick-names-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.name-chip-btn {
    background: white;
    border: 1.5px solid #bdc3c7;
    border-radius: 8px;
    padding: 3px 10px;
    font-size: clamp(0.75rem, 1.5vh, 0.85rem);
    font-weight: 600;
    font-family: var(--font-main);
    color: #34495e;
    cursor: pointer;
    transition: all 0.15s ease;
}

.name-chip-btn:hover {
    border-color: var(--color-gold);
    background: #fef9e7;
}

.name-chip-btn.active-chip {
    background: var(--color-gold);
    border-color: var(--color-gold-dark);
    color: white;
    font-weight: 700;
}

.naming-action-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.btn-grand-start {
    background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    font-size: clamp(1.05rem, 2.4vh, 1.3rem);
    font-weight: 800;
    font-family: var(--font-main);
    border: none;
    border-radius: 12px;
    padding: clamp(10px, 2vh, 16px);
    cursor: pointer;
    box-shadow: 0 4px 0 #1e8449, 0 6px 16px rgba(39, 174, 96, 0.4);
    transition: all 0.15s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.btn-grand-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1e8449, 0 10px 22px rgba(39, 174, 96, 0.5);
}

.btn-grand-start:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1e8449;
}

.autosave-notice {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin: 0;
    text-align: center;
}

/* ========================================================
   WORLD MAP & RICH LEVEL CARDS (100% VIEWPORT FIT)
   ======================================================== */
.world-map-screen {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.2vh, 12px);
    overflow: hidden;
    padding: clamp(4px, 1vh, 10px);
}

.map-top-bar {
    background: var(--color-parchment);
    border: 3px solid var(--color-parchment-border);
    border-radius: 14px;
    padding: clamp(4px, 0.8vh, 8px) 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.player-pill {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mini-hero-avatar {
    width: clamp(34px, 5vh, 44px);
    height: clamp(34px, 5vh, 44px);
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--color-gold);
    padding: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.player-info-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.player-name {
    font-weight: 800;
    font-size: clamp(0.95rem, 2vh, 1.15rem);
    color: #2c3e50;
    line-height: 1.1;
}

.grade-tag {
    background: var(--color-gold);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 6px;
    margin-top: 2px;
    display: inline-block;
    width: fit-content;
}

.stats-pill-group {
    display: flex;
    gap: 8px;
}

.stat-badge {
    background: white;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    padding: 3px 10px;
    font-size: clamp(0.8rem, 1.6vh, 0.95rem);
    font-weight: 700;
    color: #2c3e50;
}

.stat-badge.stars-badge { border-color: var(--color-gold); background: #fefcf5; }
.stat-badge.gold-badge { border-color: #f1c40f; background: #fffdf2; }

.btn-top-action {
    background: #fff;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    padding: 4px 12px;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: clamp(0.75rem, 1.6vh, 0.85rem);
    cursor: pointer;
    transition: all 0.15s ease;
    color: #34495e;
}

.btn-top-action:hover {
    background: #f4f6f7;
    border-color: var(--color-gold);
    transform: translateY(-1px);
}

/* WORLD MAP CONTENT AREA */
.world-map-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.2vh, 10px);
    min-height: 0;
    overflow: hidden;
}

/* WORLD TABS NAV */
.world-tabs-nav {
    display: flex;
    gap: clamp(6px, 1vw, 12px);
    flex: 0 0 auto;
    overflow-x: auto;
    padding-bottom: 2px;
}

.world-tab-btn {
    flex: 1 1 auto;
    min-width: 120px;
    background: #fff;
    border: 2px solid #bdc3c7;
    border-radius: 12px;
    padding: clamp(6px, 1vh, 10px) 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.world-tab-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--color-gold);
}

.world-tab-btn.active {
    background: var(--color-gold);
    border-color: var(--color-gold-dark);
    color: white;
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.4);
}

.world-tab-btn.locked {
    opacity: 0.6;
    background: #eaeded;
    cursor: not-allowed;
    border-style: dashed;
}

.world-tab-btn.world-completed {
    border-color: #27ae60;
}

.world-tab-btn.active.world-completed {
    background: #27ae60;
    border-color: #1e8449;
}

.world-tab-icon { font-size: clamp(1rem, 2.2vh, 1.3rem); }
.world-tab-label { font-weight: 800; font-size: clamp(0.8rem, 1.7vh, 0.95rem); }
.world-tab-progress {
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(0,0,0,0.08);
    padding: 1px 6px;
    border-radius: 6px;
}

.world-tab-btn.active .world-tab-progress {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

/* ACTIVE WORLD CONTAINER */
.active-world-card {
    flex: 1 1 auto;
    background: var(--color-parchment);
    border: 4px solid var(--color-parchment-border);
    border-radius: 18px;
    box-shadow: var(--shadow-storybook);
    padding: clamp(8px, 1.5vh, 16px);
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.2vh, 12px);
    min-height: 0;
    overflow: hidden;
}

.world-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #d5dbdb;
    padding-bottom: clamp(4px, 0.8vh, 8px);
    flex: 0 0 auto;
}

.world-title-col { text-align: left; }
.active-world-title {
    margin: 0;
    font-size: clamp(1.1rem, 2.4vh, 1.4rem);
    color: #2c3e50;
    font-weight: 800;
}

.active-world-desc {
    margin: 2px 0 0 0;
    color: #7f8c8d;
    font-size: clamp(0.75rem, 1.5vh, 0.85rem);
}

.world-progress-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.progress-label-row {
    font-size: clamp(0.75rem, 1.5vh, 0.85rem);
    color: #34495e;
}

.world-progress-bar {
    width: clamp(120px, 15vw, 180px);
    height: 10px;
    background: #e0d7c6;
    border: 2px solid var(--color-parchment-border);
    border-radius: 6px;
    overflow: hidden;
}

.world-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f39c12, #27ae60);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* LEVELS RICH CARDS GRID */
.levels-rich-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: clamp(8px, 1.5vw, 16px);
    align-items: stretch;
    min-height: 0;
    overflow-y: auto;
    padding: 2px;
}

.level-rich-card {
    background: white;
    border: 3px solid #d5dbdb;
    border-radius: 16px;
    padding: clamp(8px, 1.4vh, 12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    position: relative;
    transition: all 0.2s ease;
}

.level-rich-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}

/* Card Status Variants */
.level-rich-card.status-completed {
    border-color: #27ae60;
    background: #fdfefe;
}

.level-rich-card.status-current {
    border-color: var(--color-gold);
    background: #fffdf5;
    box-shadow: 0 0 14px rgba(243, 156, 18, 0.35);
}

.level-rich-card.status-locked {
    border-color: #bdc3c7;
    background: #f2f4f4;
    opacity: 0.75;
}

.level-rich-card.boss-card {
    border-color: var(--color-crimson);
}

.level-rich-card.boss-card.status-current {
    box-shadow: 0 0 16px rgba(231, 76, 60, 0.4);
    background: #fffcfb;
}

/* Card Status Banner */
.card-status-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 4px;
    min-height: 20px;
}

.badge-completed {
    background: #d4efdf;
    color: #1e8449;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
}

.stars-awarded { font-size: 0.8rem; }

.badge-active {
    background: #fef9e7;
    border: 1px solid var(--color-gold);
    color: #d35400;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
}

.badge-boss {
    background: var(--color-crimson);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
}

.badge-locked {
    background: #d5dbdb;
    color: #566573;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}

/* ENEMY AVATAR STAGE */
.level-enemy-stage {
    width: 100%;
    height: clamp(80px, 15vh, 110px);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 4px;
}

.enemy-avatar-wrapper {
    position: relative;
    width: clamp(75px, 14vh, 100px);
    height: clamp(75px, 14vh, 100px);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(240, 240, 240, 0.5) 70%);
}

.enemy-avatar-wrapper.active-glow {
    background: radial-gradient(circle, rgba(243, 156, 18, 0.25) 0%, rgba(255, 255, 255, 0) 70%);
}

.enemy-avatar-wrapper.defeated-glow {
    background: radial-gradient(circle, rgba(39, 174, 96, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
}

.enemy-avatar-wrapper.locked-silhouette {
    filter: grayscale(1) contrast(0.7);
}

.level-enemy-img {
    max-height: 85%;
    max-width: 85%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
}

.lock-overlay {
    position: absolute;
    font-size: 1.8rem;
    color: #7f8c8d;
    background: rgba(255, 255, 255, 0.7);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.check-overlay {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #27ae60;
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* LEVEL INFO BODY */
.level-info-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1 1 auto;
    width: 100%;
}

.level-number-tag {
    font-size: 0.7rem;
    font-weight: 700;
    color: #95a5a6;
    text-transform: uppercase;
}

.level-name-title {
    margin: 0;
    font-size: clamp(0.9rem, 1.8vh, 1.1rem);
    font-weight: 800;
    color: #2c3e50;
    line-height: 1.15;
}

.level-enemy-name {
    font-size: clamp(0.7rem, 1.3vh, 0.8rem);
    color: #7f8c8d;
}

.level-math-pill {
    background: #f4f6f6;
    border: 1px solid #d5dbdb;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: clamp(0.68rem, 1.3vh, 0.78rem);
    color: #34495e;
    font-weight: 600;
    margin: 2px 0;
}

.level-stats-row {
    display: flex;
    gap: 6px;
    margin-top: 2px;
    margin-bottom: 4px;
}

.stat-bubble {
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(0,0,0,0.04);
    padding: 1px 6px;
    border-radius: 4px;
    color: #566573;
}

/* LEVEL CARD FOOTER BUTTONS */
.level-card-footer {
    width: 100%;
    margin-top: auto;
}

.btn-level-action {
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: clamp(6px, 1.2vh, 9px) 10px;
    font-weight: 800;
    font-family: var(--font-main);
    font-size: clamp(0.8rem, 1.6vh, 0.9rem);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-replay {
    background: #f39c12;
    color: white;
    box-shadow: 0 3px 0 #b9770e;
}

.btn-replay:hover {
    background: #f1c40f;
    transform: translateY(-1px);
}

.btn-battle {
    background: var(--color-forest);
    color: white;
    box-shadow: 0 3px 0 #1e8449;
}

.btn-battle:hover {
    background: #2ecc71;
    transform: translateY(-1px);
}

.btn-boss-battle {
    background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 3px 0 #922b21;
}

.btn-boss-battle:hover {
    background: #e74c3c;
    transform: translateY(-1px);
}

.btn-locked {
    background: #d5dbdb;
    color: #7f8c8d;
    cursor: not-allowed;
}

/* ========================================================
   BATTLE ARENA (100% VIEWPORT FIT - NO SCROLL)
   ======================================================== */
.battle-arena-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(4px, 1vh, 10px);
    overflow: hidden;
}

.battle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-parchment);
    border: 3px solid var(--color-parchment-border);
    border-radius: 10px;
    padding: clamp(4px, 0.8vh, 8px) 14px;
    flex: 0 0 auto;
}

.btn-back {
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    padding: 3px 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.btn-back:hover {
    background: #ffffff;
    border-color: var(--color-gold);
    transform: translateY(-1px);
}

.battle-header-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.world-title { font-size: clamp(0.95rem, 2vh, 1.15rem); font-weight: 700; }
.boss-badge { background: var(--color-crimson); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; margin-left: 4px; }
.combo-counter { font-size: clamp(0.85rem, 1.8vh, 1rem); color: #7f8c8d; }
.combo-counter.active-streak { color: var(--color-gold-dark); animation: bounce 0.5s infinite alternate; }

.feedback-banner {
    padding: clamp(4px, 0.8vh, 8px) 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-size: clamp(0.9rem, 2vh, 1.05rem);
    color: white;
    flex: 0 0 auto;
}

.feedback-critical { background: var(--color-gold); text-shadow: 1px 1px 2px black; }
.feedback-standard { background: var(--color-forest); }
.feedback-defense { background: var(--color-royal-blue); }
.feedback-error { background: var(--color-crimson); }

/* Combat Stage */
.arena-stage {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: clamp(8px, 2vw, 16px);
    align-items: center;
    border: 3px solid var(--color-parchment-border);
    border-radius: 16px;
    padding: clamp(6px, 1.2vh, 12px);
    flex: 1 1 auto;
    min-height: 0;
    box-shadow: var(--shadow-storybook);
    overflow: hidden;
}

.combatant {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    height: 100%;
}

.combatant-info { margin-bottom: 4px; }
.combatant-name {
    color: white;
    font-weight: 700;
    font-size: clamp(0.95rem, 2.2vh, 1.15rem);
    text-shadow: 1px 1px 3px black;
}

.hp-hearts { display: flex; gap: 3px; font-size: clamp(1rem, 2.2vh, 1.3rem); }

.hp-bar-wrapper {
    width: clamp(100px, 15vw, 140px);
    height: clamp(14px, 2vh, 18px);
    background: #7f8c8d;
    border-radius: 8px;
    border: 2px solid white;
    position: relative;
    overflow: hidden;
}

.hp-bar-fill { height: 100%; background: #e74c3c; transition: width 0.3s ease; }
.hp-text { position: absolute; top: 0; left: 0; right: 0; bottom: 0; font-size: 0.7rem; color: white; font-weight: 700; line-height: 14px; }

.character-sprite-box {
    position: relative;
    width: clamp(90px, 16vw, 150px);
    height: clamp(100px, 22vh, 180px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.sprite-phase-indicator {
    position: absolute;
    top: -6px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    z-index: 3;
}

.character-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.35));
}

.timer-orb {
    width: clamp(54px, 10vh, 74px);
    height: clamp(54px, 10vh, 74px);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    border: 3px solid white;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
}

.timer-green { background: var(--color-forest); }
.timer-yellow { background: var(--color-gold); }
.timer-red { background: var(--color-crimson); animation: pulse 0.5s infinite; }

.timer-seconds { font-size: clamp(0.95rem, 2vh, 1.15rem); font-weight: 700; }
.timer-label { font-size: 0.65rem; font-weight: 600; }

/* PARCHMENT ACTION BOARD */
.parchment-action-board {
    background: var(--color-parchment);
    border: 3px solid var(--color-parchment-border);
    border-radius: 16px;
    padding: clamp(6px, 1vh, 10px) clamp(8px, 1.5vw, 16px);
    box-shadow: var(--shadow-storybook);
    text-align: center;
    flex: 0 0 auto;
}

.equation-box {
    margin-bottom: clamp(4px, 0.8vh, 8px);
    min-height: clamp(48px, 7.5vh, 62px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.equation-title {
    font-size: clamp(0.72rem, 1.4vh, 0.85rem);
    font-weight: 700;
    margin-bottom: 2px;
}

.equation-text {
    font-size: clamp(1.4rem, 3.4vh, 2.1rem);
    color: #2c3e50;
    margin: 0;
    letter-spacing: 1.5px;
    white-space: pre-line;
    line-height: 1.2;
}

/* INPUT ACTION ZONE - STABLE HEIGHT FOR BOTH KEYPAD AND CHOICES */
.input-action-zone {
    min-height: clamp(185px, 28vh, 220px);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* KEYPAD */
.keypad-container {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
}

.keypad-display {
    background: white;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    padding: 4px;
    font-size: clamp(1.3rem, 3vh, 1.6rem);
    font-weight: 700;
    margin-bottom: 6px;
    min-height: clamp(34px, 5vh, 42px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(4px, 0.8vh, 6px);
}

.key-btn {
    background: white;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    font-size: clamp(1.1rem, 2.4vh, 1.3rem);
    font-weight: 700;
    font-family: var(--font-main);
    padding: clamp(4px, 0.9vh, 8px) 0;
    cursor: pointer;
    box-shadow: 0 3px 0 #bdc3c7;
}

.key-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #bdc3c7; }
.key-btn.action-key.backspace { background: #fadbd8; border-color: #e74c3c; box-shadow: 0 3px 0 #cb4335; }
.key-btn.action-key.submit { background: #d4efdf; border-color: #27ae60; box-shadow: 0 3px 0 #1e8449; }

/* CHOICE SELECTOR (DEFENSE & MULTIPLE CHOICE) */
.choice-selector-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: clamp(185px, 28vh, 220px);
}

.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(10px, 1.6vh, 14px);
    width: 100%;
    margin: 0 auto;
}

.choice-btn {
    background: white;
    border: 3px solid var(--color-gold);
    border-radius: 14px;
    padding: clamp(12px, 2.4vh, 20px) clamp(8px, 1.5vw, 16px);
    font-size: clamp(1.25rem, 2.8vh, 1.65rem);
    font-weight: 700;
    font-family: var(--font-main);
    cursor: pointer;
    box-shadow: 0 5px 0 var(--color-gold-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(52px, 8.5vh, 68px);
    transition: transform 0.1s ease, background-color 0.15s ease;
}

.choice-btn:hover { background: #fef9e7; }
.choice-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--color-gold-dark); }

/* VICTORY / DEFEAT CARDS */
/* ========================================================
   VICTORY & DEFEAT CELEBRATION MODAL (FULLSCREEN POPUP)
   ======================================================== */
.battle-end-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: clamp(10px, 2vh, 20px);
}

.celebration-modal {
    background: var(--color-parchment);
    border: 5px solid var(--color-parchment-border);
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    padding: clamp(14px, 2.5vh, 24px);
    width: 100%;
    max-width: 580px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.celebration-modal.victory-theme {
    border-color: #f39c12;
    background: linear-gradient(180deg, #fdfbf7 0%, #faebd7 100%);
}

.celebration-modal.defeat-theme {
    border-color: #e74c3c;
    background: linear-gradient(180deg, #fdfefe 0%, #fadbd8 100%);
}

.celebration-particles {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    pointer-events: none;
}

.particle {
    font-size: clamp(1.4rem, 3vh, 2rem);
    animation: particleFloat 2s infinite ease-in-out alternate;
}

.star-p1 { animation-delay: 0s; }
.star-p2 { animation-delay: 0.4s; }
.star-p3 { animation-delay: 0.8s; }
.star-p4 { animation-delay: 1.2s; }

@keyframes particleFloat {
    0% { transform: translateY(0) scale(1) rotate(0deg); }
    100% { transform: translateY(-12px) scale(1.25) rotate(20deg); }
}

.celebration-header {
    margin-bottom: clamp(6px, 1.2vh, 12px);
}

.celebration-crown {
    font-size: clamp(2.2rem, 5vh, 3.2rem);
    display: block;
    animation: bounce 1s infinite alternate;
}

.celebration-title {
    margin: 2px 0;
    font-size: clamp(1.6rem, 3.8vh, 2.3rem);
    color: #b7950b;
    font-weight: 800;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.celebration-subtitle {
    margin: 0;
    font-size: clamp(0.85rem, 1.8vh, 1rem);
    color: #7f8c8d;
    font-weight: 600;
}

.celebration-body {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: clamp(10px, 2vw, 18px);
    align-items: center;
    width: 100%;
    margin-bottom: clamp(10px, 2vh, 18px);
}

.celebration-hero-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: clamp(110px, 22vh, 160px);
    background: radial-gradient(circle, rgba(243, 156, 18, 0.3) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 16px;
}

.celebration-hero-img {
    max-height: 85%;
    max-width: 85%;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(243, 156, 18, 0.4));
}

.victory-hero-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: #2c3e50;
    margin-top: 2px;
}

.celebration-rewards-card {
    background: white;
    border: 2px solid #f39c12;
    border-radius: 14px;
    padding: clamp(8px, 1.5vh, 14px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.reward-row {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.reward-icon { font-size: clamp(1.4rem, 3vh, 1.8rem); }

.reward-info {
    display: flex;
    flex-direction: column;
}

.reward-info strong {
    font-size: clamp(0.9rem, 1.8vh, 1.1rem);
    color: #27ae60;
    font-weight: 800;
}

.reward-info span {
    font-size: 0.75rem;
    color: #7f8c8d;
}

.celebration-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-grand-celebration {
    width: 100%;
    padding: clamp(10px, 2vh, 15px);
    border: none;
    border-radius: 12px;
    font-size: clamp(1rem, 2.2vh, 1.25rem);
    font-weight: 800;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-next-quest {
    background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    box-shadow: 0 4px 0 #1e8449, 0 8px 20px rgba(39, 174, 96, 0.4);
    animation: pulse 1.2s infinite;
}

.btn-next-quest:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1e8449, 0 12px 24px rgba(39, 174, 96, 0.5);
}

.secondary-actions-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

.btn-secondary-celebration {
    flex: 1;
    background: #fff;
    border: 2px solid #bdc3c7;
    border-radius: 10px;
    padding: clamp(6px, 1.2vh, 10px);
    font-size: clamp(0.8rem, 1.6vh, 0.95rem);
    font-weight: 700;
    font-family: var(--font-main);
    color: #34495e;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-secondary-celebration:hover {
    background: #f4f6f7;
    border-color: #7f8c8d;
}

/* Defeat Modal Styling */
.defeat-header { margin-bottom: 8px; }
.defeat-icon { font-size: clamp(2rem, 4.5vh, 2.8rem); display: block; }
.defeat-title { margin: 2px 0; font-size: clamp(1.4rem, 3.2vh, 1.9rem); color: #c0392b; font-weight: 800; }
.defeat-subtitle { color: #7f8c8d; font-size: clamp(0.8rem, 1.6vh, 0.95rem); margin: 0; }
.defeat-encouragement {
    font-size: clamp(0.85rem, 1.8vh, 1rem);
    color: #2c3e50;
    font-style: italic;
    background: white;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px dashed #e74c3c;
    margin: 8px 0 14px 0;
}

.btn-retry-quest {
    background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 0 #922b21;
}

.btn-retry-quest:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #922b21;
}

/* ========================================================
   FAIRYTALE LEVEL TRANSITION SCREEN (INTERACTIVE FACE-OFF)
   ======================================================== */
.transition-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(26, 37, 47, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: clamp(8px, 1.5vh, 16px);
}

.transition-parchment-box {
    background: var(--color-parchment);
    border: 4px solid var(--color-gold);
    border-radius: 20px;
    padding: clamp(12px, 2.5vh, 22px) clamp(16px, 3vw, 28px);
    text-align: center;
    box-shadow: 0 14px 40px rgba(0,0,0,0.6);
    max-width: 560px;
    width: 95%;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 1.5vh, 14px);
    overflow-y: auto;
}

.transition-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.transition-badge {
    background: var(--color-gold);
    color: white;
    font-size: clamp(0.7rem, 1.3vh, 0.8rem);
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.transition-title {
    font-size: clamp(1.2rem, 2.6vh, 1.6rem);
    color: #8b5a2b;
    margin: 0;
    font-weight: 800;
    line-height: 1.2;
}

.transition-faceoff-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2vw, 16px);
    width: 100%;
}

.faceoff-card {
    flex: 1 1 0;
    background: white;
    border: 3px solid var(--color-parchment-border);
    border-radius: 14px;
    padding: clamp(8px, 1.5vh, 12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.faceoff-card.hero-side {
    border-color: #27ae60;
}

.faceoff-card.enemy-side {
    border-color: #e74c3c;
}

.faceoff-avatar-pedestal {
    width: 100%;
    height: clamp(80px, 15vh, 115px);
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, rgba(243, 156, 18, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
}

.faceoff-avatar-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.25));
}

.faceoff-name {
    font-weight: 800;
    font-size: clamp(0.85rem, 1.8vh, 1.05rem);
    color: #2c3e50;
    line-height: 1.1;
}

.faceoff-role {
    font-size: clamp(0.68rem, 1.3vh, 0.78rem);
    color: #27ae60;
    font-weight: 700;
}

.faceoff-hp-badge {
    background: #fadbd8;
    color: #c0392b;
    font-size: clamp(0.7rem, 1.3vh, 0.8rem);
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #f5b7b1;
}

.faceoff-vs-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #34495e;
    color: #f1c40f;
    border: 3px solid var(--color-gold);
    border-radius: 50%;
    width: clamp(40px, 7vh, 52px);
    height: clamp(40px, 7vh, 52px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    flex: 0 0 auto;
    animation: vsPulse 1.5s infinite ease-in-out alternate;
}

.vs-text {
    font-weight: 900;
    font-size: clamp(0.75rem, 1.5vh, 0.9rem);
    line-height: 1;
}

.vs-swords {
    font-size: clamp(0.65rem, 1.2vh, 0.8rem);
    line-height: 1;
}

@keyframes vsPulse {
    0% { transform: scale(0.95); }
    100% { transform: scale(1.08); box-shadow: 0 0 14px rgba(243, 156, 18, 0.6); }
}

.transition-details-card {
    background: #fdfefe;
    border: 1.5px dashed var(--color-gold);
    border-radius: 10px;
    padding: clamp(6px, 1.2vh, 10px) 14px;
    width: 100%;
}

.transition-math-info {
    margin: 0;
    font-size: clamp(0.78rem, 1.5vh, 0.9rem);
    color: #34495e;
    line-height: 1.3;
}

.transition-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 2px;
}

.btn-transition-start {
    width: 100%;
    background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    font-size: clamp(0.95rem, 2.2vh, 1.2rem);
    font-weight: 800;
    padding: clamp(8px, 1.8vh, 14px);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 0 #1e8449, 0 6px 14px rgba(39, 174, 96, 0.4);
    transition: all 0.15s ease;
}

.btn-transition-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #1e8449, 0 8px 18px rgba(39, 174, 96, 0.5);
    background: linear-gradient(180deg, #32d67a 0%, #2ecc71 100%);
}

.btn-transition-start:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #1e8449;
}

/* ANIMATION KEYFRAMES */
@keyframes victoryModalPop {
    0% { transform: scale(0.7) translateY(20px); opacity: 0; }
    70% { transform: scale(1.05) translateY(-4px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.anim-victory-modal-pop {
    animation: victoryModalPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.anim-hero-victory {
    animation: heroVictoryJump 1.2s infinite ease-in-out alternate;
}

@keyframes heroVictoryJump {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-8px) scale(1.08) rotate(2deg); }
    100% { transform: translateY(0) scale(1); }
}

.anim-hero-march {
    animation: heroMarchBob 0.6s infinite ease-in-out alternate;
}

@keyframes heroMarchBob {
    0% { transform: translateY(0) rotate(-2deg); }
    100% { transform: translateY(-6px) rotate(2deg); }
}

.anim-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}

.anim-hero-idle { animation: idleBreathe 3s infinite ease-in-out; }
.anim-enemy-idle { animation: idleBreathe 3s infinite ease-in-out 0.5s; }
.anim-hero-attack { animation: heroAttackDash 0.8s ease-out; }
.anim-enemy-attack { animation: enemyAttackDash 0.8s ease-out; }
.anim-hero-hurt, .anim-enemy-hurt { animation: hurtShake 0.5s ease-in-out; }

@keyframes idleBreathe {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.02) translateY(-3px); }
}

@keyframes heroAttackDash {
    0% { transform: translateX(0); }
    30% { transform: translateX(35px) scale(1.08) rotate(4deg); }
    100% { transform: translateX(0); }
}

@keyframes enemyAttackDash {
    0% { transform: translateX(0); }
    30% { transform: translateX(-35px) scale(1.08) rotate(-4deg); }
    100% { transform: translateX(0); }
}

@keyframes hurtShake {
    0%, 100% { transform: translateX(0); filter: brightness(1); }
    20%, 60% { transform: translateX(-8px); filter: brightness(1.4) saturate(1.8); }
    40%, 80% { transform: translateX(8px); }
}

/* ========================================================
   WASM PRE-LOADER & ERROR UI
   ======================================================== */
.wasm-loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    max-height: 100dvh;
    width: 100vw;
    background: radial-gradient(circle, #34495e 0%, #1a252f 100%);
    font-family: var(--font-main, sans-serif);
    overflow: hidden;
}

.wasm-loader-box {
    background: #fcf6e8;
    border: 4px solid #8b5a2b;
    border-radius: 20px;
    padding: clamp(20px, 4vh, 32px) clamp(24px, 4vw, 44px);
    text-align: center;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    max-width: 400px;
    width: 90%;
}

.wasm-crown { font-size: clamp(2rem, 5vh, 2.8rem); animation: bounce 1.2s infinite alternate; }
.wasm-title { font-size: clamp(1.6rem, 4vh, 2rem); color: #8b5a2b; margin: 6px 0 2px 0; font-weight: 800; }
.wasm-subtitle { color: #7f8c8d; font-size: 0.9rem; margin-bottom: 16px; }

.wasm-progress-bar {
    width: 100%;
    height: 12px;
    background: #e0d7c6;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #8b5a2b;
}

.wasm-progress-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #f39c12, #27ae60, #f39c12);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: progressShimmer 1.5s infinite linear;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#blazor-error-ui {
    background: #fadbd8;
    color: #922b21;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 10000;
    font-family: var(--font-main, sans-serif);
    font-weight: 700;
}

#blazor-error-ui .reload { color: #1e8449; margin-left: 1rem; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ========================================================
   EDUCATIONAL PAUSE & EXPLANATION MODAL (ON INCORRECT ANSWER)
   ======================================================== */
.explanation-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: clamp(10px, 2.5vh, 24px);
}

.explanation-parchment-box {
    background: linear-gradient(180deg, #fffdf8 0%, #f7edd7 100%);
    border: 4px solid var(--color-parchment-border);
    border-radius: 22px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 6px rgba(212, 163, 89, 0.35);
    padding: clamp(14px, 2.2vh, 22px) clamp(16px, 2.5vw, 28px);
    width: 100%;
    max-width: 580px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow-y: auto;
    scrollbar-width: thin;
}

.explanation-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: clamp(8px, 1.4vh, 14px);
}

.explanation-owl-icon {
    font-size: clamp(2rem, 4.2vh, 2.8rem);
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
    animation: bounce 1.8s infinite ease-in-out alternate;
}

.explanation-badge {
    background: #795548;
    color: #fef5e7;
    font-size: clamp(0.7rem, 1.4vh, 0.82rem);
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 3px 12px;
    border-radius: 12px;
    border: 1px solid #5d4037;
}

.explanation-title {
    font-size: clamp(1.25rem, 2.8vh, 1.65rem);
    color: #8b3a2b;
    margin: 2px 0 0 0;
    font-weight: 800;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.8);
}

.explanation-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vh, 14px);
    margin-bottom: clamp(10px, 1.8vh, 16px);
}

.explanation-equation-card {
    background: #ffffff;
    border: 2px solid #e2d4be;
    border-radius: 14px;
    padding: clamp(8px, 1.4vh, 12px) clamp(10px, 1.8vw, 16px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.equation-question-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.equation-question-row .equation-label {
    font-weight: 700;
    color: #6d4c41;
    font-size: clamp(0.9rem, 1.8vh, 1.05rem);
}

.explanation-equation-card .equation-text {
    font-size: clamp(1.15rem, 2.5vh, 1.45rem);
    font-weight: 800;
    color: #2c3e50;
    margin: 0;
}

.equation-answers-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.answer-box {
    border-radius: 10px;
    padding: clamp(6px, 1.2vh, 10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.answer-box.user-answer {
    background: #fde8e8;
    border: 2px solid #f87171;
    color: #991b1b;
}

.answer-box.correct-answer {
    background: #e6f9ed;
    border: 2px solid #34d399;
    color: #065f46;
}

.answer-box .ans-label {
    font-size: clamp(0.7rem, 1.3vh, 0.8rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.answer-box .ans-val {
    font-size: clamp(1rem, 2.2vh, 1.3rem);
    font-weight: 800;
}

.explanation-step-card {
    background: #fffdf5;
    border: 2px dashed #d4a359;
    border-radius: 14px;
    padding: clamp(8px, 1.6vh, 14px) clamp(10px, 2vw, 16px);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #795548;
    font-size: clamp(0.85rem, 1.7vh, 0.95rem);
}

.step-explanation-text {
    margin: 0;
    color: #2d3748;
    font-size: clamp(0.88rem, 1.8vh, 1.05rem);
    line-height: 1.45;
    font-weight: 600;
    background: rgba(254, 243, 199, 0.45);
    padding: clamp(6px, 1.2vh, 10px) clamp(8px, 1.5vw, 12px);
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
}

.explanation-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

.btn-explanation-continue {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: 3px solid #047857;
    border-radius: 16px;
    font-size: clamp(0.95rem, 2.2vh, 1.2rem);
    font-weight: 800;
    padding: clamp(10px, 1.8vh, 14px) clamp(18px, 3vw, 28px);
    cursor: pointer;
    box-shadow: 0 6px 0 #065f46, 0 8px 16px rgba(16, 185, 129, 0.35);
    transition: all 0.15s ease;
    width: 100%;
    max-width: 420px;
}

.btn-explanation-continue:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #065f46, 0 12px 20px rgba(16, 185, 129, 0.45);
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.btn-explanation-continue:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #065f46;
}

/* ========================================================
   GLOBAL AUDIO CONTROL WIDGET (DUAL CHANNEL: MUSIC & SFX)
   ======================================================== */
.global-audio-widget {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
    user-select: none;
}

.audio-channel-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(254, 250, 240, 0.95);
    backdrop-filter: blur(8px);
    border: 2px solid var(--color-parchment-border);
    border-radius: 999px;
    padding: 3px 10px 3px 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22), 0 0 0 1.5px rgba(243, 156, 18, 0.2);
    transition: all 0.2s ease;
}

.audio-channel-pill:hover {
    background: #ffffff;
    border-color: var(--color-gold);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(243, 156, 18, 0.35);
    transform: translateY(-1px);
}

.audio-channel-pill.is-muted {
    opacity: 0.65;
    border-color: #bdc3c7;
    background: #f2f4f4;
}

.channel-toggle-btn {
    background: rgba(243, 156, 18, 0.12);
    border: 1px solid rgba(243, 156, 18, 0.35);
    border-radius: 999px;
    padding: 3px 7px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #5c3a21;
    font-family: var(--font-main);
    font-size: 11px;
    font-weight: 800;
    transition: all 0.15s ease;
}

.channel-toggle-btn:hover {
    background: rgba(243, 156, 18, 0.25);
    transform: scale(1.05);
}

.channel-toggle-btn:active {
    transform: scale(0.95);
}

.channel-icon {
    font-size: 13px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.channel-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.channel-slider-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
}

.channel-slider {
    -webkit-appearance: none;
    appearance: none;
    width: clamp(48px, 6vw, 68px);
    height: 5px;
    background: #e0d2bc;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    border: 1px solid #b89874;
    transition: width 0.2s ease;
}

.channel-slider:hover {
    width: clamp(58px, 7.5vw, 80px);
}

.channel-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f39c12 0%, #d68910 100%);
    border: 1.5px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.channel-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.sfx-slider::-webkit-slider-thumb {
    background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
}

.channel-percent {
    font-size: 10px;
    font-weight: 800;
    color: #6d4c41;
    min-width: 26px;
    text-align: right;
    font-family: var(--font-main);
}

@media (max-width: 640px) {
    .global-audio-widget {
        top: 6px;
        right: 6px;
        gap: 4px;
        transform: scale(0.88);
        transform-origin: top right;
    }

    .channel-slider {
        width: 38px;
    }

    .channel-slider:hover {
        width: 46px;
    }

    .channel-label {
        display: none;
    }
}


