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

body {
    background-color: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    font-family: sans-serif;
    /* 기본적으로 커서가 보이도록 설정 */
    cursor: default !important;
}

/* 게임 플레이 영역인 컨테이너에만 특정 클래스가 붙었을 때 커서를 숨김 */
#game-container.playing {
    cursor: none !important;
}

#game-container {
    position: relative;
    /* 9:16 비율 기준 (모바일 해상도 기준 540x960으로 잡음) */
    width: 540px; 
    height: 960px;
    /* 화면이 작을 경우 꽉 차게 리사이즈되도록 max-width/height 설정 */
    max-width: 100vw;
    max-height: 177.77vh; /* 16/9 = 1.777... */
    background-color: #1a4b6e; /* 물 배경 기본색 */
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    /* 텍스트 선택 방지 등 조작 쾌적화 */
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-canvas {
    z-index: 1; /* 배, 적, 파티클 등이 그려질 층 */
}

#ui-canvas {
    z-index: 10; /* 커서, 드래그 궤적, UI가 그려질 최상단 층 */
    pointer-events: none; 
}

/* HTML 기반 UI 영역 */
#html-ui {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none; /* 클릭을 아래 캔버스로 통과시킴 */
    z-index: 20;
    color: white;
}

#hud {
    position: absolute;
    top: 20px;
    width: 100%;
    text-align: center;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.stat-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    margin: 0 20px;
    font-size: 1.2rem;
}

.level-info {
    white-space: nowrap;
}

.xp-bar-container {
    flex-grow: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-left: 15px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.xp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffd700, #ff8c00);
    transition: width 0.3s ease;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    color: white;
    text-shadow: 1px 1px 2px black;
}

.hp-bar-container {
    height: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin: 5px 20px 0;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.hp-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff3333, #ff0000);
    transition: width 0.3s ease;
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    color: white;
    text-shadow: 1px 1px 2px black;
}

.game-info {
    display: flex;
    justify-content: space-between;
    padding: 8px 20px;
    margin: 10px 20px 0;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

#level-up-screen, #game-over-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* 여긴 클릭 받아야 함 */
}

#level-up-screen.hidden, #game-over-screen.hidden {
    display: none;
}

#level-up-screen h2, #game-over-screen h2 {
    font-size: 2.5rem;
    color: #ffd700;
    margin-bottom: 10px;
}

#game-over-screen h2 {
    color: #ff3333;
}

#game-over-screen p {
    font-size: 1.2rem;
    margin-bottom: 30px;
}

#restart-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    background: #0096ff;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

#restart-btn:hover {
    background: #007acc;
    transform: scale(1.05);
}

#cards-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    margin-top: 30px;
}

.item-card {
    background: #222;
    border: 2px solid #555;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.item-card:hover {
    transform: scale(1.05);
    border-color: #ffd700;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.item-card h3 {
    margin-bottom: 10px;
    color: #0096ff;
}

.item-card p {
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.4;
}

#how-to-play-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* 클릭 받아야 함 */
    z-index: 50; /* 최상단 유지 */
}

#how-to-play-screen.hidden {
    display: none;
}

#how-to-play-screen h2 {
    font-size: 2.0rem;
    color: #fff;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.instructions {
    width: 85%;
    text-align: left;
    margin-bottom: 30px;
    font-size: 1rem;
    line-height: 1.5;
}

.instructions p {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #0096ff;
}

.instructions p:nth-child(2) { border-left-color: #ff3232; }
.instructions p:nth-child(3) { border-left-color: #ffd700; }

#start-game-btn {
    background-color: #0096ff;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.1s, background-color 0.2s;
}

#start-game-btn:hover {
    background-color: #007acc;
    transform: translateY(-2px);
}
