/* client/css/style.css 에서 플레이 관련 부분만 복사 (시뮬레이션 스타일 제외) */
/* ─── 변수 ─────────────────────────────────────────────────── */
:root {
  /* 먹빛 + 금박 팔레트 */
  --bg:          #080a0e;
  --panel:       #0d1018;
  --panel2:      #111520;
  --border:      #1c2232;
  --text:        #dfd7cb;
  --text-dim:    #545868;
  --accent:      #c8a84e;
  --accent-dim:  rgba(200,168,78,0.1);
  --green:       #5faa8a;
  --red:         #c44c42;
  --orange:      #c8883a;
  --purple:      #9b7fc8;

  /* 오방색 — 원소 */
  --c-fire:      #d43535;
  --c-light:     #d4b030;
  --c-wind:      #45aa7a;
  --c-earth:     #a05828;
  --c-water:     #3a6898;
  --c-fire-bg:   #150606;
  --c-light-bg:  #151108;
  --c-wind-bg:   #061510;
  --c-earth-bg:  #140a04;
  --c-water-bg:  #060c16;

  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans:   'Noto Sans KR', -apple-system, sans-serif;
  --radius:      6px;
  --radius-lg:   10px;
  --gold-line:   rgba(200,168,78,0.28);
}

/* ─── 리셋 & 베이스 ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 100% 60% at 8%  8%,  rgba(200,168,78,0.03) 0%, transparent 55%),
    radial-gradient(ellipse 80%  80% at 92% 92%, rgba(58,104,152,0.03) 0%, transparent 55%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  outline: none;
}

input, select {
  font-family: var(--font-mono);
  background: #080b10;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 7px;
  transition: border-color 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: rgba(200,168,78,0.4);
}

/* ─── 레이아웃 ───────────────────────────────────────────────── */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* ─── 탭 네비게이션 ──────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  position: relative;
}
.tabs::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-line) 30%, var(--gold-line) 70%, transparent 100%);
  pointer-events: none;
}

.tab-btn {
  padding: 10px 28px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s;
}
.tab-btn:hover   { color: var(--text); }
.tab-btn.active  { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel        { display: none; }
.tab-panel.active { display: block; }

/* ─── 공용 컴포넌트 ──────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { color: var(--text); border-color: rgba(255,255,255,0.1); }
.chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(200,168,78,0.4);
  box-shadow: 0 0 8px rgba(200,168,78,0.08);
}

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.section-title {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  border-bottom: none;
  padding-bottom: 8px;
  padding-left: 12px;
  margin-bottom: 14px;
  margin-top: 20px;
  position: relative;
}
.section-title::before {
  content: '';
  position: absolute;
  left: 0; top: 1px;
  width: 3px; height: 12px;
  background: var(--accent);
  border-radius: 2px;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 48px; height: 1px;
  background: var(--gold-line);
}
.section-title:first-child { margin-top: 0; }

.btn {
  padding: 8px 22px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  transition: all 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, #d4b058, #a88830);
  color: #0a0805;
  box-shadow: 0 2px 12px rgba(200,168,78,0.22), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #dfc068, #b8983e);
  box-shadow: 0 4px 20px rgba(200,168,78,0.35);
  transform: translateY(-1px);
}
.btn-primary:disabled { background: #151820; color: #363a42; cursor: not-allowed; box-shadow: none; }

.btn-danger {
  background: linear-gradient(135deg, #c44c42, #943832);
  color: #fff;
  box-shadow: 0 2px 12px rgba(196,76,66,0.22);
}
.btn-danger:hover { filter: brightness(1.12); box-shadow: 0 4px 18px rgba(196,76,66,0.35); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--accent);
  border-color: rgba(200,168,78,0.3);
  background: rgba(200,168,78,0.04);
}

/* ─── 히스토그램 ─────────────────────────────────────────────── */
.histogram { margin-bottom: 16px; }
.histogram-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.histogram-label  { font-size: 13px; font-weight: 600; }
.histogram-stats  { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.histogram-bars   { display: flex; align-items: flex-end; height: 80px; gap: 1px; }
.histogram-bar    { flex: 1; border-radius: 2px 2px 0 0; min-height: 0; transition: height 0.3s; opacity: 0.85; }
.histogram-range  {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* ─── 비율 테이블 ─────────────────────────────────────────────── */
.ratio-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 11px; }
.ratio-table th, .ratio-table td { padding: 4px 8px; text-align: right; }
.ratio-table th:first-child, .ratio-table td:first-child { text-align: left; }
.ratio-table thead tr { border-bottom: 1px solid var(--border); }
.ratio-table tbody tr { border-bottom: 1px solid rgba(28,34,50,0.6); }
.ratio-table tfoot tr { border-top: 1px solid var(--border); font-weight: 600; }

/* ─── 전투 시뮬 ──────────────────────────────────────────────── */
#combat-sim { min-height: calc(100vh - 80px); }

/* 학파 선택 카드 */
.school-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.school-card {
  width: 148px;
  padding: 18px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: center;
  transition: all 0.25s;
  background: var(--panel);
  position: relative;
  overflow: hidden;
}
.school-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.07) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.school-card:hover:not(.disabled) {
  transform: translateY(-5px);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 14px 36px rgba(0,0,0,0.6);
}
.school-card:hover:not(.disabled)::after { opacity: 1; }
.school-card.disabled { opacity: 0.22; cursor: default; }

.school-card-icon { font-size: 34px; margin-bottom: 10px; }
.school-card-name { font-size: 15px; font-weight: 800; margin-bottom: 4px; letter-spacing: 0.3px; }
.school-card-elem { font-size: 10px; margin-bottom: 8px; letter-spacing: 0.5px; text-transform: uppercase; }
.school-card-desc { font-size: 10px; color: var(--text-dim); line-height: 1.5; }

/* 카드 컴포넌트 */
.card-comp {
  width: 130px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  cursor: default;
  transition: all 0.18s;
  background: linear-gradient(165deg, #131825, #0a0e18);
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}
.card-comp.selectable { cursor: pointer; }
.card-comp.selected {
  background: linear-gradient(165deg, #1c2238, #111828);
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 6px 24px rgba(0,0,0,0.6);
}
.card-comp:hover.selectable {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.06);
}

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card-el-name { font-size: 13px; font-weight: 800; letter-spacing: 0.3px; }
.card-dir-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.card-power-row { text-align: center; margin-bottom: 4px; }
.card-power { font-size: 28px; font-weight: 900; text-shadow: 0 0 16px currentColor; opacity: 0.95; }
.card-stab  { font-size: 16px; font-weight: 800; margin-left: 2px; opacity: 0.75; }

.card-arch { font-size: 10px; color: var(--text-dim); text-align: center; margin-bottom: 6px; letter-spacing: 0.3px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.card-tag  {
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 2px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.2px;
}
.card-tag.stab {
  font-weight: 700;
  background: rgba(200,168,78,0.1);
  color: rgba(200,168,78,0.8);
}

/* 크리스탈 컴포넌트 */
.crystal {
  width: 72px;
  height: 90px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s;
  cursor: default;
  background: linear-gradient(165deg, #10141e, #070a12);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.03);
}
.crystal.selectable { cursor: pointer; }
.crystal.selectable:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.55); }
.crystal.selected {
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 0 18px rgba(255,255,255,0.1), 0 4px 16px rgba(0,0,0,0.5);
}
.crystal.cracked { opacity: 0.45; }

.crystal-elem-name  { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.crystal-count      { font-size: 22px; font-weight: 800; text-shadow: 0 0 10px currentColor; }
.crystal-crack-mark { font-size: 18px; color: var(--red); font-weight: 900; }

.crystal-bar-wrap {
  width: 50px; height: 3px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  margin-top: 3px;
}
.crystal-bar { height: 100%; border-radius: 2px; transition: width 0.3s; box-shadow: 0 0 4px currentColor; }

.crystal-traces { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; justify-content: center; }
.crystal-trace-label { font-size: 8px; font-weight: 600; }
.crystal-idx    { position: absolute; top: 3px; left: 6px; font-size: 9px; color: rgba(255,255,255,0.15); }
.crystal-healres { position: absolute; top: 3px; right: 5px; font-size: 8px; color: #ff8844; font-weight: 700; }

/* 배리어 라인 (크리스탈 방어막) */
.crystal-barrier-line {
  position: absolute;
  left: 4px; right: 4px; height: 3px;
  border-radius: 2px;
  pointer-events: none;
}
.crystal-barrier-line.barrier-above {
  bottom: calc(100% + 3px + var(--barrier-offset, 0) * 7px);
}
.crystal-barrier-line.barrier-below {
  top: calc(100% + 3px + var(--barrier-offset, 0) * 7px);
}
.crystal-barrier-line.barrier-phase {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.6),
              0 0 12px 4px rgba(255, 255, 255, 0.25);
}
.crystal-barrier-line.barrier-resist {
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 240, 220, 0.85) 0px,
    rgba(255, 240, 220, 0.85) 6px,
    transparent 6px,
    transparent 9px
  );
  box-shadow: 0 0 5px 1px rgba(255, 240, 220, 0.45),
              0 0 10px 3px rgba(255, 240, 220, 0.15);
}
.crystal-barrier-line .barrier-val {
  position: absolute; right: -2px; top: 50%;
  transform: translateY(-50%);
  font-size: 7px; font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
  line-height: 1;
}
.crystal.cracked .crystal-barrier-line { display: none; }

/* 전투 화면 */
.battle-screen {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  max-width: 900px;
  margin: 0 auto;
  gap: 8px;
}
.battle-header  { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; flex-shrink: 0; }
.crystals-row   { display: flex; gap: 8px; justify-content: center; flex-shrink: 0; }
.hand-row       { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; flex-shrink: 0; }
.opp-hand-row   { display: flex; gap: 4px; justify-content: center; align-items: center; flex-shrink: 0; }

.opp-card-back {
  width: 40px; height: 24px;
  border-radius: 4px;
  background: linear-gradient(135deg, #0d1018, #080b12);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: rgba(255,255,255,0.1);
}

.action-bar { display: flex; gap: 8px; justify-content: center; flex-shrink: 0; flex-wrap: wrap; }

.action-btn {
  padding: 6px 16px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: rgba(255,255,255,0.02);
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: all 0.12s;
}
.action-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(200,168,78,0.3);
  background: rgba(200,168,78,0.04);
}
.action-btn.selected-action {
  background: rgba(200,168,78,0.08);
  color: var(--accent);
  border-color: rgba(200,168,78,0.4);
  box-shadow: 0 0 12px rgba(200,168,78,0.1);
}
.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.confirm-btn {
  padding: 8px 30px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #6ab898, #3a8868);
  color: #040e08;
  box-shadow: 0 2px 12px rgba(95,170,138,0.22), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: all 0.15s;
}
.confirm-btn:hover:not(:disabled) {
  filter: brightness(1.12);
  box-shadow: 0 4px 20px rgba(95,170,138,0.38);
  transform: translateY(-1px);
}
.confirm-btn:disabled { background: #151820; color: #363a42; cursor: not-allowed; box-shadow: none; }

.diss-pool {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 11px; padding: 7px 14px;
  background: linear-gradient(135deg, #080b10, #060810);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* 전투 아레나 (양쪽 카드 표시 공간) */
.battle-arena {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-height: 170px;
  flex-shrink: 0;
}
.arena-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 138px;
}
.arena-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.2);
  text-transform: uppercase;
}
.arena-slot {
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arena-sep {
  width: 1px;
  height: 80px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.06), transparent);
  flex-shrink: 0;
}
.arena-pass {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.25);
  padding: 20px 28px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
}

/* 아레나 카드 애니메이션 */
@keyframes arena-slide-in {
  from { transform: translateY(14px) scale(0.93); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}
@keyframes arena-pop-out {
  0%   { transform: scale(1);    opacity: 1; }
  35%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(0.1);  opacity: 0; }
}
@keyframes arena-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.arena-slide-in { animation: arena-slide-in 0.28s ease-out both; }
.arena-pop      { animation: arena-pop-out  0.38s ease-in  both; }
.arena-fade     { animation: arena-fade-out 0.55s ease-out both; }

/* 크리스탈 피격/치유 플래시 */
@keyframes crystal-attack-flash {
  0%   { box-shadow: 0 4px 14px rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.08); }
  20%  { box-shadow: 0 0 0 10px rgba(255,55,55,0.65), 0 0 32px 6px rgba(255,55,55,0.45); border-color: #ff3333; }
  55%  { box-shadow: 0 0 0 5px  rgba(255,55,55,0.35), 0 0 18px 3px rgba(255,55,55,0.25); border-color: #ff4444; }
  100% { box-shadow: 0 4px 14px rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.08); }
}
@keyframes crystal-heal-flash {
  0%   { box-shadow: 0 4px 14px rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.08); }
  20%  { box-shadow: 0 0 0 10px rgba(80,210,140,0.65), 0 0 32px 6px rgba(80,210,140,0.45); border-color: #57cc99; }
  55%  { box-shadow: 0 0 0 5px  rgba(80,210,140,0.35), 0 0 18px 3px rgba(80,210,140,0.25); border-color: #69dba8; }
  100% { box-shadow: 0 4px 14px rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.08); }
}
.crystal.crystal-attacked { animation: crystal-attack-flash 0.75s ease-out; }
.crystal.crystal-healed   { animation: crystal-heal-flash   0.75s ease-out; }

.log-panel {
  flex: 1;
  overflow-y: auto;
  background: linear-gradient(180deg, #08090e, #060710);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #50546a;
  white-space: pre-wrap;
  min-height: 80px;
  line-height: 1.8;
}

/* 게임 종료 오버레이 */
.game-over-banner {
  position: fixed; inset: 0;
  background: rgba(4,5,8,0.88);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.game-over-box {
  background: linear-gradient(160deg, #111828, #0a0e18);
  border: 1px solid rgba(200,168,78,0.28);
  border-radius: var(--radius-lg);
  padding: 48px 72px;
  text-align: center;
  box-shadow: 0 0 80px rgba(0,0,0,0.8), 0 0 40px rgba(200,168,78,0.06);
}

/* AI 숙고 모달 */
.ai-thinking-modal {
  position: fixed; inset: 0;
  background: rgba(4,5,8,0.6);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 90;
}
.ai-thinking-box {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(160deg, #111828, #0a0e18);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 20px 32px;
  font-size: 14px; font-weight: 700;
  color: rgba(255,255,255,0.6);
  letter-spacing: 1px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}
.ai-thinking-dots {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  animation: thinking-pulse 1.2s ease-in-out infinite;
}
@keyframes thinking-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.2); }
}

/* ─── 덱 빌딩 ────────────────────────────────────────────────── */
.deck-build-grid { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.deck-counter {
  position: fixed;
  bottom: 20px; right: 20px;
  background: linear-gradient(135deg, #0f1220, #0a0d16);
  border: 1px solid rgba(200,168,78,0.22);
  border-radius: var(--radius-lg);
  padding: 12px 22px;
  display: flex; gap: 14px; align-items: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 20px rgba(200,168,78,0.05);
  z-index: 50;
}

/* ─── 집중도 레퍼런스 테이블 ─────────────────────────────────── */
.focus-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 11px; }
.focus-table th, .focus-table td { padding: 3px 6px; text-align: right; }
.focus-table th:first-child, .focus-table td:first-child { text-align: left; }
.focus-table thead tr { border-bottom: 1px solid var(--border); }
.focus-table tbody tr { border-bottom: 1px solid rgba(28,34,50,0.5); }

/* ─── 스크롤바 ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(200,168,78,0.22); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(200,168,78,0.45); }

/* ─── 로딩 스피너 ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(200,168,78,0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 균열 애니메이션 ────────────────────────────────────────── */
@keyframes crack-flash {
  0%   { box-shadow: 0 0 0  0 rgba(196,76,66,0.5); }
  50%  { box-shadow: 0 0 20px 8px rgba(196,76,66,0.35); }
  100% { box-shadow: 0 0 0  0 transparent; }
}
.crystal.just-cracked { animation: crack-flash 0.6s ease-out; }

/* ─── 유틸 ───────────────────────────────────────────────────── */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8           { gap: 8px; }
.gap-4           { gap: 4px; }
.text-center     { text-align: center; }
.text-dim        { color: var(--text-dim); }
.text-accent     { color: var(--accent); }
.text-green      { color: var(--green); }
.text-red        { color: var(--red); }
.text-orange     { color: var(--orange); }
.mb-8            { margin-bottom: 8px; }
.mb-16           { margin-bottom: 16px; }
.mt-8            { margin-top: 8px; }
.mt-16           { margin-top: 16px; }
.mono            { font-family: var(--font-mono); }
.fw-700          { font-weight: 700; }
.fw-900          { font-weight: 900; }
.fs-12           { font-size: 12px; }
.fs-11           { font-size: 11px; }
.overflow-auto   { overflow: auto; }

/* 그라디언트 타이틀 */
.gradient-title {
  background: linear-gradient(90deg, #d43535 0%, #d4b030 25%, #45aa7a 50%, #c8a84e 75%, #3a6898 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════════════════════════════════════════
   크래프팅 탭
   ═══════════════════════════════════════════════════════════════ */

#craft-sim { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* 학파 선택 그리드 */
.craft-school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.craft-school-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s;
  background: var(--panel);
  position: relative;
  overflow: hidden;
}
.craft-school-card::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.06) 0%, transparent 65%);
  opacity: 0;
  transition: opacity 0.22s;
  pointer-events: none;
}
.craft-school-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.55);
  border-color: rgba(200,168,78,0.2);
}
.craft-school-card:hover::after { opacity: 1; }

.craft-school-elem { font-size: 22px; font-weight: 900; margin-bottom: 5px; }
.craft-school-name { font-size: 15px; font-weight: 800; margin-bottom: 7px; letter-spacing: 0.3px; }
.craft-school-desc { font-size: 10px; color: var(--text-dim); line-height: 1.5; }

/* 홈 화면 */
.craft-home-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 20px; }
.craft-home-body   { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }

.craft-panel     { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.craft-nav-panel { display: flex; flex-direction: column; gap: 12px; min-width: 160px; justify-content: center; }

/* 인벤토리 */
.inventory-grid { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.inv-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(28,34,50,0.5);
}
.inv-row:last-child { border-bottom: none; }
.inv-label  { font-weight: 700; font-size: 13px; min-width: 32px; flex-shrink: 0; }
.inv-cells  { display: flex; flex-wrap: wrap; gap: 4px; }
.inv-cell   {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 3px;
  padding: 2px 7px;
  font-size: 12px;
  white-space: nowrap;
}

/* 크래프트 select */
.craft-select {
  background: #080b10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 4px 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.craft-select:focus { outline: none; border-color: rgba(200,168,78,0.4); }

/* 크래프팅 화면 */
.craft-crafting-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.craft-slot-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(28,34,50,0.5);
}
.craft-slot-row:last-child { border-bottom: none; }
.slot-num   { color: var(--text-dim); font-size: 12px; min-width: 16px; text-align: center; }
.slot-avail { font-size: 13px; font-weight: 700; min-width: 36px; text-align: right; }

/* 카드 프리뷰 */
.card-preview {
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: linear-gradient(160deg, #0f1220, #080c16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.card-preview-tags  { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.card-preview-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.stat-label { color: var(--text-dim); margin-right: 4px; }

/* 태그 */
.tag    { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 3px; padding: 2px 8px; font-size: 11px; }
.tag-sm { padding: 1px 6px; font-size: 11px; }

/* 카드 창고 (레거시) */
.card-warehouse { display: flex; flex-direction: column; gap: 8px; max-height: 600px; overflow-y: auto; }
.card-entry     { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }

/* ─── 카드 창고 & 덱 빌딩 화면 ──────────────────────────────── */
.warehouse-top-sticky {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(200,168,78,0.12);
  margin-bottom: 20px;
}
.warehouse-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.deck-grid    { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.storage-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-bottom: 48px; }

/* 미니 카드 — 4:6 비율 (86×150) */
.mini-card {
  width: 86px; height: 150px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: stretch;
  padding: 6px 5px;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
  position: relative;
  user-select: none;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
.mini-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 14px 32px rgba(0,0,0,0.7);
  border-color: rgba(255,255,255,0.14);
}
.mini-card.in-deck { outline: 1px solid rgba(255,255,255,0.06); }

.mini-card-slot {
  width: 86px; height: 150px;
  border-radius: 7px;
  border: 1px dashed rgba(200,168,78,0.1);
  background: rgba(200,168,78,0.01);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: rgba(200,168,78,0.07);
  flex-shrink: 0;
}

.mini-card-elem {
  font-size: 10px; font-weight: 800;
  text-align: center; letter-spacing: 0.8px;
  text-transform: uppercase; margin-bottom: 1px;
}
.mini-card-dir {
  font-size: 8px; font-weight: 600;
  padding: 1px 3px; border-radius: 2px;
  background: rgba(255,255,255,0.05);
  text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px; letter-spacing: 0.3px;
  text-transform: uppercase;
}
.mini-card-power {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; line-height: 1;
  padding: 4px 0;
  text-shadow: 0 0 12px currentColor;
}
.mini-card-stats { font-size: 8px; color: rgba(255,255,255,0.35); text-align: center; line-height: 1.7; }
.mini-card-stats b { color: rgba(255,255,255,0.7); }
.mini-card-divider { border: none; border-top: 1px solid rgba(255,255,255,0.06); margin: 3px 0; }
.mini-card-idx {
  position: absolute; top: 3px; right: 4px;
  font-size: 8px; color: rgba(255,255,255,0.15);
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════════════
   연금술사 테이블 (크래프팅 화면 3)
   ═══════════════════════════════════════════════════════════════ */

.alch-toast {
  text-align: center;
  font-size: 13px;
  min-height: 20px;
  transition: opacity 0.5s;
  margin-bottom: 10px;
}

.alch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

/* 결과 카드 — 상단 중앙 */
.alch-result-area {
  max-width: 380px;
  margin: 0 auto 32px;
}

.alch-empty-result {
  text-align: center;
  padding: 40px 0;
  color: var(--text-dim);
  font-size: 13px;
}

.alch-empty-result-icon {
  font-size: 44px;
  margin-bottom: 12px;
  opacity: 0.25;
  display: block;
}

/* 테이블 영역 — 슬롯 + 피커 + 버튼 */
.alch-table {
  max-width: 560px;
  margin: 0 auto;
}

/* 슬롯 행 */
.alch-slots-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* 슬롯 카드 */
.alch-slot {
  width: 96px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--panel);
  flex-shrink: 0;
}

.alch-slot:hover:not(.active) {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.02);
}

/* 원소 오브 */
.alch-slot-orb {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.alch-slot-orb-icon { font-size: 28px; line-height: 1; }

.alch-slot-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.alch-slot-src {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}

.alch-slot-stock {
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--green, #3fb950);
  background: rgba(63,185,80,0.08);
  border: 1px solid rgba(63,185,80,0.25);
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 4px;
  letter-spacing: 0.3px;
}
.alch-slot-stock-empty {
  color: var(--red, #f85149);
  background: rgba(248,81,73,0.08);
  border-color: rgba(248,81,73,0.25);
}

/* +/- 버튼 */
.alch-slot-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  align-self: center;
}

.alch-slot-ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  cursor: pointer;
  padding: 0;
}

.alch-slot-ctrl-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgba(200,168,78,0.45);
  background: rgba(200,168,78,0.06);
}

.alch-slot-ctrl-btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* 피커 패널 */
.alch-picker {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alch-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.alch-picker-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  min-width: 30px;
  flex-shrink: 0;
}

/* 실행 버튼 */
.alch-footer {
  text-align: center;
  padding-top: 4px;
}

.alch-craft-btn {
  min-width: 220px;
  padding: 13px 48px;
  font-size: 14px;
  letter-spacing: 2px;
}

/* 레서피 섹션 */
.recipe-section {
  margin-top: 12px;
  padding: 10px 12px 6px;
  border-top: 1px solid var(--border, #333);
}
.recipe-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #aaa;
  margin-bottom: 8px;
  text-align: center;
}
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.recipe-btn {
  position: relative;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 7px 4px;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-sans);
  transition: all 0.18s;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.recipe-btn.recipe-empty {
  background: rgba(255,255,255,0.02);
  color: #555;
}
.recipe-btn.recipe-empty .recipe-empty-label {
  font-size: 16px;
  font-weight: 700;
  opacity: 0.4;
}
.recipe-btn.recipe-empty:hover {
  border-color: #58a6ff55;
  background: rgba(88,166,255,0.06);
}
.recipe-btn.recipe-filled {
  background: linear-gradient(160deg, rgba(88,166,255,0.10), rgba(88,166,255,0.03));
  border-color: #58a6ff40;
  color: #ccc;
}
.recipe-btn.recipe-filled:hover {
  border-color: #58a6ff80;
  background: linear-gradient(160deg, rgba(88,166,255,0.18), rgba(88,166,255,0.06));
  box-shadow: 0 0 12px rgba(88,166,255,0.15);
}
.recipe-btn.recipe-unavail {
  opacity: 0.5;
  border-color: #f8514940;
  background: linear-gradient(160deg, rgba(248,81,73,0.06), transparent);
}
.recipe-btn.recipe-unavail:hover {
  opacity: 0.7;
  border-color: #f8514960;
}
.recipe-btn.recipe-running {
  pointer-events: none;
  opacity: 0.6;
  animation: recipe-pulse 0.6s ease-in-out infinite;
}
@keyframes recipe-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.9; }
}
.recipe-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.recipe-slots-desc {
  font-size: 10px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 레서피 컨텍스트 메뉴 */
.recipe-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #1a1e2e;
  border: 1px solid #333;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  padding: 4px 0;
  min-width: 160px;
}
.recipe-ctx-item {
  padding: 8px 14px;
  font-size: 13px;
  color: #ccc;
  cursor: pointer;
  transition: background 0.12s;
}
.recipe-ctx-item:hover {
  background: rgba(88,166,255,0.15);
  color: #fff;
}
.recipe-ctx-delete {
  color: #f85149;
}
.recipe-ctx-delete:hover {
  background: rgba(248,81,73,0.15);
  color: #f85149;
}

/* 크래프팅 화면 — 보유 원소 요약 */
.alch-inv-summary {
  margin-top: 14px;
  padding: 10px 12px;
  border-top: 1px solid var(--border, #333);
}
.alch-inv-summary-title {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
  text-align: center;
}
.alch-inv-summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.alch-inv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid #444;
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: #ccc;
}
.alch-inv-chip b {
  font-weight: 700;
  color: #ddd;
}
.alch-inv-grade {
  font-size: 11px;
  color: #777;
  margin-left: 4px;
}
.alch-inv-grade b {
  color: #bbb;
}

