/* ===== STYLE GŁÓWNY GRY WYŚCIG ===== */
#wyscig-game {
    font-family: Arial, sans-serif;
    position: relative;
    width: 100%;
    min-height: 100vh;
}

/* ===== HEADER Z PRZYCISKIEM PEŁNEGO EKRANU ===== */
.wyscig-header {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 300;
}

#fullscreen-wrapper {
    pointer-events: auto;
}

/* ===== KONTENER GRY ===== */
#gameContainer {
    position: relative;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
    background: linear-gradient(to right, #4f883d 0%, #4f883d 20%, #333 20%, #333 80%, #4f883d 80%, #4f883d 100%);
    overflow: hidden;
    touch-action: none;
}

#road {
    position: absolute;
    left: 20%;
    top: 0;
    width: 60%;
    height: 100%;
    background: #333;
    border-left: 5px solid #fff;
    border-right: 5px solid #fff;
}

#roadLines {
    position: absolute;
    left: 50%;
    top: 0;
    width: 5px;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 30px,
        #fff 30px,
        #fff 60px
    );
    animation: none;
    transform: translateX(-50%);
}

#wyscig-game.is-playing #roadLines {
    animation: moveLines 2s linear infinite;
}

@keyframes moveLines {
    0% { transform: translateX(-50%) translateY(0); }
    100% { transform: translateX(-50%) translateY(60px); }
}

#car {
    position: absolute;
    bottom: 50px;
    left: 50%;
    width: 60px;
    height: 90px;
    transition: none;
    cursor: grab;
    z-index: 100;
    transform: translateX(-50%);
}

#car img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

#car:active {
    cursor: grabbing;
}

.gate {
    position: absolute;
    top: -150px;
    width: 25%;
    min-height: 80px;
    height: auto;
    background: #fff;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    border: 3px solid #fff;
    padding: 8px 12px;
    box-sizing: border-box;
    transition: all 0.5s ease;
    animation: none;
    overflow: visible;
    line-height: 1.3;
    word-wrap: break-word;
    hyphens: auto;
}

@keyframes moveDown {
    0% { 
        top: -150px;
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% { 
        top: 100vh;
        opacity: 0;
    }
}

.gate.correct {
    background: #006400 !important;
    border-color: #00ff00;
    animation-play-state: paused;
}

.gate.collision {
    background: #ff6666 !important;
    border-color: #ff0000;
    animation-play-state: paused;
}


#gate1 {
    left: 22%;
}

#gate2 {
    right: 22%;
}

.gate-barrier {
    position: absolute;
    top: -150px;
    left: 50%;
    width: 7%;
    min-height: 80px;
    background: repeating-linear-gradient(
        -45deg,
        #ffa000,
        #ffa000 12px,
        #222 12px,
        #222 24px
    );
    border: 2px solid #fff;
    border-radius: 6px;
    transform: translateX(-50%);
    animation: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
    z-index: 90;
}

.gate-barrier.collision {
    background: #b71c1c;
    border-color: #ffeb3b;
    animation-play-state: paused;
}

#gameOver {
    display: none; /* legacy element hidden; replaced by popup */
}

#restartBtn {
    display: none; /* legacy element hidden; replaced by popup */
}

/* Popup summary */
.wyscig-popup {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.wyscig-popup.is-visible {
    opacity: 1;
    pointer-events: auto;
}
.wyscig-popup .omni-save-result-section {
    max-width: 400px;
    margin: 18px auto 0;
    padding: 20px;
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    text-align: center;
}

.wyscig-popup .omni-save-checkbox-label {
    display: block;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: #4f883d;
}

.wyscig-popup .omni-save-checkbox-label input {
    margin-right: 8px;
    transform: scale(1.2);
    vertical-align: middle;
}

.wyscig-popup .omni-learner-name-field {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.wyscig-popup .omni-learner-name-field > label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
    text-align: center;
}

.wyscig-popup .omni-learner-name-input {
    width: 100%;
    padding: 18px 20px;
    font-size: 16px;
    line-height: 1.45;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 54px;
}

.wyscig-popup .omni-learner-name-input:focus {
    outline: none;
    border-color: #4f883d;
    box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.15);
}

.wyscig-popup .omni-learner-name-input:read-only,
.wyscig-popup .omni-learner-name-input:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
}

.wyscig-popup .omni-save-result-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin: 8px 0 12px;
    background: linear-gradient(135deg, #4f883d 0%, #3e6c31 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wyscig-popup .omni-save-result-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 136, 61, 0.3);
}

.wyscig-popup .omni-save-result-btn.saved {
    background-color: #4f883d !important;
    cursor: default;
}

.wyscig-popup .omni-save-result-btn:disabled {
    opacity: 0.7;
}

.wyscig-popup .omni-privacy-note {
    margin: 0 0 10px;
    font-size: 12px;
    color: #1e1e1e;
    font-style: italic;
    text-align: center;
}

.wyscig-popup .omni-save-result-message {
    margin-top: 15px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
}

.wyscig-popup .omni-save-result-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.wyscig-popup .omni-save-result-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.wyscig-popup .omni-summary-popup-note--teacher{
    margin: 14px auto 6px;
    max-width: 500px;
    font-size: 14px;
    line-height: 1.45;
    color: #1b1b1b;
}
.wyscig-popup-inner {
    position: relative;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 6px 32px #2222;
    padding: 32px 30px 26px;
    min-width: 280px;
    max-width: 90vw;
    text-align: center;
    animation: wyscig-popup-in 0.5s cubic-bezier(.6,2,.4,1);
}
@keyframes wyscig-popup-in {
    0% { transform: scale(.85) translateY(32px); opacity:0; }
    100% { transform: scale(1) translateY(0); opacity:1; }
}
.wyscig-popup-title {
    font-size: 2.1em;
    font-weight: 700;
    color: #4f883d;
    margin: 0 0 10px;
}
.wyscig-popup-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 22px;
    text-align: left;
}
.wyscig-popup-summary-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 1.05em;
    color: #111827;
}
.wyscig-popup-summary-label { font-weight: 600; }
.wyscig-popup-summary-value { font-weight: 700; color: #4f883d; }
.wyscig-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.wyscig-popup-btn {
    background: #4f883d;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 30px;
    font-size: 1.05em;
    cursor: pointer;
    box-shadow: 0 1px 4px #4f883d33;
    transition: background .2s;
}
.wyscig-popup-btn:hover { background: #6bb94a; }
.wyscig-popup-btn--outline {
    background: #fff;
    color: #4f883d;
    border: 2px solid #4f883d;
    box-shadow: none;
}
.wyscig-popup-btn--outline:hover { background: #f1f5f9; }
.wyscig-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: 1px solid rgba(0,0,0,0.12);
    background: #fff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: #4a4a4a;
    font-size: 18px;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    z-index: 3;
}
.wyscig-popup-close:hover { background: rgba(255,255,255,0.9); }

#restartBtn:hover {
    background: #cc3333;
}

#level {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #fff;
    color: #000;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    z-index: 200;
    margin-top: 50px;
}

#controls {
    position: absolute;
    bottom: 20px;
    left: 2%;
    color: white;
    padding: 10px;
    font-size: 14px;
    max-width: 16%;
    z-index: 200;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    line-height: 1.6;
}

.success-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 128, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 10px;
    font-size: 20px;
    display: none;
    z-index: 999;
}

.wyscig-start-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.wyscig-start-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.wyscig-start-box {
    background: #ffffff;
    color: #1f1f1f;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    max-width: 420px;
    width: calc(100% - 40px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.wyscig-start-box h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
}

.wyscig-start-instructions {
    text-align: left;
    margin-bottom: 25px;
    font-size: 16px;
    line-height: 1.5;
}

.wyscig-start-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #e5e5e5;
}

.wyscig-start-row:last-child {
    border-bottom: none;
}

.wyscig-start-label {
    font-weight: 600;
}

.wyscig-start-button {
    display: inline-block;
    padding: 0.75em 2em;
    background: #2270b8;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.wyscig-start-button:hover,
.wyscig-start-button:focus {
    background: #1a5a9a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34, 112, 184, 0.35);
}

#wyscig-game .omni-fullscreen-btn {
    background: transparent;
    border: 2px solid #ffffff;
    color: #ffffff;
    box-shadow: none;
}

#wyscig-game .omni-fullscreen-btn .omni-fullscreen-icon,
#wyscig-game .omni-fullscreen-btn .omni-fullscreen-label {
    color: inherit;
}

#wyscig-game .omni-fullscreen-btn:hover,
#wyscig-game .omni-fullscreen-btn:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #ffffff;
    color: #ffffff;
}

/* ===== OPIS NAUCZYCIELA I NOTATKA ADMINA ===== */
.omni-game-teacher-opis {
    margin-bottom: 30px;
    color: #000;
}

.omni-game-teacher-opis p {
    margin: 0.5em 0;
    line-height: 1.6;
    color: #000;
}

.omni-game-admin-note {
    margin-top: 30px;
    color: #000;
}

.omni-game-admin-note p {
    margin: 0.5em 0;
    line-height: 1.6;
    color: #000;
}

.wyscig-no-questions {
    padding: 40px;
    text-align: center;
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin: 20px 0;
}

/* ===== TRYB PEŁNEGO EKRANU ===== */
#wyscig-game:fullscreen,
#wyscig-game:-webkit-full-screen,
#wyscig-game:-moz-full-screen,
#wyscig-game:-ms-fullscreen,
#wyscig-game.is-fs {
    background: #ffffff;
}

#wyscig-game:fullscreen #gameContainer,
#wyscig-game:-webkit-full-screen #gameContainer,
#wyscig-game:-moz-full-screen #gameContainer,
#wyscig-game:-ms-fullscreen #gameContainer,
#wyscig-game.is-fs #gameContainer {
    width: 100vw;
    height: 100vh;
}

/* ===== RESPONSYWNOŚĆ DLA TELEFONÓW ===== */
@media (max-width: 768px) {
    #controls {
        font-size: 11px;
        padding: 6px;
        max-width: 16%;
        bottom: 15px;
    }
    
    .gate {
        width: 28%;
        min-height: 70px;
        font-size: 16px;
        padding: 6px 10px;
        line-height: 1.2;
    }
    
    #car {
        width: 50px;
        height: 75px;
    }
}
