/* Dark Meridian - 다크 판타지 하드코어 로그라이크 공통 스타일 */
:root {
    --bg: #090b10;
    --bg-glow: #182039;
    --panel: #141925;
    --panel-alt: #1b2232;
    --panel-raised: #20293b;
    --border: #39455a;
    --border-soft: #283347;
    --text: #e5e9f2;
    --text-muted: #9ba6b8;
    --gold: #f0ce78;
    --gold-dim: #a88945;
    --blood: #d65057;
    --link: #8dbdff;
    --focus: #9ec8ff;
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
    scroll-behavior: smooth;
    /* .tip::after 같은 절대배치 요소가 화면 오른쪽 끝 근처 앵커에서 뷰포트 밖으로 삐져나오면
       visibility:hidden 상태에서도 문서 가로 폭에 반영돼 모바일에서 좌우 바운스/여백이 생긴다.
       .table-scroll처럼 의도된 가로 스크롤 영역은 없으므로 여기서 안전하게 막는다. */
    overflow-x: hidden;
}

body {
    font-family: 'Malgun Gothic', 'Noto Sans KR', 'Courier New', sans-serif;
    background:
        radial-gradient(ellipse 75% 42% at 50% -8%, var(--bg-glow) 0%, transparent 68%),
        linear-gradient(115deg, rgba(65, 81, 117, 0.09) 1px, transparent 1px),
        var(--bg);
    background-size: auto, 28px 28px, auto;
    background-attachment: fixed;
    color: var(--text);
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem clamp(1rem, 3vw, 2.25rem) 3rem;
    line-height: 1.55;
    /* html의 overflow-x:hidden과 짝 - 모바일 브라우저마다 뷰포트 스크롤러로 html/body 중 어느 쪽을
       쓰는지 갈리므로 양쪽 다 막아야 확실하다. */
    overflow-x: hidden;
}

a {
    color: var(--link);
}

h1, h2, h3 {
    font-family: 'Cinzel', 'Malgun Gothic', serif;
    letter-spacing: 0.03em;
    color: var(--gold);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.55rem;
}

h1 {
    font-family: 'Cinzel Decorative', 'Cinzel', 'Malgun Gothic', serif;
    text-align: center;
    text-shadow: 0 0 12px rgba(224, 193, 104, 0.35);
    font-size: clamp(1.55rem, 3.5vw, 2.2rem);
    margin: 0.25rem 0 1.4rem;
    padding-bottom: 0.8rem;
    border-bottom-color: rgba(240, 206, 120, 0.28);
}

h2 { font-size: clamp(1.25rem, 2.4vw, 1.55rem); }
h3 { font-size: 1.08rem; margin-top: 0; }

::selection { background: rgba(141, 189, 255, 0.3); color: #fff; }

/* 상단 공통 네비게이션 */
.nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
    margin: -0.55rem 0 1.5rem;
    padding: 0.45rem;
    border: 1px solid rgba(57, 69, 90, 0.72);
    border-radius: 10px;
    background: rgba(12, 16, 25, 0.72);
    backdrop-filter: blur(12px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
}
.nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.88rem;
    letter-spacing: 0.02em;
    padding: 0.42rem 0.64rem;
    border-radius: 6px;
    white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.nav a:hover, .nav a:focus-visible {
    color: var(--gold);
    background: rgba(240, 206, 120, 0.1);
}
.nav a.is-active {
    color: #fff5cf;
    background: linear-gradient(180deg, rgba(240, 206, 120, 0.22), rgba(240, 206, 120, 0.09));
    box-shadow: inset 0 0 0 1px rgba(240, 206, 120, 0.2);
}
.nav .nav-logout {
    color: #ef9a9e;
    margin-left: auto;
}

.panel {
    background: linear-gradient(145deg, rgba(31, 40, 57, 0.96), rgba(20, 25, 37, 0.98));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(1rem, 2vw, 1.45rem);
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow);
}

.stat-line {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-soft);
    padding: 0.25rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.7rem;
    background: rgba(5, 8, 13, 0.16);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    /* th 안의 안내 말풍선이 테이블 테두리에 잘리지 않도록 숨기지 않는다. */
    overflow: visible;
}

/* 좁은 화면에서 이름이 아주 길어도 본문이 가로로 넘치지 않도록 표 자체를 감싸 가로 스크롤시킨다.
   (마지막 안전장치 - 대부분의 이름은 아래 keep-all 규칙으로 한 줄에 들어간다.) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 한글 이름/버튼 라벨이 음절 단위로 세로로 쪼개지지 않게 - 공백 단위로만 줄바꿈(CJK 친화). */
td, th { word-break: keep-all; }

th, td {
    text-align: left;
    /* 행마다 높이가 달라도(예: 지역이동 표의 설명 줄 수 차이) 모든 칸이 같은 기준선에서 시작하도록
       세로 중앙 정렬 대신 위쪽 정렬을 쓴다 - 버튼 칸만 top이고 나머지가 middle이면 같은 행 안에서도
       버튼이 다른 칸보다 위/아래로 어긋나 보인다. */
    vertical-align: top;
    padding: 0.62rem 0.7rem;
    border-bottom: 1px solid var(--border-soft);
}

th {
    color: var(--text-muted);
    font-weight: normal;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tbody tr { transition: background-color 0.15s ease; }
tbody tr:hover { background: rgba(141, 189, 255, 0.055); }

/* 버튼: 줄바꿈 시에도 간격이 일정하도록 항상 여백을 갖는다 */
button, .btn {
    display: inline-block;
    background: linear-gradient(180deg, #34425e, #273249);
    color: var(--text);
    border: 1px solid #445;
    border-radius: 6px;
    padding: 0.55rem 0.9rem;
    margin: 0;
    font-family: inherit;
    font-size: 0.95em;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
    min-height: 2.5rem;
    font-weight: 600;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

button:hover:not(:disabled), .btn:hover {
    background: linear-gradient(180deg, #405273, #2d3c58);
    border-color: #61769b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

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

.btn-primary {
    background: linear-gradient(180deg, #4c8a4c, #3a6b3a);
    border-color: #5ba75b;
}
.btn-primary:hover {
    background: linear-gradient(180deg, #5ba75b, #4c8a4c);
}

.btn-gold {
    background: linear-gradient(180deg, #6b5a25, #4d4019);
    border-color: var(--gold-dim);
    color: var(--gold);
}
.btn-gold:hover {
    box-shadow: 0 0 10px rgba(224, 193, 104, 0.4);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.zone-action-btn {
    white-space: nowrap;
}

.pagination-ellipsis {
    padding: 0 0.2rem;
    color: var(--text-muted);
}

/* 폼: 라벨 위, 입력창 아래로 세로 정렬 + 모든 입력 타입 동일한 스타일 */
.form-group {
    margin-bottom: 0.75rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    color: #b7bccb;
    font-size: 0.9em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select {
    display: block;
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid #445;
    border-radius: 6px;
    padding: 0.65rem 0.7rem;
    margin-bottom: 0.75rem;
    font-family: inherit;
    font-size: 0.95em;
}

input:focus, select:focus, button:focus-visible, .btn:focus-visible, a:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(158, 200, 255, 0.22);
}

.error {
    color: #ff8080;
    min-height: 1.4em;
}
.success {
    color: #7fd98a;
    min-height: 1.4em;
}
.choice-summary {
    margin: 0.6rem 0 0;
    padding: 0.55rem 0.65rem;
    border-left: 2px solid var(--gold-dim);
    background: rgba(240, 206, 120, 0.06);
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

/* 간단한 설명 툴팁 - 브라우저 기본 title 속성을 쓰되, 눈에 띄게 점선 밑줄 표시 */
/* 커스텀 툴팁: 브라우저 기본 title 툴팁은 뜨기까지 1초 넘게 걸려서 답답하다는 피드백이 있어,
   title 속성값을 그대로 재사용(attr(title))하면서 훨씬 짧은 지연으로 뜨는 카드형 툴팁을 얹는다.
   title 자체는 지우지 않아서 커스텀 스타일이 안 먹는 예외 상황(스크린리더 등)에도 정보는 남는다. */
.tip {
    position: relative;
    border-bottom: 1px dotted var(--link);
    cursor: help;
}
.tip::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(3px);
    width: max-content;
    max-width: min(260px, calc(100vw - 1.5rem));
    white-space: normal;
    text-align: left;
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--gold-dim);
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font-size: 0.78em;
    line-height: 1.4;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    z-index: 90;
    transition: opacity 0.12s ease 0.15s, visibility 0.12s ease 0.15s, transform 0.12s ease 0.15s;
}
.tip[data-tooltip]::after { content: attr(data-tooltip); }
.tip:hover::after, .tip:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.tip.tip-edge-left::after {
    left: 0;
    transform: translateX(0) translateY(3px);
}
.tip.tip-edge-left:hover::after, .tip.tip-edge-left:focus-visible::after { transform: translateX(0) translateY(0); }
.tip.tip-edge-right::after {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(3px);
}
.tip.tip-edge-right:hover::after, .tip.tip-edge-right:focus-visible::after { transform: translateX(0) translateY(0); }
.tip.tip-below::after { top: calc(100% + 8px); bottom: auto; }

.muted {
    color: var(--text-muted);
    font-size: 0.9em;
}

.grade-normal { color: #ffffff; }
.grade-magic { color: #4da6ff; }
.grade-rare { color: #b060ff; }
.grade-unique { color: #ff9d33; }
.grade-legendary { color: #ff5555; }
/* 몬스터 grade는 normal/rare/boss 3단계 - normal/rare는 위 아이템 등급과 공유, boss만 별도 */
.grade-boss { color: #ff3860; font-weight: bold; }

/* 카드 테두리/발광 버전 - 등급별 프레임 연출용 */
.frame-normal { border-color: #55585f !important; }
.frame-magic { border-color: #4da6ff !important; box-shadow: 0 0 8px rgba(77, 166, 255, 0.25); }
.frame-rare { border-color: #b060ff !important; box-shadow: 0 0 8px rgba(176, 96, 255, 0.28); }
.frame-unique { border-color: #ff9d33 !important; box-shadow: 0 0 10px rgba(255, 157, 51, 0.3); }
.frame-legendary { border-color: #ff5555 !important; box-shadow: 0 0 12px rgba(255, 85, 85, 0.35); }
.frame-boss { border-color: #ff3860 !important; box-shadow: 0 0 14px rgba(255, 56, 96, 0.4); }

/* 속성 (원소) 색상 */
.element-physical { color: var(--text); }
.element-fire { color: #ff6a3d; }
.element-ice { color: #66ccff; }
.element-lightning { color: #ffe14d; }
.element-dark { color: #a35cff; }
.element-holy { color: #ffe08a; }
.element-poison { color: #5cd65c; }
.element-bleed { color: #d9435a; }
.element-none { color: var(--text-muted); }

.gold-value {
    color: var(--gold);
    font-weight: bold;
}

/* HP/MP/AP 게이지 바 - 숫자만으론 한눈에 안 보여서 시각화 */
.bar {
    position: relative;
    width: 100%;
    height: 1.2rem;
    background: #0d0f14;
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    overflow: hidden;
    margin: 0.15rem 0 0.6rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transition: width 0.3s ease;
}
.bar-fill.hp { background: linear-gradient(90deg, #7a2020, #d94848); }
.bar-fill.mp { background: linear-gradient(90deg, #1f4a7a, #4d90d9); }
.bar-fill.ap { background: linear-gradient(90deg, #7a6a1f, #d9b94d); }
.bar-fill.monster-hp { background: linear-gradient(90deg, #6b1f1f, #b83a3a); }
.bar-label {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    text-shadow: 0 1px 2px #000;
}

/* 캐릭터 능력치(힘/지능/민첩/체력/정신) - 캐릭터 시트풍의 얇은 구분선 띠 형태 (자원 카드와 시각적으로 구분) */
.attr-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0.75rem 0;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    background: linear-gradient(180deg, rgba(224, 193, 104, 0.05), transparent 60%);
    background-clip: padding-box;
}
.attr-item {
    flex: 1 1 0;
    min-width: 84px;
    text-align: center;
    padding: 0.65rem 0.4rem;
    border-right: 1px solid var(--border-soft);
}
.attr-item:last-child {
    border-right: none;
}
.attr-label {
    font-family: 'Cinzel', serif;
    font-size: 1em;
    letter-spacing: 0.06em;
    color: var(--gold-dim);
    margin-bottom: 0.3rem;
}
.attr-value {
    font-size: 1.6em;
    font-weight: bold;
    color: var(--text);
}
.attr-value .bonus {
    display: block;
    font-size: 0.65em;
    font-weight: normal;
    color: #7fd97f;
    margin-top: 0.1rem;
}
/* 인벤토리 아이템 카드의 공격/방어 - 강화 보너스는 캐릭터 능력치 패널과 달리 한 줄 안에 이어 붙는다 */
.item-card-meta .bonus {
    color: #7fd97f;
    margin-left: 0.2em;
}

/* 캐릭터 스탯 카드 그리드 - HP/MP/AP/골드 등을 숫자 나열이 아닌 카드로 한눈에 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0;
}
.stat-card {
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
}
.stat-card .stat-card-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.stat-card .stat-card-value {
    font-weight: bold;
}
.stat-card .bar {
    margin-bottom: 0;
}

/* 아이템 카드 그리드 (인벤토리/장착 장비) */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.item-card {
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.item-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.item-card-icon {
    font-size: 1.3em;
    flex-shrink: 0;
}
.item-card-name {
    font-weight: bold;
    line-height: 1.3;
}
.item-card-meta {
    font-size: 0.85em;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    /* space-between이었을 때는 같은 줄의 span 개수가 카드마다 달라서(2개 vs 3개 vs 4개) 남는 공간을
       나눠 갖는 방식이라 "GS" 위치가 카드마다 들쑥날쑥해 보였다 - 항목 수와 무관하게 항상 왼쪽부터
       일정한 간격으로 붙여서 카드 간 정렬이 맞도록 고정. */
    justify-content: flex-start;
    gap: 0.2rem 0.6rem;
}
/* 베이스 랜덤옵션이 늘어나면서(최대 4개) 이 줄의 span 수가 가변적으로 늘어난다 - 한 줄에 다 안 들어가면
   컨테이너가 각 span을 억지로 줄이면서 "공격 23"처럼 라벨과 숫자가 서로 다른 줄로 쪼개져 보이는
   버그가 있었다. 각 span을 통째로(안 쪼개지게) 다음 줄로 넘기도록 고정. */
.item-card-meta > span {
    white-space: nowrap;
}
/* 등급/속성처럼 "왼쪽 항목 - 오른쪽 항목"으로 나눠 보이고 싶은 줄에서, 오른쪽에 둘 항목에만 붙여서
   그 항목(과 그 뒤에 오는 형제 요소, 예: 강화 수치 배지)을 줄 끝으로 밀어낸다. */
.item-card-meta .push-right {
    margin-left: auto;
}
/* GS처럼 한 줄을 통째로 차지하는 item-card-stat-line 중 오른쪽 정렬이 필요한 항목용. */
.item-card-stats .stat-right {
    text-align: right;
}
/* 공격/방어/GS/베이스옵션처럼 개수가 아이템마다 달라지는 항목들 - item-card-meta(flex-wrap)처럼 한 줄에
   여러 개를 채우면 카드마다 줄바꿈 위치가 달라져 옆 카드와 안 맞아 보인다. 무조건 한 줄에 하나씩만
   쌓아서(GS → 공격/방어 → 추가옵션 순) 카드가 몇 개를 갖고 있든 같은 항목은 항상 같은 순서로 보이게 한다.
   (전투/프로필 등 다른 화면의 장착 장비 카드도 동일 클래스 재사용 - inventory.jsp 참고) */
.item-card-stats {
    font-size: 0.85em;
    color: var(--text-muted);
}
.item-card-stat-line {
    padding: 0.1rem 0;
}
.item-card-effect {
    font-size: 0.85em;
    color: var(--gold);
    margin: 0;
    line-height: 1.4;
}
.item-card-footer {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}
.item-card-footer > button,
.item-card-footer > .item-action-menu > summary,
.item-action-popover button {
    min-height: 2.2rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.86rem;
}

/* 카드에는 주 행동만 두고, 드문 관리 행동은 작은 메뉴로 감춘다. */
.item-action-menu { position: relative; }
.item-action-menu > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
}
.item-action-menu > summary::-webkit-details-marker { display: none; }
.item-action-menu > summary::after { content: "⌄"; margin-left: 0.35rem; color: var(--gold-dim); }
.item-action-menu[open] > summary { color: var(--text); border-color: var(--gold-dim); }
.item-action-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.4rem);
    z-index: 20;
    display: flex;
    gap: 0.35rem;
    padding: 0.4rem;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    white-space: nowrap;
}
.locked-badge {
    margin-left: auto;
    padding: 0.1rem 0.38rem;
    border: 1px solid var(--gold-dim);
    border-radius: 999px;
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 700;
}
.enhance-stone-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: baseline;
    margin: -0.15rem 0 0.75rem;
    color: var(--text-muted);
}
.enhance-stone-summary strong { color: var(--gold); }
.inventory-control-row { align-items: center; }
.inventory-control-row select {
    width: auto;
    min-width: 12rem;
    margin: 0;
}
.sell-toolbar button {
    min-height: 2.15rem;
    padding: 0.38rem 0.62rem;
    font-size: 0.82rem;
}
.item-card.equipped {
    border-color: var(--gold-dim);
}
/* 인벤토리 상단 "장착 장비" 요약 카드는 그 부위 탭으로 바로 이동하는 링크라 <a>로 감싼다 -
   기본 링크 밑줄/색을 지우고 카드처럼 보이게 한다. */
a.item-card {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}
a.item-card:hover {
    border-color: var(--focus);
    transform: translateY(-1px);
}
.slot-empty-card {
    border-style: dashed;
    opacity: 0.65;
}
.slot-empty-card:hover {
    opacity: 1;
}
.enhance-panel {
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: rgba(224, 193, 104, 0.08);
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    font-size: 0.9em;
}
.enhance-resource {
    margin: 0.45rem 0;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    color: #b9d9a2;
    background: rgba(127, 217, 127, 0.08);
}
.enhance-resource.is-short {
    color: #ff9a9a;
    background: rgba(214, 80, 87, 0.1);
}

/* 아이템을 고른 뒤에는 화면 어디에 있든 같은 자리에서 처리할 수 있다. */
.inventory-selection-bar {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 100;
    display: none;
    width: min(720px, calc(100vw - 2rem));
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem 0.65rem 1rem;
    background: rgba(27, 34, 50, 0.97);
    border: 1px solid var(--gold-dim);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.48);
    transform: translateX(-50%);
}
.inventory-selection-bar.is-visible { display: flex; }
.inventory-selection-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.inventory-selection-bar button { min-height: 2.2rem; padding: 0.4rem 0.7rem; font-size: 0.86rem; }

/* 프로필 이동은 일반 링크가 아니라 이름 중심의 조용한 상호작용으로 표현한다. */
.character-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.character-link:hover, .character-link:focus-visible { color: var(--gold); border-bottom-color: var(--gold-dim); }
.character-link-cue {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0;
    transform: translateX(-2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.character-link:hover .character-link-cue, .character-link:focus-visible .character-link-cue { opacity: 1; transform: translateX(0); }

/* 판매용 체크박스로 선택된 카드 - frame-*가 border-color를 !important로 깔아놔서 일반 규칙으론 안 먹히므로
   똑같이 !important로 덮어쓰고, 등급 발광과는 별개로 눈에 띄도록 바깥쪽 글로우도 추가한다 */
.item-card.selected {
    border-color: var(--gold) !important;
    background: rgba(224, 193, 104, 0.08);
    box-shadow: 0 0 0 2px rgba(224, 193, 104, 0.5);
}

/* 물약 사용 시 회복 순간을 눈에 띄게 - 카드가 잠깐 초록빛으로 번쩍였다 사라진다 */
@keyframes potion-flash {
    0% { box-shadow: 0 0 0 2px rgba(127, 217, 127, 0.9); }
    100% { box-shadow: 0 0 0 2px rgba(127, 217, 127, 0); }
}
.item-card.potion-flash {
    animation: potion-flash 0.6s ease-out;
}

/* 전투 VS 레이아웃 - 나와 상대의 상태를 좌우로 대비시켜 한눈에 파악 */
.vs-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 0.75rem;
}
.vs-divider {
    font-family: 'Cinzel', serif;
    color: var(--gold-dim);
    font-weight: bold;
    padding-top: 1.6rem;
    text-align: center;
}
.combatant-card {
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
    transition: background-color 0.3s ease;
}
.combatant-card.enemy {
    border-color: rgba(255, 56, 96, 0.35);
}
.combatant-card.ally {
    border-color: rgba(127, 178, 255, 0.35);
}

/* 전투 카드 모션 - battle-fx.js가 액션 종류에 따라 클래스를 붙였다 뗀다 */
.card-low-hp { background: rgba(184, 58, 58, 0.22); }

@keyframes fx-lunge-ally {
    0% { transform: translateX(0); }
    40% { transform: translateX(14px); }
    100% { transform: translateX(0); }
}
@keyframes fx-lunge-enemy {
    0% { transform: translateX(0); }
    40% { transform: translateX(-14px); }
    100% { transform: translateX(0); }
}
@keyframes fx-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
@keyframes fx-shake-crit {
    0%, 100% { transform: translateX(0) scale(1); }
    15% { transform: translateX(-10px) scale(1.03); }
    30% { transform: translateX(10px) scale(1.03); }
    45% { transform: translateX(-8px) scale(1.02); }
    60% { transform: translateX(8px) scale(1.02); }
    75% { transform: translateX(-4px) scale(1); }
}
@keyframes fx-shield-pulse {
    0% { box-shadow: 0 0 0 0 rgba(224, 193, 104, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(224, 193, 104, 0); }
    100% { box-shadow: 0 0 0 0 rgba(224, 193, 104, 0); }
}
/* 회피 - 맞을 뻔한 쪽이 살짝 몸을 젖혔다 돌아온다(피격 흔들림과 구분되는 부드러운 움직임) */
@keyframes fx-dodge {
    0% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-7px) scale(0.97); }
    65% { transform: translateY(3px) scale(1.01); }
    100% { transform: translateY(0) scale(1); }
}
/* 전사 반격 스턴 - 맞은 쪽이 어지러운 듯 좌우로 기운다 */
@keyframes fx-stun {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-6deg); }
    40% { transform: rotate(5deg); }
    60% { transform: rotate(-4deg); }
    80% { transform: rotate(3deg); }
}
/* 흑마법사 흡수 - 자기 카드에 어두운 보라색 펄스 */
@keyframes fx-absorb-pulse {
    0% { box-shadow: 0 0 0 0 rgba(163, 92, 255, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(163, 92, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(163, 92, 255, 0); }
}
.fx-lunge-ally { animation: fx-lunge-ally 0.35s ease; }
.fx-lunge-enemy { animation: fx-lunge-enemy 0.35s ease; }
.fx-shake { animation: fx-shake 0.35s ease; }
.fx-shake-crit { animation: fx-shake-crit 0.5s ease; }
.fx-shield { animation: fx-shield-pulse 0.5s ease; }
.fx-dodge { animation: fx-dodge 0.3s ease; }
.fx-stun { animation: fx-stun 0.6s ease; }
.fx-absorb { animation: fx-absorb-pulse 0.5s ease; }

@keyframes fx-projectile-fly {
    0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
    12% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    85% { opacity: 1; }
    100% { transform: translate(calc(-50% + var(--fx-dx)), calc(-50% + var(--fx-dy))) scale(1); opacity: 0; }
}
/* game-icons.net SVG를 <img>로 박아넣으면 색을 못 바꾸므로, mask로 씌워서 background-color로
   자유롭게 색을 입힌다 (아이콘/색은 battle-fx.js가 --fx-icon/--fx-color로 지정). */
.battle-fx-projectile {
    position: fixed;
    width: 2.6rem;
    height: 2.6rem;
    pointer-events: none;
    z-index: 200;
    animation: fx-projectile-fly 0.45s ease forwards;
    background-color: var(--fx-color, var(--gold));
    -webkit-mask-image: var(--fx-icon);
    mask-image: var(--fx-icon);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    filter: drop-shadow(0 0 6px rgba(224, 193, 104, 0.85));
}
/* 발사체와 달리 카드 하나에서만 튀어올랐다 사라지는 자기 자신 전용 아이콘 뱃지 (방어/회피/회복/
   흡수/치명타 등). mask 방식은 위 .battle-fx-projectile과 동일. */
@keyframes fx-badge-pop {
    0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translate(-50%, -65%) scale(1); opacity: 0; }
}
.battle-fx-badge {
    position: fixed;
    width: 2.1rem;
    height: 2.1rem;
    pointer-events: none;
    z-index: 200;
    animation: fx-badge-pop 0.5s ease forwards;
    background-color: var(--fx-color, var(--gold));
    -webkit-mask-image: var(--fx-icon);
    mask-image: var(--fx-icon);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.7));
}
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.4rem;
    font-size: 1.4em;
    font-family: 'Cinzel', serif;
    background: var(--panel-alt);
    border: 2px solid var(--border);
}
.combatant-card.ally .avatar { border-color: var(--link); color: var(--link); }
.combatant-card.enemy .avatar { border-color: #ff3860; color: #ff3860; }
.avatar-portrait {
    background-color: currentColor;
    -webkit-mask-image: var(--avatar-portrait-src);
    mask-image: var(--avatar-portrait-src);
    -webkit-mask-size: 68%;
    mask-size: 68%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}
.combatant-name {
    font-weight: bold;
    margin-bottom: 0.35rem;
}
.opponent-info-line {
    font-weight: normal;
    font-size: 0.9em;
    color: var(--text);
}

.turn-log {
    background: #0a0b0e;
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    padding: 0.75rem;
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 0.92em;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
}
/* 전투 로그 색상 차별화 - 카드 테두리(.combatant-card ally/enemy)와 같은 색으로 이름을 강조하고,
   지속피해/회복/치명타 줄은 그 성격이 한눈에 들어오도록 별도 색을 준다. */
.log-name-ally { color: var(--link); font-weight: bold; }
.log-name-enemy { color: #ff3860; font-weight: bold; }
/* 지속피해는 속성별로 색을 나눈다(.element-* 배지와 같은 색) - 다 빨강으로 뭉치면 적 이름 색(빨강)과
   구분이 안 됐음. .log-line-dot은 위 세 코드에 없는 미지의 dot 타입을 위한 대비용 fallback. */
.log-line-poison { color: #5cd65c; }
.log-line-bleed { color: #d9435a; }
.log-line-curse { color: #a35cff; }
.log-line-dot { color: #e0a468; }
.log-line-regen { color: #5cd65c; }
.log-line-crit { color: var(--gold); font-size: 1.12em; font-weight: bold; }

/* 인벤토리 슬롯 구분 섹션 - 슬롯별로 지금 뭘 입고 있는지 한눈에 보이게 */
.slot-section {
    margin-bottom: 1.3rem;
}
.slot-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.4rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-soft);
}
.slot-section-icon {
    font-size: 1.2em;
}
.slot-section-title {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    letter-spacing: 0.03em;
}
.slot-section-status {
    margin-left: auto;
    font-size: 0.85em;
}
.slot-section-status.filled {
    color: #7fd97f;
}
.slot-section-status.empty {
    color: var(--text-muted);
}
.slot-empty-placeholder {
    color: var(--text-muted);
    font-size: 0.9em;
    padding: 0.5rem 0;
}

/* 대전기록 결과 배지 */
.result-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: bold;
}
.result-win { background: rgba(76, 138, 76, 0.25); color: #7fd97f; }
.result-lose { background: rgba(184, 58, 58, 0.25); color: #ff8080; }
.result-flee { background: rgba(138, 143, 156, 0.25); color: var(--text-muted); }

/* 강화 기록 결과 배지 - success는 win과 같은 초록, fail_downgrade는 lose와 같은 빨강,
   fail_safe(강화석만 소모, 단계 유지)는 위험하지 않다는 걸 색으로 구분하기 위해 중립 노랑 */
.result-success { background: rgba(76, 138, 76, 0.25); color: #7fd97f; }
.result-fail_safe { background: rgba(224, 193, 104, 0.2); color: #e0c168; }
.result-fail_downgrade { background: rgba(184, 58, 58, 0.25); color: #ff8080; }

/* 상점 도박 결과 모달 - 주사위 굴리는 연출 후 결과 카드 공개 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    min-width: 300px;
    max-width: 90vw;
    text-align: center;
}
.enhance-result-box { max-width: 430px; }
.enhance-result-box h3 { margin: 0.75rem 0 0.45rem; }
.enhance-result-box p:not(.result-badge) { margin: 0.4rem 0 1.15rem; color: var(--text); }

/* 스크롤 적용 결과(전/후 옵션 비교) 모달 */
.scroll-result-box { max-width: 440px; text-align: left; }
.scroll-result-box h3 { margin: 0 0 0.75rem; text-align: center; }
.scroll-result-item-name { margin: 0 0 0.85rem; text-align: center; font-weight: bold; font-size: 1.05em; }
.scroll-diff-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-soft);
    font-size: 0.92em;
}
.scroll-diff-row:last-child { border-bottom: none; }
.scroll-diff-label { color: var(--text-muted); flex-shrink: 0; }
.scroll-diff-value { text-align: right; }
.scroll-diff-changed .scroll-diff-value { display: inline-flex; align-items: center; gap: 0.4rem; }
.scroll-diff-before { color: var(--text-muted); text-decoration: line-through; }
.scroll-diff-arrow { color: var(--gold); }
.scroll-diff-after { color: var(--gold); font-weight: bold; }
/* 등급 행처럼 값 자체가 grade-* 색을 갖는 경우, 그 색이 우선 적용되어 버려서 이전/이후 강조가 묻힌다 -
   diff 표시가 등급색보다 항상 우선하도록 명시적으로 덮어쓴다. */
.scroll-diff-before [class*="grade-"] { color: inherit; }
.scroll-diff-after [class*="grade-"] { color: inherit; font-weight: inherit; }
.scroll-diff-delta.up { color: #7fd97f; }
.scroll-diff-delta.down { color: #ff8080; }
.dice-spin {
    font-size: 3.5rem;
    line-height: 1;
    animation: dice-roll 0.6s infinite linear;
}
@keyframes dice-roll {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.15); }
    100% { transform: rotate(360deg) scale(1); }
}
#gamble-result .item-card {
    text-align: left;
    background: var(--panel-alt);
    border-width: 2px;
    transition: box-shadow 0.3s, border-color 0.3s;
}
/* 등급이 높을수록 카드가 더 화려해진다 - normal/magic은 은은하게, rare부터 펄스 애니메이션이 붙고
   legendary는 이중 글로우 + 카드 자체가 살짝 확대되는 등장감을 준다. */
#gamble-result .item-card.reveal-magic {
    border-color: #4da6ff;
    box-shadow: 0 0 14px rgba(77, 166, 255, 0.55);
}
#gamble-result .item-card.reveal-rare {
    border-color: #b060ff;
    box-shadow: 0 0 20px rgba(176, 96, 255, 0.6);
    animation: gamble-glow-rare 1.6s ease-in-out infinite;
}
#gamble-result .item-card.reveal-unique {
    border-color: #ff9d33;
    box-shadow: 0 0 26px rgba(255, 157, 51, 0.7);
    animation: gamble-glow-unique 1.4s ease-in-out infinite;
}
#gamble-result .item-card.reveal-legendary {
    border-color: #ff5555;
    box-shadow: 0 0 20px rgba(255, 85, 85, 0.85), 0 0 46px rgba(224, 193, 104, 0.5);
    animation: gamble-glow-legendary 1.1s ease-in-out infinite, gamble-pop-in 0.5s ease-out;
}
@keyframes gamble-glow-rare {
    0%, 100% { box-shadow: 0 0 20px rgba(176, 96, 255, 0.6); }
    50% { box-shadow: 0 0 30px rgba(176, 96, 255, 0.9); }
}
@keyframes gamble-glow-unique {
    0%, 100% { box-shadow: 0 0 26px rgba(255, 157, 51, 0.7); }
    50% { box-shadow: 0 0 42px rgba(255, 157, 51, 1); }
}
@keyframes gamble-glow-legendary {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 85, 85, 0.85), 0 0 46px rgba(224, 193, 104, 0.5); }
    50% { box-shadow: 0 0 34px rgba(255, 85, 85, 1), 0 0 70px rgba(224, 193, 104, 0.8); }
}
@keyframes gamble-pop-in {
    0% { transform: scale(0.85); }
    60% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

/* 전투 결과 배너 - 승리/패배/사망/도주를 턴 로그와 확실히 구분해 강조한다.
   하드코어 영구사망을 로그 한 줄로 흘려보내 놓치는 걸 막기 위함. */
.battle-result-banner {
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: center;
    font-weight: 700;
}
.battle-result-banner .banner-title { display: block; font-size: 1.25rem; letter-spacing: 0.02em; }
.battle-result-banner .banner-sub { display: block; margin-top: 0.25rem; font-size: 0.85rem; font-weight: 500; opacity: 0.9; }
.battle-result-banner.banner-won  { border-color: var(--gold-dim); color: var(--gold);  background: rgba(240, 206, 120, 0.08); }
.battle-result-banner.banner-died { border-color: var(--blood);    color: var(--blood); background: rgba(214, 80, 87, 0.14); }
.battle-result-banner.banner-lost { border-color: var(--blood);    color: #e0a0a4;      background: rgba(214, 80, 87, 0.06); }
.battle-result-banner.banner-fled { border-color: var(--border);   color: #9aa5b5;      background: rgba(255, 255, 255, 0.03); }

/* 작은 화면에서는 "축소된 데스크톱" 대신 한 손 조작에 맞춘 흐름으로 전환한다. */
@media (max-width: 680px) {
    body {
        padding: 1rem 0.75rem 2rem;
        font-size: 15px;
        background-size: auto, 22px 22px, auto;
    }

    h1 {
        margin: 0.2rem 0 1rem;
        padding-bottom: 0.6rem;
    }

    .nav {
        position: sticky;
        top: 0.45rem;
        z-index: 80;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -0.1rem 1rem;
        padding: 0.38rem;
        scrollbar-width: none;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { padding: 0.52rem 0.68rem; }
    .nav .nav-logout { margin-left: 0; }

    .panel {
        border-radius: 9px;
        padding: 1rem;
        margin-bottom: 0.85rem;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }
    .stat-card { padding: 0.55rem 0.6rem; }
    .stat-card .stat-card-label { font-size: 0.78rem; }

    .attr-row { margin: 0.65rem 0; }
    .attr-item {
        flex-basis: 33.333%;
        min-width: 0;
        padding: 0.55rem 0.25rem;
    }
    .attr-item:nth-child(3) { border-right: none; }
    .attr-item:nth-child(-n + 3) { border-bottom: 1px solid var(--border-soft); }
    .attr-value { font-size: 1.3rem; }

    .btn-row > button, .btn-row > .btn { flex: 1 1 auto; }
    button, .btn { min-height: 2.7rem; }

    .card-grid { grid-template-columns: 1fr; gap: 0.6rem; }
    .item-card { padding: 0.7rem; }

    .vs-layout {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    .vs-divider { padding: 0; font-size: 0.85rem; }
    .combatant-card { padding: 0.65rem; }
    .combatant-card .bar { margin-bottom: 0.35rem; }

    /* 표는 글자를 너무 작게 만들지 않고 여백만 줄여 정보를 유지한다. */
    table {
        font-size: 0.86rem;
    }
    th, td { padding: 0.55rem 0.6rem; }
    /* 모바일은 hover가 없어 '프로필' 큐가 보이지도 않으면서 이름 칸 폭만 잡아먹는다 - 숨겨서 이름에 공간을 준다.
       (inline-flex 자식이라 opacity:0이어도 레이아웃 폭을 차지하던 것을 제거) */
    .character-link-cue { display: none; }
    .ranking-table td:nth-child(2) { min-width: 5.5em; }
    /* 표가 모바일 폭에 눌려 글자 단위로 세로로 쪼개지지 않도록 - 셀은 줄바꿈을 막고,
       .table-scroll 래퍼(overflow-x:auto)가 넘치는 폭을 가로 스크롤로 처리한다(전투기록/랭킹 표). */
    .table-scroll th, .table-scroll td { white-space: nowrap; }

    .slot-section-header { align-items: flex-start; flex-wrap: wrap; }
    .slot-section-status { margin-left: 0; width: 100%; padding-left: 1.75rem; }
    .sell-toolbar > span[style*="margin-left:auto"] { margin-left: 0 !important; width: 100%; }
    .inventory-control-row { align-items: stretch; }
    .inventory-control-row > .muted { width: 100%; }
    .inventory-control-row select { width: 100%; min-width: 0; }
    .inventory-selection-bar {
        bottom: 0.7rem;
        align-items: stretch;
        flex-direction: column;
        gap: 0.45rem;
        padding: 0.65rem;
    }
    .inventory-selection-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
    .inventory-selection-actions button { min-width: 0; padding: 0.35rem; }
    .item-action-popover { right: auto; left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
