@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    background: #0a0a0f;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', cursive;
    overflow: hidden;
}

/* Vietnamese font override - VT323 supports Vietnamese diacritics */
body.lang-vi,
body.lang-vi button,
body.lang-vi input {
    font-family: 'VT323', monospace;
    font-weight: bold;
}

body.lang-vi #startScreen .subtitle {
    font-size: 12px;
}

body.lang-vi #startScreen .instructions {
    font-size: 10px;
}

body.lang-vi .sprite-btn .desc {
    font-size: 10px;
}
/* End Vietnamese font override */

/* Responsive scaling for different screen sizes */
@media (max-width: 1400px), (max-height: 850px) {
    #gameWrapper {
        transform: scale(0.9);
        transform-origin: center center;
    }
}

@media (max-width: 1280px), (max-height: 780px) {
    #gameWrapper {
        transform: scale(0.8);
        transform-origin: center center;
    }
}

@media (max-width: 1150px), (max-height: 700px) {
    #gameWrapper {
        transform: scale(0.7);
        transform-origin: center center;
    }
}

@media (max-width: 1000px), (max-height: 620px) {
    #gameWrapper {
        transform: scale(0.6);
        transform-origin: center center;
    }
}

@media (max-width: 850px), (max-height: 540px) {
    #gameWrapper {
        transform: scale(0.5);
        transform-origin: center center;
    }
}

#gameWrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

#languagePanel {
    background: #1a1a2e;
    border: 2px solid #2a2a3a;
    padding: 10px;
    color: #fff;
    font-size: 8px;
    width: 100px;
    height: 758px;
    flex-shrink: 0;
}

#languagePanel h3 {
    margin-bottom: 10px;
    font-size: 8px !important;
    color: #aaa;
    font-family: 'Press Start 2P', cursive !important;
    line-height: 1.2;
}

.lang-btn {
    display: block;
    width: 100%;
    background: linear-gradient(180deg, #333, #222);
    border: 2px solid #444;
    color: #fff;
    font-family: 'Press Start 2P', cursive !important;
    font-size: 8px;
    padding: 8px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.1s;
}

.lang-btn:hover {
    background: linear-gradient(180deg, #444, #333);
    border-color: #666;
}

.lang-btn.active {
    border-color: #5f5;
    background: linear-gradient(180deg, #353, #232);
}

.sound-btn {
    display: block;
    width: 100%;
    background: linear-gradient(180deg, #333, #222);
    border: 2px solid #444;
    color: #fff;
    font-size: 20px;
    padding: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.sound-btn:hover {
    background: linear-gradient(180deg, #444, #333);
    border-color: #666;
}

#gameContainer {
    position: relative;
    border: 4px solid #2a2a3a;
    box-shadow: 0 0 40px rgba(100, 200, 255, 0.2), inset 0 0 60px rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
}

#gameCanvas {
    display: block;
    background: #1a1a2e;
    image-rendering: pixelated;
}

#leftPanel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 200px;
    height: 758px;
    flex-shrink: 0;
}

#ui {
    background: #1a1a2e;
    border: 2px solid #2a2a3a;
    padding: 10px;
    color: #fff;
    font-size: 10px;
    flex-shrink: 0;
}

#ui div {
    margin-bottom: 8px;
}

.health-bar {
    width: 150px;
    height: 14px;
    background: #333;
    border: 2px solid #555;
    position: relative;
}

.health-fill {
    height: 100%;
    background: linear-gradient(180deg, #5f5, #2a2);
    transition: width 0.2s;
}

.points-bar {
    width: 150px;
    height: 10px;
    background: #333;
    border: 2px solid #555;
    margin-top: 2px;
}

.points-fill {
    height: 100%;
    background: linear-gradient(180deg, #ff0, #aa0);
    transition: width 0.2s;
}

#skillDisplay {
    background: #1a1a2e;
    border: 2px solid #2a2a3a;
    padding: 10px;
    color: #fff;
    font-size: 10px;
    flex-shrink: 0;
}

#skillDisplay.has-skill {
    border-color: #5ff;
    animation: skillPulse 1s infinite;
}

@keyframes skillPulse {
    0%, 100% { box-shadow: 0 0 5px #5ff; }
    50% { box-shadow: 0 0 15px #5ff; }
}

#skillName {
    color: #5ff;
    font-size: 10px;
}

#skillHint {
    color: #888;
    font-size: 8px;
    margin-top: 4px;
}

#spritePanel {
    background: #1a1a2e;
    border: 2px solid #2a2a3a;
    padding: 12px;
    color: #fff;
    font-size: 10px;
    flex: 1;
    overflow-y: auto;
}

#spritePanel h3 {
    margin-bottom: 10px;
    font-size: 10px;
    color: #aaa;
}

#skillDisplay > div:first-child {
    color: #aaa;
    font-size: 10px;
    margin-bottom: 8px;
}

#spriteButtons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sprite-btn {
    background: linear-gradient(180deg, #444, #222);
    border: 2px solid #666;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 6px 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.1s;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    height: 42px;
    box-sizing: border-box;
}

.sprite-btn .cost {
    color: #ff0;
}

.sprite-btn .desc {
    color: #aaa;
    font-size: 6px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.sprite-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #555, #333);
    border-color: #888;
}

.sprite-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sprite-btn.affordable {
    border-color: #5f5;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 5px #5f5; }
    50% { box-shadow: 0 0 15px #5f5; }
}

#waveInfo {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 10px;
    text-shadow: 2px 2px 0 #000;
    text-align: center;
}

#startScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #0a0a1a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    z-index: 100;
}

#startScreen h1 {
    font-size: 36px;
    color: #4af;
    text-shadow: 0 0 20px #4af, 0 4px 0 #248;
    margin-bottom: 10px;
}

#startScreen .subtitle {
    font-size: 10px;
    color: #888;
    margin-bottom: 40px;
}

.start-btn {
    background: linear-gradient(180deg, #4a4, #282);
    border: 4px solid #5c5;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    padding: 20px 50px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 30px;
    animation: startPulse 2s infinite;
}

@keyframes startPulse {
    0%, 100% { box-shadow: 0 0 10px #4a4; transform: scale(1); }
    50% { box-shadow: 0 0 30px #4a4; transform: scale(1.02); }
}

.start-btn:hover {
    background: linear-gradient(180deg, #5b5, #393);
    border-color: #7d7;
    transform: scale(1.05);
}

.cheat-btn {
    background: linear-gradient(180deg, #a44, #622);
    border: 3px solid #c55;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 30px;
}

.cheat-btn:hover {
    background: linear-gradient(180deg, #b55, #733);
    border-color: #d77;
    transform: scale(1.05);
}

#startScreen .instructions {
    font-size: 8px;
    color: #666;
    line-height: 2;
    max-width: 600px;
}

#startScreen .instructions span {
    color: #aaa;
}

#gameOver, #victory, #pauseScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    z-index: 50;
}

#pauseScreen h1 {
    color: #4af;
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px #4af;
}

#pauseScreen p {
    font-size: 10px;
    color: #888;
    margin-bottom: 30px;
}

#gameOver h1 {
    color: #f44;
    font-size: 28px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px #f44;
}

#victory h1 {
    color: #4f4;
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px #4f4;
}

#gameOver p, #victory p {
    font-size: 10px;
    margin-bottom: 30px;
}

.restart-btn {
    background: linear-gradient(180deg, #555, #333);
    border: 3px solid #777;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 15px 30px;
    cursor: pointer;
    transition: all 0.2s;
}

.restart-btn:hover {
    background: linear-gradient(180deg, #666, #444);
    border-color: #999;
    transform: scale(1.05);
}

.menu-btn {
    margin-top: 10px;
    padding: 8px 15px;
    font-size: 8px;
    border-width: 2px;
    background: linear-gradient(180deg, #433, #322);
    border-color: #644;
}

.menu-btn:hover {
    background: linear-gradient(180deg, #544, #433);
    border-color: #866;
}

#controls {
    margin-top: 20px;
    color: #666;
    font-size: 8px;
    text-align: center;
    height: 24px;
    line-height: 24px;
    overflow: hidden;
}

#bossHealth {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    display: none;
}

#gameTimerDisplay {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 10px;
    text-shadow: 2px 2px 0 #000;
    background: #0008;
    padding: 6px 12px;
    border: 2px solid #555;
}

#bossHealth .boss-name {
    color: #f44;
    font-size: 10px;
    text-align: center;
    margin-bottom: 4px;
    text-shadow: 2px 2px 0 #000;
}

#bossHealth .health-bar {
    width: 100%;
    height: 18px;
    border-color: #f44;
}

#bossHealth .health-fill {
    background: linear-gradient(180deg, #f44, #a00);
}
