* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#hud {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 10px;
    z-index: 10;
    pointer-events: none;
}

#player-info {
    display: flex;
    justify-content: space-between;
    width: 230px;
    margin-bottom: 8px;
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 5px;
    align-self: flex-end;
    flex-wrap: wrap;
}

#sprint-indicator {
    color: #00ff00;
    font-size: 12px;
    animation: pulse 1s infinite;
    width: 100%;
    text-align: center;
    margin-top: 2px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#quest-tracker {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    background-color: rgba(0, 40, 80, 0.9);
    border: 2px solid #4CAF50;
    border-radius: 10px;
    padding: 15px;
    color: white;
    font-size: 14px;
    z-index: 90;
}

#quest-tracker h3 {
    margin: 0 0 10px 0;
    color: #4CAF50;
    font-size: 16px;
    text-align: center;
}

#current-objective {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    border-left: 3px solid #4CAF50;
}

#quest-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

#quest-counter {
    color: #ffcc00;
    font-weight: bold;
}

#quest-hint {
    color: #ccc;
    font-style: italic;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

#block-info {
    position: absolute;
    top: 120px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: 5px;
    max-width: 250px;
    pointer-events: auto;
    z-index: 100;
    border: 2px solid #ffcc00;
}

#block-name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #ffcc00;
}

#block-properties {
    font-size: 12px;
    line-height: 1.3;
}

#inventory {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 300px;
    pointer-events: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 15px 5px 5px 5px;
    border-radius: 5px;
    margin-top: 10px;
}

.inventory-slot {
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #555;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    position: relative;
}

.inventory-slot::after {
    content: attr(data-key);
    position: absolute;
    top: -12px;
    right: -2px;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.9);
    color: #ffcc00;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: normal;
    border: 1px solid #ffcc00;
    min-width: 8px;
    text-align: center;
}

.inventory-slot.selected {
    border-color: #ffcc00;
    transform: translateY(-2px);
    background-color: rgba(0, 0, 0, 0.9);
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.7);
}

#equation-builder {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 5px;
}

#game-controls {
    margin-top: 10px;
    display: flex;
    gap: 5px;
    pointer-events: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 5px;
}

#game-controls button {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid #ffcc00;
    padding: 5px 10px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 3px;
}

#current-equation {
    color: white;
    font-size: 14px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 5px 8px;
    border-radius: 3px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid #ffcc00;
}

#check-equation {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    border: 1px solid white;
}

#game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Usunięto background-color */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

#start-screen, #math-challenge, #level-complete {
    background-color: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    color: white;
    max-width: 80%;
    border: 3px solid #ffcc00;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

h1 {
    font-size: 3em;
    margin-bottom: 20px;
    color: #ffcc00;
}

h2 {
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #ffcc00;
}

button {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin: 10px 0;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #45a049;
}

.instructions {
    margin-top: 20px;
    text-align: left;
    padding: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.instructions h2 {
    margin-top: 15px;
    color: #ffcc00;
    text-align: center;
}

.instructions ol {
    padding-left: 30px;
    margin: 10px 0;
}

.instructions li {
    margin-bottom: 8px;
}

.hidden {
    display: none;
}

#challenge-question {
    font-size: 2em;
    margin: 20px 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.modal-header h2 {
    margin: 0;
    flex-grow: 1;
}

.close-button {
    background: #ff4444;
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    transition: background-color 0.2s;
}

.close-button:hover {
    background: #ff6666;
}

.challenge-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.challenge-buttons button {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#submit-answer {
    background: #4CAF50;
    color: white;
}

#submit-answer:hover {
    background: #45a049;
}

#skip-challenge {
    background: #666;
    color: white;
}

#skip-challenge:hover {
    background: #777;
}

#challenge-answer {
    padding: 10px;
    font-size: 18px;
    border: 2px solid #333;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    width: 200px;
    margin: 10px 0;
}

#challenge-answer:focus {
    outline: none;
    border-color: #4CAF50;
    background: rgba(255, 255, 255, 0.2);
}

.equation-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.equation-controls button {
    padding: 8px 16px;
    font-size: 14px;
}

#clear-equation {
    background: #f44336;
}

#clear-equation:hover {
    background: #e53935;
}

#equation-feedback {
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
    font-weight: bold;
}

#equation-feedback.success {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4CAF50;
    color: #4CAF50;
}

#equation-feedback.error {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
    color: #f44336;
}

#equation-feedback.info {
    background: rgba(33, 150, 243, 0.2);
    border: 1px solid #2196F3;
    color: #2196F3;
}

#challenge-answer {
    padding: 10px;
    font-size: 18px;
    width: 100px;
    text-align: center;
    margin-bottom: 10px;
}

/* Dziennik i panel postępów */
#journal, #progress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(51, 51, 51, 0.95);
    width: 80%;
    max-width: 700px;
    max-height: 75vh;
    padding: 15px;
    border-radius: 10px;
    color: white;
    overflow-y: auto;
    z-index: 1000;
    border: 2px solid #ffcc00;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

/* Przycisk zamknięcia dla dziennika i panelu postępów */
#close-journal, #close-progress {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: transparent;
    color: #ffcc00;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 10px;
}

#close-journal:hover, #close-progress:hover {
    color: white;
    background-color: rgba(255, 204, 0, 0.3);
}

.journal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.journal-tab {
    padding: 8px 15px;
    background-color: #555;
    border: none;
    color: white;
    border-radius: 5px;
    cursor: pointer;
}

.journal-tab.active {
    background-color: #ffcc00;
    color: #333;
    font-weight: bold;
}

.journal-page {
    line-height: 1.6;
}

.journal-page h3 {
    color: #ffcc00;
    margin-bottom: 15px;
}

.journal-page h4 {
    color: #4caf50;
    margin: 15px 0 5px;
}

.journal-page ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.hidden {
    display: none;
}

/* Panel postępów */
.progress-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    flex-wrap: wrap;
}

.progress-stat {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    min-width: 150px;
}

.stat-label {
    font-size: 14px;
    display: block;
    margin-bottom: 5px;
    color: #ccc;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #ffcc00;
}

.achievements {
    margin-top: 15px;
}

.achievement {
    margin-bottom: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 5px;
}

.achievement-name {
    display: block;
    margin-bottom: 5px;
}

.achievement-progress-bar {
    height: 10px;
    background-color: #555;
    border-radius: 5px;
    overflow: hidden;
}

.achievement-progress {
    height: 100%;
    background-color: #4caf50;
}

/* Animacja shake dla błędnych odpowiedzi */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.crosshair::before,
.crosshair::after {
    content: "";
    position: absolute;
    background-color: white;
}

.crosshair::before {
    width: 2px;
    height: 20px;
    left: 9px;
    top: 0;
}

.crosshair::after {
    width: 20px;
    height: 2px;
    left: 0;
    top: 9px;
}

/* Responsywne zachowanie dla małych ekranów */
@media screen and (max-width: 768px) {
    #hud {
        bottom: 5px;
        right: 5px;
    }
    
    #quest-tracker {
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 280px;
        padding: 10px;
        font-size: 12px;
    }
    
    #block-info {
        top: 100px;
        left: 10px;
        max-width: 200px;
        padding: 8px;
    }
    
    .inventory-slot {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .inventory-slot::after {
        font-size: 8px;
        padding: 1px 2px;
        top: -10px;
    }
    
    #inventory {
        padding: 12px 3px 3px 3px;
        margin-top: 8px;
    }
    
    #equation-builder, #game-controls {
        margin-top: 5px;
    }
    
    #current-equation {
        max-width: 150px;
        font-size: 12px;
    }
    
    #check-equation, #game-controls button {
        font-size: 12px;
        padding: 4px 8px;
    }
}

/* Przyciski interakcji */
#interaction-buttons {
    position: fixed;
    left: 20px;
    bottom: 10px;
    display: flex;
    gap: 10px;
    z-index: 10;
    pointer-events: auto;
}

#toggle-inventory-btn {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid #ffcc00;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: bold;
}

/* Stan zwinięty */
.hud-collapsed #inventory,
.hud-collapsed #equation-builder,
.hud-collapsed #game-controls {
    display: none;
}

.hud-collapsed #toggle-inventory-btn {
    background-color: rgba(0, 0, 0, 0.5);
}