body {
    margin: 0;
    padding: 0;
    background-color: #0055ff; /* Blue background */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Arial Black', Impact, sans-serif; /* Cartoonish chunky font */
    overflow: hidden;
}
#game-container {
    position: relative;
    width: 100vw;
    max-width: 1024px;
    height: 100vh;
    max-height: 768px;
    border: 4px solid #333;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e8dcc4; /* Sepia base */
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#health-bar {
    position: absolute;
    top: 5%;
    left: 5%;
    font-size: clamp(16px, 3vw, 28px);
    color: #cc3333; /* Faded red */
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000; /* Cartoon outline */
    font-weight: 900;
    letter-spacing: 2px;
}

#score {
    position: absolute;
    top: 5%;
    right: 5%;
    font-size: clamp(16px, 3vw, 28px);
    color: #e8dcc4; /* Parchment white */
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    font-weight: 900;
    letter-spacing: 2px;
}

#level-display {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(20px, 4vw, 36px);
    color: #dfb238; /* Vintage gold/yellow */
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
}

#boss-ui {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 400px;
    text-align: center;
}

#boss-name {
    color: #fff;
    font-size: clamp(16px, 3vw, 24px);
    margin-bottom: 5px;
    text-shadow: 2px 2px 0 #000;
    font-weight: bold;
    text-transform: uppercase;
}

#boss-hp-bar-bg {
    width: 100%;
    height: 20px;
    background: #333;
    border: 2px solid #fff;
    border-radius: 10px;
    overflow: hidden;
}

#boss-hp-bar {
    width: 100%;
    height: 100%;
    background: #cc3333; /* Faded vintage red */
    transition: width 0.2s;
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 1000;
    pointer-events: auto;
    overflow-y: auto;
    padding: 20px 0;
    box-sizing: border-box;
}

#game-over h1 {
    color: #ff3366;
    margin: 0 0 10px 0;
    font-size: clamp(32px, 6vw, 48px);
    text-shadow: 2px 2px 0 #000;
}

#game-over p {
    color: #fff;
    font-size: clamp(16px, 3vw, 24px);
    margin: 0 0 20px 0;
}

#level-complete {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: #e8dcc4;
    padding: clamp(20px, 4vw, 40px);
    border: 6px solid #4a5c68;
    box-shadow: 0 0 0 10px #333, inset 0 0 20px rgba(0,0,0,0.5);
    border-radius: 10px;
    width: 80%;
    max-width: 500px;
}

#level-complete h1 {
    color: #4a8b75;
    margin: 0 0 10px 0;
    font-size: clamp(32px, 6vw, 48px);
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

#level-complete p {
    color: #333;
    font-size: clamp(16px, 3vw, 24px);
    margin: 0 0 20px 0;
    font-weight: bold;
}

.restart-btn {
    pointer-events: auto;
    background: #00ffcc;
    color: #000;
    font-size: clamp(16px, 3vw, 24px);
    font-weight: bold;
    padding: clamp(10px, 2vw, 20px);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.5);
}
.restart-btn:active {
    transform: scale(0.95);
}

.hidden {
    display: none !important;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10; /* Ensure on top */
}

.mbtn {
    pointer-events: auto; 
    background: rgba(0, 40, 60, 0.6);
    border: 2px solid #0ff;
    color: #0ff;
    font-weight: bold;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    outline: none;
}
.mbtn:active {
    background: rgba(0, 255, 255, 0.5);
    color: #fff;
}

#dpad {
    position: absolute;
    bottom: 10%;
    left: 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.dpad-row {
    display: flex;
    justify-content: center;
}
.dbtn {
    width: 15vmin;
    height: 15vmin;
    min-width: 75px;
    min-height: 75px;
    margin: 5px;
    font-size: 6vmin;
    border-radius: 10px;
}
#m-up { margin-bottom: 0; }

#action-buttons {
    position: absolute;
    bottom: 5%;
    right: 5%;
    width: 60vmin;
    height: 60vmin;
    max-width: 300px;
    max-height: 300px;
}
.abtn {
    position: absolute;
    width: 15vmin;
    height: 15vmin;
    min-width: 60px;
    min-height: 60px;
    max-width: 80px;
    max-height: 80px;
    border-radius: 50%;
    font-size: clamp(12px, 3vmin, 18px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* Diamond Layout Responsive */
#m-jump { bottom: 0; left: 50%; transform: translateX(-50%); } 
#m-shoot { top: 50%; left: 0; transform: translateY(-50%); } 
#m-dash { top: 0; left: 50%; transform: translateX(-50%); } 
#m-lock { top: 50%; right: 0; transform: translateY(-50%); }

/* --- ANA SAYFA BUTONU --- */
#home-link-fixed {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20000;
    text-decoration: none;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.95), rgba(184, 56, 75, 0.95));
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.5px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.5), inset 0 2px 4px rgba(255,255,255,0.4);
    pointer-events: auto;
    touch-action: manipulation;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

#home-link-fixed:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.7), inset 0 2px 8px rgba(255,255,255,0.6);
    border-color: #fff;
    color: #ffeb3b;
}

#home-link-fixed:active {
    transform: translateY(1px) scale(0.95);
}

@media (max-width: 768px) { 
    #home-link-fixed { font-size: 11px; padding: 8px 12px; top: 15px; right: 15px; } 
}

/* --- CUPHEAD STYLE DEATH CARD --- */
#death-card {
    background: #e8dcc4; /* Vintage parchment */
    border: 4px solid #4a5c68; /* Inner blue-grey border */
    outline: 6px solid #e8dcc4;
    box-shadow: 0 0 0 10px #333, inset 0 0 20px rgba(0,0,0,0.5), 0 20px 50px rgba(0,0,0,0.8);
    width: 90%;
    max-width: 400px;
    padding: clamp(15px, 4vw, 30px);
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin: auto;
    /* Noise texture overlay */
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
    transform: scale(0.9); /* slight scale down for mobile fit */
}

@media (max-width: 480px) {
    #death-card {
        transform: scale(0.85);
        box-shadow: 0 0 0 6px #333, inset 0 0 10px rgba(0,0,0,0.5);
    }
}

.death-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: #a9a896; /* Darker vintage circle */
    border: 3px solid #333;
    margin-bottom: 10px;
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
}

.death-quote {
    font-family: 'Georgia', serif;
    font-size: clamp(14px, 3.5vw, 18px);
    font-style: italic;
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    padding: 0 10px;
    line-height: 1.4;
    text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
}

#death-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.death-progress {
    width: 90%;
    position: relative;
    height: 60px;
    margin-bottom: 20px;
}

.progress-line {
    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
}

.progress-markers {
    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;
    height: 25px;
}

.marker {
    position: absolute;
    bottom: 0;
    width: 4px;
    height: 15px;
    background: #333;
}
.m-start { left: 0%; }
.m-mid { left: 50%; }
.m-end { left: 100%; }

.progress-flag {
    position: absolute;
    right: -10px;
    bottom: 5px;
    font-size: 24px;
}

.progress-player {
    position: absolute;
    bottom: 12px;
    left: 0%; /* Dynamic */
    transform: translateX(-50%);
    transition: left 1s ease-out;
}

#death-player-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--player-color, #ff7700); /* Will be set via JS */
    border: 2px solid #000;
    box-shadow: 2px 2px 0 #b00;
}

.death-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.death-btn {
    font-family: 'Arial Black', Impact, sans-serif;
    font-size: 24px;
    font-weight: 900;
    color: #333;
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.1s, color 0.1s;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.death-btn:first-child {
    color: #b00;
}

.death-btn:hover {
    transform: scale(1.1);
    color: #000;
}
.death-btn:first-child:hover {
    color: #f00;
}

.death-footer {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    font-family: serif;
    font-size: 10px;
    color: #555;
    text-transform: uppercase;
    border-top: 1px solid #999;
    padding-top: 5px;
}

/* --- MUU STUDIO CINEMATIC INTRO --- */
#intro-cinematic {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: #f1c40f; /* Sarı ekran */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.intro-word {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}
.intro-letter {
    font-family: 'Georgia', 'Brush Script MT', serif; /* Süslü harfler */
    font-size: clamp(80px, 15vw, 150px);
    font-weight: bold;
    color: #2c3e50;
    text-shadow: 6px 6px 0px white;
}
#intro-m { transform: translateX(-100vw); animation: introLeft 1s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
#intro-h { transform: translateY(-100vh); animation: introTop 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards; }
#intro-u2 { transform: translateX(100vw); animation: introRight 1s cubic-bezier(0.25, 1, 0.5, 1) forwards; }

#intro-studio {
    font-family: 'Arial', sans-serif;
    font-size: clamp(20px, 5vw, 40px);
    font-weight: bold;
    color: white;
    letter-spacing: 20px;
    text-shadow: 2px 2px 0px #2c3e50;
    transform: translateY(100vh);
    opacity: 0;
    animation: introBottom 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards 0.5s; /* 0.5s gecikmeli gelsin */
}

@keyframes introLeft { to { transform: translateX(0); } }
@keyframes introRight { to { transform: translateX(0); } }
@keyframes introTop { to { transform: translateY(0); } }
@keyframes introBottom { to { transform: translateY(0); opacity: 1; } }

#story-cinematic {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.story-content {
    background: rgba(20, 20, 25, 0.8);
    border: 3px solid #e74c3c;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 0 30px #c0392b;
    max-width: 900px;
    width: 90%;
}
.story-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.5);
    transition: transform 0.1s, box-shadow 0.1s;
}
.story-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 rgba(0,0,0,0.5);
}

/* Mobile/iPad Scaling for Shop and Story Box */
@media (max-width: 1024px) {
    #shop-modal {
        transform: translate(-50%, -50%) scale(0.85) !important;
    }
    .story-content {
        transform: scale(0.9);
    }
}
@media (max-width: 768px) {
    #shop-modal {
        transform: translate(-50%, -50%) scale(0.7) !important;
    }
    #story-image {
        max-height: 200px !important;
    }
    #story-text {
        font-size: 18px !important;
    }
    .story-content {
        padding: 20px !important;
    }
}
@media (max-width: 480px), (max-height: 500px) {
    #shop-modal {
        transform: translate(-50%, -50%) scale(0.55) !important;
    }
    #story-image {
        max-height: 120px !important;
        margin-bottom: 10px !important;
    }
    #story-text {
        font-size: 14px !important;
        min-height: 50px !important;
    }
    .story-content {
        padding: 10px !important;
        border-width: 2px !important;
    }
    .story-btn {
        padding: 8px 15px !important;
        font-size: 14px !important;
    }
}

/* NEW MOBILE SHOP LAYOUT */
@media (max-width: 768px), (max-height: 600px) {
    #shop-modal {
        transform: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border: none !important;
        border-radius: 0 !important;
    }
    #shop-modal > div:last-child {
        flex-direction: column !important;
        overflow-y: auto !important;
    }
    #shop-modal > div:last-child > div {
        flex: none !important;
        width: 100% !important;
        padding: 10px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    #merchant-canvas {
        width: 100% !important;
        height: 150px !important;
        object-fit: cover;
    }
    .shop-item-btn {
        font-size: 14px !important;
        padding: 5px !important;
    }
}
