/* Slay the Spire 2 분위기: 어두운 첨탑, 촛불빛 금색 테두리, 양피지 툴팁 */

:root {
  --bg: #0d0f14;
  --bg-2: #161a22;
  --panel: rgba(22, 24, 31, .86);
  --panel-solid: #191c24;
  --line: rgba(217, 164, 65, .28);
  --line-strong: rgba(217, 164, 65, .6);
  --gold: #d9a441;
  --gold-hi: #f3dfae;
  --text: #ece4d0;
  --muted: #a39a86;
  --danger: #e5484d;
  --radius: 10px;
  --tile-w: 74px;
  --tile-h: 100px;
  --icon: 64px;
  --creature-w: 96px;
  --creature-h: 82px;
  --font-title: "Gowun Batang", "Kreon", serif;
  --font-game: "Kreon", "Gowun Batang", serif;
  --font-ui: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-hi); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* ---- 배경 ---- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.bg-tint {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(140, 70, 40, .35), transparent 60%),
    radial-gradient(900px 700px at 100% 110%, rgba(60, 40, 110, .35), transparent 60%),
    radial-gradient(800px 600px at 0% 100%, rgba(30, 70, 90, .3), transparent 60%),
    linear-gradient(180deg, #13151c 0%, #0b0c10 100%);
}
.bg-embers {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 30%, rgba(255, 190, 100, .5), transparent),
    radial-gradient(1.5px 1.5px at 78% 22%, rgba(255, 170, 90, .45), transparent),
    radial-gradient(2px 2px at 40% 80%, rgba(255, 200, 120, .35), transparent),
    radial-gradient(1.5px 1.5px at 88% 70%, rgba(255, 160, 80, .4), transparent),
    radial-gradient(1px 1px at 60% 45%, rgba(255, 220, 160, .4), transparent);
  animation: embers 18s linear infinite;
  opacity: .8;
}
@keyframes embers { from { transform: translateY(0); } to { transform: translateY(-40px); } }

/* ---- 상단 ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(10, 11, 15, .95), rgba(10, 11, 15, .8));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--gold-hi);
  font-family: var(--font-title); font-weight: 700; font-size: 18px;
  letter-spacing: -.01em;
}
.topnav { display: flex; gap: 4px; }
.topnav a {
  padding: 6px 12px; border-radius: 999px;
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600;
}
.topnav a:hover { color: var(--text); }
.topnav a.active { color: #1a1206; background: linear-gradient(180deg, #f0c76a, #c98f2c); }

.app { max-width: 1240px; margin: 0 auto; padding: 20px 16px 40px; }
.app:focus, .app:focus-visible { outline: none; }

.foot {
  max-width: 1240px; margin: 0 auto; padding: 24px 16px 40px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  color: var(--muted); font-size: 13px;
}
.foot p { margin: 4px 0; }

/* ---- 버튼 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: linear-gradient(180deg, #2a2620, #1b1915);
  color: var(--gold-hi); font-weight: 650; font-size: 14px;
  text-decoration: none; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 230, 170, .12), 0 2px 6px rgba(0, 0, 0, .4);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.btn:hover { border-color: var(--gold); background: linear-gradient(180deg, #353026, #221f19); }
.btn:active { transform: translateY(1px); }
.btn.primary { color: #1a1206; border-color: #f0c76a; background: linear-gradient(180deg, #f0c76a, #c48a28); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 2px 10px rgba(217, 164, 65, .3); }
.btn.primary:hover { background: linear-gradient(180deg, #f6d37e, #cf952f); }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .15); color: var(--muted); box-shadow: none; }
.btn.ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: #ffb4b0; border-color: rgba(229, 72, 77, .5); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- 툴바 ---- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin-bottom: 16px;
}
.back { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--text); }
.title-input, .toolbar-title {
  flex: 1 1 280px; min-width: 0;
  margin: 0;
  font-family: var(--font-title); font-weight: 700; font-size: clamp(20px, 3vw, 28px);
  color: var(--gold-hi);
}
.title-input {
  padding: 4px 8px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
}
.title-input:hover { border-color: rgba(255, 255, 255, .12); }
.title-input:focus { border-color: var(--gold); background: rgba(0, 0, 0, .3); outline: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.progress { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sync { color: var(--muted); font-size: 12.5px; }
.sync[data-state="saved"]::before { content: "✓ "; color: #9ccc5a; }
.sync[data-state="offline"] { color: #f5c451; }
.help { margin: -6px 0 14px; color: var(--muted); font-size: 14px; }
.toolbar select, .filters select, .filter-search {
  min-height: 34px; padding: 0 10px;
  background: #13151b; border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px;
  font-size: 13.5px;
}
.seg { display: inline-flex; border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px; overflow: hidden; }
.seg button { padding: 6px 12px; background: transparent; border: 0; color: var(--muted); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--gold); color: #1a1206; }

/* ---- 보드 ---- */
.board { position: relative; }
.rows {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(8, 9, 12, .75);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .6);
}
.row {
  display: flex;
  min-height: calc(var(--tile-h) + 12px);
  border-top: 1px solid rgba(217, 164, 65, .18);
  transition: background .12s ease;
}
.row:first-child { border-top: 0; }
.board:not(.readonly) .row.drop-hover { background: color-mix(in srgb, var(--tier) 10%, transparent); }
.row-label {
  flex: 0 0 104px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 8px 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 100%, white 12%), color-mix(in srgb, var(--tier) 100%, black 18%));
  color: #1a1206;
  text-align: center;
  box-shadow: inset -2px 0 0 rgba(0, 0, 0, .35);
  position: relative;
}
.row-label-text { font-family: var(--font-game); font-weight: 700; font-size: 30px; line-height: 1.05; overflow-wrap: anywhere; }
.row-label-text:not(:only-child), .row-label-sub + .row-label-text { font-size: 20px; }
.row-label-sub { font-size: 12px; font-weight: 700; opacity: .75; }
.row-label.editable { cursor: pointer; }
.row-label.editable::after {
  content: "✎"; position: absolute; top: 4px; right: 6px;
  font-size: 12px; opacity: 0; transition: opacity .12s ease;
}
.row-label.editable:hover::after, .row-label.editable:focus-visible::after { opacity: .7; }
.row .zone-items {
  flex: 1; min-width: 0;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px;
  padding: 6px;
}

.pool {
  margin-top: 18px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pool.drop-hover { border-color: var(--gold); }
.pool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.pool-head h3 { margin: 0; font-family: var(--font-title); font-size: 18px; color: var(--gold-hi); }
.pool-head .count { color: var(--muted); font-family: var(--font-ui); font-size: 13px; font-weight: 500; }
.pool .zone-items { display: flex; flex-wrap: wrap; gap: 6px; min-height: 60px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-search { width: 180px; }

/* ---- 타일 ---- */
.tile {
  position: relative;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 6px;
  cursor: grab;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform .12s ease, filter .12s ease;
}
.tile img {
  /* 원본 크기와 상관없이 항상 칸 안에 맞춘다 (원화가 칸 밖으로 넘치지 않게) */
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .55));
}
/* 캐릭터·적 원화는 칸 모양의 배경 위에 둔다 */
.tile-portrait:not(.no-img), .tile-creature:not(.no-img) {
  border-radius: 8px;
  background:
    radial-gradient(90% 70% at 50% 85%, rgba(255, 210, 140, .14), transparent 70%),
    linear-gradient(180deg, #23262e, #15171c);
  border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, .35);
}
.tile-portrait:not(.no-img) img, .tile-creature:not(.no-img) img { inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); }
.tile-card, .tile-portrait { width: var(--tile-w); height: var(--tile-h); }
.tile-icon { width: var(--icon); height: var(--icon); }
.tile-creature { width: var(--creature-w); height: var(--creature-h); }
.tile-icon:not(.no-img) { background: radial-gradient(circle at 50% 55%, rgba(255, 220, 150, .12), transparent 70%); }
.tile.no-img {
  padding: 4px;
  background: linear-gradient(180deg, #2b2f38, #1c1f26);
  border: 1px solid rgba(255, 255, 255, .12);
}
.tile-name { font-family: var(--font-game); font-size: 11.5px; line-height: 1.2; text-align: center; color: var(--text); }
.board:not(.readonly) .tile:hover { transform: translateY(-2px) scale(1.04); filter: brightness(1.12); z-index: 2; }
.tile.selected { outline: 2px solid var(--gold); outline-offset: 2px; filter: brightness(1.2); }
.tile.dragging { opacity: .25; }
.board.readonly .tile { cursor: default; }
.tile .badge {
  position: absolute; right: -4px; bottom: -4px;
  padding: 1px 5px; border-radius: 6px;
  background: rgba(0, 0, 0, .85); border: 1px solid var(--line-strong);
  color: var(--gold-hi); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 100;
  pointer-events: none;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .6)) brightness(1.1);
}
.tile-placeholder {
  flex: 0 0 auto;
  border: 2px dashed var(--gold);
  border-radius: 6px;
  background: rgba(217, 164, 65, .08);
}
body.is-dragging { cursor: grabbing; }
body.is-dragging * { cursor: grabbing !important; }

/* 선택 안내 (탭 모드) */
.select-hint {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px;
  background: rgba(20, 18, 14, .96);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
}
.select-hint-body { min-width: 0; }
.select-hint-body .tip-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.select-hint-help { grid-column: 1; color: var(--gold); font-size: 12.5px; }
.select-hint-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 6px; }

/* ---- 툴팁 (양피지 느낌의 어두운 패널) ---- */
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 50;
  max-width: 300px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #2a241b, #1b1712);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
  pointer-events: none;
}
.tip-title { font-family: var(--font-game); font-weight: 700; font-size: 16px; color: var(--gold-hi); }
.tip-meta { margin-top: 2px; font-size: 12px; color: var(--gold); }
.tip-text { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--text); white-space: pre-line; }
.tip-text b { color: var(--gold); font-weight: 700; }
.tip-text .up { color: #7fd36b; font-weight: 700; }
.tip-text .ic { font-style: normal; }
.tip-text .ic.energy { color: #f5c451; }
.tip-text .ic.star { color: #f3dfae; }
.tip-hint { margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(217, 164, 65, .2); font-size: 11.5px; color: var(--muted); }

/* ---- 팝오버 ---- */
.popover {
  position: absolute; z-index: 40;
  width: min(300px, calc(100vw - 16px));
  padding: 12px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
}
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field input { min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .16); background: #101217; color: var(--text); font-size: 15px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .4); cursor: pointer; }
.swatch.on { border-color: #fff; }
.menu-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- 공유 보기 ---- */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(217, 164, 65, .08);
}
.banner p { margin: 0; }
.shared-title { margin: 0 0 14px; font-family: var(--font-title); color: var(--gold-hi); font-size: clamp(22px, 3.4vw, 32px); }

/* ---- 밸런스 결과 ---- */
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.result {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 10px;
}
.result.few { opacity: .7; }
.result .tile { cursor: default; }
.result .tile-card, .result .tile-portrait { --tile-w: 54px; --tile-h: 72px; }
.result .tile-icon { --icon: 52px; }
.result .tile-creature { --creature-w: 64px; --creature-h: 56px; }
.result-main { flex: 1; min-width: 0; }
.result-name { font-family: var(--font-game); font-weight: 700; font-size: 16px; color: var(--gold-hi); }
.result-group { margin-left: 8px; font-family: var(--font-ui); font-size: 12px; font-weight: 500; color: var(--muted); }
.bar {
  display: flex; height: 20px; margin: 6px 0 4px;
  border-radius: 5px; overflow: hidden;
  background: rgba(255, 255, 255, .06);
}
.bar span {
  display: grid; place-items: center;
  min-width: 2px;
  color: #140f08; font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.result-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; vertical-align: 1px; }
.result-legend .n { margin-left: auto; }
/* 화면이 넓으면 두 칸으로 (순서는 왼쪽 → 오른쪽, 위 → 아래) */
@media (min-width: 900px) {
  .result-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.empty { padding: 60px 0; text-align: center; }
.empty h2 { font-family: var(--font-title); color: var(--gold-hi); }
.empty p { color: var(--muted); }

/* ---- 토스트 ---- */
.toast {
  position: fixed; left: 50%; top: 70px; z-index: 60;
  transform: translate(-50%, -10px);
  padding: 10px 16px; border-radius: 10px;
  background: rgba(20, 18, 14, .96); border: 1px solid var(--line-strong);
  color: var(--gold-hi); font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 모바일 ---- */
@media (max-width: 640px) {
  :root { --tile-w: 56px; --tile-h: 76px; --icon: 50px; --creature-w: 74px; --creature-h: 64px; }
  .app { padding: 14px 12px 32px; }
  .topbar { padding: 8px 12px; }
  .brand span { font-size: 16px; }
  .topnav a { padding: 5px 10px; font-size: 13px; }
  .row-label { flex-basis: 64px; }
  .row-label-text { font-size: 22px; }
  .row-label-text:not(:only-child), .row-label-sub + .row-label-text { font-size: 14px; }
  .row-label-sub { font-size: 10.5px; }
  .row .zone-items, .pool .zone-items { gap: 4px; }
  .filter-search { width: 100%; }
  .filters { width: 100%; }
  .filters select { flex: 1; }
  .result { gap: 10px; padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-embers { animation: none; }
  .tile, .btn, .tpl, .toast { transition: none; }
}

/* ---- 상세 정보 창 ---- */
body.modal-open { overflow: hidden; }
.detail-backdrop {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(5, 6, 9, .78);
  backdrop-filter: blur(3px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.detail {
  position: relative;
  width: min(860px, 100%);
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow: auto;
  display: grid; grid-template-columns: 260px 1fr; gap: 24px;
  padding: 24px;
  background: linear-gradient(180deg, #221d17, #15130f);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 220, 150, .08);
}
.detail-close {
  position: absolute; top: 10px; right: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .15); background: rgba(0, 0, 0, .3);
  color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
}
.detail-close:hover { border-color: var(--gold); color: var(--gold-hi); }
.detail-media { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.detail-media img { width: 100%; max-height: 360px; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .6)); }
.detail-media.kind-icon img { width: 160px; height: 160px; }
.detail-media.kind-card img { max-width: 240px; }
.detail-noimg {
  width: 100%; aspect-ratio: 3 / 4; display: grid; place-items: center; padding: 12px;
  border-radius: 10px; background: #2b2f38; font-family: var(--font-game); font-size: 20px; text-align: center;
}
.detail-body { min-width: 0; }
.detail-title { margin: 0 40px 2px 0; font-family: var(--font-game); font-size: 28px; color: var(--gold-hi); line-height: 1.2; }
.detail-sub { color: var(--muted); font-size: 14px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.detail-chips span { padding: 3px 9px; border-radius: 999px; background: rgba(217, 164, 65, .12); border: 1px solid rgba(217, 164, 65, .3); color: var(--gold-hi); font-size: 12.5px; font-weight: 600; }
.detail-text { font-size: 15.5px; line-height: 1.65; white-space: pre-line; }
.detail-text b, .moves b { color: var(--gold); }
.detail-text .up, .tip-text .up { color: #7fd36b; font-weight: 700; }
.detail-text .chg { text-decoration: underline; text-decoration-color: #7fd36b; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.detail-text .ic.energy { color: #f5c451; font-style: normal; }
.detail-text .ic.star { color: #f3dfae; font-style: normal; }
.detail-cost { margin: 0 0 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.detail-cost.changed { color: #7fd36b; }
.detail-title.is-up { color: #9be08a; }
.detail-text.is-up .up { color: #7fd36b; font-weight: 700; }
.detail-media img.flip { cursor: pointer; }
.upgrade-switch {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 6px 16px 6px 8px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .3); color: var(--text);
  font-size: 14.5px; font-weight: 700; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.upgrade-switch:hover { border-color: var(--line-strong); }
.switch-track { position: relative; width: 44px; height: 24px; border-radius: 999px; background: #3a3d45; transition: background .15s ease; }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #e9e2cf; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); transition: transform .15s ease; }
.upgrade-switch.on { border-color: rgba(127, 211, 107, .55); background: rgba(127, 211, 107, .1); }
.upgrade-switch.on .switch-track { background: #4f9a52; }
.upgrade-switch.on .switch-knob { transform: translateX(20px); }
.upgrade-switch.on .switch-label { color: #9be08a; }
@media (prefers-reduced-motion: reduce) { .switch-knob, .switch-track { transition: none; } }
.detail-note { margin: 12px 0 0; color: var(--muted); font-size: 12.5px; }
.detail-note .up { color: #7fd36b; font-weight: 700; }
.detail-note .chg { text-decoration: underline; text-decoration-color: #7fd36b; text-underline-offset: 3px; }
.detail-flavor { margin: 14px 0 0; color: var(--muted); font-style: italic; font-size: 14px; }
.detail-sec { margin-top: 14px; }
.detail-sec h3 { margin: 0 0 6px; font-family: var(--font-game); font-size: 17px; color: var(--gold-hi); }
.detail-hp { margin: 0 0 8px; font-weight: 700; }
.asc { color: #f2884b; }
.moves { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.moves li { padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, .25); font-size: 14px; line-height: 1.5; }
.move-name { display: block; font-family: var(--font-game); color: var(--gold-hi) !important; font-size: 15px; }
.relic-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.relic-link {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 8px; border: 1px solid rgba(255, 255, 255, .08); background: rgba(0, 0, 0, .25);
  color: var(--text); font-size: 13px; text-align: left; cursor: pointer;
}
.relic-link:hover { border-color: var(--gold); }
.relic-link img { width: 32px; height: 32px; object-fit: contain; }
.detail-wiki { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--muted); }
.detail-wiki:hover { color: var(--gold-hi); }
.result { cursor: pointer; }
.result:hover { border-color: var(--line-strong); }
.board.readonly .tile { cursor: zoom-in; }

@media (max-width: 640px) {
  .detail { grid-template-columns: 1fr; padding: 18px 16px; gap: 14px; }
  .detail-media img { max-height: 240px; }
  .detail-title { font-size: 23px; }
    }

/* ================================================================ 홈 */
.hero { text-align: center; padding: 28px 0 8px; }
.eyebrow { margin: 0; color: var(--gold); font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.hero h1 {
  margin: 6px 0 22px;
  font-family: var(--font-title); font-weight: 700;
  font-size: clamp(30px, 6vw, 52px); line-height: 1.15; letter-spacing: -.02em;
  color: var(--gold-hi);
  text-shadow: 0 2px 0 #3b2510, 0 0 24px rgba(217, 164, 65, .35);
}

/* 모드 선택 카드 */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 820px; margin: 0 auto; text-align: left; }
.mode-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(22, 24, 31, .7);
  color: var(--text); text-decoration: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.mode-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.mode-card.on {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(217, 164, 65, .16), rgba(217, 164, 65, .05));
  box-shadow: 0 0 0 1px rgba(217, 164, 65, .25), 0 10px 30px rgba(0, 0, 0, .35);
}
.mode-icon { font-size: 28px; line-height: 1; }
.mode-text { display: grid; gap: 3px; }
.mode-text strong { font-family: var(--font-title); font-size: 19px; color: var(--gold-hi); }
.mode-text span { font-size: 13.5px; color: var(--muted); line-height: 1.45; }

/* 구역 */
.block { margin-top: 30px; }
.block-title {
  --accent: var(--gold);
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px;
  font-family: var(--font-title); font-size: 20px; color: var(--gold-hi);
}
.block-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); }

/* 카테고리 카드 */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cat-card, .tpl-card {
  --accent: var(--gold);
  position: relative;
  display: flex; flex-direction: column;
  border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .09);
  background: var(--panel);
  color: var(--text); text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  transition: transform .15s ease, border-color .15s ease;
}
.cat-card:hover, .tpl-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.cat-card-body { padding: 12px 14px 14px; display: grid; gap: 4px; }
.cat-card h3 { margin: 0; font-family: var(--font-title); font-size: 20px; color: var(--gold-hi); }
.cat-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.cat-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cat-card-meta span { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .06); font-size: 12px; color: var(--muted); }
.cat-card-meta .badge-on { background: rgba(217, 164, 65, .18); color: var(--gold-hi); }

/* 대표 이미지 틀: 고정 높이 안에 겹치지 않게 나란히 */
.thumbs {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 108px; padding: 10px 12px;
  background:
    radial-gradient(120% 90% at 50% 100%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, .05));
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  overflow: hidden;
}
.thumbs img { flex: 0 1 auto; min-width: 0; height: 100%; max-width: 25%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .6)); }
.thumbs.kind-icon img { height: 64px; }
.thumbs.kind-creature img { height: 80px; }

/* 묶음 카드 */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tpl-card { border-top: 3px solid var(--accent); }
.tpl-card .thumbs { height: 84px; padding: 8px 10px; }
.tpl-card .thumbs.kind-icon img { height: 48px; }
.tpl-card .thumbs.kind-creature img { height: 62px; }
.tpl-card-body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.tpl-card strong { font-size: 15px; line-height: 1.35; }
.tpl-card-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tpl-card.is-progress { border-color: rgba(217, 164, 65, .35); }
.tpl-card.is-submit { border-color: rgba(245, 196, 81, .6); }
.tpl-card.is-submit .tpl-card-meta { color: #f5c451; font-weight: 600; }
.tpl-card.is-done .tpl-card-meta { color: #9ccc5a; font-weight: 600; }
.cat-card-meta .badge-done { background: rgba(156, 204, 90, .14); color: #b7dd84; }
.cat-card-meta .badge-submit { background: rgba(245, 196, 81, .2); color: #f5c451; }

.pbar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.pbar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #c48a28, #f0c76a); }

/* 경로 표시 */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 14px; font-size: 13.5px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--gold-hi); text-decoration: underline; }
.crumbs [aria-current] { color: var(--text); font-weight: 600; }
.crumbs .sep { opacity: .5; }

.page-head h1 { margin: 0; font-family: var(--font-title); font-size: clamp(26px, 4vw, 36px); color: var(--gold-hi); }
.page-head p { margin: 6px 0 0; color: var(--muted); }

/* 보드 화면 머리 */
.board-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 14px; }
.board-title { flex: 1 1 320px; min-width: 0; display: grid; gap: 8px; }
.board-title .title-input { width: 100%; margin-left: -8px; }
.board-h1 { margin: 0; font-family: var(--font-title); font-size: clamp(20px, 3vw, 28px); color: var(--gold-hi); line-height: 1.25; }
.board-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-progress .pbar { width: min(260px, 50vw); }

.hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding: 10px 14px;
  border-radius: 10px; border: 1px solid rgba(217, 164, 65, .3);
  background: rgba(217, 164, 65, .07);
  font-size: 13.5px; line-height: 1.55;
}
.hint strong { color: var(--gold-hi); }
.hint .btn { flex-shrink: 0; }

@media (max-width: 640px) {
  .hero { padding-top: 14px; }
  .hero h1 { margin-bottom: 16px; }
  .modes { grid-template-columns: 1fr; }
  .mode-card { padding: 12px 14px; }
  .block { margin-top: 22px; }
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cat-card .thumbs { height: 76px; padding: 8px; }
  .thumbs.kind-icon img { height: 44px; }
  .thumbs.kind-creature img { height: 56px; }
  .cat-card-body { padding: 10px 11px 12px; }
  .cat-card h3 { font-size: 17px; }
  .cat-card p { font-size: 12px; }
  .tpl-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tpl-card .thumbs { height: 68px; }
  .board-head { align-items: stretch; }
  .board-head .actions { width: 100%; }
  .board-head .actions .btn { flex: 1; }
  .hint { flex-direction: column; align-items: stretch; }
}

/* 모바일: 미배치 항목을 화면 아래에 붙은 서랍으로 두어 줄과 항목을 오가며 스크롤하지 않게 한다 */
@media (max-width: 640px) {
  .board:not(.readonly) .pool {
    position: sticky; bottom: 0; z-index: 15;
    margin-top: 14px; padding: 10px 10px 12px;
    overflow: visible;
    border-radius: 14px 14px 0 0;
    background: rgba(18, 19, 25, .97);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, .55);
    backdrop-filter: blur(6px);
  }
  .board:not(.readonly) .pool-head { margin-bottom: 8px; gap: 6px; }
  /* 항목은 가로로 넘기는 2줄 띠 */
  .board:not(.readonly) .pool .zone-items {
    display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto);
    grid-auto-columns: max-content; gap: 6px;
    overflow-x: auto; overscroll-behavior-x: contain;
    min-height: 0; padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .board:not(.readonly) .pool .zone-items > .tile[hidden] { display: none !important; }
  .board:not(.readonly) .pool-head h3 { font-size: 15px; }
  .filters { flex-wrap: nowrap; }
  .filter-search { width: auto; flex: 1 1 auto; min-width: 0; }
  .filters select { flex: 0 0 auto; min-width: 104px; max-width: 46%; }
  /* 선택 안내는 아래 서랍을 가리지 않게 위쪽에 띄운다 */
  .select-hint { top: 58px; bottom: auto; }
  .row { min-height: calc(var(--tile-h) + 10px); }
}

@media (pointer: coarse) { .kbd-only { display: none; } }

/* 넓은 화면: 미배치 항목을 오른쪽 고정 패널로 두어 스크롤 없이 끌어다 놓는다 */
@media (min-width: 1100px) {
  .board:not(.readonly):has(> .pool) { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
  .board:not(.readonly) > .pool {
    position: sticky; top: 70px;
    margin-top: 0;
    max-height: calc(100vh - 86px); max-height: calc(100dvh - 86px);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .board:not(.readonly) > .pool .pool-head { position: sticky; top: -14px; z-index: 1; margin: -14px -14px 10px; padding: 14px 14px 10px; background: var(--panel-solid); }
  .board:not(.readonly) > .pool .filters { width: 100%; }
  .board:not(.readonly) > .pool .filter-search { flex: 1 1 100%; }
  .app:has(.board:not(.readonly) > .pool) { max-width: 1440px; }
}

/* 줄 높이는 타일 크기에 맞춘다 (아이콘 묶음이 카드 높이만큼 비어 보이지 않게) */
.board.kind-icon .row { min-height: calc(var(--icon) + 12px); }
.board.kind-creature .row { min-height: calc(var(--creature-h) + 12px); }

/* ================================================================ 글자 줄바꿈·잘림 */
.brand span, .topnav a, .btn, .crumbs a, .crumbs span, .tpl-card-meta, .cat-card-meta span, .board-progress span { white-space: nowrap; }
.row-label-text { word-break: keep-all; overflow-wrap: anywhere; }
.row-label-sub { word-break: keep-all; line-height: 1.2; }
.tile-name { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; word-break: keep-all; overflow-wrap: anywhere; }
.detail-title, .result-name, .tip-title { overflow-wrap: anywhere; }
.filters select { padding-right: 26px; }

@media (max-width: 640px) {
  /* 밸런스 줄 이름(너프 필요/너무 어려움)이 단어 중간에서 끊기지 않게 */
  .board .row-label { flex-basis: 76px; padding: 6px 4px; }
  .board .row-label-sub + .row-label-text, .row-label-text:not(:only-child) { font-size: 14px; white-space: nowrap; }
  .row-label-sub { font-size: 10.5px; white-space: nowrap; }
  .board-h1 { font-size: 21px; }
  .crumbs { font-size: 12.5px; }
}

/* 밸런스 투표: 임시 저장 / 제출 */
.draft-note { color: #f5c451; font-weight: 600; }
.draft-note.ok { color: #9ccc5a; font-weight: 500; }
.btn.submit { min-width: 180px; }
.btn.submit.done { color: #9ccc5a; border-color: rgba(156, 204, 90, .45); opacity: 1; }
.btn:disabled { cursor: default; opacity: .55; }
.btn.submit.done:disabled { opacity: 1; }
.btn.primary.submit { animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 2px 10px rgba(217, 164, 65, .3); } 50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 0 0 4px rgba(217, 164, 65, .25), 0 2px 16px rgba(217, 164, 65, .45); } }
@media (prefers-reduced-motion: reduce) { .btn.primary.submit { animation: none; } }

/* 진행 표시: 완료 초록 · 일부 주황 · 시작 안 함 빨강 */
.st { font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-card-meta .st, .tpl-card-meta .st { padding: 2px 9px; border-radius: 999px; }
.st-done { color: #9fdc7a !important; background: rgba(110, 190, 80, .18) !important; }
.st-partial { color: #f6a347 !important; background: rgba(242, 136, 75, .18) !important; }
.st-none { color: #f07a7d !important; background: rgba(229, 72, 77, .16) !important; }
.tpl-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tpl-card-meta .badge-submit { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.tpl-card.is-done { border-color: rgba(110, 190, 80, .45); }
.tpl-card.is-progress { border-color: rgba(242, 136, 75, .45); }
.tpl-card .pbar span { background: linear-gradient(90deg, #d9702f, #f6a347); }

/* ================================================================ 내 투표 */
.my-votes-link {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 14px; padding: 10px 16px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, .3); color: var(--text); text-decoration: none; font-size: 14.5px;
}
.my-votes-link:hover { border-color: var(--gold); }
.my-votes-link strong { color: var(--gold-hi); }
.my-count { color: var(--gold-hi); font-weight: 700; }
.my-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px; padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--v) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--v) 60%, transparent);
  font-family: var(--font-ui); font-size: 12px; font-weight: 700; color: var(--text); vertical-align: 2px;
}
.my-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--v); }
.my-chip em { font-style: normal; font-weight: 600; }
.my-chip .agree { color: #9fdc7a; }
.my-chip .differ { color: #f6a347; }
.my-list .my-chip { margin: 4px 0 2px; }
.tile .mine-dot {
  position: absolute; left: -4px; top: -4px;
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 800; color: #140f08;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .7);
}
.my-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 12px; }
.my-stat {
  display: grid; gap: 2px; min-width: 130px;
  padding: 12px 16px; border-radius: 12px;
  background: var(--panel); border: 1px solid rgba(255, 255, 255, .08);
}
.my-stat strong { font-family: var(--font-title); font-size: 26px; color: var(--gold-hi); line-height: 1.1; }
.my-stat span { font-size: 12.5px; color: var(--muted); }
.my-stat.warn strong { color: #f5c451; }
.my-filter { margin-bottom: 4px; }
.my-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.my-sec-head .block-title { margin: 0; }
.my-sec-count { margin-left: 8px; font-family: var(--font-ui); font-size: 13px; color: var(--muted); font-weight: 500; }
.bar.small { height: 14px; margin: 4px 0 2px; }
@media (max-width: 640px) {
  .my-chip { margin-left: 0; margin-top: 4px; }
  .result-name { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; }
  .my-stat { flex: 1 1 40%; min-width: 0; }
}

/* 결과 나눠 보기 */
.result-sec { margin-top: 22px; }
.result-sec:first-of-type { margin-top: 6px; }
.result-sec .block-title { font-size: 18px; margin-bottom: 10px; }

/* ================================================================ 상단 막대
   넓은 화면: 로고 | 메뉴 | 로그인·언어 한 줄.
   좁은 화면: 1줄 로고 + 로그인·언어, 2줄 메뉴(가로로 고르게, 넘치면 옆으로 넘김). */
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.topnav { min-width: 0; }
.lang-pick {
  position: relative; display: inline-flex; align-items: center;
  height: 34px; padding: 0 8px 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(0, 0, 0, .3); color: var(--muted);
  cursor: pointer;
}
.lang-pick:hover { border-color: var(--gold); color: var(--text); }
.lang-icon { font-size: 14px; line-height: 1; }
.lang-pick select {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent; color: inherit;
  padding: 0 14px 0 6px; font: 600 13px var(--font-ui); cursor: pointer;
}
.lang-pick::after {
  content: ""; position: absolute; right: 10px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); pointer-events: none;
}
.lang-pick select option { background: #16181e; color: var(--text); }

@media (max-width: 860px) {
  .topbar {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand right" "nav nav";
    row-gap: 8px; padding: 8px 12px;
  }
  .brand { grid-area: brand; min-width: 0; }
  .brand span { display: inline; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { grid-area: right; }
  .topnav {
    grid-area: nav; gap: 4px;
    overflow-x: auto; scrollbar-width: none;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { flex: 1 0 auto; text-align: center; padding: 6px 10px; font-size: 13.5px; }
}
@media (max-width: 380px) {
  .brand span { display: none; }
}
