:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --success-color: #16a34a;
    --warning-color: #ca8a04;
    --error-color: #dc2626;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --font-main: 'Inter', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden; /* Prevent scrolling on body during test */
}

/* UTILS */
.hidden { display: none !important; }
.view { display: none; height: 100%; width: 100%; overflow-y: auto; padding-bottom: 2rem; }
.view.active { display: flex; flex-direction: column; align-items: center; }

/* LAYOUT */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.main-header {
    width: 100%;
    padding: 1.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    z-index: 10;
}

.brand h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.highlight { color: var(--primary-color); }
.subtitle { font-size: 0.85rem; color: var(--text-muted); }

.test-meta {
    background: var(--text-main);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
}
.timer-label { display: block; font-size: 0.65rem; opacity: 0.8; letter-spacing: 1px; }
.timer-value { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: #fbbf24; }

/* CARDS & FORMS */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    margin-top: 2rem;
}

h2 { margin-bottom: 1rem; color: var(--text-main); }
.instruction-text { margin-bottom: 2rem; color: var(--text-muted); }

.form-group { margin-bottom: 1.25rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
input[type="text"], input[type="email"], input[type="date"], select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
}

.alert-box {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.875rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-align: center;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; opacity: 0.7; }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.1rem; padding: 1rem 2rem; width: 100%; }

/* INSTRUCTION STEPS */
.step {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}
.step-num {
    background: var(--primary-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.example-box {
    margin-top: 0.5rem;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: center;
}
.col-example {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
}
.line { width: 100%; height: 2px; background: #333; margin: 0.25rem 0; }
.res { color: var(--text-muted); text-decoration: line-through; }
.input-box { color: var(--primary-color); border: 2px solid var(--primary-color); padding: 2px 8px; border-radius: 4px; margin-top: 4px; }

/* TEST AREA */
.test-area-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 1rem;
}

.test-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
}
.progress-fill { height: 100%; background: var(--success-color); width: 0%; transition: width 0.3s; }

.column-info {
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.kraepelin-grid-wrapper {
    display: flex;
    justify-content: center;
    gap: 2rem;
    height: 80vh; /* Increased from 70vh to show more */
    max-height: 800px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.col-container {
    display: flex;
    flex-direction: column-reverse; /* Bottom to top for Kraepelin? Usually Top to Bottom or Bottom to Top depending on variant. Standard Pauli is Top->Bottom, Kraepelin usually Bottom->Top. Let's stick to standard instruction: Add FROM BOTTOM TO TOP. */
    align-items: center;
    width: 60px;
    transition: all 0.3s ease;
}

/* Kraepelin Standard: Often Bottom to Top. Let's make it configurable but default to BOTTOM-UP */
.col-container.active-col {
    opacity: 1;
    transform: scale(1);
    filter: none;
}
.col-container.prev-col, .col-container.next-col {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
    filter: blur(1px);
}

.num-cell {
    height: 50px; /* Increased from 32px */
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.5rem; /* Increased from 1.25rem */
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}
.input-cell {
    height: 40px; /* Increased from 32px */
    width: 40px; /* Increased width */
    border: none;
    border-bottom: 2px solid var(--border-color);
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.25rem; /* Increased size */
    color: var(--primary-color);
    background: transparent;
    outline: none;
    margin: 4px 0; /* Changed from -8px to positive margin for spacing */
    z-index: 5;
    padding: 0;
}
.input-cell:focus {
    border-bottom-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

/* FINISH PAGE */
.finish-card { text-align: center; }
.icon-success {
    background: var(--success-color);
    color: white;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1.5rem;
}
.status-box { margin-top: 1.5rem; padding: 1rem; background: var(--bg-color); border-radius: 8px; font-family: var(--font-mono); font-size: 0.9rem; }

/* RESPONSIVE */
@media (max-width: 600px) {
    .kraepelin-grid-wrapper { 
        gap: 0.5rem; 
        height: 75vh;
    }
    .col-container.prev-col, .col-container.next-col { display: none; }
    
    /* Better Mobile Visibility */
    .col-container.active-col {
        transform: scale(1.1); /* Slightly larger on mobile */
    }
    .num-cell { font-size: 1.75rem; }
    .input-cell { font-size: 1.5rem; width: 50px; margin: 8px 0; }
    
    .form-row { flex-direction: column; gap: 0; }
    
    .test-area-container { padding-top: 2rem; }
}
