:root {
    --primary-color: #ff5722;   /* Яскраво-помаранчевий */
    --secondary-color: #4caf50; /* Зелений тропічний */
    --bg-color: #03a9f4;        /* Небо */
    --text-color: #ffffff;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #111;
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none; /* Забороняємо стандартні жести на мобільних пристроях */
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 600px;
    background: linear-gradient(180deg, var(--bg-color) 0%, #bbdefb 100%);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Щоб кліки проходили на canvas */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#controls-top-left {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    left: max(20px, env(safe-area-inset-left));
    display: flex;
    gap: 15px;
    z-index: 100;
    pointer-events: auto;
}

#score-display, #level-display, #lives-display {
    position: absolute;
    left: max(20px, env(safe-area-inset-left));
    font-size: 24px;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    z-index: 10;
    transition: opacity 0.3s ease;
}

#score-display {
    top: max(20px, env(safe-area-inset-top));
}

#level-display {
    top: calc(max(20px, env(safe-area-inset-top)) + 40px);
    color: #FFD54F;
}

#lives-display {
    top: calc(max(20px, env(safe-area-inset-top)) + 80px);
    font-size: 20px;
}

#score-display.hidden, #level-display.hidden, #lives-display.hidden, #coins-display.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.screen {
    position: relative; /* Щоб flexbox його центрував */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 12px;
    text-align: center;
    color: var(--text-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    pointer-events: auto; /* Відновити кліки для меню */
    width: 95%;
    max-width: 750px;
    max-height: 95%; /* Не даємо вилізти за межі екрану */
    overflow-y: auto; /* Дозволяємо прокрутку, якщо не влазить */
    touch-action: pan-y; /* Дозволяємо скролл пальцем на iOS */
    transition: opacity 0.3s ease;
    z-index: 1100;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

#orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    transform: none;
    text-align: center;
    padding: 20px;
}

#orientation-warning h2 {
    color: #ffeb3b;
    font-size: 28px;
    margin-bottom: 15px;
}

@media screen and (max-width: 768px) and (orientation: portrait) {
    #orientation-warning {
        display: flex !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Адаптація під мобільні екрани */
@media (max-width: 600px), (max-height: 650px) {
    .screen {
        width: 95%;
        padding: 8px;
        max-height: 98%;
    }
    .screen h1 {
        font-size: 20px;
        margin-bottom: 4px;
    }
    .screen h2 {
        font-size: 18px;
        margin-bottom: 4px;
    }
    .instructions {
        font-size: 11px;
        padding: 4px;
        margin: 4px 0;
        gap: 2px 10px;
    }
    .instructions p {
        margin: 0;
        min-width: 140px;
        flex: 1 1 45%;
    }
    .screen > p {
        font-size: 12px;
        margin-bottom: 3px;
    }
    .character-select {
        margin: 4px 0 6px 0;
    }
    .character-select h3 {
        font-size: 11px;
        margin-bottom: 3px;
    }
    .birds-container {
        flex-wrap: wrap;
        overflow-x: visible;
        justify-content: center;
        padding: 5px;
    }
    .birds-container::-webkit-scrollbar {
        display: none;
    }
    .bird-option {
        padding: 4px 2px;
        width: 65px;
        flex-shrink: 0;
    }
    .bird-option canvas {
        width: 32px;
        height: 32px;
        margin-bottom: 2px;
    }
    .bird-option span {
        font-size: 10px;
    }
    button {
        padding: 8px 16px;
        font-size: 15px;
        margin-bottom: 5px;
    }
    #mute-btn, #pause-btn, #quest-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    #controls-top-right {
        gap: 10px;
    }
    #score-display {
        font-size: 18px;
    }
    #lives-display {
        font-size: 16px;
        top: calc(max(20px, env(safe-area-inset-top)) + 28px);
    }
    #quest-display {
        font-size: 14px;
        bottom: 15px;
        left: 15px;
        padding: 5px 10px;
    }
    #coins-display {
        font-size: 16px;
        bottom: 65px;
        left: 15px;
        padding: 5px 10px;
    }
    #lives-display {
        top: calc(max(20px, env(safe-area-inset-top)) + 82px);
    }
}

#quest-display, #coins-display {
    position: absolute;
    left: max(20px, env(safe-area-inset-left));
    font-weight: bold;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    z-index: 10;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 15px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

#quest-display {
    bottom: max(20px, env(safe-area-inset-bottom));
    font-size: 18px;
    color: #ffeb3b; /* Золотистий */
}

#coins-display {
    bottom: calc(max(20px, env(safe-area-inset-bottom)) + 50px);
    font-size: 20px;
    color: #FFD700; /* Gold */
}

#quest-display.hidden, #coins-display.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

#quest-display.complete {
    transform: scale(1.1);
    background: rgba(76, 175, 80, 0.6); /* Зелений при виконанні */
}

.screen h1 {
    font-size: 30px;
    margin-bottom: 6px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    color: #ffeb3b; 
}

.screen h2 {
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    color: #ff5252;
}

.instructions-modal-content {
    margin: 15px 0;
    font-size: 15px;
    line-height: 1.6;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 12px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    text-align: left;
}

.instructions-modal-content p {
    margin-bottom: 8px;
}

#how-to-play-btn {
    z-index: 10;
    font-size: 24px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background-color 0.2s;
    text-transform: none;
}

#how-to-play-btn:hover {
    background-color: rgba(255,255,255,0.5);
    transform: scale(1.1);
}

#how-to-play-btn.hidden {
    display: none;
}

.screen > p {
    font-size: 14px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.instructions {
    margin: 4px 0;
    font-size: 13px;
    line-height: 1.4;
    background: rgba(0,0,0,0.3);
    padding: 6px;
    border-radius: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 15px;
}

.instructions p {
    margin: 0;
    min-width: 200px;
    flex: 1 1 40%;
}

.character-select {
    margin: 10px 0 15px 0;
}

#start-coins-display {
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-block;
    margin: 10px 0;
    font-weight: bold;
    color: #FFD700;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.character-select h3 {
    margin-bottom: 8px;
    font-size: 14px;
    color: #ffd54f;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.birds-container {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.bird-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: rgba(0,0,0,0.4);
    padding: 4px 2px;
    width: 80px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    word-break: break-word;
}

.bird-option canvas {
    width: 36px;
    height: 36px;
    margin-bottom: 2px;
    pointer-events: none; /* Щоб не перехоплювали кліки */
}

.acc-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: rgba(0,0,0,0.4);
    padding: 8px 4px;
    width: 80px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    word-break: break-word;
}

.acc-option .acc-icon {
    font-size: 32px;
    margin-bottom: 5px;
    line-height: 1;
}

.acc-option:hover {
    background: rgba(255,255,255,0.2);
}

.acc-option.selected {
    border-color: #ffeb3b;
    background: rgba(255,255,255,0.25);
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    transform: scale(1.05);
}

.acc-option.locked {
    filter: grayscale(0.9);
    opacity: 0.7;
    position: relative;
}

.acc-option.locked::after {
    content: '🔒';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
}

.acc-option.unlocked .price-tag {
    display: none;
}

.bird-option:hover {
    background: rgba(255,255,255,0.2);
}

.bird-option.selected {
    border-color: #ffeb3b;
    background: rgba(255,255,255,0.25);
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    transform: scale(1.05);
}

.bird-option.locked {
    filter: grayscale(0.9);
    opacity: 0.7;
    position: relative;
}

.bird-option.locked::after {
    content: '🔒';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
}

.price-tag {
    margin-top: 4px;
    font-size: 9px;
    background: rgba(255, 215, 0, 0.2);
    padding: 2px 4px;
    border-radius: 4px;
    color: #fff;
}

.bird-option.unlocked .price-tag {
    display: none;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 87, 34, 0.4);
    transition: transform 0.2s, background-color 0.2s;
    text-transform: uppercase;
}

button:hover {
    background-color: #e64a19;
    transform: scale(1.05);
}

button:active {
    transform: scale(0.95);
}

@media (pointer: coarse) {
    button {
        padding: 18px 36px;
        min-height: 50px;
    }
}


#controls-top-right {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    display: flex;
    flex-direction: row-reverse;
    gap: 15px;
    z-index: 100;
    pointer-events: auto;
}

#mute-btn {
    z-index: 10;
    font-size: 24px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background-color 0.2s;
    text-transform: none; /* Відміняємо капслок для емодзі */
}

#mute-btn:hover {
    background-color: rgba(255,255,255,0.5);
    transform: scale(1.1);
}

#pause-btn {
    z-index: 10;
    font-size: 24px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background-color 0.2s;
    text-transform: none;
}

#pause-btn.hidden {
    display: none;
}

#pause-btn:hover {
    background-color: rgba(255,255,255,0.5);
    transform: scale(1.1);
}

#quest-btn {
    z-index: 10;
    font-size: 24px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    padding: 0;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, background-color 0.2s;
    text-transform: none;
}

#quest-btn.hidden {
    display: none;
}

#quest-btn:hover {
    background-color: rgba(255,255,255,0.5);
    transform: scale(1.1);
}

/* Quest Log Styles */
#quest-log-content {
    margin: 20px 0;
    text-align: left;
}

.quest-item {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 12px;
    margin-top: 10px;
}

.quest-item span {
    font-size: 18px;
    font-weight: bold;
    color: #ffeb3b;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: #444;
    border-radius: 6px;
    margin: 10px 0;
    overflow: hidden;
}

#quest-log-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    transition: width 0.3s ease;
}

#quest-log-progress-text {
    font-size: 14px;
    text-align: right;
    margin: 0;
}

@media (max-width: 430px) {
    .coin-text {
        font-size: 13px;
    }
}

@media (max-width: 600px), (max-height: 500px) {
}
#game-version {
    position: absolute;
    bottom: 5px;
    right: 8px;
    font-size: 11px;
    opacity: 0.5;
    font-family: monospace;
    color: #fff;
    text-shadow: 1px 1px 1px #000;
    pointer-events: none;
    z-index: 9999;
}
