:root {
    --bg-color: #000;
    --text-color: #eee;
    --accent-color: #e74c3c;
    --xp-color: #3742fa;
    --font-main: 'GameFont', 'Press Start 2P', cursive;
}

/* Define Mixed Font Family */
/* 1. English: Press Start 2P */
@font-face {
    font-family: 'GameFont';
    src: local('Press Start 2P'), url('https://fonts.gstatic.com/s/pressstart2p/v14/e3t4euO8T-267oIAQAu6jDQyK3nVivM.woff2') format('woff2');
    unicode-range: U+0000-007F;
}

/* 2. Korean: NeoDunggeunmo with 130% size adjustment */
@font-face {
    font-family: 'GameFont';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.3/NeoDunggeunmo.woff') format('woff');
    unicode-range: U+AC00-D7A3, U+3130-318F, U+1100-11FF;
    size-adjust: 130%;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: var(--font-main);
    color: var(--text-color);
    user-select: none;
}

/* Canvas is the background layer */
canvas {
    display: block;
    /* Dimensions handled by JS resize() for letterboxing */
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    border: 1px solid #222;
    /* Subtle separation */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><circle cx="16" cy="16" r="12" fill="none" stroke="%23ff0000" stroke-width="2"/><line x1="16" y1="4" x2="16" y2="28" stroke="%23ff0000" stroke-width="2"/><line x1="4" y1="16" x2="28" y2="16" stroke="%23ff0000" stroke-width="2"/></svg>') 16 16, crosshair;
}

/* Base style for all full-screen overlays */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    /* Always above canvas */
    pointer-events: auto;
    /* Capture clicks */
    text-align: center;
}

.hidden {
    display: none !important;
}

/* === Title Screen === */
#start-screen {
    background-image: url('assets/title_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 0 0 2000px rgba(0, 0, 0, 0.5);

    /* Layout Adjustment */
    justify-content: flex-start;
    padding-top: 100px;
    /* Push content down slightly from top, but overall higher than center */
}

h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    line-height: 1.2;
    text-shadow: 4px 4px 0 #000;
    color: #ff4757;
}

.subtitle {
    font-size: 1.5rem;
    color: #f1f2f6;
    display: block;
    margin-top: 10px;
}

.clone-text {
    font-size: 1rem;
    color: #ffd32a;
    display: block;
    margin-top: 10px;
    letter-spacing: 5px;
}

#total-gold-display {
    font-size: 1.2rem;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border: 2px solid #ffd700;
}

.credits {
    position: absolute;
    bottom: 20px;
    font-size: 0.8rem;
    color: #aaa;
}

/* === Buttons === */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 100%;
}

button {
    font-family: 'Press Start 2P', cursive;
    padding: 20px 0;
    width: 300px;
    /* Fixed width */
    font-size: 1.2rem;
    cursor: pointer;
    background: #c0392b;
    color: white;
    border: 4px solid #96281b;
    box-shadow: 6px 6px 0px #000;
    transition: transform 0.1s;
    text-transform: uppercase;
}

button:hover {
    background: #e74c3c;
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0px #000;
}

button:active {
    transform: translate(3px, 3px);
    box-shadow: 3px 3px 0px #000;
}

/* === HUD === */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 50;
    /* Above canvas, below screens */
    pointer-events: none;
    /* Let clicks pass through */
}

#stats {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000;
    color: white;
}

.bar-container {
    width: 100%;
    height: 20px;
    background: #333;
    border: 2px solid #fff;
    margin-bottom: 8px;
}

.bar {
    height: 100%;
    width: 100%;
    background: #ff4757;
    transition: width 0.2s;
}

.bar-container.xp {
    height: 12px;
    margin-top: 5px;
}

.bar-container.xp .bar {
    background: var(--xp-color);
}

/* === Modals === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    /* Highest priority */
    pointer-events: auto;
}

.modal-content {
    background: #2c3e50;
    border: 4px solid #fff;
    box-shadow: 10px 10px 0 #000;
    color: white;
    padding: 30px;
    width: 600px;
    max-width: 90%;
    text-align: center;
}

.setting-item {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

input[type=range] {
    width: 100%;
    cursor: pointer;
}

/* === Upgrades === */
#cards-container {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.card {
    background: #34495e;
    border: 4px solid #fff;
    padding: 20px;
    width: 280px;
    /* Increased width */
    height: 400px;
    /* Fixed larger height */
    cursor: pointer;
    box-shadow: 6px 6px 0 #000;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    transition: transform 0.1s;
}

.card:hover {
    background: #3d566e;
    border-color: #f1c40f;
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0 #000;
}

.card-icon {
    font-size: 6rem;
    margin-bottom: 30px;
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.2);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #fff;
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.card h3 {
    color: #f1c40f;
    font-size: 1.5rem;
    /* Larger Title */
    margin: 0;
    word-break: break-word;
}

.card-level {
    color: #e74c3c;
    font-size: 1.3rem;
    font-weight: bold;
    margin: 5px 0;
}

.card-desc {
    font-size: 1.1rem;
    line-height: 1.5;
    color: #eee;
    white-space: pre-wrap;
}

.victory-text {
    color: #f1c40f;
    animation: pulse 1s infinite alternate;
}

.gold-text {
    color: #ffd700;
    font-size: 1.5rem;
    margin: 20px 0;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

/* Shop Specific */
.shop-content {
    width: 800px;
    /* Wider modal */
    max-width: 95%;
}

#shop-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
}

.shop-item {
    background: #34495e;
    border: 2px solid #ecf0f1;
    padding: 15px;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 4px 4px 0 #000;
}

.shop-item h3 {
    color: #f1c40f;
    font-size: 0.9rem;
    margin: 0;
}

.shop-item p {
    font-size: 0.7rem;
    color: #bdc3c7;
    margin: 0;
}

.shop-item .stat-value {
    color: #2ecc71;
    font-weight: bold;
}

.shop-item button {
    width: 100%;
    padding: 10px;
    font-size: 0.8rem;
    margin-top: auto;
    /* Push to bottom */
}

.max-level {
    color: #e74c3c;
    font-weight: bold;
}

/* === Weapon List HUD === */
/* === Weapon List HUD === */
#weapon-list {
    display: flex;
    gap: 15px;
    /* Increased gap */
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 30px;
    /* Increased margin */
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.weapon-icon {
    width: 48px;
    /* Larger */
    height: 48px;
    /* Larger */
    background: #333;
    border: 3px solid #fff;
    /* Thicker border */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    /* Larger emoji */
    position: relative;
    color: #fff;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* ... existing weapon-level-badge ... */

/* === Duck Screen === */
.duck-title {
    color: #f1c40f;
    font-size: 2.5rem;
    text-shadow: 4px 4px 0 #000;
    margin-bottom: 30px;
    animation: bounce 1s infinite alternate;
}

.mystery-card {
    width: 200px;
    height: 300px;
    background: linear-gradient(135deg, #f1c40f, #e67e22);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    animation: pulse 0.5s infinite alternate;
    position: relative;
    /* For spawning children */
}

/* Pop Out Animation */
.duck-pop-icon {
    position: absolute;
    width: 64px;
    height: 64px;
    font-size: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    animation: popOut 1s forwards ease-out;
    z-index: 2100;
    text-shadow: 0 0 10px white;
}

@keyframes popOut {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.5) rotate(-10deg);
        opacity: 1;
    }

    100% {
        /* Use CSS Variables set in JS for random direction */
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(2) rotate(10deg);
        opacity: 0;
    }
}

#duck-result {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #2ecc71;
    white-space: pre-line;
    line-height: 1.6;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }
}