:root {
    --primary-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --canvas-border: rgba(148, 163, 184, 0.2);
    --accent-color: #38bdf8;
    --text-color: #f8fafc;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Press Start 2P', cursive;
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    overflow: hidden;
}

.game-container {
    position: relative;
    border-radius: 8px;
    /* Sharper edges for pixel style */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 4px solid var(--canvas-border);
}

canvas {
    display: block;
    background: #000;
    image-rendering: pixelated;
    /* Sharp pixel art rendering */
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1rem;
    text-align: center;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 1rem;
    width: 100%;
}

.stats-left {
    text-align: left;
}

#scoreDisplay,
#levelDisplay,
#emeraldDisplayUI {
    font-size: 1.1rem;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.5rem;
}

#levelDisplay {
    color: #ffcc00;
}

#emeraldDisplayUI {
    color: #00ffaa;
}

.pixel-btn {
    pointer-events: auto;
    font-family: 'Press Start 2P', cursive;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background: #22c55e;
    color: white;
    border: 4px solid #166534;
    cursor: pointer;
    margin: 0.5rem;
    transition: transform 0.1s;
    box-shadow: 0 6px 0 #166534;
}

.pixel-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #166534;
}

.pixel-btn.secondary {
    background: #0ea5e9;
    border-color: #075985;
    box-shadow: 0 6px 0 #075985;
}

.pixel-btn.small {
    padding: 0.6rem 1.2rem;
    font-size: 0.8rem;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.hint {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 1rem;
}

/* Character Selection Screen - Premium Styles */
.char-select-screen {
    width: 95% !important;
    max-width: 900px;
    padding: 2rem 1rem !important;
}

.char-list {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.char-card {
    background: rgba(15, 23, 42, 0.8);
    border: 4px solid #334155;
    padding: 1rem;
    width: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    cursor: pointer;
    position: relative;
}

.char-card:hover {
    transform: translateY(-10px) scale(1.05);
    border-color: #38bdf8;
    box-shadow: 0 10px 30px rgba(56, 189, 248, 0.3);
}

.char-card.active {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.char-img-container {
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    image-rendering: pixelated;
}

.char-img-container img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.char-card h3 {
    font-size: 0.8rem;
    color: #fff;
    margin-bottom: 0.8rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    text-align: center;
}

.char-desc {
    font-size: 0.6rem;
    color: #94a3b8;
    margin-bottom: 1.2rem;
    height: 1.5rem;
    line-height: 1.4;
}

.select-btn {
    pointer-events: auto;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    padding: 0.6rem;
    width: 100%;
    cursor: pointer;
    border: 3px solid #075985;
    background: #0ea5e9;
    color: white;
    transition: 0.2s;
    box-shadow: 0 4px 0 #075985;
}

.select-btn:hover:not(:disabled) {
    background: #38bdf8;
}

.select-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #075985;
}

.select-btn:disabled {
    background: #64748b;
    border-color: #334155;
    box-shadow: 0 4px 0 #1e293b;
    cursor: not-allowed;
}

.char-card.locked {
    filter: grayscale(1) opacity(0.5);
    cursor: not-allowed;
}

.char-card.hide {
    display: none;
}

.screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    border: 4px solid var(--accent-color);
    padding: 2.5rem;
    text-align: center;
    width: 70%;
    animation: pulse 1.5s infinite steps(2);
    /* Steppy animation for pixel feel */
    background-size: cover;
    background-position: center;
}

#creditsScreen {
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('görseller/background 2.jpg');
    background-size: cover;
    background-position: center;
}

.screen.hide {
    display: none;
}

.screen.show {
    display: block;
}

.screen h2 {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    text-shadow: 4px 4px 0px var(--accent-color);
    line-height: 1.4;
}

.screen p {
    font-size: 1rem;
    line-height: 1.6;
}

.score-board {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border: 2px dashed var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    text-align: left;
}

.score-details p {
    font-size: 1.2rem;
    margin: 0.8rem 0;
}

.medal-box {
    font-size: 4rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 90px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.2), 0 0 10px rgba(0, 0, 0, 0.5);
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
}

.screen span {
    color: var(--accent-color);
    font-weight: 700;
}

.screen span.number {
    color: #ffcc00;
}

.level-up-popup {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    text-align: center;
    pointer-events: none;
    width: 100%;
}

.level-up-popup h1 {
    font-size: 3rem;
    color: #ffcc00;
    text-shadow: 6px 6px 0px #000;
    margin-bottom: 1rem;
    animation: levelUpPop 2s forwards;
}

.level-up-popup h2 {
    font-size: 2rem;
    color: #fff;
    text-shadow: 4px 4px 0px #000;
    animation: levelUpPop 2s forwards;
}

.level-up-popup.hide {
    display: none;
}

@keyframes levelUpPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    20% {
        transform: scale(1.2);
        opacity: 1;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }

    80% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
}

.hp-container-mini {
    width: 200px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    margin-top: 5px;
    overflow: hidden;
    pointer-events: auto;
}

.hp-bar-fill {
    width: 100%;
    height: 100%;
    background: #22c55e;
    transition: width 0.3s ease;
}

.hp-bar-fill.boss-fill {
    background: #ef4444;
}

.pixel-switch {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    cursor: pointer;
    pointer-events: auto;
}

.pixel-switch input {
    margin-left: 10px;
}

/* Mobile Responsiveness & Layout Fixes */
@media (max-width: 850px) {
    body {
        margin: 0;
        padding: 0;
    }
    .game-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border: none;
        border-radius: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #000;
    }
    canvas {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    
    .screen {
        width: 95%;
        padding: 1.5rem;
    }
    .screen h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    .pixel-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    .char-card {
        width: 100%;
        max-width: 250px;
    }
    .char-list {
        flex-wrap: wrap;
        overflow-y: auto;
        max-height: 50vh;
    }
    .ui-overlay {
        padding: 1rem;
    }
    #scoreDisplay, #levelDisplay, #emeraldDisplayUI {
        font-size: 0.9rem;
    }
}

/* Landscape / Portrait Warning Overlay */
@media (orientation: portrait) and (pointer: coarse) {
    /* If the device is in portrait mode on mobile */
    #landscapeWarning {
        display: flex !important;
    }
}

#landscapeWarning {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
}
#landscapeWarning h2 {
    color: #ef4444;
    text-shadow: 2px 2px 0px #000;
    margin-bottom: 1rem;
}

/* Virtual Joystick */
#joystickZone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 150px;
    z-index: 50;
    pointer-events: none; /* Only JS will bind to it directly or we bind to canvas */
}
#joystickZone.hide {
    display: none !important;
}
#joystickBase {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255,255,255,0.4);
    position: relative;
    top: 15px;
    left: 15px;
}
#joystickKnob {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    position: absolute;
    top: 35px;
    left: 35px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}