/* 해킹 리듬 방어 — 카드 + 타이머 리듬 게임 UI */

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

body {
    font-family: "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    background: #0a0e14;
    color: #e8eef4;
    min-height: 100vh;
}

.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
}

/* 상단 */
.top-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.brand h1 {
    font-size: 1.5rem;
    color: #00ff9d;
    text-shadow: 0 0 20px rgba(0, 255, 157, 0.35);
}

.brand p {
    font-size: 0.85rem;
    color: #8b9cb3;
    margin-top: 0.25rem;
}

.top-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.game-status {
    color: #58a6ff;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* 레이아웃 */
.layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
    align-items: start;
}

.card {
    background: rgba(16, 22, 32, 0.95);
    border: 1px solid rgba(0, 255, 157, 0.15);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 0.95rem;
    color: #58a6ff;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(88, 166, 255, 0.25);
    padding-bottom: 0.4rem;
}

.card h2 small {
    font-size: 0.7rem;
    color: #6e7681;
    font-weight: normal;
}

/* 버튼 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
}

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

.btn-primary {
    background: linear-gradient(135deg, #00ff9d, #00c978);
    color: #0a0e14;
    font-weight: bold;
}

.btn-ghost {
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    border: 1px solid rgba(88, 166, 255, 0.35);
}

/* 난이도 */
.difficulty-panel.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.difficulty-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.difficulty-option:has(input:checked) {
    border-color: #00ff9d;
    background: rgba(0, 255, 157, 0.08);
}

.diff-label {
    font-weight: bold;
    color: #00ff9d;
    min-width: 3rem;
}

.diff-desc {
    font-size: 0.8rem;
    color: #8b9cb3;
}

/* HUD */
.hud-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hud-label {
    font-size: 0.75rem;
    color: #6e7681;
    text-transform: uppercase;
}

#stage-display {
    font-size: 1.4rem;
    color: #58a6ff;
}

.hp-bar {
    display: flex;
    gap: 0.2rem;
}

.hp-heart {
    font-size: 1.25rem;
    color: #333;
    transition: color 0.2s, transform 0.2s;
}

.hp-heart.alive {
    color: #ff6b9d;
    text-shadow: 0 0 8px rgba(255, 107, 157, 0.6);
}

.hp-heart.dead {
    color: #333;
    opacity: 0.4;
}

.combo-hud strong {
    font-size: 1.3rem;
    color: #ffd700;
}

.combo-hud strong.combo-hot {
    animation: combo-pulse 0.6s ease infinite alternate;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}

.max-combo {
    font-size: 0.72rem;
    color: #6e7681;
}

@keyframes combo-pulse {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

/* 공격 카드 */
.attack-card {
    position: relative;
    min-height: 160px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.attack-card.idle {
    opacity: 0.85;
}

.attack-card.active {
    border-color: rgba(255, 138, 138, 0.5);
    box-shadow: 0 0 24px rgba(255, 90, 90, 0.15);
}

.attack-card.danger-high-card {
    border: 2px solid #ff3355;
    box-shadow: 0 0 20px rgba(255, 51, 85, 0.45), inset 0 0 30px rgba(255, 51, 85, 0.08);
    animation: neon-pulse 1.2s ease-in-out infinite alternate;
}

.attack-card.special-card {
    border-color: #ffd700;
}

@keyframes neon-pulse {
    from { box-shadow: 0 0 12px rgba(255, 51, 85, 0.4); }
    to { box-shadow: 0 0 28px rgba(255, 51, 85, 0.75); }
}

.attack-card.flash-success {
    animation: flash-green 0.45s ease;
}

.attack-card.shake-fail {
    animation: shake-red 0.5s ease;
}

@keyframes flash-green {
    0%, 100% { background: rgba(16, 22, 32, 0.95); }
    50% { background: rgba(0, 255, 157, 0.25); border-color: #00ff9d; }
}

@keyframes shake-red {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); background: rgba(255, 60, 60, 0.2); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.attack-card-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.danger-badge {
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.danger-low {
    background: rgba(0, 200, 120, 0.25);
    color: #00ff9d;
}

.danger-medium {
    background: rgba(255, 180, 60, 0.25);
    color: #ffb83c;
}

.danger-high {
    background: rgba(255, 51, 85, 0.35);
    color: #ff5577;
}

.special-badge {
    font-size: 0.7rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 215, 0, 0.25);
    color: #ffd700;
}

.special-badge.hidden {
    display: none;
}

.attack-name {
    font-size: 1.2rem;
    color: #ff8a8a;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.attack-desc {
    font-size: 0.9rem;
    color: #b8c5d6;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

/* 타이머 바 */
.timer-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timer-track {
    flex: 1;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00ff9d, #58a6ff);
    border-radius: 5px;
    transition: width 0.05s linear, background 0.2s;
}

.timer-bar.timer-urgent {
    background: linear-gradient(90deg, #ff6b6b, #ff3355);
    box-shadow: 0 0 10px rgba(255, 90, 90, 0.6);
}

.timer-text {
    font-size: 0.85rem;
    color: #00ff9d;
    min-width: 2.5rem;
    text-align: right;
}

/* 방어 버튼 */
.defense-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.defense-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 0.25rem;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.4);
    color: #e8eef4;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
}

.defense-btn .key-cap {
    font-size: 1.1rem;
    font-weight: bold;
    color: #00ff9d;
}

.defense-btn .key-label {
    font-size: 0.62rem;
    color: #8b9cb3;
    margin-top: 0.25rem;
    line-height: 1.2;
    text-align: center;
}

.defense-btn:hover:not(:disabled) {
    border-color: #58a6ff;
}

.defense-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.defense-btn.pressed {
    transform: scale(0.95);
    box-shadow: 0 0 16px rgba(0, 255, 157, 0.45);
    border-color: #00ff9d;
}

.result-message {
    margin-top: 0.75rem;
    min-height: 1.25rem;
    font-weight: bold;
    text-align: center;
}

.result-message.success { color: #00ff9d; }
.result-message.fail { color: #ff6b6b; }

/* 플로팅 FX */
.fx-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fx-text {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    animation: fx-rise 0.85s ease forwards;
    text-shadow: 0 0 20px currentColor;
}

.fx-success { color: #00ff9d; top: 40%; }
.fx-fail { color: #ff6b6b; top: 42%; }
.fx-combo { color: #ffd700; font-size: 1.4rem; top: 48%; }
.fx-stage { color: #58a6ff; font-size: 2.2rem; }

@keyframes fx-rise {
    0% { opacity: 1; transform: scale(0.8) translateY(20px); }
    100% { opacity: 0; transform: scale(1.2) translateY(-40px); }
}

.stage-up-banner {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    z-index: 60;
    pointer-events: none;
}

.stage-up-banner.hidden {
    display: none;
}

.stage-up-banner.animate {
    animation: stage-pop 1.5s ease forwards;
}

@keyframes stage-pop {
    0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
    20% { opacity: 1; transform: translateX(-50%) scale(1.1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* 점수판 */
.score-list {
    list-style: none;
}

.score-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.score-list span { color: #8b9cb3; }
.score-list strong { color: #00ff9d; }

.grade-s { color: #ffd700 !important; }
.grade-a { color: #00ff9d !important; }
.grade-b { color: #58a6ff !important; }
.grade-c { color: #ff6b6b !important; }

/* 로그 */
.log-card { max-height: 420px; }
.log-list {
    max-height: 340px;
    overflow-y: auto;
    font-size: 0.75rem;
}

.log-empty { color: #6e7681; }

.log-item {
    padding: 0.5rem;
    margin-bottom: 0.4rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    border-left: 3px solid #58a6ff;
}

.log-item.success { border-left-color: #00ff9d; }
.log-item.fail { border-left-color: #ff6b6b; }

.log-time { color: #6e7681; font-size: 0.7rem; }
.log-meta { color: #58a6ff; font-size: 0.68rem; margin: 0.15rem 0; }
.log-result { font-weight: bold; margin-top: 0.2rem; }

/* 모달 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden { display: none; }

.modal-box {
    width: 90%;
    max-width: 400px;
}

.gameover-box h2 {
    color: #ff6b6b;
    border: none;
    text-align: center;
}

.gameover-sub {
    text-align: center;
    color: #8b9cb3;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.gameover-stats {
    list-style: none;
    margin-bottom: 1rem;
}

.gameover-stats li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .defense-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .defense-buttons .defense-btn:nth-child(5) {
        grid-column: span 2;
    }
}
