:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --accent-color: #38bdf8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --panel-radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Prevent scrollbars if possible */
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100vh;
}

header {
    text-align: center;
}

header h1 {
    font-weight: 600;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: #94a3b8;
}

main.grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1.5fr 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.simulation-container {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    position: relative;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    border-radius: var(--panel-radius);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.controls {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.graph-container {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.graph-container h3,
.table-container h3 {
    font-size: 1rem;
    color: #94a3b8;
    margin: 0;
    font-weight: 500;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--accent-color);
    color: #0f172a;
}

#graphCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
}

.table-container {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Contain the scrollable area */
    padding: 1rem;
}

.table-wrapper {
    flex: 1;
    overflow-y: auto;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th {
    position: sticky;
    top: 0;
    background: #1e293b;
    color: #94a3b8;
    padding: 0.5rem;
    text-align: left;
    font-weight: 500;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 0.4rem 0.5rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: monospace;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}

::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--panel-radius);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.data-display {
    position: absolute;
    top: 1rem;
    left: 1rem;
    min-width: 150px;
    /* Removed glass-panel class from here in HTML to avoid double background, 
       but kept styling if needed. The HTML change removed the class, so this is fine. */
}

.controls h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.9rem;
    color: #cbd5e1;
}

.range-value {
    text-align: right;
    font-size: 0.9rem;
    color: var(--accent-color);
    font-family: monospace;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #334155;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.btn-primary {
    margin-top: auto;
    padding: 0.75rem;
    background: var(--accent-color);
    color: #0f172a;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

@media (max-width: 1024px) {
    main.grid-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
    }

    .simulation-container {
        grid-column: 1 / -1;
        grid-row: 1;
        height: 400px;
    }

    .controls {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .graph-container {
        grid-column: 1 / -1;
        grid-row: 3;
        height: 300px;
    }

    .table-container {
        grid-column: 1 / -1;
        grid-row: 4;
        height: 300px;
    }
}