:root {
    --bg-color: #0b0f19;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.4);
    --spades: #e2e8f0;
    --clubs: #94a3b8;
    --hearts: #ef4444;
    --diamonds: #f87171;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
.background-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, #1e1b4b 0%, var(--bg-color) 40%);
    z-index: -2;
    animation: pulseBg 15s infinite alternate ease-in-out;
}

@keyframes pulseBg {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, #c4b5fd, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px var(--accent-glow);
}

nav {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    color: var(--text-main);
    background: var(--glass-bg);
}

.nav-btn.active {
    color: #fff;
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Main Content */
main {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.app-section {
    display: none;
    animation: fadeIn 0.5s ease forwards;
}

.app-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(45deg, #fff, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glass Components */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.glass-card h3 {
    margin-bottom: 1rem;
    color: #c4b5fd;
    font-size: 1.4rem;
}

.glass-card p {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }

/* Tutorial Elements */
.example-box {
    display: flex;
    justify-content: space-evenly;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    font-size: 1.2rem;
    font-family: 'Cinzel', serif;
    border: 1px dashed var(--glass-border);
}

.suit-cycle {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    font-size: 1.2rem;
}

.spades { color: var(--spades); }
.clubs { color: var(--clubs); }
.hearts { color: var(--hearts); }
.diamonds { color: var(--diamonds); }

.hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Interactive Elements */
.magic-input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.magic-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.magic-input option {
    background: #1e1b4b;
    color: #fff;
}

.magic-btn {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--accent-glow);
    transition: all 0.3s ease;
}

.magic-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.magic-btn.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: none;
}

.magic-btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* Flashcards */
.flashcard-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.card-display {
    width: 200px;
    height: 280px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px dashed var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-display img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.quiz-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.feedback {
    font-size: 1.2rem;
    font-weight: 600;
    height: 1.5rem;
}
.feedback.success { color: #10b981; }
.feedback.error { color: #ef4444; }

/* Calculators */
.calculator-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    align-items: center;
}

@media(min-width: 600px) {
    .calculator-grid { grid-template-columns: 1fr 1fr; }
}

.card-picker {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.predict-result-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 0 15px var(--accent-glow);
}

.result-img-box {
    width: 120px;
    height: 168px;
    margin: 1rem auto;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    color: var(--glass-border);
    overflow: hidden;
}

.result-img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-text {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: #c4b5fd;
}

.result-text.large {
    font-size: 1.8rem;
    text-align: center;
    color: #10b981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* Deck Viewer */
.deck-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    perspective: 1000px;
}

.deck-card {
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    cursor: pointer;
}

.deck-card:hover {
    transform: translateY(-10px) rotateY(10deg);
    box-shadow: 0 15px 25px var(--accent-glow);
}

.deck-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- PERFORMANCE STUDIO LAYOUT --- */
.studio-layout {
    display: block;
    margin-top: 1rem;
}

/* --- GLOBAL SIDEBAR DRAWER --- */
#global-sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    z-index: 9999;
    border-radius: 0 16px 16px 0;
    transition: left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-left: none;
    box-shadow: 5px 0 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
}

#global-sidebar.open {
    left: 0;
}

#global-sidebar h3 {
    margin-bottom: 2rem;
    color: #c4b5fd;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    border-bottom: 1px dashed var(--glass-border);
    padding-bottom: 1rem;
}

#menu-toggle {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid var(--accent);
    color: white;
}
#menu-toggle:hover {
    background: rgba(139, 92, 246, 0.4);
    box-shadow: 0 0 10px var(--accent-glow);
}

.trick-library h3 {
    margin-bottom: 1rem;
    color: #c4b5fd;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.trick-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.trick-item {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.trick-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.trick-item.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4), rgba(67, 56, 202, 0.4));
    border-color: rgba(139, 92, 246, 0.6);
    color: var(--text-light);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.trick-item .badge {
    display: inline-block;
    background: rgba(139, 92, 246, 0.8);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trick-display {
    flex: 1;
}

.trick-content {
    animation: fadeIn 0.4s ease forwards;
}

/* Trick 1 Simulator Layout */
.trick-console.step-flow {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media(min-width: 800px) {
    .trick-console.step-flow {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 2rem;
        align-items: start;
    }
}

.step-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px dashed var(--glass-border);
    text-align: center;
    animation: fadeIn 0.5s ease forwards;
}

.step-container h4 {
    color: #c4b5fd;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.text-sm {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.guess-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.peek-hidden {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    font-size: 3rem;
    color: var(--glass-border);
}

.flip {
    animation: flipCard 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes flipCard {
    0% { transform: scale(1) rotateY(0deg); }
    50% { transform: scale(1.1) rotateY(90deg); }
    100% { transform: scale(1) rotateY(0deg); }
}
