body {
margin: 0;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 16px;
box-sizing: border-box;
background: linear-gradient(135deg, #1b1038, #3a0ca3 55%, #0f3460);
color: #ffffff;
font-family: 'Paperlogy', 'Noto Sans KR', sans-serif;
}

.game {
width: 100%;
max-width: 1100px;
background: rgba(43, 54, 72, 0.85);
border-radius: 20px;
padding: 24px;
box-sizing: border-box;
text-align: center;
box-shadow: 0 0 30px rgba(255, 209, 102, 0.25);
}

h1 {
margin: 0 0 8px;
font-size: 30px;
background: linear-gradient(90deg, #ffd166, #ef476f, #06d6a0);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}

.status {
font-size: 16px;
font-weight: bold;
color: #ffd166;
margin-bottom: 12px;
}

.monster-area,
#hero-area {
margin: 12px 0;
padding: 14px;
background: #222b3a;
border-radius: 16px;
}

.stage {
position: relative;
width: 100%;
height: 62vh;
min-height: 380px;
border-radius: 16px;
overflow: hidden;
border: 3px solid #ffd166;
background: #1d2633;
margin-bottom: 10px;
}

.stage canvas {
display: block;
width: 100%;
height: 100%;
}

.popup {
position: absolute;
top: 35%;
transform: translateX(-50%);
font-size: 46px;
font-weight: bold;
text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, 0.5);
pointer-events: none;
animation: floatUp 0.9s ease-out forwards;
}

@keyframes floatUp {
from { opacity: 1; margin-top: 0; }
to { opacity: 0; margin-top: -80px; }
}

.monster-name {
font-size: 20px;
font-weight: bold;
margin: 4px 0;
}

.bar {
height: 18px;
background: #444;
border-radius: 9px;
overflow: hidden;
margin: 6px 0;
}

.fill {
height: 100%;
width: 100%;
transition: width 0.3s;
}

.red {
background: linear-gradient(90deg, #ef476f, #ff9b54);
}

.green {
background: linear-gradient(90deg, #06d6a0, #9ef01a);
}

.log {
min-height: 56px;
font-size: 18px;
line-height: 1.5;
}

.buttons {
display: flex;
gap: 10px;
}

button {
flex: 1;
padding: 16px;
font-size: 22px;
font-weight: bold;
border: none;
border-radius: 14px;
background: linear-gradient(135deg, #ffd166, #ff9f1c);
color: #222;
cursor: pointer;
font-family: inherit;
box-shadow: 0 6px 0 #c77700;
transition: transform 0.1s;
}

button:active {
transform: translateY(4px);
box-shadow: 0 2px 0 #c77700;
}

button:disabled {
opacity: 0.5;
cursor: not-allowed;
}

#attack-btn:not(:disabled) {
animation: pulse 1.2s infinite;
}

@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.04); }
}

.hidden {
display: none;
}

.end-panel {
margin-top: 16px;
padding: 18px;
background: linear-gradient(135deg, #3d2f5b, #7b2cbf);
border-radius: 16px;
}

.gold-text {
font-size: 16px;
color: #ffd166;
font-weight: bold;
margin: 6px 0 0;
}

.buttons {
flex-wrap: wrap;
}

.buttons button {
min-width: 100px;
font-size: 18px;
}

.skill-btn {
background: linear-gradient(135deg, #ff6b35, #d62828);
color: #ffffff;
box-shadow: 0 6px 0 #9d0208;
}

.shop-btn {
background: linear-gradient(135deg, #06d6a0, #118ab2);
color: #ffffff;
box-shadow: 0 6px 0 #05668d;
}

.skill2-btn {
background: linear-gradient(135deg, #ffe066, #7b2cbf);
color: #111111;
box-shadow: 0 6px 0 #4c1d95;
}

.heal-btn {
background: linear-gradient(135deg, #8ef5a0, #06d6a0);
color: #111111;
box-shadow: 0 6px 0 #04876a;
}

.plain-btn {
background: #555555;
color: #ffffff;
box-shadow: 0 6px 0 #222222;
}

.panel {
margin-top: 16px;
padding: 18px;
background: linear-gradient(135deg, #2b3c5a, #3a0ca3);
border-radius: 16px;
}

.panel h2 {
margin: 0 0 10px;
font-size: 24px;
}

.panel .buttons {
margin-top: 10px;
}

.shop-items {
display: flex;
flex-direction: column;
gap: 8px;
margin-bottom: 10px;
}

.shop-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
background: rgba(0, 0, 0, 0.25);
padding: 10px;
border-radius: 12px;
text-align: left;
}

.shop-item p {
margin: 0;
font-size: 16px;
}

.shop-item button {
flex: none;
font-size: 16px;
padding: 10px 14px;
}

.ending {
position: fixed;
inset: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
box-sizing: border-box;
overflow-y: auto;
background: radial-gradient(circle, #ffd166 0%, #7b2cbf 45%, #10002b 100%);
animation: fadeIn 1.2s ease-out;
}

.ending.hidden {
display: none;
}

.ending-scene {
text-align: center;
max-width: 560px;
}

.ending-icons {
font-size: 56px;
margin-bottom: 12px;
}

.ending-icons span {
display: inline-block;
margin: 0 6px;
}

.hero-icon {
animation: bounce 1s infinite;
}

.princess-icon {
animation: bounce 1s infinite 0.5s;
}

.heart {
animation: pulse 1s infinite;
}

.ending-lines p {
font-size: 20px;
line-height: 1.6;
margin: 8px 0;
animation: fadeIn 1s ease-out;
}

.ending-scene button {
margin-top: 16px;
}

.ending-icons {
display: none;
}

.ending-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
}

.ending-scene {
position: absolute;
inset: 0;
max-width: none;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
padding: 16px;
box-sizing: border-box;
pointer-events: none;
}

.ending-lines {
width: 100%;
max-width: 720px;
min-height: 90px;
background: rgba(16, 0, 43, 0.7);
border: 2px solid #ffd166;
border-radius: 16px;
padding: 12px;
box-sizing: border-box;
margin-bottom: 12px;
}

.ending-lines p {
font-size: clamp(18px, 4vw, 24px);
line-height: 1.6;
margin: 0;
animation: fadeIn 1s ease-out;
}

.ending-scene button {
pointer-events: auto;
margin-top: 0;
min-width: 200px;
flex: none;
}

@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}

@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-12px); }
}

.story {
position: fixed;
inset: 0;
z-index: 20;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
box-sizing: border-box;
background: radial-gradient(circle at 50% 40%, #2b1d52 0%, #0b0520 100%);
animation: fadeIn 0.8s ease-out;
}

.story.hidden {
display: none;
}

.story-box {
max-width: 960px;
width: 100%;
text-align: center;
}

.story-canvas {
width: 100%;
height: 62vh;
min-height: 380px;
border-radius: 16px;
border: 3px solid #ffd166;
background: #0b0520;
margin-bottom: 12px;
}

.story-icon {
font-size: 80px;
animation: bounce 1.6s infinite;
}

.story-text {
font-size: 26px;
line-height: 1.7;
min-height: 110px;
animation: fadeIn 0.9s ease-out;
}

.story-box button {
margin-top: 20px;
min-width: 160px;
}

.end-panel h2 {
margin: 0 0 8px;
font-size: 26px;
}
