/* 헥사 크라운 — 나무 판자와 금박 테두리의 전술 테이블 UI */
:root {
  --wood: #2b1f17;
  --wood-2: #3a2a1e;
  --wood-3: #4a3726;
  --line: #6b4f33;
  --gold: #e3b046;
  --gold-2: #f5d27a;
  --parch: #f4e8cc;
  --muted: #c2ad8a;
  --red: #e2574c;
  --green: #5fc46e;
  --blue: #5aa3ff;
  --display: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  --body: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fc4e8; color: var(--parch); font-family: var(--body); -webkit-user-select: none; user-select: none; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#overlay { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
button { font: inherit; color: inherit; }
button:focus-visible, .traits li:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
kbd { font: 600 10px ui-monospace, Menlo, monospace; border: 1px solid rgba(244,232,204,.35); border-radius: 3px; padding: 0 4px; margin-left: 6px; opacity: .75; }

.panel { background: linear-gradient(180deg, var(--wood-2), var(--wood)); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,220,160,.12), 0 6px 18px rgba(0,0,0,.35); }

.back-btn { position: fixed; top: 12px; left: 12px; z-index: 30; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--parch); text-decoration: none; border-radius: 8px; background: rgba(43,31,23,.88); border: 1px solid var(--line); }
.back-btn:hover { border-color: var(--gold); }

/* 상단 라운드 */
.hud-top { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.stage-box { display: flex; align-items: center; gap: 12px; padding: 6px 16px 6px 8px; border-radius: 12px; background: linear-gradient(180deg, var(--wood-2), var(--wood)); border: 1px solid var(--line); box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.stage-id { font: 700 22px var(--display); color: var(--gold-2); background: var(--wood); border: 1px solid var(--gold); border-radius: 8px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.stage-meta { display: grid; gap: 4px; font-size: 13px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 16px; height: 6px; border-radius: 3px; background: rgba(244,232,204,.2); }
.pips i.boss { width: 22px; background: rgba(226,87,76,.35); }
.pips i.creep { background: rgba(95,196,110,.3); }
.pips i.done { background: var(--muted); }
.pips i.now { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.rival-box { font-size: 12px; padding: 3px 12px; border-radius: 999px; background: rgba(43,31,23,.82); border: 1px solid var(--line); }
.rival-box .vs { color: var(--red); font-weight: 700; margin-right: 6px; }

/* 좌측 */
.hud-left { position: fixed; left: 12px; top: 56px; z-index: 20; width: 214px; display: grid; gap: 8px; }
.hp-box { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: linear-gradient(180deg, var(--wood-2), var(--wood)); border: 1px solid var(--line); }
.heart { color: var(--red); font-size: 18px; }
.hp-track { flex: 1; height: 10px; border-radius: 5px; background: #1a120c; overflow: hidden; border: 1px solid #120c08; }
.hp-track i { display: block; height: 100%; background: linear-gradient(90deg, #c43b33, #f06a55); transition: width .4s; }
.hp-box b { font: 700 18px var(--display); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.streak { margin: 0; font-size: 12px; color: var(--gold-2); min-height: 0; }
.streak:empty { display: none; }
.panel-title { margin: 4px 2px 0; font: 700 14px var(--display); color: var(--gold-2); letter-spacing: .04em; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.traits { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.traits li { position: relative; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; background: rgba(43,31,23,.88); border: 1px solid var(--line); font-size: 13px; }
.traits li.hint { display: block; color: var(--muted); font-size: 12px; }
.t-ico { width: 28px; height: 28px; display: grid; place-items: center; font-size: 15px; border-radius: 6px; background: #1d150f; color: var(--muted); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.traits li.bronze .t-ico { background: #b07a4a; color: #2b1a0c; }
.traits li.silver .t-ico { background: #c9d2dc; color: #1f2833; }
.traits li.gold .t-ico { background: var(--gold); color: #3a2506; box-shadow: 0 0 10px var(--gold); }
.traits li.off { opacity: .72; }
.t-main { display: grid; gap: 2px; }
.t-steps { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.t-steps i { font-style: normal; }
.t-steps i.on { color: var(--gold-2); font-weight: 700; }
.t-n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.t-tip { display: none; position: absolute; left: calc(100% + 8px); top: 0; width: 240px; padding: 8px 10px; border-radius: 8px; background: #1d150f; border: 1px solid var(--gold); font-size: 12px; line-height: 1.5; z-index: 5; }
.t-tip span { display: block; color: var(--muted); }
.t-tip span.on { color: var(--parch); }
.traits li:hover .t-tip, .traits li:focus .t-tip { display: block; }
.augs { display: flex; flex-wrap: wrap; gap: 4px; }
.augs span { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(90,163,255,.18); border: 1px solid rgba(90,163,255,.5); }

/* 우측 */
.hud-right { position: fixed; right: 12px; top: 12px; z-index: 20; display: grid; gap: 8px; justify-items: end; }
.board-count { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: rgba(43,31,23,.9); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.board-count b { font: 700 16px var(--display); color: var(--parch); font-variant-numeric: tabular-nums; }
.board-count:has(b.under) { border-color: var(--gold); }
.board-count b.under { color: var(--gold-2); }
.fight-btn { cursor: pointer; padding: 12px 22px; border-radius: 12px; font: 700 18px var(--display); color: #2b1a06; background: linear-gradient(180deg, #ffe08e, #e3a83a); border: 2px solid #fff1c4; box-shadow: 0 4px 0 #9a6a1c, 0 8px 18px rgba(0,0,0,.35); }
.fight-btn:hover:not(:disabled) { filter: brightness(1.07); }
.fight-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #9a6a1c; }
.fight-btn:disabled { cursor: default; background: linear-gradient(180deg, #8b7b63, #6a5b46); border-color: #a8987c; color: #2b1f17; box-shadow: 0 4px 0 #3a2f22; }
.mini-row { display: flex; gap: 6px; }
.mini { cursor: pointer; min-width: 42px; height: 34px; border-radius: 8px; background: rgba(43,31,23,.9); border: 1px solid var(--line); font-weight: 700; }
.mini:hover { border-color: var(--gold); }

/* 정보 패널 */
.info[hidden] { display: none; }
.info { position: fixed; right: 12px; top: 176px; z-index: 20; width: 260px; padding: 12px; border-radius: 12px; background: linear-gradient(180deg, var(--wood-2), var(--wood)); border: 1px solid var(--tier, var(--line)); box-shadow: 0 8px 22px rgba(0,0,0,.4); display: grid; gap: 10px; font-size: 13px; }
.i-head { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.i-head img { width: 64px; height: 64px; border-radius: 10px; background: radial-gradient(circle at 50% 35%, #5d4a36, #241a12); border: 2px solid var(--tier); }
.i-head h3 { margin: 0; font: 700 17px var(--display); }
.i-head p { margin: 0; }
.i-stars { color: var(--gold-2); font-size: 13px; letter-spacing: 1px; }
.foe { font-size: 11px; color: #fff; background: var(--red); border-radius: 4px; padding: 0 5px; letter-spacing: 0; }
.i-tr { color: var(--muted); font-size: 12px; }
.i-cost { color: var(--gold-2); }
.i-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0; }
.i-stats div { background: rgba(0,0,0,.25); border-radius: 6px; padding: 4px 6px; }
.i-stats dt { font-size: 10px; color: var(--muted); }
.i-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.i-skill h4 { margin: 0 0 2px; font: 700 14px var(--display); color: var(--gold-2); }
.i-skill p { margin: 0; color: #e8dcc0; line-height: 1.5; }
.i-skill b { color: var(--muted); font-weight: 600; }
.i-skill b.cur { color: var(--parch); text-decoration: underline; text-decoration-color: var(--gold); }
.sell-btn { cursor: pointer; justify-self: start; padding: 6px 12px; border-radius: 8px; background: #5a2a22; border: 1px solid #a8483c; font-weight: 700; }
.sell-btn:hover { background: #6e3127; }

/* 상점 */
.shop { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 20; width: min(1000px, calc(100vw - 24px)); display: grid; grid-template-columns: 170px 1fr 170px; gap: 10px; padding: 10px; border-radius: 14px; background: linear-gradient(180deg, rgba(58,42,30,.97), rgba(43,31,23,.97)); border: 1px solid var(--gold); box-shadow: 0 -2px 0 rgba(255,220,160,.08) inset, 0 10px 30px rgba(0,0,0,.45); }
.shop-side { display: grid; gap: 8px; align-content: center; }
.lvl { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 4px 6px; font-size: 12px; color: var(--muted); }
.lvl b { font: 700 22px var(--display); color: var(--parch); }
.xp-track { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: #1a120c; overflow: hidden; }
.xp-track i { display: block; height: 100%; background: linear-gradient(90deg, #4f8de0, #8fc2ff); transition: width .3s; }
.lvl small { grid-column: 1 / -1; font-variant-numeric: tabular-nums; }
.shop-btn { cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 10px; border-radius: 9px; background: var(--wood-3); border: 1px solid var(--line); font-size: 13px; font-weight: 700; white-space: nowrap; }
.shop-btn:hover { border-color: var(--gold); background: #56402c; }
.shop-btn .g { color: var(--gold-2); }
.shop-btn .g::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); margin: 0 3px 0 2px; vertical-align: -1px; box-shadow: inset 0 -2px 0 #a3741c; }
.btn-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.lock[aria-pressed="true"] { border-color: var(--gold); background: #5a4422; }
.gold-box { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px; }
.gold-box .coin { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3c2 0 15%, var(--gold) 16%); box-shadow: inset 0 -3px 0 #a3741c; }
.gold-box b { font: 700 26px var(--display); color: var(--gold-2); font-variant-numeric: tabular-nums; }
.gold-box.flash { animation: flash .5s; }
@keyframes flash { 30% { transform: scale(1.15); color: var(--red); } }

.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.card { cursor: pointer; position: relative; display: grid; grid-template-rows: 1fr auto; overflow: hidden; height: 128px; padding: 0; border-radius: 10px; background: radial-gradient(circle at 50% 30%, #5d4a36, #1f1610 75%); border: 2px solid var(--tier); text-align: left; transition: transform .12s; }
.card:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.4), 0 0 0 1px var(--tier); }
.card:disabled:not(.empty) { filter: grayscale(.7) brightness(.7); cursor: not-allowed; }
.card img { position: absolute; inset: -6px 0 auto; width: 100%; height: 118px; object-fit: cover; object-position: 50% 20%; pointer-events: none; }
.card.empty { border-style: dashed; border-color: var(--line); background: rgba(0,0,0,.2); place-items: center; color: var(--muted); font-size: 12px; display: grid; }
.c-traits { position: relative; z-index: 1; display: grid; align-content: start; gap: 2px; padding: 5px 6px; font-size: 10px; }
.c-traits span { justify-self: start; padding: 1px 5px; border-radius: 4px; background: rgba(20,14,10,.72); }
.c-foot { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 5px 7px; background: linear-gradient(0deg, rgba(20,14,10,.95), rgba(20,14,10,.6)); font-size: 12px; }
.c-foot b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-cost { flex: none; display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: var(--gold-2); }
.c-cost::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: inset 0 -2px 0 #a3741c; }
.combine { position: absolute; z-index: 2; top: 5px; right: 5px; font-size: 10px; font-weight: 700; color: #2b1a06; background: var(--gold-2); padding: 2px 6px; border-radius: 999px; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 10px var(--gold-2); transform: scale(1.06); } }

.sell-zone { display: none; position: absolute; inset: 0; border-radius: 14px; place-items: center; background: rgba(120,30,24,.85); border: 2px dashed #ffb4a8; font: 700 22px var(--display); }
.shop.selling .sell-zone { display: grid; }

/* 유닛 체력바 */
.ubar { position: absolute; left: 0; top: 0; width: 64px; display: grid; gap: 2px; will-change: transform; }
.ubar.boss { width: 110px; }
.ustars { text-align: center; font-size: 11px; line-height: 1; color: #d9dde3; text-shadow: 0 1px 2px #000, 0 0 2px #000; letter-spacing: -1px; }
.ustars[data-star="2"] { color: #cfe2ff; }
.ustars[data-star="3"] { color: var(--gold-2); }
.uhp { position: relative; height: 7px; border-radius: 2px; background: #1a120c; border: 1px solid #0c0806; overflow: hidden; }
.uhp i { position: absolute; top: 0; bottom: 0; left: 0; }
.ubar.ally .hpf { background: linear-gradient(180deg, #7fe08a, #3ea24c); }
.ubar.enemy .hpf { background: linear-gradient(180deg, #ff8a7a, #c8392e); }
.shf { background: #f2f4f7; }
.ump { height: 3px; border-radius: 2px; background: #1a120c; overflow: hidden; }
.ump i { display: block; height: 100%; background: #5aa3ff; }

.ftxt { position: absolute; left: 0; top: 0; font: 800 15px var(--body); color: #fff; text-shadow: 0 1px 0 #000, 0 0 3px #000; white-space: nowrap; will-change: transform; }
.ftxt.mag { color: #c7a8ff; }
.ftxt.phy { color: #ffe1c4; }
.ftxt.onally { font-size: 13px; opacity: .9; }
.ftxt.crit { font-size: 19px; color: #ffd166; }
.ftxt.gold { color: var(--gold-2); font-size: 18px; }
.ftxt.star { color: var(--gold-2); font: 700 18px var(--display); }
.ftxt.info { color: #a9e8ff; font-size: 14px; }

/* 배너·토스트·모달 */
.banner { position: fixed; top: 108px; left: 50%; transform: translateX(-50%); z-index: 25; display: grid; justify-items: center; gap: 4px; padding: 10px 26px; border-radius: 12px; background: rgba(28,20,14,.9); border: 1px solid var(--gold); opacity: 0; pointer-events: none; text-align: center; max-width: calc(100vw - 32px); }
.banner b { font: 700 24px var(--display); color: var(--gold-2); }
.banner b.win { color: #8ff09a; }
.banner b.lose { color: #ff8a7a; }
.banner span { font-size: 13px; color: var(--muted); }
.banner.show { animation: banner 2.4s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -10px); } 12%, 78% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.toast { position: fixed; bottom: 168px; left: 50%; transform: translateX(-50%); z-index: 26; padding: 8px 16px; border-radius: 999px; background: rgba(28,20,14,.94); border: 1px solid var(--line); font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(12,9,6,.55); backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.sheet { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px; border-radius: 16px; background: linear-gradient(180deg, #3f2e20, #261b13); border: 1px solid var(--gold); box-shadow: 0 20px 60px rgba(0,0,0,.6); display: grid; gap: 12px; }
.sheet h2 { margin: 0; font: 700 30px var(--display); color: var(--gold-2); }
.sheet p { margin: 0; line-height: 1.6; color: #eadfc4; }
.eyebrow { font-size: 12px; letter-spacing: .08em; color: var(--muted) !important; }
.howto { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; color: #eadfc4; }
.howto b { color: var(--gold-2); margin-right: 4px; }
.best { font-size: 13px; color: var(--gold-2) !important; }
.primary { cursor: pointer; justify-self: start; padding: 12px 26px; border-radius: 12px; font: 700 18px var(--display); color: #2b1a06; background: linear-gradient(180deg, #ffe08e, #e3a83a); border: 2px solid #fff1c4; box-shadow: 0 4px 0 #9a6a1c; }
.primary:hover { filter: brightness(1.07); }
.aug-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.aug-card { cursor: pointer; display: grid; align-content: start; gap: 8px; min-height: 150px; padding: 14px; border-radius: 12px; text-align: left; background: radial-gradient(circle at 50% 0, #4d6fa8 0, #23324d 70%); border: 1px solid #8fb8ff; }
.aug-card:hover { transform: translateY(-3px); box-shadow: 0 0 18px rgba(143,184,255,.5); }
.aug-card b { font: 700 17px var(--display); color: #e6f0ff; }
.aug-card span { font-size: 13px; line-height: 1.5; color: #cdd9ee; }
.over-stats { font-size: 14px; }
.over-stats b { color: var(--gold-2); }
.over-team { display: flex; flex-wrap: wrap; gap: 8px; }
.over-team figure { margin: 0; width: 76px; text-align: center; font-size: 11px; color: var(--muted); }
.over-team img { width: 76px; height: 76px; border-radius: 10px; border: 2px solid var(--tier); background: radial-gradient(circle at 50% 35%, #5d4a36, #241a12); }
.over-team figcaption { line-height: 1.3; }
.sheet.victory { border-color: var(--gold-2); box-shadow: 0 0 60px rgba(245,210,122,.35); }

.loading { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #3f2e20, #140e09); }
.loading[hidden] { display: none; }
.load-card { width: min(360px, calc(100vw - 32px)); display: grid; gap: 12px; text-align: center; }
.load-card h1 { margin: 0; font: 700 40px var(--display); color: var(--gold-2); }
.load-track { height: 8px; border-radius: 4px; background: #1a120c; overflow: hidden; border: 1px solid var(--line); }
.load-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #c88d2c, var(--gold-2)); transition: width .2s; }
.load-card p, .load-err { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center; padding: 16px; }

/* 좁은 화면 */
@media (max-width: 980px) {
  .hud-left { width: 170px; top: 52px; }
  .traits li { grid-template-columns: 24px 1fr auto; padding: 4px 6px; font-size: 12px; }
  .t-ico { width: 24px; height: 24px; font-size: 13px; }
  .shop { grid-template-columns: 120px 1fr 120px; padding: 8px; gap: 6px; }
  .card { height: 104px; }
  .card img { height: 96px; }
  .c-traits { font-size: 9px; }
  .shop-btn { font-size: 11px; padding: 6px; }
  .shop-btn kbd { display: none; }
  .info { width: 220px; top: 168px; }
  .aug-list { grid-template-columns: 1fr; }
  .aug-card { min-height: 0; }
}
@media (max-width: 640px) {
  .hud-left { width: 132px; }
  .traits li { grid-template-columns: 1fr auto; }
  .traits .t-ico, .t-steps { display: none; }
  .shop { grid-template-columns: 1fr 1fr; }
  .cards { grid-column: 1 / -1; grid-row: 1; }
  .card { height: 92px; }
  .c-traits { display: none; }
  .stage-box { padding: 4px 10px 4px 6px; }
  .rival-box { display: none; }
  .info { left: 12px; right: 12px; width: auto; top: auto; bottom: 230px; }
}
@media (prefers-reduced-motion: reduce) {
  .combine, .gold-box.flash { animation: none; }
  .banner.show { animation-duration: .01s; opacity: 1; }
}
