:root {
    --bg-color: #f5f5f7;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent-blue: #0071e3;
    --accent-green: #34c759;
    --accent-red: #ff3b30;
    --accent-yellow: #ffcc00;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    opacity: 0;
    animation: pageFadeIn 0.8s ease-out forwards;
}

body.fade-out {
    animation: pageFadeOut 0.5s ease-in forwards;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pageFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 3rem;
    text-align: center;
}

.breadcrumb {
    font-family: 'Outfit', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-blue);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: inline-block;
    margin-bottom: 1rem;
}

.subheading {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* --- Simulator Layout --- */
.lab-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 28px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* New Layout Containers */
.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.simulator-layout {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 2rem;
}

@media (max-width: 900px) {
    .top-controls {
        flex-wrap: wrap;
    }

    .simulator-layout {
        grid-template-columns: 1fr;
    }
}

/* Mobile-specific fixes */
@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    .lab-card {
        padding: 1rem;
        border-radius: 18px;
    }

    .top-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .control-group {
        width: 100%;
    }

    .control-group label {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .button-group {
        min-width: 0;
        width: 100%;
    }

    .button-group button {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    .canvas-container {
        aspect-ratio: 4 / 3;
    }

    .graph-container {
        height: 140px;
    }

    .live-data-overlay {
        right: 10px;
        top: 10px;
        gap: 8px;
    }

    .data-box {
        min-width: 110px;
        padding: 8px 10px;
    }

    .graphs-grid {
        gap: 1rem;
    }

    .graph-title {
        font-size: 0.8rem;
    }

    .breadcrumb { font-size: 0.75rem; }
    h1 { font-size: 1.6rem; }
    .tagline { font-size: 0.95rem; }
}

/* --- Controls Panel Items --- */
.control-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
}

.unit-label {
    text-transform: none;
    font-weight: 400;
    opacity: 0.8;
}

.input-with-note {
    position: relative;
}

.note {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 500;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

input[type="number"]:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}


.button-group {
    display: flex;
    gap: 1rem;
    min-width: 200px;
}

button {
    flex: 1;
    padding: 1rem;
    border-radius: 14px;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-start {
    background: #16A34A;
    color: white;
}

.btn-start:hover {
    background: #16A34A;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.btn-start:disabled {
    background: #cccccc;
    color: #888888;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-start:disabled:hover {
    background: #cccccc;
    transform: none;
    box-shadow: none;
}

.button-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.finished-message {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 500;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
}

.btn-reset {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.btn-reset:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* --- Simulation Area --- */
.simulation-main {
    position: relative;
}

.canvas-container {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #000;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Data Displays --- */
.live-data-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.data-box {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 140px;
}

.data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
}

.data-label {
    font-size: 0.75rem;
    opacity: 0.8;
}

.data-acc {
    color: var(--accent-green);
}

.data-vel {
    color: var(--accent-blue);
}

.data-disp {
    color: var(--accent-yellow);
}

/* --- Force Analysis Panel --- */
.analysis-panel {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.force-card {
    background: rgba(255, 255, 255, 0.4);
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.force-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0;
}

.force-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
}

.force-net {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.force-net .force-value {
    color: #248a3d;
}

/* --- Graphs Section --- */
.graphs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

@media (max-width: 900px) {
    .graphs-grid {
        grid-template-columns: 1fr;
    }
}

.graph-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 0;
    /* Remove default margin from lab-card */
}

.graph-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.graph-container {
    width: 100%;
    height: 200px;
    background: white;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}