:root {
    --primary: #2563eb;
    --success: #059669;
    --bg: #f8fafc;
    --text: #1e293b;
    /* Šířka osy podle zařízení; výška se řídí layoutem (celá osa ve výřezu okna) */
    --axis-width: clamp(112px, 26vw, 220px);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.hidden { display: none !important; }

.shadow { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }

.card {
    background: white;
    padding: 40px;
    border-radius: 12px;
    max-width: 500px;
    text-align: center;
}

/* Experiment: celá osa v rámci okna; po zobrazení tlačítka „Uložit“ musí jít dostat k patičce (viz overflow). */
#experiment-screen.screen {
    justify-content: flex-start;
    align-items: stretch;
    padding: 12px 16px 16px;
    box-sizing: border-box;
    height: 100svh;
    max-height: 100svh;
    min-height: 0;
    /* hidden by ořízl patičku s tlačítkem, jakmile se po dokončení objeví (footer předtím měl nulovou výšku) */
    overflow-x: hidden;
    overflow-y: auto;
}

#experiment-screen .footer {
    flex-shrink: 0;
    padding-top: 8px;
    scroll-margin-bottom: 24px;
}

/* Layout experimentu */
.main-layout {
    display: flex;
    gap: clamp(16px, 3vw, 32px);
    width: 100%;
    max-width: 1280px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    margin: 0 auto;
}

.sidebar {
    flex: 0 1 min(380px, 42vw);
    min-width: min(240px, 100%);
    background: white;
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.words-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    min-height: min(160px, 22svh);
}

/* Vertikální Osa - HLAVNÍ ZMĚNA */
.axis-area {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.axis-container {
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    position: relative;
    padding-right: clamp(48px, 8vw, 72px);
}

/* Stupnice (čísla) */
.axis-ticks {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 0 0 auto;
    padding-right: 15px;
    font-weight: bold;
    color: #64748b;
    text-align: right;
    align-self: stretch;
}

.axis {
    flex: 0 0 var(--axis-width);
    width: var(--axis-width);
    align-self: stretch;
    min-height: 0;
    background: #f1f5f9;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    position: relative;
}

.axis-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #cbd5e1;
    transform: translateX(-50%);
}

/* Design slova (karty) */
.word {
    padding: 8px 16px;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    cursor: grab;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
    z-index: 100;
}

.word.in-axis {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: min(148px, calc(var(--axis-width) + 40px));
    min-width: 56px;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

.word:not(.in-axis):active {
    cursor: grabbing;
    transform: scale(1.05);
}

.word.in-axis:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.05);
}

/* Tlačítka */
input[type="text"] {
    width: 80%;
    padding: 12px;
    margin: 20px 0;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1rem;
}

label {
    display: block;
    text-align: left;
    width: 80%;
    margin: 0 auto 8px auto;
    font-weight: 600;
}

select {
    width: 80%;
    padding: 12px;
    margin-bottom: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
}

button {
    background: var(--success);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.btn-save { background: #1e293b; margin-top: 20px; }

.submit-error-banner {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Na úzkých displejích pod sebou: slova nahoře (scrollovatelná oblast), osa do zbytku výšky okna */
/* Dotazník CRS-15 (samostatná obrazovka po experimentu) */
#questionnaire-screen.screen {
    justify-content: flex-start;
    align-items: stretch;
    padding: 20px 16px 32px;
    box-sizing: border-box;
    min-height: 100svh;
    overflow-x: hidden;
    overflow-y: auto;
}

.crs-container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 28px 24px 32px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
}

.crs-title {
    margin: 0 0 12px 0;
    font-size: 1.35rem;
    line-height: 1.3;
}

.crs-lead {
    margin: 0 0 24px 0;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.5;
}

.crs-error-banner {
    margin-bottom: 16px;
}

.crs-error-banner[hidden] {
    display: none !important;
}

.crs-fieldset {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px 16px;
    margin: 0 0 18px 0;
    background: #fafafa;
}

.crs-legend {
    padding: 0 6px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text);
}

.crs-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 10px;
    font-size: 0.92rem;
    line-height: 1.35;
}

.crs-option input {
    margin-top: 3px;
    flex-shrink: 0;
}

.crs-option label {
    display: inline;
    width: auto;
    margin: 0;
    font-weight: normal;
    cursor: pointer;
}

.crs-footer-actions {
    margin-top: 28px;
    display: flex;
    justify-content: center;
}

@media (max-width: 720px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        flex: 0 1 auto;
        max-height: min(38svh, 280px);
        max-width: none;
        width: 100%;
    }

    .axis-area {
        flex: 1 1 auto;
        min-height: 0;
    }
}
