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

body {
    font-family: 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh;
    color: #e0e0e0;
    overflow-x: hidden;
    padding: 20px;
}

.game-container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(20, 20, 40, 0.85);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    gap: 15px;
    flex-wrap: wrap;
}

.game-header h1 {
    font-size: 2rem;
    background: linear-gradient(45deg, #ffd700, #ff8c00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    letter-spacing: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(40, 40, 70, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 8px 14px;
    font-size: 0.95rem;
}

.user-icon { font-size: 1.1rem; }

#user-nick {
    color: #fbbf24;
    font-weight: bold;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    color: #fff;
}

/* ========================
   로그인 / 회원가입
   ======================== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #1a1a3e 0%, #0a0a1e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
    overflow-y: auto;
}

.auth-overlay.hidden { display: none; }

.auth-modal {
    background: rgba(20, 20, 40, 0.95);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 20px;
    padding: 35px 30px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7),
                0 0 80px rgba(255, 215, 0, 0.15);
}

.auth-header {
    text-align: center;
    margin-bottom: 25px;
}

.auth-header h2 {
    background: linear-gradient(45deg, #ffd700, #ff8c00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.6rem;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.auth-header p { color: #999; font-size: 0.9rem; }

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 12px;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #888;
    padding: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    box-shadow: 0 2px 10px rgba(220, 38, 38, 0.4);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 14px;
}

.auth-form.active { display: flex; }

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.auth-form label > span {
    color: #d1d5db;
    font-size: 0.85rem;
    font-weight: bold;
}

.auth-form label > span em {
    color: #888;
    font-style: normal;
    font-weight: normal;
    font-size: 0.78rem;
    margin-left: 4px;
}

.auth-form input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.auth-form input:invalid:not(:placeholder-shown) {
    border-color: rgba(239, 68, 68, 0.6);
}

.auth-message {
    min-height: 1.2em;
    font-size: 0.85rem;
    text-align: center;
    color: #f87171;
    font-weight: bold;
}

.auth-message.success { color: #4ade80; }

.auth-submit {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    border: 2px solid #fbbf24;
    padding: 13px;
    font-size: 1.05rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
}

.auth-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(220, 38, 38, 0.6);
}

.auth-footer {
    margin-top: 18px;
    text-align: center;
    color: #666;
    font-size: 0.75rem;
}

/* ========================
   글로벌 랭킹 모달
   ======================== */
.ranking-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.ranking-overlay.hidden { display: none; }

.ranking-modal {
    background: rgba(20, 20, 40, 0.97);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7),
                0 0 80px rgba(255, 215, 0, 0.15);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.ranking-header h2 {
    background: linear-gradient(45deg, #ffd700, #ff8c00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
}

.ranking-close {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.ranking-close:hover {
    background: rgba(239, 68, 68, 0.4);
    color: #fff;
}

.ranking-sort {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.sort-btn {
    background: rgba(40, 40, 70, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    background: rgba(60, 60, 100, 0.8);
    color: #fff;
}

.sort-btn.active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-color: #fbbf24;
    color: #fff;
    font-weight: bold;
}

.ranking-list-wrap {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    min-height: 200px;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ranking-table thead {
    position: sticky;
    top: 0;
    background: rgba(40, 40, 70, 0.95);
    z-index: 1;
}

.ranking-table th {
    padding: 10px 8px;
    text-align: center;
    color: #fbbf24;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.ranking-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
}

.ranking-table tr.me {
    background: rgba(34, 197, 94, 0.12);
}

.ranking-table tr.me td {
    color: #4ade80;
    font-weight: bold;
}

.ranking-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.ranking-rank {
    font-weight: bold;
    color: #fbbf24;
    font-size: 1rem;
}

.ranking-rank.top1 { color: #fbbf24; font-size: 1.1rem; }
.ranking-rank.top2 { color: #d1d5db; }
.ranking-rank.top3 { color: #f97316; }

.ranking-nick {
    color: #fff;
    font-weight: bold;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-level {
    color: #fbbf24;
    font-weight: bold;
}

.ranking-empty {
    text-align: center;
    color: #888;
    padding: 40px 0;
}

.ranking-footer {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ranking-refresh {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.ranking-refresh:hover {
    background: rgba(59, 130, 246, 0.4);
    color: #fff;
}

.ranking-updated {
    color: #888;
    font-size: 0.8rem;
}

/* ========================
   미션 / 업적 모달
   ======================== */
.badge-host { position: relative; }

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
    animation: badge-pulse 1.4s infinite;
}

.badge[hidden] { display: none !important; }

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

.mission-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.mission-overlay.hidden { display: none; }

.mission-modal {
    background: rgba(20, 20, 40, 0.97);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 80px rgba(255, 215, 0, 0.15);
}

.mission-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.mission-header h2 {
    background: linear-gradient(45deg, #ffd700, #ff8c00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
}

.mission-close {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}
.mission-close:hover {
    background: rgba(239, 68, 68, 0.4);
    color: #fff;
}

.mission-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 10px;
    margin-bottom: 12px;
}

.mission-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #aaa;
    padding: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mission-tab.active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    box-shadow: 0 2px 10px rgba(220, 38, 38, 0.4);
}

.mission-reset-info {
    color: #93c5fd;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 12px;
    min-height: 1.2em;
}

.achievement-subtabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.achievement-subtabs.hidden { display: none; }

.subtab-btn {
    background: rgba(40, 40, 70, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.subtab-btn:hover {
    background: rgba(60, 60, 100, 0.8);
    color: #fff;
}

.subtab-btn.active {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-color: #fbbf24;
    color: #fff;
    font-weight: bold;
}

.sub-badge {
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.mission-list {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mission-empty {
    text-align: center;
    color: #888;
    padding: 40px 0;
}

.mission-item {
    background: rgba(40, 40, 70, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px;
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 14px;
    align-items: center;
    transition: all 0.2s ease;
}

.mission-item.claimable {
    border-color: rgba(74, 222, 128, 0.6);
    background: rgba(34, 197, 94, 0.1);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.2);
}

.mission-item.claimed {
    opacity: 0.5;
}

.mission-item.locked {
    opacity: 0.55;
}

.mission-icon {
    font-size: 2rem;
    text-align: center;
}

.mission-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.mission-name {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
}

.mission-desc {
    font-size: 0.8rem;
    color: #aaa;
}

.mission-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.mission-bar {
    flex: 1;
    height: 6px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
    overflow: hidden;
}

.mission-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.mission-bar-fill.full {
    background: linear-gradient(90deg, #fbbf24, #ffd700);
}

.mission-progress-text {
    font-size: 0.78rem;
    color: #ccc;
    min-width: 65px;
    text-align: right;
}

.mission-reward {
    text-align: center;
    min-width: 120px;
}

.mission-reward-amount {
    color: #fbbf24;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.mission-claim-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.mission-claim-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    transform: translateY(-1px);
}

.mission-claim-btn:disabled {
    background: rgba(75, 85, 99, 0.6);
    cursor: not-allowed;
    opacity: 0.7;
}

.mission-claimed-label {
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 8px;
}

@media (max-width: 600px) {
    .mission-item {
        grid-template-columns: 40px 1fr;
        grid-template-rows: auto auto;
    }
    .mission-icon { grid-row: 1 / 3; font-size: 1.6rem; }
    .mission-reward {
        grid-column: 1 / 3;
        grid-row: 2;
        text-align: left;
        display: flex;
        gap: 12px;
        align-items: center;
        min-width: 0;
    }
    .mission-reward-amount { margin-bottom: 0; }
    .mission-claim-btn { width: auto; padding: 6px 14px; }
    .ranking-table { font-size: 0.75rem; }
    .ranking-table th, .ranking-table td { padding: 6px 4px; }
}

.icon-btn {
    background: rgba(40, 40, 70, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(60, 60, 100, 0.8);
    transform: scale(1.05);
}

.icon-btn.muted {
    opacity: 0.4;
}

.gold-display {
    background: linear-gradient(135deg, #2a1810, #4a2c1a);
    padding: 12px 24px;
    border-radius: 50px;
    border: 2px solid #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3),
                inset 0 0 10px rgba(255, 215, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: bold;
}

.gold-icon { font-size: 1.3rem; }

#gold-amount {
    color: #ffd700;
    min-width: 80px;
    text-align: right;
}

.gold-unit { color: #ffd700; opacity: 0.8; }

.game-main {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.sword-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: radial-gradient(circle at center, rgba(255, 215, 0, 0.05) 0%, transparent 70%);
    padding: 30px;
    border-radius: 15px;
    position: relative;
}

.sword-display {
    position: relative;
    width: 200px;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sword-glow {
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.6;
    transition: all 0.5s ease;
    z-index: 0;
}

#sword-svg {
    width: 100%;
    height: 100%;
    z-index: 1;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s ease;
}

.sword-display.shake #sword-svg { animation: shake 0.5s ease-in-out; }
.sword-display.success #sword-svg { animation: success-pulse 0.8s ease-out; }
.sword-display.break #sword-svg { animation: break-anim 0.7s ease-in; }

@keyframes shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-10px) rotate(-3deg); }
    40% { transform: translateX(10px) rotate(3deg); }
    60% { transform: translateX(-8px) rotate(-2deg); }
    80% { transform: translateX(8px) rotate(2deg); }
}

@keyframes success-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); filter: drop-shadow(0 0 30px gold); }
    100% { transform: scale(1); }
}

@keyframes break-anim {
    0% { transform: scale(1) rotate(0); opacity: 1; }
    50% { transform: scale(1.1) rotate(15deg); opacity: 0.7; }
    100% { transform: scale(0.85) rotate(-10deg); opacity: 1; }
}

.sword-info { margin-top: 20px; text-align: center; }

.sword-name {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 10px;
    transition: all 0.5s ease;
    text-shadow: 0 0 15px currentColor;
}

.sword-level {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.level-label { color: #888; font-size: 1rem; }

.level-value {
    font-size: 2rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.info-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.info-card {
    background: rgba(40, 40, 70, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.info-label { color: #999; font-size: 0.85rem; margin-bottom: 8px; }
.info-value { font-size: 1.4rem; font-weight: bold; color: #fff; }
.info-sub {
    font-size: 0.8rem;
    color: #4ade80;
    margin-top: 4px;
    min-height: 1em;
}
.next-name { font-size: 1.1rem; color: #aaffaa; }

.progress-bar {
    margin-top: 10px;
    height: 6px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #fbbf24, #ef4444);
    transition: width 0.5s ease;
    border-radius: 3px;
}

/* ========================
   인벤토리 / 아이템
   ======================== */
.items-section {
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
}

.items-section h3 {
    margin-bottom: 15px;
    color: #fbbf24;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 4px 2px;
    transition: color 0.2s ease;
}

.items-section h3:hover { color: #ffd700; }

.toggle-chevron {
    font-size: 0.75em;
    transition: transform 0.25s ease;
    color: #ccc;
}

.items-section.collapsed .toggle-chevron {
    transform: rotate(-90deg);
}

.items-section.collapsed .items-grid {
    display: none;
}

.items-section.collapsed h3 { margin-bottom: 0; }

.items-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.item-card {
    background: rgba(20, 20, 40, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 10px;
    cursor: pointer;
    color: #fff;
    text-align: center;
    transition: all 0.2s ease;
    position: relative;
}

.item-card:hover:not(:disabled) {
    transform: translateY(-3px);
    border-color: rgba(255, 215, 0, 0.5);
    background: rgba(40, 40, 70, 0.8);
}

.item-card.active {
    border-color: #4ade80;
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.item-card:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.item-icon { font-size: 1.8rem; margin-bottom: 5px; }
.item-name { font-size: 0.95rem; font-weight: bold; margin-bottom: 3px; }
.item-desc { font-size: 0.75rem; color: #aaa; margin-bottom: 5px; }

.item-count {
    font-size: 0.85rem;
    color: #fbbf24;
    font-weight: bold;
}

/* ========================
   액션 / 자동 강화
   ======================== */
.action-section {
    display: flex;
    gap: 15px;
}

.enhance-btn {
    flex: 2;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: 2px solid #fbbf24;
    padding: 20px 40px;
    font-size: 1.3rem;
    font-weight: bold;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    box-shadow: 0 5px 20px rgba(220, 38, 38, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.enhance-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(220, 38, 38, 0.6);
}

.enhance-btn:active:not(:disabled) { transform: translateY(0); }

.enhance-btn:disabled {
    background: linear-gradient(135deg, #4b5563, #374151);
    border-color: #6b7280;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.btn-sub { font-size: 0.85rem; font-weight: normal; opacity: 0.9; }

.action-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.auto-btn, .reset-btn {
    background: linear-gradient(135deg, #4b5563, #374151);
    color: white;
    border: 2px solid #6b7280;
    padding: 12px;
    font-size: 0.95rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auto-btn:hover, .reset-btn:hover {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    transform: translateY(-2px);
}

.auto-btn.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: #60a5fa;
}

.auto-panel {
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 12px;
    padding: 18px;
    display: none;
}

.auto-panel.open { display: block; }

.auto-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.auto-row label {
    color: #aaa;
    font-size: 0.9rem;
}

.auto-row input[type="number"] {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    width: 90px;
    font-size: 1rem;
}

.auto-row input[type="number"]:focus {
    outline: none;
    border-color: #60a5fa;
}

.auto-start-btn, .auto-stop-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    color: white;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.auto-start-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.auto-start-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.auto-stop-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.auto-stop-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.auto-start-btn:disabled, .auto-stop-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.auto-status {
    color: #93c5fd;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 5px;
}

.auto-status.running {
    color: #4ade80;
    font-weight: bold;
}

/* ========================
   결과 / 통계
   ======================== */
.result-section {
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.result-message {
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-align: center;
}

.result-message.success {
    background: rgba(34, 197, 94, 0.2);
    border: 2px solid #22c55e;
    color: #4ade80;
    opacity: 1;
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
}

.result-message.fail {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid #ef4444;
    color: #f87171;
    opacity: 1;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
}

.result-message.break {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #6b7280;
    color: #d1d5db;
    opacity: 1;
}

.result-message.maxed {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 140, 0, 0.2));
    border: 2px solid #ffd700;
    color: #ffd700;
    opacity: 1;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
    animation: maxed-glow 2s infinite;
}

@keyframes maxed-glow {
    0%, 100% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 60px rgba(255, 215, 0, 0.8); }
}

.stats-section {
    background: rgba(30, 30, 50, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
}

.stats-section h3 {
    margin-bottom: 15px;
    color: #fbbf24;
    font-size: 1.2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label { color: #999; font-size: 0.85rem; margin-bottom: 5px; }
.stat-value { font-size: 1.3rem; font-weight: bold; color: #fff; }

.success-color { color: #4ade80; }
.fail-color { color: #f87171; }
.highlight-color { color: #ffd700; }

/* ========================
   모바일 압축 레이아웃
   ======================== */
@media (max-width: 600px) {
    body { padding: 8px; }

    .game-container {
        padding: 14px 12px;
        border-radius: 14px;
    }

    /* 헤더 압축 */
    .game-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
        padding-bottom: 10px;
    }
    .game-header h1 {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }
    .header-right { gap: 8px; flex-wrap: wrap; justify-content: center; }
    .icon-btn { width: 36px; height: 36px; font-size: 1rem; }
    .user-info { padding: 6px 12px; font-size: 0.82rem; gap: 6px; }
    #user-nick { max-width: 70px; }
    .logout-btn { padding: 3px 8px; font-size: 0.7rem; }
    .gold-display { padding: 7px 14px; font-size: 0.95rem; }
    #gold-amount { min-width: 60px; }

    .game-main { gap: 12px; }

    /* 검 영역 축소 */
    .sword-section { padding: 12px 8px; }
    .sword-display { width: 140px; height: 260px; }
    .sword-glow { width: 170px; height: 170px; filter: blur(30px); }
    .sword-info { margin-top: 10px; }
    .sword-name { font-size: 1.2rem; margin-bottom: 4px; }
    .level-label { font-size: 0.85rem; }
    .level-value { font-size: 1.4rem; }

    /* 정보 카드: 3열 유지하되 압축 */
    .info-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .info-card { padding: 8px 4px; border-radius: 8px; }
    .info-label { font-size: 0.68rem; margin-bottom: 3px; }
    .info-value { font-size: 0.95rem; }
    .info-sub { font-size: 0.65rem; }
    .next-name { font-size: 0.78rem; }
    .progress-bar { margin-top: 6px; height: 4px; }

    /* 인벤토리: 3열 유지 */
    .items-section { padding: 12px 10px; border-radius: 12px; }
    .items-section h3 { font-size: 0.9rem; margin-bottom: 10px; }
    .items-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .item-card { padding: 10px 4px; border-radius: 8px; }
    .item-icon { font-size: 1.3rem; margin-bottom: 2px; }
    .item-name { font-size: 0.72rem; margin-bottom: 2px; }
    .item-desc { font-size: 0.6rem; margin-bottom: 3px; }
    .item-count { font-size: 0.7rem; }

    /* 액션 버튼: 강화는 크게, 보조는 가로 */
    .action-section { flex-direction: column; gap: 8px; }
    .enhance-btn {
        padding: 14px 20px;
        font-size: 1.1rem;
        border-radius: 12px;
    }
    .btn-sub { font-size: 0.78rem; }
    .action-right { flex-direction: row; gap: 8px; }
    .auto-btn, .reset-btn {
        padding: 10px;
        font-size: 0.82rem;
        border-radius: 10px;
    }

    /* 자동 강화 패널 */
    .auto-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .auto-row input[type="number"] { width: 100%; }

    /* 결과 메시지 */
    .result-message { font-size: 0.95rem; padding: 10px 16px; }

    /* 통계: 3열로 빡빡하게 */
    .stats-section { padding: 12px 10px; border-radius: 12px; }
    .stats-section h3 { font-size: 1rem; margin-bottom: 10px; }
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .stat-item { padding: 8px 4px; border-radius: 6px; }
    .stat-label { font-size: 0.68rem; margin-bottom: 2px; }
    .stat-value { font-size: 0.95rem; }
}

/* 매우 좁은 화면 (360px 이하) - 일부 항목 더 축소 */
@media (max-width: 360px) {
    .game-header h1 { font-size: 0.95rem; }
    .sword-display { width: 120px; height: 230px; }
    .info-value { font-size: 0.85rem; }
    .stat-value { font-size: 0.85rem; }
    .item-name { font-size: 0.66rem; }
}
