/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    overflow: hidden;
    color: #fff;
}

/* ===== Game Container & Canvas ===== */
#gameContainer {
    position: relative;
    width: 100%;
    max-width: 1920px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #0f0f1a;
    border-radius: 10px;
}

#gameCanvas {
    width: 100%;
    height: auto; /* รักษา aspect ratio */
    max-height: 100%;
    display: block;
    border-radius: 10px;
}

/* ===== UI Overlay ===== */
#uiContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

#gameTitle {
    font-size: calc(2rem + 2vw);
    margin-bottom: 30px;
    text-align: center;
    text-shadow: 0 0 10px #e94560, 0 0 20px #e94560;
    letter-spacing: 4px;
    font-weight: 800;
    pointer-events: none;
}

#startButton {
    padding: 15px 40px;
    font-size: calc(1rem + 1vw);
    font-weight: bold;
    background: linear-gradient(45deg, #e94560, #ff7b9c);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#startButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(233, 69, 96, 0.6);
    background: linear-gradient(45deg, #ff7b9c, #e94560);
}

#controlsInfo {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    pointer-events: none;
}

/* ===== Health Bar ===== */
.health-bar {
    position: absolute;
    top: 20px;
    right: 10px;
    width: 20vw;
    max-width: 400px;
    height: 25px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #333;
    pointer-events: none;
}

.health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(to right, #e94560, #ff7b9c);
    transition: width 0.3s;
}

/* ===== Wave Indicator ===== */
.wave-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: calc(2rem + 2vw);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #e94560;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

/* ===== Score & Timer ===== */
.score-display, .timer-display {
    position: absolute;
    right: 10px;
    font-size: calc(14px + 1.5vw);
    color: #fff;
    text-shadow: 0 0 5px rgba(0,0,0,0.7);
    pointer-events: none;
}

#scoreDisplay { top: 10px; }
#timerDisplay { top: 50px; }
#playerHealth { top: 90px; }

/* ===== Instructions ===== */
.instructions {
    position: absolute;
    bottom: 10px;
    left: 20px;
    background: rgba(0,0,0,0.5);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 6;
}

.instructions h3 { color: #ff7b9c; margin-bottom: 10px; }
.instructions p { margin: 5px 0; font-size: 0.9rem; }

/* ===== Continue Screen ===== */
#continueScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(10,10,20,0.95);
    z-index: 20;
    pointer-events: auto;
}

#continueTitle {
    font-size: calc(2rem + 2vw);
    margin-bottom: 30px;
    text-align: center;
    text-shadow: 0 0 10px #00ffaa, 0 0 20px #00ffaa;
    letter-spacing: 3px;
    font-weight: 800;
    color: #fff;
}

#continueButton {
    padding: 15px 40px;
    font-size: calc(1rem + 1vw);
    font-weight: bold;
    background: linear-gradient(45deg, #00cc88, #00ffaa);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,255,170,0.4);
}

#continueButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,255,170,0.6);
    background: linear-gradient(45deg, #00ffaa, #00cc88);
}

#continueInfo, #rewardInfo {
    margin-top: 20px;
    font-size: calc(1rem + 0.5vw);
    color: rgba(255,255,255,0.8);
    text-align: center;
    max-width: 80%;
}

/* ===== Mobile Controls ===== */
#mobileControls {
    position: fixed;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 100;
}

#mobileControls button {
    width: 60px;
    height: 60px;
    font-size: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(5px);
    color: white;
}

/* ===== Responsive ===== */
@media (max-width: 1920px) {
    #gameCanvas { max-width: 90vw; max-height: 90vh; }
}

@media (max-width: 1440px) {
    #gameTitle, #continueTitle { font-size: calc(1.5rem + 2vw); }
    #startButton, #continueButton { font-size: calc(0.9rem + 1vw); }
}

@media (max-width: 1080px) {
    #gameTitle, #continueTitle { font-size: calc(1.2rem + 2vw); }
    #startButton, #continueButton { font-size: calc(0.8rem + 1vw); }
}

@media (max-width: 768px) {
    .health-bar { width: 50vw; max-width: 180px; }
    #scoreDisplay, #timerDisplay, #playerHealth { font-size: calc(12px + 1.5vw); }
    #mobileControls button { width: 50px; height: 50px; font-size: 16px; }
}

@media (max-width: 500px) {
    #scoreDisplay, #timerDisplay, #playerHealth { font-size: calc(10px + 2vw); right: 5px; }
    #scoreDisplay { top: 5px; }
    #timerDisplay { top: 30px; }
    #playerHealth { top: 55px; }
}

#jumpBtn, #attackBtn {
    touch-action: none;
    user-select: none;
}
/* ===== Home Button (New Style) ===== */
#homeBtn {
    /* ใช้ Style เดียวกับปุ่ม Start/Continue เพื่อความเข้ากัน */
    padding: 15px 40px;
    font-size: calc(1rem + 1vw);
    font-weight: bold;
    background: linear-gradient(45deg, #1abc9c, #16a085); /* ใช้สีใหม่ (เขียวอมฟ้า) */
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(26, 188, 156, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#homeBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(26, 188, 156, 0.6);
    background: linear-gradient(45deg, #16a085, #1abc9c);
}