/* Prodigy Gita: The Astra Chronicles - Style System */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Cinzel:wght@700&family=Noto+Sans+Devanagari:wght@500;700&display=swap');

:root {
    --primary-gold: #ECC94B;
    --primary-amber: #DD6B20;
    --royal-saffron: #FF9933;
    --divine-blue: #3182CE;
    --vedic-green: #38A169;
    --ruby-red: #E53E3E;
    --dark-bg: #1A202C;
    --parchment-bg: #FFFDF5;
    --parchment-border: #D69E2E;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-deep: 0 12px 36px rgba(0, 0, 0, 0.35);
    --font-ui: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-epic: 'Cinzel', serif;
    --font-sanskrit: 'Noto Sans Devanagari', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-ui);
    background: #0D1117;
    color: #2D3748;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Master Game Container */
#game-container {
    width: 100%;
    max-width: 1200px;
    height: 100%;
    max-height: 800px;
    position: relative;
    background: #1A202C;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   SCREENS
   ========================================================================== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 10;
}

.screen.active,
#screen-menu.active,
#screen-battle.active,
#screen-grimoire.active,
#screen-locker.active {
    display: flex !important;
}

/* Splash / Main Menu */
#screen-menu {
    background: radial-gradient(circle at center, #2B6CB0 0%, #1A365D 60%, #0F172A 100%);
    align-items: center;
    justify-content: space-between;
    padding: 30px 20px;
    color: white;
    text-align: center;
}

.menu-header h1 {
    font-family: var(--font-epic);
    font-size: 2.8rem;
    color: #FAF089;
    text-shadow: 0 4px 12px rgba(0,0,0,0.6), 0 0 20px #ECC94B;
    letter-spacing: 2px;
}

.menu-subtitle {
    font-size: 1.15rem;
    color: #E2E8F0;
    margin-top: 4px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.fumble-badge {
    display: inline-block;
    background: linear-gradient(135deg, #E53E3E, #9B2C2C);
    color: white;
    font-size: 0.88rem;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    margin-top: 8px;
    box-shadow: 0 4px 10px rgba(229, 62, 62, 0.4);
    border: 1.5px solid #FEB2B2;
}

/* Profile Switcher */
.profiles-shelf {
    display: flex;
    gap: 16px;
    margin: 15px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.profile-card {
    background: rgba(255, 255, 255, 0.12);
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-radius: 18px;
    padding: 12px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
    backdrop-filter: blur(8px);
}

.profile-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-gold);
    background: rgba(255, 255, 255, 0.2);
}

.profile-card.selected {
    background: linear-gradient(135deg, rgba(236, 201, 75, 0.3), rgba(221, 107, 32, 0.3));
    border-color: var(--primary-gold);
    box-shadow: 0 0 20px rgba(236, 201, 75, 0.6);
}

.profile-avatar-box {
    width: 65px;
    height: 65px;
    margin-bottom: 6px;
}

.profile-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #FAF089;
}

.profile-role {
    font-size: 0.8rem;
    color: #CBD5E0;
}

.profile-stats {
    font-size: 0.85rem;
    margin-top: 4px;
    color: #FEFCBF;
}

/* Mode Buttons Grid */
.menu-modes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    max-width: 600px;
    width: 100%;
}

.btn-game-mode {
    background: linear-gradient(180deg, #3182CE 0%, #2B6CB0 100%);
    border: 3px solid #63B3ED;
    border-radius: 18px;
    color: white;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-game-mode:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    border-color: #FAF089;
}

.btn-game-mode:active {
    transform: translateY(2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-duel-p1 {
    background: linear-gradient(180deg, #ED8936 0%, #DD6B20 100%);
    border-color: #FBD38D;
    grid-column: span 2;
}

.btn-secondary-mode {
    background: linear-gradient(180deg, #4A5568 0%, #2D3748 100%);
    border-color: #718096;
}

/* Top Utility Bar */
.top-utility-bar {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    gap: 10px;
    z-index: 50;
}

.icon-btn {
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: var(--primary-gold);
    transform: scale(1.08);
}

/* ==========================================================================
   BATTLE SCREEN (PRODIGY PARITY)
   ========================================================================== */
#screen-battle {
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    background: #2D3748;
}

/* Battle Arena Dynamic Background */
.battle-arena-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 68%;
    background: linear-gradient(180deg, #87CEEB 0%, #F6AD55 60%, #48BB78 85%, #2F855A 100%);
    overflow: hidden;
    z-index: 1;
}

/* Clouds and banners */
.arena-clouds {
    position: absolute;
    top: 15%;
    left: 0;
    width: 200%;
    height: 50px;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 70%);
    opacity: 0.5;
    animation: driftClouds 45s linear infinite;
}

@keyframes driftClouds {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Ground battle disc circles */
.battle-ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 35%;
    background: linear-gradient(180deg, #38A169 0%, #276749 100%);
    border-top: 4px solid #48BB78;
}

/* Floating particles layer */
#battle-particles-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Top HUD Banner */
.battle-top-hud {
    position: relative;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 20px;
    pointer-events: none;
}

.hud-player-box {
    background: rgba(26, 32, 44, 0.88);
    border: 2.5px solid #4A5568;
    border-radius: 16px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    box-shadow: 0 6px 18px rgba(0,0,0,0.4);
    min-width: 260px;
    pointer-events: auto;
    backdrop-filter: blur(6px);
}

.hud-player-box.turn-active {
    border-color: var(--primary-gold);
    box-shadow: 0 0 20px rgba(236, 201, 75, 0.7);
}

.hud-avatar-thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2D3748;
    border: 2px solid var(--primary-gold);
    overflow: hidden;
}

.hud-info {
    flex: 1;
}

.hud-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #FAF089;
    margin-bottom: 4px;
}

.hud-level-badge {
    background: #2B6CB0;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
}

/* Animated HP Bar (Prodigy green to red) */
.hud-hp-track {
    background: #1A202C;
    border-radius: 10px;
    height: 14px;
    overflow: hidden;
    position: relative;
    border: 1.5px solid #4A5568;
}

.hud-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #48BB78, #38A169);
    width: 100%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
}

.hud-hp-fill.medium {
    background: linear-gradient(90deg, #ECC94B, #D69E2E);
}

.hud-hp-fill.low {
    background: linear-gradient(90deg, #F56565, #E53E3E);
    animation: pulseLowHp 1s infinite alternate;
}

@keyframes pulseLowHp {
    from { filter: brightness(1); }
    to { filter: brightness(1.3); }
}

.hud-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.68rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.hud-mana-stars-row {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.75rem;
    color: #E2E8F0;
}

.hud-mana-orbs {
    display: flex;
    gap: 3px;
}

.mana-orb {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3182CE;
    box-shadow: 0 0 6px #63B3ED;
}

.mana-orb.empty {
    background: #4A5568;
    box-shadow: none;
}

/* Active Turn Notification Ribbon (Top Center) */
.battle-turn-ribbon {
    background: linear-gradient(135deg, #DD6B20, #C05621);
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 6px 18px;
    border-radius: 20px;
    border: 2px solid #FAF089;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    letter-spacing: 0.5px;
    animation: ribbonPulse 2s infinite ease-in-out;
}

@keyframes ribbonPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* ==========================================================================
   BATTLE STAGE (CHARACTERS & PETS)
   ========================================================================== */
.battle-stage {
    position: absolute;
    top: 14%;
    left: 0;
    width: 100%;
    height: 52%;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 70px 20px 70px;
    pointer-events: none;
}

.stage-unit-container {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

/* Summon Discs on Ground */
.summon-disc {
    position: absolute;
    bottom: 5px;
    width: 180px;
    height: 48px;
    border-radius: 50%;
    border: 3px dashed rgba(236, 201, 75, 0.4);
    background: radial-gradient(ellipse at center, rgba(49, 130, 206, 0.25) 0%, rgba(0,0,0,0) 70%);
    animation: rotateDisc 20s linear infinite;
}

@keyframes rotateDisc {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.summon-disc.active-turn {
    border: 3.5px solid #FAF089;
    box-shadow: 0 0 25px rgba(236, 201, 75, 0.6);
    background: radial-gradient(ellipse at center, rgba(236, 201, 75, 0.4) 0%, rgba(0,0,0,0) 70%);
}

.hero-sprite-wrapper {
    position: absolute;
    bottom: 20px;
    width: 140px;
    height: 140px;
    z-index: 12;
    transition: transform 0.2s ease;
}

.pet-sprite-wrapper {
    position: absolute;
    bottom: 60px;
    left: -20px;
    width: 80px;
    height: 80px;
    z-index: 14;
    animation: petHover 3s infinite ease-in-out;
}

.opponent-unit .pet-sprite-wrapper {
    left: auto;
    right: -20px;
}

/* Animations for Heroes */
.wizard-idle {
    animation: heroIdle 2.5s infinite ease-in-out;
}

@keyframes heroIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.wizard-attack {
    animation: heroAttack 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heroAttack {
    0% { transform: translateX(0); }
    40% { transform: translateX(45px) scale(1.1); }
    100% { transform: translateX(0); }
}

.opponent-unit .wizard-attack {
    animation: opponentAttack 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes opponentAttack {
    0% { transform: translateX(0); }
    40% { transform: translateX(-45px) scale(1.1); }
    100% { transform: translateX(0); }
}

/* THE FUMBLE ANIMATION (SPIN, DROP WEAPON, SMOKE PUFF) */
.wizard-fumble {
    animation: heroFumble 1.4s ease-in-out forwards;
}

@keyframes heroFumble {
    0% { transform: rotate(0deg) scale(1); }
    20% { transform: rotate(-25deg) translateY(-8px); }
    40% { transform: rotate(25deg) translateY(-4px); }
    60% { transform: rotate(-10deg) scale(0.92); }
    80% { transform: rotate(5deg) scale(0.95); }
    100% { transform: rotate(0deg) scale(0.95); }
}

.wizard-hit {
    animation: heroHit 0.5s ease;
}

@keyframes heroHit {
    0%, 100% { filter: brightness(1); transform: translateX(0); }
    20%, 60% { filter: brightness(2) drop-shadow(0 0 10px red); transform: translateX(-15px); }
    40%, 80% { transform: translateX(10px); }
}

/* Pet Hovering */
@keyframes petHover {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(3deg); }
}

/* Floating Combat Text */
.combat-text {
    position: absolute;
    font-size: 1.8rem;
    font-weight: 800;
    pointer-events: none;
    z-index: 40;
    text-shadow: 0 3px 6px rgba(0,0,0,0.8);
    animation: combatFloat 1.2s forwards ease-out;
}

.combat-damage {
    color: #FEB2B2;
}

.combat-critical {
    color: #FAF089;
    font-size: 2.2rem;
}

.combat-heal {
    color: #68D391;
}

.combat-fumble {
    color: #FC8181;
    font-size: 2rem;
    letter-spacing: 1px;
}

@keyframes combatFloat {
    0% { transform: translateY(0) scale(0.8); opacity: 0; }
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    80% { transform: translateY(-60px) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(0.9); opacity: 0; }
}

/* ==========================================================================
   PRODIGY ACTION DRAWER (BOTTOM CARDS TRAY)
   ========================================================================== */
.battle-action-tray {
    position: relative;
    z-index: 25;
    background: linear-gradient(180deg, #2D3748 0%, #1A202C 100%);
    border-top: 4px solid var(--primary-gold);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
    height: 32%;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.tray-nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.tray-tab-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid #4A5568;
    color: #E2E8F0;
    padding: 5px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tray-tab-btn.active, .tray-tab-btn:hover {
    background: var(--royal-saffron);
    border-color: #FAF089;
    color: white;
}

/* The Spell Cards Shelf */
.spell-cards-shelf {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    height: 100%;
}

.spell-card {
    background: linear-gradient(180deg, #3A475C 0%, #202938 100%);
    border: 2.5px solid #63B3ED;
    border-radius: 14px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    position: relative;
    overflow: hidden;
}

.spell-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-gold);
    box-shadow: 0 8px 20px rgba(236, 201, 75, 0.4);
}

.spell-card:active {
    transform: translateY(2px);
}

.spell-card.disabled {
    opacity: 0.4;
    filter: grayscale(0.8);
    cursor: not-allowed;
    transform: none !important;
}

/* Card Elemental Accents */
.spell-card.fire { border-color: #F56565; background: linear-gradient(180deg, #742A2A 0%, #2D1B1B 100%); }
.spell-card.water { border-color: #4299E1; background: linear-gradient(180deg, #2B6CB0 0%, #1A365D 100%); }
.spell-card.wind { border-color: #48BB78; background: linear-gradient(180deg, #276749 0%, #1C4532 100%); }
.spell-card.divine { border-color: #ECC94B; background: linear-gradient(180deg, #975A16 0%, #442408 100%); }

.card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-icon {
    font-size: 1.6rem;
}

.card-mana-badge {
    background: #3182CE;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    border: 1px solid #63B3ED;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    margin-top: 2px;
}

.card-damage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #E2E8F0;
}

.card-dmg-val {
    color: #FAF089;
    font-weight: 700;
}

/* ==========================================================================
   PRODIGY QUESTION OVERLAY MODAL
   ========================================================================== */
#modal-question-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#modal-question-overlay.active {
    display: flex;
}

/* Parchment Stone Dialog */
.question-parchment-box {
    width: 100%;
    max-width: 820px;
    background: var(--parchment-bg);
    border: 4.5px solid var(--parchment-border);
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.6);
    padding: 20px 26px;
    position: relative;
    display: flex;
    flex-direction: column;
    animation: popModal 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popModal {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Header Tools Bar */
.parchment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #CBD5E0;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.chapter-pill {
    background: #FEFCBF;
    border: 1.5px solid #D69E2E;
    color: #744210;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
}

.parchment-actions {
    display: flex;
    gap: 8px;
}

.tool-btn {
    background: white;
    border: 2px solid #CBD5E0;
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #4A5568;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    border-color: var(--royal-saffron);
    color: var(--royal-saffron);
    transform: translateY(-1px);
}

/* Sanskrit Verse Display */
.sanskrit-verse-box {
    background: #FFF8E7;
    border-left: 5px solid var(--royal-saffron);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sanskrit-verse-text {
    font-family: var(--font-sanskrit);
    font-size: 1.15rem;
    font-weight: 700;
    color: #9C4221;
    line-height: 1.5;
}

/* Kid Question Prompt */
.question-prompt {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1A202C;
    line-height: 1.4;
    margin-bottom: 16px;
}

/* 4 Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.option-btn {
    background: white;
    border: 3px solid #E2E8F0;
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2D3748;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.35;
    box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.option-btn:hover {
    border-color: var(--divine-blue);
    background: #EBF8FF;
    transform: translateY(-2px);
}

.option-btn:active {
    transform: translateY(1px);
}

.option-letter {
    background: #EDF2F7;
    border-radius: 8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #4A5568;
    flex-shrink: 0;
}

.option-btn.correct {
    background: #C6F6D5 !important;
    border-color: #38A169 !important;
    color: #22543D !important;
}

.option-btn.fumble-wrong {
    background: #FED7D7 !important;
    border-color: #E53E3E !important;
    color: #742A2A !important;
    animation: shakeOption 0.4s ease;
}

@keyframes shakeOption {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* Fumble Notice Banner (Prominent in Modal) */
.fumble-notice-banner {
    background: #FFF5F5;
    border: 1.5px solid #FEB2B2;
    border-radius: 10px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #C53030;
    font-weight: 600;
}

/* Scratchpad Drawing Canvas Overlay */
#scratchpad-container {
    display: none;
    position: absolute;
    top: 60px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    background: rgba(255, 255, 255, 0.96);
    border: 3px solid var(--primary-gold);
    border-radius: 18px;
    z-index: 120;
    flex-direction: column;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#scratchpad-container.active {
    display: flex;
}

.scratchpad-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.color-palette {
    display: flex;
    gap: 8px;
}

.palette-color {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.palette-color.selected {
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

#scratchpad-canvas {
    flex: 1;
    border: 2px dashed #CBD5E0;
    border-radius: 12px;
    background: white;
    cursor: crosshair;
}

/* GIANT FUMBLE STAMP ANIMATION OVERLAY */
#fumble-stamp-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg) scale(0);
    background: #E53E3E;
    color: white;
    border: 6px solid #FFF;
    border-radius: 20px;
    padding: 16px 36px;
    font-family: var(--font-epic);
    font-size: 2.4rem;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 12px 35px rgba(0,0,0,0.7);
    z-index: 150;
    display: none;
    pointer-events: none;
}

#fumble-stamp-overlay.stamp-active {
    display: block;
    animation: stampSlam 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes stampSlam {
    0% { transform: translate(-50%, -50%) rotate(-15deg) scale(3); opacity: 0; }
    70% { transform: translate(-50%, -50%) rotate(-15deg) scale(0.9); opacity: 1; }
    100% { transform: translate(-50%, -50%) rotate(-15deg) scale(1); opacity: 1; }
}

/* Correct Stamp */
#correct-stamp-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(10deg) scale(0);
    background: #38A169;
    color: white;
    border: 6px solid #FFF;
    border-radius: 20px;
    padding: 16px 36px;
    font-family: var(--font-epic);
    font-size: 2.4rem;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 12px 35px rgba(0,0,0,0.7);
    z-index: 150;
    display: none;
    pointer-events: none;
}

#correct-stamp-overlay.stamp-active {
    display: block;
    animation: stampSlam 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ==========================================================================
   VICTORY & REWARDS MODAL
   ========================================================================== */
#modal-victory {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 200;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#modal-victory.active {
    display: flex;
}

.victory-card {
    background: linear-gradient(180deg, #1A365D 0%, #0F172A 100%);
    border: 4px solid var(--primary-gold);
    border-radius: 24px;
    width: 100%;
    max-width: 550px;
    padding: 26px;
    text-align: center;
    color: white;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    animation: popModal 0.4s ease;
}

.victory-title {
    font-family: var(--font-epic);
    font-size: 2.5rem;
    color: #FAF089;
    text-shadow: 0 0 20px rgba(236, 201, 75, 0.8);
}

.victory-shloka-unlocked {
    background: rgba(255, 255, 255, 0.08);
    border: 2px dashed #ECC94B;
    border-radius: 14px;
    padding: 12px;
    margin: 16px 0;
    font-size: 0.95rem;
}

/* ==========================================================================
   GRIMOIRE & LOCKER
   ========================================================================== */
#screen-grimoire, #screen-locker {
    background: #1A202C;
    color: white;
    padding: 20px 30px;
    overflow-y: auto;
}

.subscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #4A5568;
    padding-bottom: 12px;
}

.grimoire-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.grimoire-card {
    background: #2D3748;
    border: 2px solid #4A5568;
    border-radius: 16px;
    padding: 14px;
    transition: all 0.2s ease;
}

.grimoire-card:hover {
    border-color: var(--primary-gold);
    transform: translateY(-2px);
}

/* Mobile / iPad Responsive */
@media (max-width: 768px) {
    .menu-header h1 { font-size: 2.1rem; }
    .battle-stage { padding: 0 20px 15px 20px; }
    .stage-unit-container { width: 160px; height: 160px; }
    .hero-sprite-wrapper { width: 110px; height: 110px; }
    .pet-sprite-wrapper { width: 60px; height: 60px; }
    .options-grid { grid-template-columns: 1fr; }
    .spell-cards-shelf { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .hud-player-box { min-width: 170px; padding: 6px 10px; }
}
