:root {
    --primary: #2ecc71;
    --dark: #1e272e;
    --accent: #f1c40f;
    --bg: #f5f6fa;
    --white: #ffffff;
    --shadow: 0 15px 35px rgba(0,0,0,0.1);

    /* ── Layout kintamieji — valdomi per temas ── */
    --screen-radius:      30px;
    --screen-max-width:   420px;
    --screen-padding:     35px 25px;
    --screen-text-align:  center;
    --screen-border:      none;
    --screen-anim:        fadeIn;

    --body-font:          'Segoe UI', system-ui, -apple-system, sans-serif;
    --heading-font:       inherit;

    --btn-radius:         16px;
    --btn-padding:        16px;
    --btn-font-weight:    700;
    --btn-font-size:      1rem;
    --btn-transform-active: scale(0.98);

    --logo-size:          90px;
    --logo-margin:        0 0 15px 0;

    --login-direction:    column;
    --login-gap:          0px;
    --login-align:        center;

    --transition-speed:   0.3s;

    --finish-text-align:  center;
    --finish-padding:     30px 20px;

    --map-levels-justify: center;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: var(--body-font);
    background: var(--bg);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--dark);
}

.screen {
    background: var(--white);
    width: 92%;
    max-width: var(--screen-max-width);
    padding: var(--screen-padding);
    border-radius: var(--screen-radius);
    box-shadow: var(--shadow);
    text-align: var(--screen-text-align);
    position: relative;
    animation: var(--screen-anim) 0.4s ease-out;
    border: var(--screen-border);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInFlat {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}

/* ── Login ekrano layout ── */
#start-screen .screen-inner {
    display: flex;
    flex-direction: var(--login-direction);
    gap: var(--login-gap);
    align-items: var(--login-align);
    width: 100%;
}

#start-screen .logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Gulsčias layout: logo kairėje, forma dešinėje */
#start-screen.layout-horizontal {
    max-width: var(--screen-max-width);
    text-align: left;
    padding: 28px 24px 24px;
}

#start-screen.layout-horizontal .screen-inner {
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
}

#start-screen.layout-horizontal .logo-container {
    flex: 0 0 120px;
    min-width: 0;
    align-items: center;
    text-align: center;
    padding-top: 28px; /* vieta back-to-index mygtukui */
}

#start-screen.layout-horizontal .logo-container h1 {
    font-size: clamp(0.95rem, 3.5vw, 1.3rem) !important;
    line-height: 1.2;
    margin: 6px 0 2px;
    word-break: break-word;
}

#start-screen.layout-horizontal .logo-container p {
    font-size: clamp(0.7rem, 2vw, 0.85rem) !important;
    margin: 0;
}

#start-screen.layout-horizontal .main-logo-img,
#start-screen.layout-horizontal .main-icon {
    width: 80px !important;
    height: 80px !important;
    font-size: 3rem !important;
    margin: 0 auto 6px !important;
}

#start-screen.layout-horizontal .form-section {
    flex: 1;
    min-width: 0;
    text-align: left;
    padding-top: 10px;
}

#start-screen.layout-horizontal .form-section button {
    text-align: center;
}

#start-screen.layout-horizontal .input-container {
    margin-bottom: 8px;
}

/* Kai labai siauras ekranas — grįžti prie stačio */
@media (max-width: 380px) {
    #start-screen.layout-horizontal .screen-inner {
        flex-direction: column;
    }
    #start-screen.layout-horizontal .logo-container {
        flex: none;
        padding-top: 8px;
    }
}

/* Pilno ekrano layout */
#start-screen.layout-fullscreen {
    width: 100%;
    max-width: 100% !important;
    min-height: 100vh;
    border-radius: 0 !important;
    padding: 60px 30px 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: none !important;
    border: none !important;
}

/* Kai fullscreen — body neturi centruoti kortelės vertikaliai */
body:has(#start-screen.layout-fullscreen:not(.hidden)) {
    align-items: flex-start;
}

/* Kortelė su stipriu šešėliu */
#start-screen.layout-card {
    border-radius: var(--screen-radius);
    box-shadow: 0 25px 60px rgba(0,0,0,0.18);
}

/* --- Status Bar --- */
.status-bar {
    position: fixed; top: 0; left: 0; right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    display: flex; justify-content: space-between;
    font-weight: 800; 
    border-bottom: 1px solid #eee; 
    z-index: 100;
}

/* --- Mygtukai --- */
button {
    width: 100%;
    padding: var(--btn-padding);
    border-radius: var(--btn-radius);
    border: none;
    font-size: var(--btn-font-size);
    font-weight: var(--btn-font-weight);
    cursor: pointer;
    margin: 8px 0;
    transition: var(--transition-speed);
    font-family: var(--body-font);
}

.primary-btn { 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.primary-btn:active { transform: var(--btn-transform-active); }
.secondary-btn { background: #f1f2f6; color: var(--dark); }
button:disabled { background: #ccc !important; cursor: not-allowed; opacity: 0.7; }

/* ── Logo ── */
.main-logo-img {
    width: var(--logo-size);
    height: var(--logo-size);
    object-fit: contain;
    margin: var(--logo-margin);
}

.main-icon {
    font-size: var(--logo-size);
    line-height: 1;
    display: block;
    margin: var(--logo-margin);
}

/* --- Lyderių Lentelės GRID Sistema --- */
.leaderboard-header, 
.entry {
    display: grid !important;
    grid-template-columns: 35px 1.2fr 75px 60px 65px !important; 
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 12px 10px;
}

.leaderboard-header {
    background: #f8f9fa;
    border-radius: 15px 15px 0 0;
    font-size: 0.65rem;
    font-weight: 800;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 5px;
}

.leaderboard-header div { text-align: center; }
.leaderboard-header .info-col { text-align: left; }
.leaderboard-header .time-col { text-align: right; }

.overlay { 
    position: fixed; inset: 0; 
    background: rgba(0,0,0,0.4); 
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; 
    z-index: 1000; 
    animation: fadeIn 0.3s ease;
}

.overlay-content { 
    background: rgba(255, 255, 255, 0.98); 
    width: 95%; max-width: 420px; 
    padding: 25px 10px; 
    border-radius: 30px; 
    text-align: center; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.leaderboard-list { 
    margin: 10px 0; 
    overflow-y: auto; 
    text-align: left;
}

.entry {
    background: white;
    margin-bottom: 8px;
    border-radius: 15px;
    border: 1px solid #f0f0f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    font-size: 0.85rem;
}

.rank-col { text-align: center; font-weight: 800; }
.info-col { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.tasks-col { text-align: center; color: #666; font-size: 0.8rem; }
.score-col { text-align: center; font-weight: 800; color: var(--primary); }
.time-col { text-align: right; color: #888; font-size: 0.75rem; font-family: monospace; }

.entry.top-1 { border-left: 5px solid #ffd700; background: #fffdf0; }
.entry.top-2 { border-left: 5px solid #c0c0c0; }
.entry.top-3 { border-left: 5px solid #cd7f32; }

/* --- Užduoties elementai --- */
.main-image-container {
    width: 100%; max-height: 250px; overflow: hidden;
    border-radius: 20px; margin-bottom: 20px;
    border: 1px solid #eee; background: #f9f9f9;
}
.main-image-container img { width: 100%; height: 100%; object-fit: contain; }

.option-item {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #eee;
    border-radius: 15px;
    padding: 12px;
    margin-bottom: 10px;
    transition: 0.2s;
    cursor: pointer;
}
.option-item img {
    width: 50px; height: 50px;
    object-fit: cover; border-radius: 8px; margin-right: 12px;
}
.option-item:active { background: #f8f9fa; }
.option-item:hover { border-color: var(--primary); background: #f0fff4; }
.option-item input[type="radio"] {
    width: 22px; height: 22px; margin-right: 15px; flex-shrink: 0;
}

.camera-btn { 
    background: var(--dark); color: white; 
    display: flex; align-items: center; justify-content: center; 
    height: 60px; border-radius: 18px; margin-top: 20px; 
}

#image-preview { 
    width: 100%; border-radius: 20px; margin-top: 15px; 
    max-height: 220px; object-fit: cover; border: 3px solid #eee;
}

.hint-box { 
    background: #fff9e6; padding: 15px; border-radius: 15px; 
    margin-top: 10px; font-size: 0.9rem; color: #856404; 
    border: 1px solid #ffeeba; text-align: left; 
}

.result-card { 
    background: #f8f9fa; border-radius: 25px; padding: 20px; 
    margin: 20px 0; display: flex; justify-content: space-around; 
}

.input-container input { 
    width: 100%; padding: 12px 0; font-size: 1.2rem; 
    border: none; border-bottom: 2px solid #ddd; 
    outline: none; background: transparent; 
}

.name-message {
    background: #e3f2fd; color: #0d47a1; padding: 12px;
    border-radius: 15px; margin-bottom: 15px; font-weight: bold;
}

.close-btn { background: #ff4757; color: white; }

#lightbox {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999; display: none;
    align-items: center; justify-content: center;
    overflow: hidden; touch-action: none;
}

#lightbox-img {
    max-width: 95%; max-height: 95%;
    object-fit: contain; box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: absolute; top: 20px; right: 20px;
    color: white; font-size: 35px; cursor: pointer;
    width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.15); backdrop-filter: blur(5px);
    border-radius: 50%; z-index: 10001;
}

.lightbox-hint {
    position: absolute; bottom: 30px; left: 50%;
    transform: translateX(-50%);
    color: white; background: rgba(0,0,0,0.6);
    padding: 10px 20px; border-radius: 25px;
    font-size: 0.9rem; pointer-events: none; z-index: 10000;
}

.feedback-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.feedback-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

#choice-section, 
#input-section + #hint-btn { margin-top: 0 !important; }
.upload-section { margin-bottom: 20px !important; }

/* --- Modernus įvedimo laukas --- */
.input-task-wrapper { padding: 0; margin-bottom: 5px; }
#hint-btn { margin-top: 10px !important; clear: both; }

.input-group {
    position: relative; margin-bottom: 10px;
}

.input-group input {
    width: 100%; padding: 15px; font-size: 1.1rem;
    border: 2px solid #eee; border-radius: 12px;
    outline: none; transition: all 0.3s ease;
    background: #fff; text-align: center;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(46,204,113,0.1);
}

.input-group label {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #999; pointer-events: none;
    transition: all 0.3s ease;
    font-size: 1rem; background: white; padding: 0 5px;
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
    top: 0; font-size: 0.8rem;
    color: var(--primary); font-weight: bold;
}

.input-group input::placeholder { color: transparent; }

.feedback-box {
    margin: 10px 0; min-height: 50px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; font-weight: bold; transition: all 0.3s ease;
}

#submit-text-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

/* ── Finish ekrano lygiavimas ── */
#finish-screen.screen {
    text-align: var(--finish-text-align);
    padding: var(--finish-padding);
}

/* ── Map lygių išdėstymas ── */
.levels-grid {
    justify-content: var(--map-levels-justify);
}