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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, #1a0a33 0%, #2d1a4d 100%);
    color: white;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: manipulation;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 32px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: #9b4dff;
    transition: width 0.3s ease;
}

.quest-counter {
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 16px;
}

.wizard-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(155, 77, 255, 0.3);
}

.wizard-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    position: relative;
}

.reset-btn {
    position: absolute;
    right: 0;
    top: 0;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(180deg);
}

.wizard-emoji {
    font-size: 32px;
}

.wizard-title {
    font-size: 18px;
    font-weight: 600;
}

.wizard-message {
    font-size: 16px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.crafting-section {
    margin-bottom: 24px;
}

.crafting-section h3 {
    text-align: center;
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

.crafting-circle {
    width: 160px;
    height: 160px;
    margin: 0 auto;
    border: 3px solid #9b4dff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(155, 77, 255, 0.1);
    box-shadow: 0 0 20px rgba(155, 77, 255, 0.3);
}

.circle-content {
    text-align: center;
}

.circle-content .hint {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
}

.circle-content .spell-name {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.circle-content .spell-emoji {
    font-size: 48px;
}

.circle-content .rune-combo {
    font-size: 28px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.runes-section {
    margin-bottom: 24px;
}

.runes-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
    text-align: center;
}

.runes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.rune-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 16px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 80px;
    touch-action: manipulation;
}

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

.rune-btn.selected {
    background: rgba(155, 77, 255, 0.4);
    border-color: #9b4dff;
    box-shadow: 0 0 16px rgba(155, 77, 255, 0.6);
}

.rune-emoji {
    font-size: 32px;
}

.rune-name {
    font-size: 12px;
    color: white;
    font-weight: 500;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px;
    margin-top: 24px;
}

.action-buttons.with-cast {
    grid-template-columns: 1fr 1fr;
}

.btn {
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.97);
}

.btn-clear {
    background: rgba(239, 68, 68, 0.7);
    color: white;
}

.btn-craft {
    background: #3b82f6;
    color: white;
}

.btn-craft:disabled {
    background: rgba(107, 114, 128, 0.5);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-cast {
    background: #10b981;
    color: white;
    grid-column: 2;
}

.btn-primary {
    background: #9b4dff;
    color: white;
}

.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: rgba(45, 26, 77, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #1a0a33 0%, #2d1a4d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.victory-content {
    text-align: center;
    max-width: 400px;
}

.victory-emoji {
    font-size: 80px;
    margin-bottom: 24px;
}

.victory-content h1 {
    font-size: 32px;
    margin-bottom: 16px;
}

.victory-content p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 24px;
}

.mastered-spells {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: left;
}

.mastered-spells h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.mastered-spells div {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    margin: 8px 0;
}

.spellbook {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
}

.spellbook h4 {
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}

.spellbook-empty {
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px;
}

.spellbook-hint {
    font-size: 0.8em;
    opacity: 0.6;
    margin: -8px 0 12px 0;
    text-align: center;
    font-style: italic;
}

.spell-quick-cast {
    background: rgba(155, 77, 255, 0.3);
    border: 1px solid rgba(155, 77, 255, 0.5);
    color: white;
    padding: 8px 12px;
    margin: 4px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.spell-quick-cast:active {
    transform: scale(0.95);
    background: rgba(155, 77, 255, 0.5);
}

.cast-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    pointer-events: none;
    animation: castPulse 0.8s ease-out;
}

.effect-fire {
    background: radial-gradient(circle, rgba(255, 100, 0, 0.8) 0%, rgba(255, 50, 0, 0) 70%);
    box-shadow: 0 0 40px rgba(255, 100, 0, 0.8);
}

.effect-ice {
    background: radial-gradient(circle, rgba(100, 200, 255, 0.8) 0%, rgba(100, 200, 255, 0) 70%);
    box-shadow: 0 0 40px rgba(100, 200, 255, 0.8);
}

.effect-lightning {
    background: radial-gradient(circle, rgba(255, 255, 100, 0.9) 0%, rgba(200, 200, 255, 0) 70%);
    box-shadow: 0 0 40px rgba(255, 255, 100, 0.9);
    animation: castPulse 0.4s ease-out;
}

.effect-shield {
    background: radial-gradient(circle, rgba(100, 100, 255, 0.7) 0%, rgba(100, 100, 255, 0) 70%);
    box-shadow: 0 0 40px rgba(100, 100, 255, 0.7);
    animation: shieldPulse 0.8s ease-out;
}

.effect-heal {
    background: radial-gradient(circle, rgba(100, 255, 150, 0.8) 0%, rgba(100, 255, 150, 0) 70%);
    box-shadow: 0 0 40px rgba(100, 255, 150, 0.8);
}

.effect-arcane {
    background: radial-gradient(circle, rgba(200, 100, 255, 0.8) 0%, rgba(200, 100, 255, 0) 70%);
    box-shadow: 0 0 40px rgba(200, 100, 255, 0.8);
}

@keyframes castPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

@keyframes shieldPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@media (max-width: 360px) {
    .runes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .rune-btn {
        min-height: 70px;
        padding: 12px 6px;
    }
    
    .rune-emoji {
        font-size: 28px;
    }
}

/* Mute Button */
.mute-btn {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.5);
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
}

.mute-btn:active {
    transform: scale(0.9);
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.tutorial-overlay.hidden {
    display: none;
}

.tutorial-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px 20px;
    max-width: 400px;
    text-align: center;
}

.tutorial-content h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
}

.tutorial-content p {
    margin: 10px 0;
    font-size: 16px;
}

.tutorial-steps {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.tutorial-step {
    padding: 8px 0;
    font-size: 15px;
}

.tutorial-hint {
    font-size: 14px;
    opacity: 0.9;
    font-style: italic;
}

/* Hint Box */
.hint-box {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fbbf24;
    color: #000;
    padding: 12px 40px 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 500;
    max-width: 90%;
    animation: slideUp 0.3s ease;
}

.hint-box.hidden {
    display: none;
}

.hint-content {
    font-size: 14px;
}

.hint-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #000;
    padding: 4px 8px;
}

/* A2HS Hint */
.a2hs-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #4f46e5;
    padding: 12px 40px 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 500;
    max-width: 90%;
    font-size: 14px;
}

.a2hs-hint.hidden {
    display: none;
}

.a2hs-content {
    text-align: center;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Craft Particles */
.craft-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #fbbf24, #f59e0b);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: particle-burst 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes particle-burst {
    0% {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateX(60px);
        opacity: 0;
    }
}

/* Better Mute Button in Header */
.mute-btn-header {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(139, 92, 246, 0.9));
    backdrop-filter: blur(10px);
    font-size: 24px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mute-btn-header:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.mute-btn-header:active {
    transform: scale(0.95);
}

.mute-icon {
    font-size: 22px;
}

/* Recipe Hints in Spellbook */
.recipe-hint {
    display: block;
    font-size: 12px;
    opacity: 0.7;
    margin-top: 4px;
    letter-spacing: 2px;
}

/* Endless Mode Counter */
.endless-counter {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f59e0b, #d97706);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 50;
}

/* Locked Runes */
.rune-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.rune-btn.locked:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.lock-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 14px;
    opacity: 0.8;
}

.rune-hint {
    text-align: center;
    font-size: 13px;
    opacity: 0.7;
    margin: 8px 0 16px 0;
    font-style: italic;
}

/* Unlock Toast */
.unlock-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 15px;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.unlock-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
