/* ========== RESET & GLOBAL STYLES ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Prefer Inter, fall back to Segoe UI */
    background: #f0f2f5; /* Jasne, neutralne tło, typowe dla nowoczesnych pulpitów nawigacyjnych */
    height: 100vh;
    color: #333; /* Ciemniejszy tekst dla lepszego kontrastu na jasnym tle */
    line-height: 1.3; /* Jeszcze bardziej zmniejszona wysokość linii */
    overflow-y: auto; /* Zmieniono na auto, aby przewijanie pojawiało się, gdy zawartość wychodzi poza widok */
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* ========== MAIN APP CONTAINER ========== */
.app {
    max-width: 1200px;
    margin: 3px auto; /* Minimalny margines na górze i dole */
    padding: 8px 12px; /* Minimalny padding */
    min-height: calc(100vh - 6px); /* Zmieniono na min-height, aby aplikacja mogła rosnąć poza 100vh */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Minimalny odstęp między sekcjami */
    background: #ffffff;
    border-radius: 12px; /* Nieco mniejsze zaokrąglenie */
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.05); /* Delikatniejszy cień */
    /* overflow-y: auto; - Usunięto, ponieważ body będzie teraz obsługiwać główne przewijanie */
}

/* ========== HEADER ========== */
.header {
    text-align: center;
    margin-bottom: 8px; /* Zmniejszony margines */
    flex-shrink: 0;
    color: #333;
}

.header h1 {
    font-size: 2rem; /* Mniejszy rozmiar dla tytułu */
    margin-bottom: 2px;
    text-shadow: none;
    font-weight: 700;
    color: #2c3e50;
}

.subtitle {
    font-size: 0.9rem; /* Mniejszy rozmiar */
    opacity: 0.8;
    margin-bottom: 6px; /* Zmniejszony margines */
    color: #555;
}

.tech-badge {
    background: #e0f7fa;
    color: #00796b;
    padding: 3px 10px; /* Zmniejszony padding */
    border-radius: 16px; /* Mniejsze zaokrąglenie */
    font-size: 0.75rem; /* Mniejszy rozmiar czcionki */
    font-weight: 600;
    margin: 0 4px; /* Zmniejszony margines */
    display: inline-block;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06); /* Delikatniejszy cień */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tech-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* ========== SHARED CARD STYLES ========== */
.model-selector,
.model-info,
.stats-panel {
    background: #ffffff;
    backdrop-filter: none;
    border-radius: 8px; /* Mniejsze zaokrąglenie dla kart */
    padding: 12px; /* Zmniejszony padding dla kart */
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* Delikatniejszy cień */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.model-selector:hover,
.model-info:hover,
.stats-panel:hover {
    transform: translateY(-1px); /* Mniejszy efekt uniesienia */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.model-selector h3,
.model-info h4,
.stats-panel h3 {
    color: #3f51b5;
    margin-bottom: 10px; /* Zmniejszony margines */
    font-size: 1rem; /* Mniejszy rozmiar */
    font-weight: 700;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px; /* Zmniejszony padding */
}

/* Dodano styl dla zawartości w sekcji informacji o modelu */
#modelDetails {
    font-size: 0.85rem; /* Ustawienie rozmiaru czcionki zgodnego z innymi elementami informacyjnymi */
    line-height: 1.4; /* Dopasowanie wysokości linii dla lepszej czytelności */
    color: #444; /* Nieco ciemniejszy kolor dla lepszej czytelności na jasnym tle */
}

/* ========== MODEL SECTION ========== */
.model-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px; /* Zmniejszony odstęp */
    margin-bottom: 8px; /* Zmniejszony margines */
    flex-shrink: 0;
}

.selector-controls {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Zmniejszony odstęp */
    margin-bottom: 8px; /* Zmniejszony margines */
}

.selector-controls select,
.selector-controls button {
    padding: 8px 10px; /* Zmniejszony padding */
    border: 1px solid #ddd;
    border-radius: 5px; /* Mniejsze zaokrąglenie */
    font-size: 0.85rem; /* Mniejszy rozmiar czcionki */
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.selector-controls select {
    background: #f8f8f8;
    color: #333;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23555' width='14px' height='14px'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center; /* Zmniejszona pozycja strzałki */
    background-size: 14px; /* Zmniejszony rozmiar strzałki */
}

.selector-controls button {
    background: #4caf50;
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px; /* Zmniejszony odstęp między literami */
    box-shadow: 0 1px 8px rgba(76, 175, 80, 0.15); /* Delikatniejszy cień */
    border: none;
}

.selector-controls button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(76, 175, 80, 0.25);
}

.selector-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 6px; /* Zmniejszony odstęp */
    margin-bottom: 8px; /* Zmniejszony margines */
    font-size: 0.85rem; /* Mniejszy rozmiar czcionki */
    color: #555;
}

.speed-control input[type="range"] {
    flex: 1;
    height: 4px; /* Cieńszy suwak */
    background: #e0e0e0;
    border-radius: 2px; /* Mniejsze zaokrąglenie */
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; /* Mniejszy kciuk */
    height: 14px; /* Mniejszy kciuk */
    border-radius: 50%;
    background: #3f51b5;
    cursor: grab;
    box-shadow: 0 1px 4px rgba(63, 81, 181, 0.25);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3f51b5;
    cursor: grab;
    box-shadow: 0 1px 4px rgba(63, 81, 181, 0.25);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.speed-control input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    box-shadow: 0 2px 5px rgba(63, 81, 181, 0.4);
}

.speed-control input[type="range"]::-moz-range-thumb:active {
    cursor: grabbing;
    box-shadow: 0 2px 5px rgba(63, 81, 181, 0.4);
}

.performance-info {
    background: #f5f5f5;
    border-radius: 6px; /* Mniejsze zaokrąglenie */
    padding: 8px; /* Zmniejszony padding */
    font-size: 0.75rem; /* Mniejszy rozmiar czcionki */
    color: #666;
    border: 1px solid #eee;
}

/* ========== STATUS & CONTROLS SECTION ========== */
.status-section {
    text-align: center;
    margin-bottom: 8px; /* Zmniejszony margines */
    flex-shrink: 0;
}

.status {
    font-size: 1rem; /* Mniejszy rozmiar czcionki */
    font-weight: 600;
    padding: 10px; /* Zmniejszony padding */
    border-radius: 8px; /* Mniejsze zaokrąglenie */
    margin-bottom: 8px; /* Zmniejszony margines */
    background: #e0e0e0;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.status.loading {
    background: #ffecb3;
    color: #f57f17;
    animation: pulse 1.5s infinite;
}

.status.playing {
    background: #c8e6c9;
    color: #388e3c;
}

.status.error {
    background: #ffcdd2;
    color: #d32f2f;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.99; transform: scale(1.001); } /* Bardziej subtelny puls */
}

.controls {
    display: flex;
    justify-content: center;
    gap: 8px; /* Zmniejszony odstęp */
    flex-wrap: wrap;
}

.controls button {
    padding: 8px 15px; /* Zmniejszony padding */
    border: none;
    border-radius: 5px; /* Mniejsze zaokrąglenie */
    font-size: 0.85rem; /* Mniejszy rozmiar czcionki */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.start-btn {
    background: #4caf50;
    color: white;
    font-size: 0.95rem; /* Mniejszy rozmiar */
    padding: 10px 20px; /* Mniejszy padding */
    box-shadow: 0 3px 12px rgba(76, 175, 80, 0.25);
}

.controls button:not(.start-btn) {
    background: #2196f3;
    color: white;
}

.controls button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.start-btn:hover:not(:disabled) {
    box-shadow: 0 5px 18px rgba(76, 175, 80, 0.35);
}

.controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ========== GAME SECTION ========== */
.game-section {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Zmieniono na 50/50 */
    gap: 8px; /* Zmniejszony odstęp */
    flex: 1;
    margin-bottom: 8px; /* Zmniejszony margines */
    min-height: 0;
    overflow: hidden;
}

.game-area {
    display: flex;
    justify-content: center; /* Wyśrodkowanie poziome */
    align-items: center; /* Wyśrodkowanie pionowe */
    overflow: hidden;
    min-height: 220px; /* Minimalna wysokość pozostaje taka sama */
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.game-area canvas {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #263238;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Zmniejszony odstęp */
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0; /* Zmniejszony padding */
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.85rem; /* Mniejszy rozmiar czcionki */
    color: #444;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item.q-values {
    flex-direction: column;
    align-items: stretch;
    padding-top: 8px; /* Zmniejszony padding */
}

.stat-item.q-values .stat-label {
    margin-bottom: 5px; /* Zmniejszony margines */
    text-align: left;
    color: #555;
}

#qValues {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.7rem; /* Jeszcze mniejszy rozmiar czcionki */
    line-height: 1.2; /* Jeszcze mniejsza wysokość linii */
    background: #f8f8f8;
    padding: 5px; /* Zmniejszony padding */
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    color: #444;
    max-height: 80px; /* Jeszcze bardziej zmniejszona maksymalna wysokość */
    overflow-y: auto;
    border: 1px solid #eee;
}

/* ========== FOOTER ========== */
.footer {
    margin-top: auto;
    padding-top: 12px; /* Zmniejszony padding */
    flex-shrink: 0;
}

.footer-content {
    text-align: center;
    font-size: 0.75rem; /* Mniejszy rozmiar czcionki */
    opacity: 0.8;
    line-height: 1.3;
    background: #e0e0e0;
    color: #555;
    padding: 10px; /* Zmniejszony padding */
    border-radius: 8px;
    border: none;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 1024px) {
    .app {
        padding: 6px 10px;
        gap: 8px;
    }
    .model-section {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .game-section {
        grid-template-columns: 1fr; /* Zawsze 1 kolumna na mniejszych ekranach */
        gap: 8px;
    }
    .game-area canvas {
        max-width: 100%;
        height: auto;
    }
    .model-selector,
    .model-info,
    .stats-panel {
        padding: 12px;
    }
    .selector-controls select,
    .selector-controls button,
    .controls button {
        font-size: 0.8rem;
        padding: 6px 8px;
    }
    .start-btn {
        font-size: 0.9rem;
        padding: 8px 15px;
    }
    .status {
        font-size: 0.95rem;
        padding: 8px;
    }
    .stat-item {
        font-size: 0.8rem;
    }
    #qValues {
        font-size: 0.65rem;
        max-height: 70px;
    }
}

@media (max-width: 768px) {
    .app {
        padding: 4px 8px;
        gap: 6px;
    }
    .header h1 {
        font-size: 1.6rem;
    }
    .subtitle {
        font-size: 0.85rem;
    }
    .tech-badge {
        font-size: 0.65rem;
        padding: 2px 8px;
    }
    .model-selector,
    .model-info,
    .stats-panel {
        padding: 10px;
        border-radius: 6px;
    }
    .model-selector h3,
    .model-info h4,
    .stats-panel h3 {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    .controls {
        flex-direction: column;
        gap: 5px;
    }
    .controls button {
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    .start-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    .status {
        font-size: 0.85rem;
        padding: 6px;
    }
    .stat-item {
        font-size: 0.75rem;
    }
    #qValues {
        font-size: 0.6rem;
        max-height: 60px;
    }
    .footer-content {
        font-size: 0.7rem;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 2px 4px;
        gap: 4px;
    }
    .header h1 {
        font-size: 1.4rem;
    }
    .subtitle {
        font-size: 0.75rem;
    }
    .tech-badge {
        font-size: 0.6rem;
        padding: 1px 6px;
    }
    .model-selector,
    .model-info,
    .stats-panel {
        padding: 8px;
        border-radius: 4px;
    }
    .model-selector h3,
    .model-info h4,
    .stats-panel h3 {
        font-size: 0.8rem;
        margin-bottom: 6px;
    }
    .selector-controls select,
    .selector-controls button,
    .controls button {
        font-size: 0.7rem;
        padding: 5px 7px;
    }
    .start-btn {
        padding: 7px 10px;
        font-size: 0.75rem;
    }
    .status {
        font-size: 0.75rem;
        padding: 5px;
    }
    .stat-item {
        font-size: 0.7rem;
        padding: 4px 0;
    }
    #qValues {
        font-size: 0.55rem;
        padding: 4px;
        max-height: 50px;
    }
    .footer-content {
        font-size: 0.65rem;
        padding: 6px;
    }
}

/* ========== CUSTOM SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 5px; /* Jeszcze węższy scrollbar */
}

::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e;
}

/* ========== SELECTION STYLES ========== */
::selection {
    background: #bbdefb;
    color: #333;
}

a.start-btn {
  text-decoration: none;
  display: inline-block;
}