/* 백귀 행차 — 밤길 화면. 색은 아래 변수로만 쓴다. 간격은 4의 배수. */
/* 글꼴: 포털 fonts/ 와 같은 파일(본문 Pretendard 가변, 제목 Song Myung 파루 축소판 + 보충). 붓글씨는 정해진 제목에만 — 닉네임 등 바뀌는 글은 빠진 글자가 있을 수 있다 */
@font-face { font-family: Pretendard; src: url('fonts/pretendard.woff2') format('woff2-variations'), url('fonts/pretendard.woff2') format('woff2'); font-weight: 45 920; font-display: swap; }
@font-face { font-family: 'Song Myung'; src: url('fonts/SongMyung-paru.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Song Myung'; src: url('fonts/SongMyung-extra.woff2') format('woff2'); font-display: swap;
  unicode-range: U+B611,U+D33B,U+BC2D,U+BC25,U+C528,U+D73C,U+C90C,U+D0B5,U+BE8D,U+D0B4,U+AC81,U+BE8F,U+B0C4,U+C2FC,U+B3D5,U+B0A9,U+C0BD,U+ACBC,U+C0C0,U+CF30,U+C37C,U+AC16,U+ACA0,U+CEF4,U+D4E8,U+D69F,U+C140,U+B8F0,U+B738,U+B2D8,U+D790,U+C918,U+D23C,U+C88B; }
:root {
  color-scheme: dark;
  --bg: #0c0f1a;
  --bg-subtle: #121729;
  --surface: #1a2036;
  --surface-2: #232a44;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #f4f1ea;
  --text-muted: #b9b4c7;
  --text-subtle: #8a86a0;
  --brand: #f0b44c;            /* 청사초롱 불빛 */
  --brand-hover: #f6c66e;
  --brand-subtle: rgba(240, 180, 76, .14);
  --brand-ink: #1b1306;
  --success: #6fd3a0;
  --warning: #f0b44c;
  --danger: #f2747a;
  --info: #7fb5ff;
  --foe: #c96a8a;              /* 상대 쪽 빛 */
  --foe-subtle: rgba(201, 106, 138, .12);
  --tier-1: #8f9bb3;
  --tier-2: #6fbf8f;
  --tier-3: #7fa8ff;
  --tier-4: #e6a25a;
  --wisp: #6fb7ff;
  --wisp-core: #e3f3ff;
  --shadow-1: 0 1px 2px rgba(4, 6, 16, .4), 0 4px 12px rgba(4, 6, 16, .35);
  --shadow-2: 0 2px 4px rgba(4, 6, 16, .4), 0 12px 32px rgba(4, 6, 16, .5);
  --ease: cubic-bezier(0.16, 1, 0.30, 1);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --cell: min(76px, 19vw, 8.6vh);
  --font-title: 'Song Myung', Pretendard, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% 48%, var(--bg-subtle), var(--bg));
  color: var(--text);
  font-family: Pretendard, "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
p { max-width: 68ch; margin: 0; }
button { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.game {
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- 위 줄 ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.hud__label { color: var(--text-subtle); font-size: 12px; }
.hud__round strong { font-family: var(--font-title); font-size: 24px; font-weight: 400; }
.hud__sub { color: var(--text-subtle); font-size: 12px; margin-left: 2px; }
.pips { display: inline-flex; gap: 4px; vertical-align: middle; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.pip--on { background: var(--success); }
.lamp { width: 16px; height: 20px; border-radius: 6px 6px 8px 8px; background: var(--surface-2); position: relative; }
.lamp--on { background: var(--danger); box-shadow: 0 0 12px rgba(240, 180, 76, .45); }
.lamp--on::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6px; height: 4px; border-radius: 2px; background: var(--info); opacity: .8; }

/* ---------- 진형 ---------- */
.side { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.side__name { color: var(--text-subtle); font-size: 12px; min-height: 20px; text-align: center; }
.side--foe .side__name.is-set { color: var(--foe); }
.row { display: grid; grid-template-columns: repeat(4, var(--cell)); gap: 8px; }
.row--bench { grid-template-columns: repeat(3, calc(var(--cell) * .82)); }
.formation-row { display: grid; gap: 4px; width: calc(var(--cell) * 4 + 24px); }
.formation-label { color: var(--text-muted); font-size: 12px; line-height: 20px; }
.formation-label span { margin-left: 8px; color: var(--text-subtle); }
.bench-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }

.cell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px dashed var(--border);
  padding: 0;
  display: grid;
  place-items: center;
  touch-action: none;
}
.row--bench .cell { background: var(--bg-subtle); }
.side--foe .cell { background: var(--foe-subtle); border-color: transparent; }
.cell:empty::before { content: attr(data-hint); color: var(--text-subtle); font-size: 12px; opacity: .6; }
.cell.is-target { border-color: var(--brand); border-style: solid; background: var(--brand-subtle); }

/* ---------- 요괴패 ---------- */
.unit {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 2px solid var(--tier-color, var(--border-strong));
  box-shadow: var(--shadow-1);
  display: grid;
  place-items: center;
  cursor: grab;
  transition: transform 160ms var(--ease), opacity 200ms var(--ease);
}
.unit:hover { transform: scale(1.02); }
.unit.is-selected { box-shadow: 0 0 0 2px var(--brand), var(--shadow-2); }
.unit[data-tier="1"] { --tier-color: var(--tier-1); }
.unit[data-tier="2"] { --tier-color: var(--tier-2); }
.unit[data-tier="3"] { --tier-color: var(--tier-3); }
.unit[data-tier="4"] { --tier-color: var(--tier-4); }
.unit img { width: 88%; height: 88%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.side--foe .unit { transform: scaleX(-1); cursor: default; }
.side--foe .unit .stars, .side--foe .unit .hp { transform: scaleX(-1); }

.wisp { width: 52%; aspect-ratio: 1; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 62%, var(--wisp-core) 0 14%, var(--wisp) 42%, transparent 72%);
  filter: blur(.4px); }

.stars { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; pointer-events: none; }
.star { width: 8px; height: 8px; border-radius: 50%; background: var(--wisp); box-shadow: 0 0 6px var(--wisp); }

.hp { position: absolute; left: 6px; right: 6px; top: 4px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .45); overflow: hidden; pointer-events: none; }
.hp i { display: block; height: 100%; width: 100%; background: var(--success); transform-origin: left; transition: transform 120ms linear; }
.side--foe .hp i { background: var(--danger); }
.unit.is-burning .hp i { background: var(--warning); }

.unit.is-hit { animation: hit 200ms var(--ease); }
.unit.is-lunge-up { animation: lunge-up 220ms var(--ease); }
.unit.is-lunge-down { animation: lunge-down 220ms var(--ease); }
.unit.is-dead { opacity: .12; filter: grayscale(1); }
.side--foe .unit.is-hit { animation-name: hit-foe; }
@keyframes hit { 30% { transform: translateX(3px); filter: brightness(1.8); } 60% { transform: translateX(-3px); } }
@keyframes hit-foe { 30% { transform: scaleX(-1) translateX(3px); filter: brightness(1.8); } 60% { transform: scaleX(-1) translateX(-3px); } }
@keyframes lunge-up { 40% { transform: translateY(-8px); } }
@keyframes lunge-down { 40% { transform: scaleX(-1) translateY(8px); } }

/* ---------- 전투 연출 ---------- */
.unit.is-star3 { box-shadow: 0 0 0 1px var(--tier-color), 0 0 16px 2px var(--wisp), var(--shadow-1); }
.unit.is-enter { animation: enter 360ms var(--ease) both; }
.side--foe .unit.is-enter { animation-name: enter-foe; }
@keyframes enter { from { transform: translateY(16px); opacity: 0; } }
@keyframes enter-foe { from { transform: scaleX(-1) translateY(-16px); opacity: 0; } to { transform: scaleX(-1); } }

.unit.is-ascended { box-shadow: 0 0 0 2px var(--brand), 0 0 24px 4px var(--brand), var(--shadow-2); }
.unit.is-ascended img { transform: scale(1.12); transition: transform 400ms var(--ease); }
.unit.is-reborn { animation: reborn 500ms var(--ease); }
.side--foe .unit.is-reborn { animation-name: reborn-foe; }
@keyframes reborn { 0% { filter: brightness(3); } 100% { filter: none; } }
@keyframes reborn-foe { 0% { filter: brightness(3); transform: scaleX(-1); } 100% { filter: none; transform: scaleX(-1); } }
.unit.is-reaped::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, transparent 44%, var(--text) 48%, var(--bg) 52%, transparent 56%); animation: reap 420ms var(--ease) forwards; }
@keyframes reap { from { opacity: 0; transform: translate(-30%, -30%); } 40% { opacity: 1; } to { opacity: 0; transform: translate(30%, 30%); } }
.unit.is-slam { animation: slam 260ms var(--ease); }
.side--foe .unit.is-slam { animation-name: slam-foe; }
@keyframes slam { 40% { transform: translateY(-10px) scale(1.06); } 70% { transform: translateY(4px); } }
@keyframes slam-foe { 0%, 100% { transform: scaleX(-1); } 40% { transform: scaleX(-1) translateY(10px) scale(1.06); } 70% { transform: scaleX(-1) translateY(-4px); } }
.unit.is-cheer { animation: cheer 520ms var(--ease) both; }
.side--foe .unit.is-cheer { animation-name: cheer-foe; }
@keyframes cheer { 30% { transform: translateY(-8px); } 60% { transform: translateY(0); } 80% { transform: translateY(-3px); } }
@keyframes cheer-foe { 0%, 100% { transform: scaleX(-1); } 30% { transform: scaleX(-1) translateY(-8px); } 60% { transform: scaleX(-1); } 80% { transform: scaleX(-1) translateY(-3px); } }

.badge { position: absolute; right: -4px; top: -8px; z-index: 3; font-size: 12px; line-height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); pointer-events: none; }
.side--foe .badge { transform: scaleX(-1); }
.badge[data-kind="charm"] { color: var(--foe); }
.badge[data-kind="sleep"] { color: var(--info); }
.badge[data-kind="stun"] { color: var(--warning); }

.shot { position: fixed; z-index: 15; pointer-events: none; width: 12px; height: 12px; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--text) 0 30%, var(--text-muted) 70%, transparent 72%); }
.shot--wisp { width: 16px; height: 16px; background: radial-gradient(circle, var(--wisp-core) 0 25%, var(--wisp) 55%, transparent 72%); }
.shot--fire { width: 16px; height: 16px; background: radial-gradient(circle, var(--brand-hover) 0 25%, var(--danger) 60%, transparent 72%); }
.shot--orb { width: 14px; height: 14px; background: radial-gradient(circle at 40% 35%, var(--text) 0 20%, var(--foe) 60%, transparent 72%); box-shadow: 0 0 12px var(--foe); }
.shot--bubble { width: 14px; height: 14px; background: radial-gradient(circle at 35% 35%, var(--text) 0 15%, transparent 30%, var(--info) 70%, transparent 74%); }
.shot--wail { width: 24px; height: 24px; background: none; border: 2px solid var(--text-muted); }
.shot--petal { width: 12px; height: 8px; border-radius: 50% 0; background: var(--foe); }
.shot--ink { width: 16px; height: 16px; background: radial-gradient(circle, var(--bg) 0 40%, var(--text-subtle) 70%, transparent 72%); }

.float--crit { font-size: 16px; color: var(--warning); }

.float {
  position: absolute; left: 50%; top: 30%; transform: translate(-50%, 0);
  font-size: 12px; font-weight: 600; color: var(--text); text-shadow: 0 1px 2px var(--bg);
  pointer-events: none; animation: float 700ms var(--ease) forwards; white-space: nowrap; z-index: 2;
}
.float--tag { color: var(--brand); }
.float--big { font-size: 16px; color: var(--warning); }
@keyframes float { to { transform: translate(-50%, -24px); opacity: 0; } }

/* ---------- 가운데 길 ---------- */
.road {
  min-height: 40px; display: grid; place-items: center; text-align: center;
  border-radius: var(--radius); color: var(--text-muted); font-size: 14px;
  background: linear-gradient(90deg, transparent, var(--brand-subtle), transparent);
  padding: 8px 12px;
}
.road.is-win { color: var(--success); }
.road.is-lose { color: var(--danger); }

/* ---------- 무리 ---------- */
.tribes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 50%; }
.tribe { font-size: 12px; padding: 0 8px; border-radius: 999px; background: var(--surface); color: var(--text-subtle); line-height: 24px; }
.tribe--on { background: var(--brand-subtle); color: var(--brand); }

/* ---------- 장터 ---------- */
.market { position: relative; margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.market.is-sell-target { background: var(--foe-subtle); border-radius: var(--radius-lg); }
.shop { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.card {
  position: relative; border: 2px solid var(--tier-color, var(--border)); border-radius: var(--radius-lg);
  background: var(--surface); padding: 4px 4px 4px; min-height: 96px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  transition: transform 160ms var(--ease), background-color 160ms var(--ease);
}
.card:hover:not(:disabled) { transform: translateY(-2px); background: var(--surface-2); }
.card:disabled { cursor: not-allowed; opacity: .45; }
.card.is-selected { box-shadow: 0 0 0 2px var(--brand); }
.card.is-held::after { content: "묶음"; position: absolute; top: -8px; right: -4px; font-size: 12px; line-height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); }
.card[data-tier="1"] { --tier-color: var(--tier-1); }
.card[data-tier="2"] { --tier-color: var(--tier-2); }
.card[data-tier="3"] { --tier-color: var(--tier-3); }
.card[data-tier="4"] { --tier-color: var(--tier-4); }
.card__art { width: 100%; aspect-ratio: 1; display: grid; place-items: center; max-height: 52px; }
.card__art img { width: 52px; height: 52px; object-fit: contain; }
.card__name { font-size: 12px; line-height: 16px; text-align: center; }
.card__cost { font-size: 12px; line-height: 16px; color: var(--brand); }
.card__own { position: absolute; top: 4px; left: 4px; font-size: 12px; line-height: 16px; padding: 0 4px; border-radius: 4px;
  background: var(--bg-subtle); color: var(--text-muted); }
.card.is-pair { box-shadow: 0 0 0 1px var(--wisp), 0 0 12px var(--wisp); }
.card.is-pair .card__own { background: var(--wisp); color: var(--bg); }
.card.is-pair.is-selected { box-shadow: 0 0 0 2px var(--brand), 0 0 12px var(--wisp); }
.tribe--preview { outline: 1px dashed var(--text-subtle); outline-offset: -1px; color: var(--text); }
.tribe--lights { outline-color: var(--brand); color: var(--brand); }
.market.is-sell-target::before { content: attr(data-sell); position: absolute; inset: 0; z-index: 6; display: grid; place-items: center;
  border-radius: var(--radius-lg); background: var(--foe-subtle); color: var(--text); font-size: 16px; font-weight: 600; pointer-events: none; }
.card--empty { border-style: dashed; border-color: var(--border); background: transparent; cursor: default; }

/* 설명 칸은 장터 위에 떠서 판을 밀지 않는다 */
.info { position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 5;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); padding: 12px 16px; display: grid; gap: 4px; box-shadow: var(--shadow-2); }
.info__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.info__name { font-family: var(--font-title); font-size: 20px; font-weight: 400; letter-spacing: 0; }
.info__meta { color: var(--text-subtle); font-size: 12px; }
.info__ability { color: var(--text); }
.info__ability b { color: var(--brand); font-weight: 600; }
.info__lore { color: var(--text-muted); font-size: 12px; }
.info__actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.actions { display: flex; align-items: center; gap: 8px; }
.gold { display: flex; align-items: center; gap: 4px; margin-right: auto; font-size: 20px; }
.gold strong { font-weight: 600; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: var(--brand); box-shadow: inset 0 0 0 4px var(--brand-hover); position: relative; }
.coin::after { content: ""; position: absolute; inset: 5px; background: var(--bg); border-radius: 1px; }

.battlebar { display: flex; gap: 8px; justify-content: flex-end; margin-top: auto; padding-top: 8px; }

/* ---------- 단추 ---------- */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color 160ms var(--ease), transform 160ms var(--ease), opacity 160ms var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn--ghost { background: transparent; border-color: var(--border-strong); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn__cost { color: var(--brand); font-weight: 400; font-size: 12px; }
.btn[data-loading] { pointer-events: none; opacity: .7; }

/* ---------- 덮개 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 6, 16, .72); display: grid; place-items: center; padding: 16px; z-index: 10; }
.sheet { background: var(--surface); border-radius: var(--radius-xl); padding: 24px; width: min(400px, 100%); box-shadow: var(--shadow-2); display: grid; gap: 16px; }
.sheet h2 { margin: 0; font-family: var(--font-title); font-size: 24px; font-weight: 400; letter-spacing: 0; }
.sheet p { color: var(--text-muted); }
.sheet__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.sheet__stats div { background: var(--bg-subtle); border-radius: var(--radius); padding: 8px; }
.sheet__stats strong { display: block; font-size: 20px; font-weight: 600; }
.sheet__stats span { color: var(--text-subtle); font-size: 12px; }
.sheet__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet ol { margin: 0; padding-left: 20px; color: var(--text-muted); display: grid; gap: 4px; }

/* ---------- 위 줄 단추·도감 ---------- */
.hud__tools { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; border-radius: var(--radius); border: 0; background: transparent; color: var(--text-subtle);
  display: grid; place-items: center; cursor: pointer; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn[aria-pressed="false"] { color: var(--text-subtle); opacity: .7; }

.dex { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 48vh; overflow-y: auto; padding: 4px; }
.dex__cell { border: 2px solid var(--tier-color, var(--border)); border-radius: var(--radius); background: var(--bg-subtle); padding: 4px;
  display: grid; justify-items: center; gap: 0; cursor: pointer; transition: background-color 160ms var(--ease); }
.dex__cell:hover { background: var(--surface-2); }
.dex__cell[data-tier="1"] { --tier-color: var(--tier-1); }
.dex__cell[data-tier="2"] { --tier-color: var(--tier-2); }
.dex__cell[data-tier="3"] { --tier-color: var(--tier-3); }
.dex__cell[data-tier="4"] { --tier-color: var(--tier-4); }
.dex__cell.is-unknown { border-color: var(--border); }
.dex__cell.is-unknown .dex__art { filter: brightness(0) opacity(.45); }
.dex__art { width: 40px; height: 40px; display: grid; place-items: center; }
.dex__art img { width: 40px; height: 40px; object-fit: contain; }
.dex__name { font-size: 12px; line-height: 16px; text-align: center; }
.dex__marks { display: flex; gap: 4px; margin-top: 4px; }
.dex__mark { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); }
.dex__mark.is-on { background: var(--brand); }
.dex__detail { display: flex; align-items: center; gap: 16px; }
.dex__big { width: 96px; height: 96px; display: grid; place-items: center; border-radius: var(--radius-lg); background: var(--bg-subtle); }
.dex__big img { width: 88px; height: 88px; object-fit: contain; }
.tribes--dex { max-width: none; justify-content: flex-start; }

.charms { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.charms li { display: grid; gap: 4px; padding: 12px 16px; border-radius: var(--radius); background: var(--bg-subtle); }
.charms b { color: var(--brand); font-weight: 600; }
.charms span { color: var(--text-muted); font-size: 14px; }
.sheet__actions .btn { flex: 1 1 auto; }

.share { margin: 0; padding: 12px; border-radius: var(--radius); background: var(--bg-subtle); color: var(--text); font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

.mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-width: 280px; margin: 0 auto; }
.mini__cell { position: relative; aspect-ratio: 1; border-radius: var(--radius); background: var(--bg-subtle); }
.mini__cell .unit { cursor: default; }
.battlebar { flex-wrap: wrap; }

/* ---------- 꾸미기 ---------- */
:root { --look-cheong: #c4412e; --look-cheong-band: #2f5d9a; --look-hong: #b8322a; --look-hong-band: #e8b14a;
  --look-wisp: #4f9bff; --look-wisp-band: #cfe6ff; --look-gold: #b8862e; --look-gold-band: #fff1c4; }
.lamp--look-cheong { --lamp-body: var(--look-cheong); --lamp-band: var(--look-cheong-band); }
.lamp--look-hong { --lamp-body: var(--look-hong); --lamp-band: var(--look-hong-band); }
.lamp--look-wisp { --lamp-body: var(--look-wisp); --lamp-band: var(--look-wisp-band); }
.lamp--look-gold { --lamp-body: var(--look-gold); --lamp-band: var(--look-gold-band); }
.lamp--on { background: var(--lamp-body, var(--danger)); }
.lamp--on::after { background: var(--lamp-band, var(--info)); }
.flag { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px 4px 12px 4px; font-family: var(--font-title);
  font-size: 16px; line-height: 1; color: var(--lamp-band, var(--text)); background: var(--lamp-body, var(--surface-2)); vertical-align: middle; }
.look__head { margin: 8px 0 0; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.looks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.looks--flags { grid-template-columns: repeat(4, 1fr); }
.look { display: grid; justify-items: center; gap: 4px; padding: 8px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-subtle); color: var(--text); cursor: pointer; transition: background-color 160ms var(--ease); }
.look:hover:not(:disabled) { background: var(--surface-2); }
.look:disabled { opacity: .45; cursor: not-allowed; }
.look.is-on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.look small { font-size: 12px; color: var(--text-subtle); text-align: center; }

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; }
.board li { display: grid; grid-template-columns: 32px 1fr auto; gap: 8px; padding: 8px 12px; border-radius: var(--radius); background: var(--bg-subtle); }
.board li span:first-child { color: var(--text-subtle); }
.board li.is-me { background: var(--brand-subtle); color: var(--brand); }
.sheet b { color: var(--brand); font-weight: 600; }

.drag-ghost { position: fixed; width: var(--cell); height: var(--cell); pointer-events: none; z-index: 20; opacity: .9; transform: translate(-50%, -50%) scale(1.06); }
.drag-ghost .unit { cursor: grabbing; }

.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--surface-2); color: var(--text); padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow-2); font-size: 14px; z-index: 30; animation: toast 1600ms var(--ease) forwards; pointer-events: none; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

.noscript { padding: 16px; }

/* ---------- 첫 행렬 실습 ---------- */
.hud__tools { flex-wrap: wrap; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.coach { padding: 16px 18px; border: 1px solid rgba(240,180,76,.35); border-radius: var(--radius-xl);
  background: linear-gradient(120deg, var(--brand-subtle), var(--bg-subtle) 80%); display: grid; gap: 8px; }
.coach__top { display: flex; align-items: center; gap: 12px; color: var(--brand); font-size: 12px; }
.eyebrow { font-weight: 700; letter-spacing: .08em; }
.coach__exit { margin-left: auto; min-height: 36px; padding: 4px 8px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.coach h2 { font-size: 20px; line-height: 1.4; margin: 0 0 4px; }
.coach h2:focus { outline: none; }
.coach p { font-size: 14px; line-height: 1.6; }
.coach .coach__detail { color: var(--text-muted); }
.coach .coach__note { color: var(--text-subtle); font-size: 12px; }
.coach progress { width: 100%; height: 4px; border: 0; appearance: none; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.coach progress::-webkit-progress-bar { background: var(--surface-2); }
.coach progress::-webkit-progress-value { background: var(--brand); border-radius: 8px; }
.coach progress::-moz-progress-bar { background: var(--brand); }
.is-learning:not(.is-lesson-battle) .side--foe { display: none; }
.is-learning .market { margin-top: 8px; }
.is-learning .info { position: static; order: 0; }
.is-learning .cell:disabled { cursor: default; }
.is-coach-target { outline: 2px solid var(--brand); outline-offset: 3px; box-shadow: 0 0 0 6px var(--brand-subtle); }
.cell.is-coach-target { background: var(--brand-subtle); border-color: var(--brand); }
.cell.is-coach-source { border-style: solid; border-color: var(--info); }
.is-coach-source::after { content: '여기서'; position: absolute; bottom: -5px; right: -4px; padding: 0 6px; border-radius: 8px; background: var(--info); color: var(--brand-ink); font-size: 11px; z-index: 4; }
.cell.is-coach-result { border-style: solid; border-color: var(--success); box-shadow: 0 0 0 2px var(--success); cursor: default; }
.cell.is-coach-result .unit { cursor: default; }
.cell.is-coach-result .unit:hover { transform: none; }
.cell.is-coach-result::after { content: '2혼 완성'; position: absolute; bottom: -5px; right: -4px; padding: 0 6px; border-radius: 8px; background: var(--success); color: var(--bg); font-size: 11px; z-index: 4; pointer-events: none; }
.welcome__art { display: flex; justify-content: center; gap: 24px; padding: 4px 0 12px; }
.welcome__art img, .welcome__art .wisp { width: 76px; height: 76px; }
.welcome__lead { color: var(--brand); font-size: 18px; font-weight: 600; }

/* ---------- 전투 돌아보기 ---------- */
.battle-report { flex-basis: 100%; width: 100%; min-width: 0; display: grid; gap: 16px; padding-bottom: 12px; }
.battle-report h2 { font-size: 20px; line-height: 1.4; margin: 0; }
.report__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-subtle); font-size: 12px; }
.report__result { background: var(--surface-2); padding: 4px 10px; border-radius: 999px; color: var(--text-muted); font-weight: 700; }
.report__result--win { color: var(--success); }
.report__result--lose { color: var(--danger); }
.report__numbers { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.report__numbers > div { display: grid; gap: 4px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 10px; }
.report__numbers span { font-size: 12px; color: var(--text-muted); }
.report__numbers strong { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.4; }
.report__numbers small { font-size: 12px; color: var(--text-subtle); font-weight: 400; }
.report__facts, .report__advice ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.report__facts b, .report__advice b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.report__facts p, .report__advice p { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.report__advice { padding: 14px; border: 1px solid rgba(240,180,76,.25); background: var(--brand-subtle); border-radius: var(--radius-lg); }
.report__advice h3 { font-size: 12px; color: var(--brand); margin: 0 0 12px; }
.report__details { border-top: 1px solid var(--border-strong); padding-top: 12px; }
.report__details summary { cursor: pointer; min-height: 36px; color: var(--text-muted); font-size: 13px; }
.report__details table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.report__details caption { text-align: left; font-weight: 600; padding: 12px 0 6px; color: var(--brand); }
.report__details th, .report__details td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.report__details th { font-weight: 500; }
.report__details thead { color: var(--text-subtle); }
.report__details small { display: block; color: var(--text-subtle); font-size: 11px; }
.report__note { font-size: 11px; color: var(--text-subtle); line-height: 1.7; }
.report__notice { padding: 12px; background: var(--surface); border-radius: var(--radius); }
.sheet { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
@media (min-width: 720px) {
  :root { --cell: min(80px, 9vh); }
  .game { padding-top: 24px; }
}
/* PC: 판은 왼쪽, 장터는 오른쪽 기둥 — 세로로 줄 세우지 않아 한눈에 보인다 */
@media (min-width: 960px) and (min-height: 600px) {
  :root { --cell: min(104px, 12.5vh); }
  .game {
    max-width: 1040px; display: grid; align-content: start; column-gap: 48px; row-gap: 12px;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-areas: "hud hud" "foe side" "road side" "me side";
    padding-top: 32px;
  }
  .hud { grid-area: hud; }
  .coach { grid-area: coach; }
  .game.is-learning { grid-template-areas: "hud hud" "coach coach" "foe side" "road side" "me side"; }
  .game.is-learning:not(.is-lesson-battle) { grid-template-areas: "hud hud" "coach coach" "road side" "me side"; }
  .side--foe { grid-area: foe; }
  .road { grid-area: road; font-size: 16px; }
  .side--me { grid-area: me; }
  .market, .battlebar { grid-area: side; align-self: start; margin-top: 0; border-top: 0; padding: 16px;
    background: var(--bg-subtle); border-radius: var(--radius-xl); }
  .battlebar { flex-direction: column; align-items: stretch; }
  .battle-report { flex-basis: auto; }
  .shop { grid-template-columns: repeat(3, 1fr); }
  .card { min-height: 112px; }
  .card__art img { width: 64px; height: 64px; }
  .card__art { max-height: 64px; }
  .info { position: static; order: 2; box-shadow: none; background: var(--surface); }
  .market { display: flex; flex-direction: column; }
  .actions { order: 3; flex-wrap: wrap; }
  .actions .gold { flex-basis: 100%; }
  .actions .btn { flex: 1; }
  .market.is-sell-target::before { border-radius: var(--radius-xl); }
}

/* ---------- 친구 대결 ---------- */
.sheet__sub { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: 12px; }
.duel-join { display: grid; gap: 8px; }
.duel-join label { color: var(--text-muted); font-size: 12px; }
.duel-join__row { display: flex; gap: 8px; }
.field { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--bg-subtle); color: var(--text); font: inherit; font-size: 16px; letter-spacing: .12em; text-transform: uppercase;
  transition: border-color 160ms var(--ease); }
.field::placeholder { color: var(--text-subtle); letter-spacing: 0; text-transform: none; }
.field:hover { border-color: var(--text-subtle); }
.field:focus-visible { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.field[aria-invalid="true"] { border-color: var(--danger); }
.field-error { margin: 0; color: var(--danger) !important; font-size: 12px; }
.duels { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; }
.duel-item { width: 100%; display: grid; grid-template-columns: 72px 1fr auto; gap: 8px; align-items: center; min-height: 44px; padding: 8px 12px;
  border: 1px solid transparent; border-radius: var(--radius); background: var(--bg-subtle); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.duel-item:hover { background: var(--surface-2); border-color: var(--border-strong); }
.duel-item--static { cursor: default; }
.duel-item--static:hover { background: var(--bg-subtle); border-color: transparent; }
.duel-item > span:first-child { color: var(--text-subtle); }
.duel-item__code { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.duel-item strong { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.duel-item strong.is-win, .duel-rounds .is-win { color: var(--success); }
.duel-item strong.is-lose, .duel-rounds .is-lose { color: var(--danger); }
.duel-item strong.is-draw, .duel-rounds .is-draw { color: var(--text-muted); }
.duel-code { margin: 0; padding: 12px; border-radius: var(--radius); background: var(--bg-subtle); text-align: center;
  font-size: 32px; font-weight: 600; letter-spacing: .24em; color: var(--brand) !important; user-select: all; }
.duel-score { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px; border-radius: var(--radius); background: var(--bg-subtle); }
.duel-score div { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.duel-score span { color: var(--text-muted); font-size: 12px; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-score strong { font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; }
.duel-score i { font-style: normal; color: var(--text-subtle); font-size: 24px; }
.duel-rounds li { grid-template-columns: 24px 1fr auto auto; align-items: center; }

/* ---------- 야행주 ---------- */
.hero-btn { position: relative; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer;
  display: grid; place-items: center; transition: background-color 160ms var(--ease); }
.hero-btn:hover:not(:disabled) { background: var(--surface); }
.hero-btn:disabled { opacity: .35; cursor: default; }
.hero-btn .hero-art { width: 28px; height: 28px; }
.hero-btn__lv { position: absolute; right: 2px; bottom: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 600; line-height: 16px; text-align: center; }
.hero-art { border-radius: 50%; background: var(--text); object-fit: cover; flex: none; }
.heroes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; }
.hero-card { width: 100%; display: flex; gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid transparent; border-radius: var(--radius);
  background: var(--bg-subtle); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.hero-card:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.hero-card.is-on { border-color: var(--brand); background: var(--brand-subtle); }
.hero-card:disabled { cursor: not-allowed; }
.hero-card:disabled .hero-art { filter: grayscale(1) brightness(.5); }
.hero-card__text { display: grid; gap: 4px; min-width: 0; }
.hero-card__text strong { font-size: 14px; font-weight: 600; }
.hero-card__good { color: var(--success); font-size: 12px; }
.hero-card__bad { color: var(--text-muted); font-size: 12px; }
.hero-card__lock { color: var(--text-subtle); font-size: 12px; }
.hero-card__tag { margin-left: 4px; padding: 0 8px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 600; }
.level { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.level > span:first-child { color: var(--text-muted); font-size: 14px; }
.level__bar { height: 8px; border-radius: 4px; background: var(--bg-subtle); overflow: hidden; }
.level__bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width 400ms var(--ease); }
.growth { margin: 0; }
.mastery { display: flex; gap: 8px; align-items: center; margin: 0; }
.mastery__stars { display: inline-flex; gap: 4px; }
.mastery__star { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border-strong); }
.mastery__star.is-on { background: var(--brand); border-color: var(--brand); }
.duel-score .hero-art { width: 40px; height: 40px; }

/* ---------- 설정 — 어썸 계정·의견 보내기 ---------- */
.settings__group { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.settings__group:first-child { padding-top: 0; border-top: 0; }
.settings__group p { margin: 0; }
.acct { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: var(--radius); background: var(--bg-subtle); }
.acct__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.btn[data-loading] { opacity: .6; cursor: progress; }
/* 휴대폰: 위 줄 단추 8개를 4개씩 두 줄로(외톨이 줄이 생기지 않게) */
@media (max-width: 719px) {
  .hud__tools { display: grid; grid-template-columns: repeat(4, 44px); gap: 0; justify-items: center; }
}
