:root {
    --phet-bg: #fdfdf5;
    --phet-border: #808080;
    --phet-blue: #8fc6fd;
    --phet-blue-dark: #3a8ee6;
    --phet-green: #a4eeba;
    --phet-green-dark: #559e66;
    --phet-text: #222;
}

html,
body.phet-theme {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #fdfdf5;
    font-family: 'Inter', Arial, sans-serif;
    overscroll-behavior: none;
    touch-action: none; /* Disable browser defaults for panning */
}

#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    background: radial-gradient(circle at center, #fdfdf5 0%, #f7f7eb 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: 0 0; /* Updated for custom pan/zoom math */
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    touch-action: none;
}



/* Visibility State Handling */
.measure-only {
    display: none !important;
}

body.measure-mode .measure-only {
    display: flex !important;
    flex-direction: column;
}

body.measure-mode .prep-only {
    display: none !important;
}

/* Animation Classes */
.transfer-animation {
    animation: transferToRight 0.8s cubic-bezier(0.5, 0, 0.5, 1) forwards;
    z-index: 100;
}

@keyframes transferToRight {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    50% {
        transform: translateX(300px) scale(1.2);
        opacity: 0.8;
    }

    100% {
        transform: translateX(600px) scale(1);
        opacity: 0;
    }
}

@keyframes coinFlipSpin {
    0% {
        transform: rotateY(0) scale(1);
    }

    25% {
        transform: rotateY(450deg) scale(1.3);
    }

    50% {
        transform: rotateY(900deg) scale(1.5);
    }

    75% {
        transform: rotateY(1350deg) scale(1.3);
    }

    100% {
        transform: rotateY(1800deg) scale(1);
    }
}

.coin-spin {
    animation: coinFlipSpin 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}



.phet-nav {
    position: relative !important;
    background: #e2e8f0 !important;
    height: 65px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    border-bottom: 2px solid #cbd5e1;
    flex-shrink: 0;
    box-sizing: border-box;
    z-index: 100;
}


.tabs {
    display: flex;
    gap: 0.5rem;
}

.tab-btn {
    padding: 0.5rem 1.5rem;
    border: 2px solid #aaa;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
}

.tab-btn.active {
    background: white;
    border-color: #0084ff;
    color: #0084ff;
}

.main-simulation {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 20px;
    position: relative;
    width: 1280px;
}

.coin-prep {
    flex: 0.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    overflow-y: auto;
    touch-action: pan-y;
}

.section-title.underline {
    border-bottom: 2px solid #333;
    padding-bottom: 0.2rem;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.symbol-large {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.coin-img-lg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.coin-img-sm {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.symbol-result {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phet-btn-green {
    background: linear-gradient(to bottom, #a4eeba, #88d19e);
    border: 2px solid #559e66;
    padding: 0.7rem 1.4rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    color: #2e5a3a;
    box-shadow: 0 4px #448052;
    transition: all 0.1s;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.phet-btn-green:active {
    box-shadow: 0 1px #448052;
    transform: translateY(3px);
}

.phet-btn-green:hover {
    filter: brightness(1.05);
}


/* Middle Section */
.divider-section {
    width: 60px;
    display: flex;
    justify-content: center;
    position: relative;
}

.dashed-line {
    border-left: 2px dashed #999;
    height: 100%;
}

.send-arrow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(to bottom, #a4eeba, #88d19e);
    border: 2px solid #559e66;
    width: 55px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 5;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px #448052;
}

.send-arrow-btn:active {
    box-shadow: 0 1px #448052;
    transform: translateY(calc(-50% + 3px));
}

.orient-btn {
    width: 65px;
    height: 65px;
    border: 2px solid #ccc;
    background: linear-gradient(to bottom, #ffffff, #f0f0f0);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.orient-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.orient-btn.active {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3), inset 0 0 0 2px #3b82f6;
}


/* Measurements Area */
.measurements {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    touch-action: pan-y;
}

.measure-layout {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: center;
}

.measurement-box {
    background: #ffffff;
    border: 8px solid #888;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 8px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
}


.single-box {
    width: 220px;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 180px;
}

.phet-btn-blue {
    background: linear-gradient(to bottom, #8fc6fd, #68aced);
    border: 2px solid #3a8ee6;
    padding: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    color: #1e4b7a;
    box-shadow: 0 5px #3a8ee6;
    transition: all 0.1s;
    font-size: 1rem;
}

.phet-btn-blue:active {
    box-shadow: 0 1px #3a8ee6;
    transform: translateY(4px);
}

.phet-btn-blue:hover {
    filter: brightness(1.05);
}


/* Multiple Layout */
.multiple-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.grid-container {
    width: 250px;
    height: 250px;
    border-width: 3px;
    padding: 10px;
}

.coin-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    width: 100%;
}

.grid-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes dotFlip1 {
    0% {
        transform: scale(1) rotateY(0) translateY(0);
        opacity: 0;
    }

    30% {
        transform: scale(1.5) rotateY(90deg) translateY(-20px);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotateY(180deg) translateY(0);
        opacity: 1;
    }
}

@keyframes dotFlip2 {
    0% {
        transform: scale(1) rotateX(0) translateY(0);
        opacity: 0;
    }

    30% {
        transform: scale(1.5) rotateX(90deg) translateY(-20px);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotateX(180deg) translateY(0);
        opacity: 1;
    }
}

.dot-anim-1 {
    animation: dotFlip1 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.dot-anim-2 {
    animation: dotFlip2 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}




.stats-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.n-label {
    font-weight: bold;
    font-size: 1.1rem;
}

.histogram-container {
    height: 200px;
    width: 200px;
    border-bottom: 2px solid #333;
    position: relative;
    display: flex;
    align-items: flex-end;
}

.coin-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(200, 200, 200, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 20;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
}

.coin-cover.hidden {
    display: none !important;
}


.phet-reset-btn {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 50px;
    height: 50px;
    background: #ff9800;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 0 #cc7a00;
}

.phet-reset-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}