@font-face {
    font-family: 'ONE Mobile POP';
    src: url('ONE Mobile POP.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body { 
    margin: 0; 
    background-color: #1a2a18; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 100dvh; 
    width: 100vw;
    color: white; 
    font-family: 'ONE Mobile POP', sans-serif; 
    overflow: hidden; 
    touch-action: none; 
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100dvh * (450 / 700));
    max-height: calc(100vw * (700 / 450));
    aspect-ratio: 450 / 700; 
    background-color: #2c4228; 
    box-shadow: 0 0 0 6px #5c3a21, 0 0 50px rgba(0,0,0,0.9); 
    overflow: hidden;
    font-size: 2.5vh; 
    margin: 0 auto;
    image-rendering: pixelated; 
}

canvas { 
    width: 100%; 
    height: 100%; 
    display: block;
    image-rendering: pixelated; 
    background-color: #8fbc8f; 
}

.overlay-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(26, 42, 24, 0.95);
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    z-index: 100; box-sizing: border-box; padding: 20px;
}

#ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 105; display: none; }

h1 { font-size: 5vmin; margin: 1vh 0; text-shadow: 2px 2px 0px #3e2723; color: #ffd700; }
h2 { font-size: 4vmin; text-shadow: 2px 2px 0px #3e2723; }
h3 { font-size: 3.5vmin; margin: 0.5vh 0; color: #ffd700; text-shadow: 2px 2px 0px #3e2723; }

.bar-container { width: 60%; height: 2vh; background-color: #3e2723; margin: 0.5vh auto; border: 2px solid #d2b48c; position: relative; }
#hp-bar { width: 100%; height: 100%; background-color: #ff4500; transition: width 0.2s; }
#xp-bar { width: 0%; height: 100%; background-color: #ffd700; transition: width 0.2s; }
#boss-ui { display: none; margin-top: 1vh; } 
#boss-hp-bar { width: 100%; height: 100%; background-color: #dc143c; transition: width 0.2s; }
.bar-text { position: absolute; top: 0; left: 0; width: 100%; font-size: 2vmin; line-height: 2vh; color: white; text-shadow: 1px 1px #000; font-weight: bold; }

#title-screen { display: flex; text-align: center; }
.main-title { 
    font-size: 10vmin; 
    color: #ffd700; 
    text-shadow: 4px 4px 0px #5c3a21; 
    margin-bottom: 5vh; 
    font-weight: normal; 
    letter-spacing: 2px; 
}
.start-btn { 
    padding: 2vh 6vw;      
    font-size: 4.5vmin;    
    background: #8b5a2b; 
    color: #fff; 
    border: 4px solid #d2b48c; 
    cursor: pointer; 
    transition: 0.2s; 
    font-weight: normal; 
    text-shadow: 2px 2px #3e2723;
    white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis;
    font-family: inherit; 
}
.start-btn:hover { background: #ffd700; color: #5c3a21; text-shadow: none; border-color: #fff; }
.start-btn:disabled { border-color: #5c3a21; color: #888; cursor: not-allowed; background: #3e2723; text-shadow: none;}

#loadout-screen { display: none; justify-content: flex-start; padding-top: 5vh; }
.loadout-container { display: flex; flex-direction: column; align-items: center; gap: 2vh; margin-bottom: 2vh; width: 100%; flex: 1; overflow: hidden; }
.selection-slots { display: flex; gap: 5%; margin-bottom: 1vh; width: 80%; justify-content: center; }

.slot { 
    width: 45%; aspect-ratio: 100/120; height: auto;
    border: 4px dashed #8b5a2b; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    cursor: pointer; background: #3e2723; transition: 0.2s; 
}
.slot.active { border-color: #ffd700; box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.4); }
.slot.filled { border-style: solid; border-color: #ffd700; background: #5c3a21; }
.slot-label { font-size: 2.5vmin; color: #d2b48c; margin-bottom: 1vh; text-shadow: 1px 1px #000; }
.slot-icon { width: 6vmin; height: 6vmin; background: #2c4228; border-radius: 0; border: 2px solid #d2b48c; margin-bottom: 0.5vh; }
.slot-name { font-size: 3vmin; color: white; text-align: center; text-shadow: 1px 1px #000;}

.part-grid { 
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2vmin; width: 90%; max-height: 35vh; overflow-y: auto; 
    padding: 10px; background: rgba(0,0,0,0.4); border: 4px solid #5c3a21; 
}
.mini-card { 
    width: 100%; aspect-ratio: 60/80; height: auto;
    background: #4a3b2c; border: 2px solid #8b5a2b; 
    cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    padding: 2px; transition: 0.2s; box-sizing: border-box;
}
.mini-card:hover { border-color: #ffd700; background: #5c3a21; }
.mini-card.selected { border-color: #adff2f; background: #6b4423; box-shadow: inset 0 0 10px rgba(173, 255, 47, 0.5); }
.mini-card.in-use { opacity: 0.4; border-color: #2e1a10; pointer-events: none; }

#upgrade-modal { display: none; } 
.modal-title { font-size: 5vmin; margin-bottom: 3vh; color: #ffd700; text-shadow: 2px 2px #5c3a21; text-align: center; }
.card-container { display: flex; gap: 3%; margin-bottom: 3vh; width: 100%; justify-content: center; align-items: stretch; }

.card { 
    width: 30%; height: auto; aspect-ratio: 100/160;
    background: #3e2723; border: 4px solid #8b5a2b; 
    cursor: pointer; display: flex; flex-direction: column; align-items: center; 
    padding: 1vh; transition: transform 0.2s, background 0.2s; position: relative; box-sizing: border-box;
}
.card.disabled { opacity: 0.5; cursor: not-allowed; border-color: #3e2723; }
.highlighted { border: 4px solid #ffd700 !important; background: #5c3a21 !important; transform: scale(1.05) !important; z-index: 10; }
.card-icon { width: 8vmin; height: 8vmin; margin-bottom: 1vh; flex-shrink: 0; background: #2c4228; border: 2px solid #d2b48c;}
.card-name { font-size: 3vmin; margin-bottom: 0.5vh; color: #ffd700; text-align: center; text-shadow: 1px 1px #000;}
.card-desc { font-size: 2.2vmin; color: #d2b48c; text-align: center; line-height: 1.3; flex-grow: 1; display: flex; align-items: center; justify-content: center; }
.card-level { margin-top: auto; font-size: 2.5vmin; color: #adff2f; text-shadow: 1px 1px #000;}
.key-badge, .max-badge { position: absolute; font-size: 2vmin; padding: 2px 4px; font-weight: normal; border: 2px solid #fff;}
.key-badge { top: 5px; left: 5px; background: #fff; color: #000; }
.max-badge { top: 5px; right: 5px; background: #ff4500; color: white; }

#fixed-upgrade-container { display: flex; gap: 3%; border-top: 4px dashed #5c3a21; padding-top: 2vh; width: 90%; justify-content: center; }
.fixed-btn { 
    width: 48%; padding: 1.5vh; 
    background: #4a3b2c; border: 2px solid #8b5a2b; 
    color: white; font-size: 3vmin; cursor: pointer; transition: 0.2s; font-family: inherit;
}
.fixed-btn:hover { background: #ffd700; color: #5c3a21; border-color: #fff; }

#replace-ui { display: none; flex-direction: column; align-items: center; gap: 2vh; width: 100%; }
.replace-btn { 
    width: 80%; padding: 2vh; font-size: 3.5vmin; 
    background: #5c3a21; color: white; border: 4px solid #8b5a2b; 
    cursor: pointer; font-family: inherit;
}
.replace-btn:hover { background: #ffd700; color: #5c3a21; border-color: #fff; }

.dict-card {
    background: #3e2723; border: 2px solid #8b5a2b; padding: 10px;
    display: flex; gap: 15px; align-items: center; box-shadow: 4px 4px 0px #1a1008;
}
.dict-icon { width: 60px; height: 60px; flex-shrink: 0; background: #2c4228; border: 2px solid #d2b48c; padding: 2px;}
.dict-text-box { text-align: left; flex-grow: 1; display:flex; flex-direction:column; justify-content:center;}
.dict-name { font-size: 18px; color: #ffd700; margin-bottom: 5px; text-shadow: 2px 2px #1a1008; }
.dict-desc { font-size: 13px; color: #e0d8c8; line-height: 1.5; word-break: keep-all; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #3e2723; border-left: 2px solid #1a1008; }
::-webkit-scrollbar-thumb { background: #8b5a2b; border: 2px solid #d2b48c; }