* { box-sizing: border-box; }
body, html { 
    margin: 0; padding: 0; width: 100%; height: 100%; 
    overflow: hidden; background: #000; 
    font-family: 'Noto Sans KR', sans-serif; 
    color: white; user-select: none;
}
#app { display: flex; flex-direction: column; height: 100vh; }

#bottom-view canvas { touch-action: none; }

.screen-shake {
    animation: screenShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes screenShake {
    10%, 90% { transform: translate3d(-5px, 5px, 0); }
    20%, 80% { transform: translate3d(10px, -10px, 0); }
    30%, 50%, 70% { transform: translate3d(-15px, 15px, 0); }
    40%, 60% { transform: translate3d(15px, -15px, 0); }
}

#top-view { 
    flex: 1; display: flex; flex-direction: column; 
    justify-content: center; align-items: center; 
    position: relative; background: #1a1a2e; 
    border-bottom: 4px solid #fff; z-index: 2;
}

#monster-container { position: relative; display: flex; flex-direction: column; align-items: center; }
#monster { 
    width: 120px; height: 120px; background: #800080; 
    border-radius: 15px; margin-bottom: 30px; 
    box-shadow: 0 0 20px #800080; transition: all 0.3s, transform 0.05s; 
    display: flex; justify-content: center; align-items: center;
}
#warning-light {
    width: 30px; height: 30px; background: #ff0000; border-radius: 50%;
    box-shadow: 0 0 15px #ff0000;
    animation: pulse 1s infinite alternate;
}
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 1; }
}

.boss-attack {
    animation: bossLunge 0.5s cubic-bezier(.36,.07,.19,.97) forwards;
}
@keyframes bossLunge {
    0% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.3) translateY(40px); }
    100% { transform: scale(1) translateY(0); }
}

.relic-common { border-color: #4a4a6a; }
.relic-rare { border-color: #0088ff; box-shadow: 0 0 10px rgba(0,136,255,0.5); }
.relic-legendary { border-color: #ffaa00; box-shadow: 0 0 15px rgba(255,170,0,0.8); }

#recipe-board {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #888;
    border-radius: 10px;
    padding: 15px;
    width: 250px;
    color: #fff;
    font-size: 13px;
    z-index: 100;
    display: none; /* 기본 숨김 - 도움말 버튼으로 토글 */
}
#recipe-board.visible { display: block; }
#recipe-board h3 { margin-top: 0; font-size: 15px; color: #ffd700; border-bottom: 1px solid #555; padding-bottom: 5px; }
#recipe-board ul { list-style: none; padding: 0; margin: 0; }
#recipe-board li { margin-bottom: 8px; background: rgba(255,255,255,0.1); padding: 5px; border-radius: 5px; }

#btn-help {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    aspect-ratio: 1 / 1;
    padding: 0;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(255, 215, 0, 0.05);
}
#btn-help:hover { 
    background: rgba(255, 215, 0, 0.15); 
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4), inset 0 0 15px rgba(255, 215, 0, 0.1);
    transform: scale(1.05);
}
#btn-help.active { 
    background: #ffd700; 
    color: #000;
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
}

#relic-inventory {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 300px;
    z-index: 100;
}
.relic-item {
    position: relative;
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #555;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: help;
}
.relic-item.tier-common { border-color: #4a4a6a; }
.relic-item.tier-rare { border-color: #0088ff; box-shadow: 0 0 5px rgba(0,136,255,0.5); }
.relic-item.tier-legendary { border-color: #ffaa00; box-shadow: 0 0 10px rgba(255,170,0,0.8); }

.relic-tooltip {
    visibility: hidden;
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #777;
    white-space: nowrap;
    font-size: 12px;
    z-index: 110;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.relic-item:hover .relic-tooltip {
    visibility: visible;
    opacity: 1;
}

.relic-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.relic-card-icon {
    font-size: 28px;
}

.relic-common { background: linear-gradient(135deg, #1a1a2e, #16213e); }
.relic-rare { background: linear-gradient(135deg, #0f3460, #005c99); }
.relic-legendary { background: linear-gradient(135deg, #5c4000, #b37700); }

.projectile-effect {
    position: absolute;
    font-size: 40px;
    pointer-events: none;
    z-index: 150;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.shake { 
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; 
    background: #ff00ff !important; box-shadow: 0 0 40px #ff00ff !important; 
}
.screen-shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}
.screen-shake-light {
    animation: shakeLight 0.3s cubic-bezier(.36,.07,.19,.97) both;
}
.screen-shake-heavy {
    animation: shakeHeavy 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeLight {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
    40%, 60% { transform: translate3d(2px, 0, 0); }
}

@keyframes shakeHeavy {
    10%, 90% { transform: translate3d(-3px, 3px, 0); }
    20%, 80% { transform: translate3d(5px, -5px, 0); }
    30%, 50%, 70% { transform: translate3d(-10px, 10px, 0); }
    40%, 60% { transform: translate3d(10px, -10px, 0); }
}

.flash-anim {
    animation: flash 0.3s ease-out both;
}

@keyframes flash {
    0% { opacity: 1; }
    100% { opacity: 0; display: none; }
}

.floating-player-dmg {
    position: absolute;
    color: #ff3333;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 10px #000;
    pointer-events: none;
    animation: floatUpPlayer 1s ease-out forwards;
    z-index: 100;
}
.floating-player-blocked {
    position: absolute;
    color: #aaaaaa;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px #000;
    pointer-events: none;
    animation: floatUpPlayer 1s ease-out forwards;
    z-index: 100;
}
@keyframes floatUpPlayer {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-50px) scale(1); }
}

@keyframes shake {
    10%, 90% { transform: translate3d(-3px, 0, 0); }
    20%, 80% { transform: translate3d(5px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-10px, 0, 0); }
    40%, 60% { transform: translate3d(10px, 0, 0); }
}

#hp-bar-bg { 
    width: 300px; height: 25px; background: #333; 
    border-radius: 12px; border: 2px solid #555; overflow: hidden; position: relative; 
}
#hp-bar-fill { height: 100%; background: linear-gradient(90deg, #ff416c, #ff4b2b); width: 100%; transition: width 0.2s ease-out; }
#hp-text { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 14px; text-shadow: 1px 1px 2px black; }

#player-container {
    position: absolute; bottom: 20px; left: 20px; 
    display: flex; flex-direction: column; align-items: flex-start;
}
#player-hp-bar-bg { 
    width: 200px; height: 20px; background: #333; 
    border-radius: 10px; border: 2px solid #555; overflow: hidden; position: relative; 
}
#player-hp-bar-fill { height: 100%; background: #4caf50; width: 100%; transition: width 0.2s ease-out; }
#player-hp-text { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 12px; text-shadow: 1px 1px 2px black; }

/* 유물 도박장 UI 스타일 */
#reward-ui {
    position: absolute; top:0; left:0; width:100%; height:100%; 
    background: rgba(0,0,0,0.85); z-index: 100; 
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#reward-ui h2 { margin: 0 0 10px 0; color: #ffeb3b; font-size: 32px; text-shadow: 0 0 10px #ffeb3b; }
#reward-ui p { margin: 0 0 30px 0; font-size: 16px; }

.artifact-cards-container { display: flex; gap: 20px; }
.artifact-card {
    background: #2a2a4a; border: 2px solid #4a4a6a; border-radius: 12px;
    padding: 20px; width: 220px; text-align: center; cursor: not-allowed;
    filter: grayscale(0.5) brightness(0.7); transition: all 0.3s;
}
.artifact-card h3 { margin: 0 0 10px 0; color: #fff; }
.artifact-card p { font-size: 13px; color: #ccc; margin-bottom: 15px; height: 40px;}
.artifact-card .recipe { font-size: 24px; letter-spacing: 5px; background: #111; padding: 10px; border-radius: 8px;}

/* 조건 만족 시 카드 활성화 */
.artifact-card.active {
    filter: none; border-color: #ffeb3b; cursor: pointer; box-shadow: 0 0 15px rgba(255, 235, 59, 0.5);
}
.artifact-card.active:hover {
    transform: translateY(-5px); box-shadow: 0 0 25px rgba(255, 235, 59, 0.8);
}
#btn-skip-artifact { margin-top: 30px; background: #888; }
#btn-skip-artifact:hover { background: #666; }


.floating-text { 
    position: absolute; color: #ffeb3b; font-weight: bold; 
    font-size: 28px; pointer-events: none; white-space: nowrap;
    animation: floatUp 1s ease-out forwards; z-index: 10; text-shadow: 2px 2px 0 #000; 
}
@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-40px) scale(1.3); opacity: 1; }
    100% { transform: translateY(-80px) scale(1); opacity: 0; }
}

#bottom-view { flex: 1; position: relative; background: #222; overflow: hidden; }
#bottom-view canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
#tray-ui { 
    position: absolute; top: 15px; left: 15px; right: 15px; 
    display: flex; justify-content: space-between; align-items: center; 
    z-index: 10; pointer-events: none; 
}
#rolls-text { font-size: 24px; font-weight: bold; text-shadow: 1px 1px 2px black; }
.controls { display: flex; gap: 15px; pointer-events: auto; }

button { 
    padding: 12px 24px; font-size: 16px; font-weight: bold; 
    cursor: pointer; border: none; border-radius: 8px; 
    background: #4caf50; color: white; box-shadow: 0 4px 6px rgba(0,0,0,0.3); transition: background 0.2s, transform 0.1s; 
}
button:hover:not(:disabled) { background: #45a049; transform: translateY(-2px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { background: #555; color: #888; cursor: not-allowed; box-shadow: none; transform: none; }
#btn-end-turn { background: #f44336; }
#btn-end-turn:hover:not(:disabled) { background: #da190b; }

/* 모바일 반응형 */
@media (max-width: 768px) {
    #monster { width: 80px; height: 80px; margin-bottom: 15px; }
    #hp-bar-bg { width: 200px; height: 20px; }
    #hp-text { font-size: 11px; }
    #player-container { bottom: 10px; left: 10px; }
    #player-hp-bar-bg { width: 140px; height: 16px; }
    
    #recipe-board { width: 220px; top: 55px; right: 10px; font-size: 11px; padding: 10px; }
    #btn-help { top: 10px; right: 10px; width: 34px; height: 34px; aspect-ratio: 1/1; padding: 0; font-size: 16px; }
    
    #relic-inventory { top: 10px; left: 10px; width: 180px; gap: 6px; }
    .relic-item { width: 32px; height: 32px; font-size: 16px; }
    
    #rolls-text { font-size: 18px; }
    button { padding: 8px 16px; font-size: 14px; }
    
    .artifact-card { width: 160px; padding: 12px; }
    .artifact-card h3 { font-size: 14px; }
    .artifact-card p { font-size: 11px; height: auto; }
    .artifact-card .recipe { font-size: 18px; }
    
    #reward-ui h2 { font-size: 22px; }
    #reward-ui p { font-size: 13px; }
}

@media (max-width: 480px) {
    #hp-bar-bg { width: 150px; }
    #player-hp-bar-bg { width: 100px; }
    .artifact-cards-container { flex-direction: column; align-items: center; }
    .artifact-card { width: 90%; max-width: 260px; }
}
