/* =====================================================
   BASE STYLES (Desktop-First)
   ===================================================== */

body { 
    font-family: Arial, sans-serif; 
    padding: 5px; 
    background-color: #f4f4f4;
    margin: 0;
    /* Mobile overscroll protection */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

h2 {
    text-align: center;
    color: #878787;
    margin: 5px;
}

.main-header {
    text-align: center;
}

.main-header h2 {
    margin: 0;
    font-size: 1.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.edition-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    background: silver;
    color: white;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.footer-logo {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    border-top: 1px solid #ddd;
}

.footer-logo a {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 0.9em;
}

.footer-logo img {
    height: 30px;
    width: auto;
}

.footer-logo:hover a {
    color: #333;
    transition: color 0.3s ease;
}

/* =====================================================
   SNAKE GAME STYLES
   ===================================================== */

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
}

.level-header {
    width: 100%;
    max-width: 400px;
    text-align: center;
    margin-bottom: 5px;
}

.level-name {
    margin: 0 0 5px 0;
    color: #373737;
    font-size: 1.5em;
}

.progress-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

canvas {
    border: 2px solid #333;
    background-color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* Touch optimization */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.game-info {
    margin-top: 5px;
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

.score-display {
    font-size: 18px;
    font-weight: bold;
    color: #388E3C;
    text-align: center;
}

.controls {
    margin-top: 5px;
    font-size: 14px;
    color: #666;
    text-align: center;
} 
 /* .controls {
    text-align: center;
    margin: 10px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 14px;
} */

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

/* =====================================================
   BUTTONS
   ===================================================== */

button, .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

button {
    background-color: #4CAF50;
    color: white;
}

button:hover {
    background-color: #388E3C;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover, .btn-info:active {
    background-color: #138496;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover, .btn-success:active {
    background-color: #218838;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover, .btn-warning:active {
    background-color: #e0a800;
}

/* =====================================================
   RATING SYSTEM
   ===================================================== */

.rating-title {
    font-size: 18px;
    margin-bottom: 15px;
}

.rating-group {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.rating-group label {
    cursor: pointer;
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s;
    display: block;
}


.rating-group label span {
    margin-left: 8px;
}

.rating-group input[type="radio"] {
    display: none;
}

.rating-group input[type="radio"]:checked + span {
    font-weight: bold;
    color: #388E3C;
}

.rating-group label:hover, .rating-group label:active {
    background-color: #f0f0f0;
}

.rating-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* =====================================================
   MODALS
   ===================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    padding: 20px;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    text-align: center;
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    color: #495057;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover, .close:active {
    color: #333;
}

.modal-title {
    font-size: 24px;
    margin-bottom: 20px;
}

/* =====================================================
   LOADING SPINNER
   ===================================================== */

.loader, .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content {
    text-align: center;
    padding: 40px;
    max-width: 300px;
}

/* =====================================================
   QUESTION STYLES
   ===================================================== */

.question-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.question-label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
    font-size: 1.05em;
}

#feedbackText {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.char-count {
    text-align: right;
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
}


/* =====================================================
   SNAKE BACKGROUND ANIMATION
   ===================================================== */

.modal-content.with-snake-bg {
    position: relative; 
    overflow: hidden; 
}

.modal-content.with-snake-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.03;
    pointer-events: none;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 19px, #ddd 19px, #ddd 20px),
        repeating-linear-gradient(90deg, transparent, transparent 19px, #ddd 19px, #ddd 20px);
    background-size: 20px 20px;
    z-index: 0;
}

.snake-canvas-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.15;
    z-index: 1;
}

.modal-content.with-snake-bg > *:not(.snake-canvas-bg) {
    position: relative;
    z-index: 10;
}

/* je li potreban? */
.modal-title {
    position: relative;
    z-index: 10;
}

/* =====================================================
   WELCOME INSTRUCTIONS
   ===================================================== */

.welcome-instructions {
    color: #495057;
    text-align: left;
}

.welcome-instructions strong {
    display: block;
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #495057;
    font-weight: 700;
}

.welcome-instructions .bullet {
    color: grey;
    font-weight: bold;
    margin-right: 8px;
}

.welcome-instructions p {
    margin: 10px 0;
}

/* =====================================================
   ACCESSIBILITY
   ===================================================== */

.btn:focus, button:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* =====================================================
   RESPONSIVE - MOBILE ADAPTATIONS
   Media queries samo za mobile prilagodbe
   ===================================================== */

/* Tablets (768px and down) */
@media (max-width: 768px) {
    /* Za mobile - sakrij desktop kontrole */
    .desktop-only {
        display: none;
    }

    .modal-content.with-snake-bg {
        /* position: fixed;  */
        overflow: inherit;
    }

    .welcome-instructions p {
        margin: 8px 0;
    }
    .welcome-instructions strong{
        font-size: 1.1em;
        margin-bottom: 12px;
    }
    
    .welcome-instructions {
        font-size: 0.95em;
    }

    .char-count {
        font-size: 0.8em;
    }

    .loading-content {
        padding: 30px 20px;
    }

    .modal-title {
        font-size: 1.3em;
        margin-bottom: 15px;
    }

    .rating-title {
        font-size: 16px;
    }

    .game-info{
        margin-top: 8px;
        max-width: 100%;
    }

    canvas {
        max-width: 100%; /* Ne prekoračuj širinu ekrana */
        height: auto;
    }

    .progress-info {
        font-size: 12px;
    }

    .game-container {
        padding: 0 5px;
    }

    .level-header {
        max-width: 100%;
    }

    .container {
        padding: 0 10px;
    }
    
    .main-header h2 {
        font-size: 1.4rem;
    }
    
    .edition-badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.5rem;
    }

    .modal-header {
        align-items: flex-start;
        padding-bottom: 12px;
        margin-bottom: 15px;
    }

    .modal-content {
        width: 90%;
        margin: 5% auto;
    }
}

/* Mobile (600px and down) */
@media (max-width: 600px) {
    body {
        padding: 3px;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .main-header h2 {
        font-size: 1.2rem;
        gap: 0.3rem;
    }
    
    .level-name {
        font-size: 1.2em;
    }
    
    .score-display {
        font-size: 16px;
    }
    
    .controls {
        font-size: 12px;
        padding: 0 10px;
    }
    
    /* Stack buttons vertically on mobile */
    .action-buttons {
        gap: 8px;
        margin-top: 10px;
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }
    
    button, .btn {
        width: 100%;
        min-height: 44px; /* Touch-friendly */
        padding: 12px 16px;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .rating-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .rating-group label {
        padding: 12px 15px;
        width: 100%;
        box-sizing: border-box;
        border: 2px solid #ddd;

        /* border-radius: 6px;
        align-items: center;
        justify-content: center; */
    }
    
    .rating-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .rating-buttons button {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
        padding: 15px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    .modal-header h2 {
        font-size: 1.2em;
    }
    
    .close {
        font-size: 32px;
        padding: 5px 10px;
        margin: -5px -10px -5px 0;
    }
    
    .question-section {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .question-label {
        font-size: 0.95em;
    }
    
    #feedbackText {
        padding: 12px;
        font-size: 14px;
        min-height: 80px;

        border: 2px solid #ddd;
        border-radius: 6px;
    }
    
    .footer-logo {
        margin-top: 20px;
        padding: 15px;
    }
    
    .footer-logo a {
        font-size: 0.85em;
        gap: 8px;
    }
    
    .footer-logo img {
        height: 25px;
    }
}


/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        margin: 10px auto;
        max-height: calc(100vh - 20px);
    }
    
    .modal-header {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    
    button, .btn {
        padding: 8px 16px;
        min-height: 36px;
    }
}

/* Very small screens (374px and down) */
@media (max-width: 374px) {
    body {
        padding: 2px;
    }
    
    .container {
        padding: 0 5px; 
        
    }
    
    .main-header h2 {
        font-size: 1.1rem;
    }
    
    .level-name {
        font-size: 1.1em;
    }
    
    button, .btn {
        font-size: 13px;
    }
}
