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

:root {
    --color-dark: #1a1a2e;
    --color-bg: #2d2d2d;
    --color-purple: #7c5cff;
    --color-yellow: #ffd166;
    --color-teal: #2dd4a8;
    --color-blue: #4a90e2;
    --color-cream: #fef8f0;
    --color-coral: #ff6b6b;

    --font-display: 'Syne', sans-serif;
    --font-body: 'Nunito', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    background: linear-gradient(135deg, var(--color-dark) 0%, var(--color-bg) 100%);
    color: var(--color-cream);
    font-family: var(--font-body);
    font-size: 16px;
}

/* ==================== GALTON HERO SECTION ==================== */

.galton-hero {
    position: relative;
    width: 100%;
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--color-dark) 0%, #1a1a2e 100%);
    border-bottom: 4px solid var(--color-yellow);
    overflow: hidden;
}

.galton-container {
    position: relative;
    width: 90%;
    height: 90%;
    max-width: 800px;
    border: 3px solid var(--color-purple);
    background: var(--color-bg);
    border-radius: 12px;
    overflow: hidden;
}

#galtonCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.galton-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.galton-title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--color-yellow);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-family: var(--font-display);
    letter-spacing: 1px;
}

.galton-button {
    padding: 12px 24px;
    background: var(--color-yellow);
    color: var(--color-dark);
    border: 2px solid var(--color-dark);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.3);
}

.galton-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.3);
}

.galton-button:active {
    transform: translate(0, 0);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.galton-stats {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(26, 26, 46, 0.95);
    padding: 15px 20px;
    border: 2px solid var(--color-teal);
    border-radius: 6px;
    font-family: var(--font-mono);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--color-teal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-yellow);
}

/* ==================== EXPERIMENT GRID ==================== */

.experiment-grid {
    padding: 60px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 700;
    color: var(--color-yellow);
    margin-bottom: 40px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.experiment-card {
    background: linear-gradient(135deg, var(--color-bg) 0%, #3a3a4a 100%);
    border: 3px solid;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: all 0.3s ease;
}

.spinner-card {
    border-color: var(--color-yellow);
}

.spinner-card:hover {
    border-color: var(--color-coral);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

.dice-card {
    border-color: var(--color-teal);
}

.dice-card:hover {
    border-color: var(--color-blue);
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.3);
}

.coin-card {
    border-color: var(--color-purple);
}

.coin-card:hover {
    border-color: var(--color-yellow);
    box-shadow: 0 0 20px rgba(255, 209, 102, 0.3);
}

.distribution-card {
    border-color: var(--color-blue);
}

.distribution-card:hover {
    border-color: var(--color-teal);
    box-shadow: 0 0 20px rgba(45, 212, 168, 0.3);
}

.experiment-header {
    border-bottom: 2px solid currentColor;
    padding-bottom: 12px;
}

.experiment-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.spinner-card .experiment-header h3 {
    color: var(--color-yellow);
}

.dice-card .experiment-header h3 {
    color: var(--color-teal);
}

.coin-card .experiment-header h3 {
    color: var(--color-purple);
}

.distribution-card .experiment-header h3 {
    color: var(--color-blue);
}

/* ==================== SPINNER ==================== */

.spinner-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.spinner {
    width: 150px;
    height: 150px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    transform-origin: center;
    transition: transform 0.05s linear;
}

.spin-button {
    padding: 10px 20px;
    background: var(--color-yellow);
    color: var(--color-dark);
    border: 2px solid var(--color-dark);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.spin-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.3);
}

.spin-button:active {
    transform: translate(0, 0);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

.spinner-result {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-yellow);
    text-align: center;
    min-height: 24px;
    font-family: var(--font-mono);
}

/* ==================== DICE ==================== */

.dice-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.dice {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--color-teal) 0%, var(--color-blue) 100%);
    border: 3px solid var(--color-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-dark);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    font-family: var(--font-display);
}

.dice.rolling {
    animation: rollDice 0.6s ease-out;
}

@keyframes rollDice {
    0% {
        transform: rotateX(0) rotateY(0);
    }
    25% {
        transform: rotateX(360deg) rotateY(180deg);
    }
    50% {
        transform: rotateX(720deg) rotateY(360deg);
    }
    75% {
        transform: rotateX(1080deg) rotateY(180deg);
    }
    100% {
        transform: rotateX(1440deg) rotateY(360deg);
    }
}

.roll-button {
    padding: 10px 20px;
    background: var(--color-teal);
    color: var(--color-dark);
    border: 2px solid var(--color-dark);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.roll-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.3);
}

.roll-button:active {
    transform: translate(0, 0);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

.dice-result {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.result-stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(45, 212, 168, 0.1);
    padding: 10px 15px;
    border: 1px solid var(--color-teal);
    border-radius: 4px;
}

.result-label {
    font-size: 0.8rem;
    color: var(--color-teal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-yellow);
    font-family: var(--font-mono);
}

/* ==================== COIN ==================== */

.coin-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin {
    width: 120px;
    height: 120px;
    background: var(--color-yellow);
    border: 3px solid var(--color-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    perspective: 1000px;
    position: relative;
    transition: transform 0.6s ease-out;
    font-family: var(--font-display);
}

.coin.flipping {
    animation: flipCoin 0.6s ease-out;
}

@keyframes flipCoin {
    0% {
        transform: rotateY(0);
    }
    50% {
        transform: rotateY(1800deg);
    }
    100% {
        transform: rotateY(3600deg);
    }
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
}

.coin-face.heads {
    background: var(--color-yellow);
    color: var(--color-dark);
}

.coin-face.tails {
    background: var(--color-purple);
    color: var(--color-cream);
    transform: rotateY(180deg);
}

.flip-button {
    padding: 10px 20px;
    background: var(--color-purple);
    color: var(--color-cream);
    border: 2px solid var(--color-dark);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.flip-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.3);
}

.flip-button:active {
    transform: translate(0, 0);
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

.coin-result {
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* ==================== DISTRIBUTION CHART ==================== */

.chart-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.distribution-chart {
    width: 100%;
    max-width: 300px;
    height: 150px;
}

.chart-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.chart-stats .stat-item {
    background: rgba(74, 144, 226, 0.1);
    padding: 10px 15px;
    border: 1px solid var(--color-blue);
    border-radius: 4px;
}

/* ==================== MEMPHIS DECORATIONS ==================== */

.memphis-decoration {
    position: fixed;
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}

.deco-1 {
    top: 10%;
    right: 10%;
    width: 150px;
    height: 150px;
}

.deco-2 {
    top: 50%;
    left: 5%;
    width: 120px;
    height: 120px;
}

.deco-3 {
    bottom: 20%;
    right: 15%;
    width: 100px;
    height: 100px;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .galton-hero {
        height: 50vh;
    }

    .experiment-grid {
        padding: 40px 20px;
    }

    .galton-overlay {
        flex-direction: column;
        gap: 15px;
    }

    .dice-container {
        gap: 20px;
    }

    .dice {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .coin {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .galton-hero {
        height: 40vh;
    }

    .experiment-grid {
        padding: 30px 15px;
    }

    .experiment-card {
        padding: 15px;
        min-height: 300px;
    }

    .section-title {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }

    .dice {
        width: 70px;
        height: 70px;
        font-size: 1.5rem;
    }

    .coin {
        width: 90px;
        height: 90px;
        font-size: 2rem;
    }

    .spinner {
        width: 120px;
        height: 120px;
    }
}
