/* v0.87.0 디지몬 TCG 모바일 — 세로 휴대폰 화면 (390 × 844 기준) */
:root {
  --bg: #0b1020;
  --panel: #131a30;
  --panel2: #1b2440;
  --line: #2c3963;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --cyan: #38bdf8;
  --gold: #f9e2af;
  --rose: #f38ba8;
  --green: #a6e3a1;
  --violet: #cba6f7;
  --card-w: 62px;
  --card-h: 87px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; font-size: 14px; line-height: 1.4; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button:disabled { opacity: .45; }
button.primary { background: #0e4a6e; border-color: var(--cyan); }
button.gold { background: #4a3d12; border-color: var(--gold); }
button.danger { background: #4a1525; border-color: var(--rose); }
button.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-width: 0; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--rose); }
.ok { color: var(--green); }
img { -webkit-user-drag: none; user-select: none; }
[data-card] { -webkit-touch-callout: none; user-select: none; touch-action: manipulation; }

/* ---------- 공통 화면 ---------- */
.screen { min-height: 100vh; padding: 12px 16px calc(24px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.screen h1 { font-size: 22px; margin: 8px 0 4px; }
.screen h2 { font-size: 17px; margin: 18px 0 8px; }
.head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.head .back { padding: 6px 12px; }
.head h1 { flex: 1; margin: 0; font-size: 19px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; }
.menu { display: grid; gap: 10px; margin-top: 14px; }
.menu button { padding: 16px; font-size: 16px; text-align: left; }
.menu button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.kv b { color: var(--muted); font-weight: normal; }
.bar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; margin: 6px 0; }
.bar > i { display: block; height: 100%; background: var(--cyan); width: 0; transition: width .2s; }
.list { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); text-align: left; width: 100%; }
.choice.on { border-color: var(--gold); background: #2a2612; }
.choice .t { flex: 1; }
.choice small { display: block; color: var(--muted); font-size: 12px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-btns > button { flex: 1; }

/* ---------- 카드 ---------- */
.card { position: relative; width: var(--card-w); height: var(--card-h); border-radius: 5px; overflow: hidden; background: #1e293b; flex: 0 0 auto; border: 1px solid #334155; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.card .nm { display: none; position: absolute; inset: 0; padding: 4px; font-size: 10px; line-height: 1.2; word-break: keep-all; background: linear-gradient(160deg, #1e293b, #0f172a); }
.card.noimg .nm { display: block; }
.card.noimg img { display: none; }
.card.back { background: repeating-linear-gradient(45deg, #1e3a8a, #1e3a8a 6px, #172554 6px, #172554 12px); }
.card .dp { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; font-weight: 700; text-align: center; background: rgba(0,0,0,.72); color: #fff; padding: 1px 0; }
.card .badge { position: absolute; top: 2px; font-size: 10px; background: rgba(0,0,0,.75); border-radius: 6px; padding: 0 4px; color: #fff; }
.card .badge.l { left: 2px; }
.card .badge.r { right: 2px; }
.card.act { box-shadow: 0 0 0 2px var(--cyan), 0 0 10px rgba(56,189,248,.6); border-color: var(--cyan); }
.card.sel { box-shadow: 0 0 0 3px var(--gold); border-color: var(--gold); }
.card.rec::after { content: "★"; position: absolute; top: 2px; right: 3px; color: var(--gold); text-shadow: 0 0 3px #000; font-size: 13px; }
.slot { display: flex; align-items: center; justify-content: center; width: var(--card-w); height: var(--card-h); flex: 0 0 auto; }
.slot.rest { width: var(--card-h); }
.slot.rest .card { transform: rotate(90deg); }

/* ---------- 대전 화면 ---------- */
.duel { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 640px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .turn { font-weight: 700; }
.topbar .opp { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topbar button { padding: 6px 10px; }
.field { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 4px; justify-content: space-between; }
.side { border-radius: 12px; padding: 4px 6px; }
.side.opp { background: linear-gradient(180deg, #2a0f1e55, transparent); }
.side.me { background: linear-gradient(0deg, #0e2a4a55, transparent); }
.zones { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
button.chip { padding: 3px 9px; border-radius: 999px; }
.chip.sec { border-color: #fab387; }
.lane { display: flex; gap: 5px; overflow-x: auto; min-height: calc(var(--card-h) + 6px); align-items: center; padding: 3px 0; scrollbar-width: none; }
.lane::-webkit-scrollbar { display: none; }
.lane.small { min-height: 0; --card-w: 44px; --card-h: 62px; }
.lane .empty { color: #475569; font-size: 12px; padding-left: 6px; }
.tamer { display: flex; align-items: center; gap: 3px; }
.under { display: flex; flex-direction: column; gap: 1px; font-size: 10px; color: var(--muted); }
.under .u { width: 30px; height: 8px; border-radius: 2px; background: #64748b; }
.under .u.fd { background: #1e3a8a; }
.mine-row { display: flex; gap: 8px; align-items: center; }
.mine-row .breed { --card-w: 50px; --card-h: 70px; }
.memory { display: flex; align-items: center; gap: 4px; padding: 2px 4px; }
.memory .lbl { font-size: 11px; color: var(--muted); width: 26px; text-align: center; }
.memory .cells { flex: 1; display: grid; grid-template-columns: repeat(21, 1fr); gap: 2px; }
.memory .cells i { height: 18px; border-radius: 3px; background: #1e293b; font-style: normal; font-size: 9px; display: flex; align-items: center; justify-content: center; color: #475569; }
.memory .cells i.o { background: #3b1324; }
.memory .cells i.m { background: #0c2c47; }
.memory .cells i.cur { background: var(--gold); color: #000; font-weight: 700; font-size: 11px; }
.hand { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; background: var(--panel); border-top: 1px solid var(--line); --card-w: 70px; --card-h: 98px; scrollbar-width: none; }
.hand::-webkit-scrollbar { display: none; }
.foot { display: flex; gap: 6px; padding: 6px 8px calc(6px + var(--safe-b)); background: var(--panel); align-items: center; }
.foot button { flex: 1; padding: 10px 6px; }
.foot .hint { flex: 2; font-size: 12px; color: var(--muted); }
.busy { position: fixed; top: 48px; left: 50%; transform: translateX(-50%); background: #0e4a6e; border: 1px solid var(--cyan); border-radius: 999px; padding: 4px 14px; font-size: 13px; z-index: 40; }

/* ---------- 겹쳐 뜨는 창 ---------- */
.shade { position: fixed; inset: 0; background: rgba(2,6,23,.72); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.shade.center { align-items: center; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; padding: 14px 16px calc(16px + var(--safe-b)); }
.shade.center .sheet { border-radius: 18px; width: calc(100% - 24px); }
.sheet h3 { margin: 0 0 6px; font-size: 16px; }
.sheet .q { white-space: pre-wrap; margin: 6px 0 10px; }
.sheet .acts { display: grid; gap: 8px; }
.sheet .acts button { text-align: left; }
.sheet .acts button.end { border-color: #fab387; }
.sheet .acts button small { display: block; font-size: 11px; color: #fab387; }
.picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border-radius: 10px; border: 1px solid transparent; }
.pick .card { --card-w: 84px; --card-h: 117px; }
.pick .cap { font-size: 11px; text-align: center; white-space: pre-wrap; line-height: 1.25; }
.pick.on { border-color: var(--gold); background: #2a2612; }
.pick .who { font-size: 10px; padding: 0 6px; border-radius: 6px; }
.pick .who.m { background: #0c2c47; }
.pick .who.o { background: #3b1324; }
.zoom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.zoom .big { width: min(78vw, 340px); aspect-ratio: 0.716; border-radius: 12px; overflow: hidden; background: #1e293b; }
.zoom .big img { width: 100%; height: 100%; object-fit: contain; }
.detail { width: 100%; font-size: 13px; }
.detail .eff { white-space: pre-wrap; background: var(--panel2); border-radius: 10px; padding: 8px; margin: 4px 0; }
.detail .warn { color: #fab387; font-size: 12px; }
.minirow { display: flex; gap: 4px; flex-wrap: wrap; --card-w: 46px; --card-h: 64px; margin: 4px 0; }
.replay { text-align: center; }
.replay .kind { display: inline-block; border: 1px solid var(--rose); border-radius: 999px; padding: 2px 12px; font-size: 12px; letter-spacing: 1px; }
.replay .cards { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 12px 0; --card-w: 120px; --card-h: 168px; }
.replay .title { font-size: 17px; font-weight: 700; }
.replay .detail2 { color: var(--muted); white-space: pre-wrap; margin-top: 4px; }
.result h2 { font-size: 40px; text-align: center; margin: 10px 0; letter-spacing: 4px; }
.result h2.win { color: var(--gold); text-shadow: 0 0 18px #f9e2af88; }
.result h2.lose { color: #cbd5e1; }
.logs { font-size: 12px; white-space: pre-wrap; display: grid; gap: 3px; }
.logs div { border-bottom: 1px solid #1e293b; padding: 2px 0; }
.toast { position: fixed; left: 12px; right: 12px; top: calc(52px + env(safe-area-inset-top, 0px)); margin: 0 auto; max-width: 600px; background: #0f2a44; border: 1px solid var(--cyan); border-radius: 12px; padding: 10px 12px; font-size: 13px; z-index: 60; }
.toast.bad { background: #3a1020; border-color: var(--rose); }

/* ---------- 덱 빌더 ---------- */
.tabs { display: flex; gap: 6px; margin: 8px 0; }
.tabs button { flex: 1; padding: 8px; }
.tabs button.on { border-color: var(--gold); background: #2a2612; }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.filters input { grid-column: 1 / -1; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.cell .card { --card-w: 100%; width: 100%; height: auto; aspect-ratio: 0.716; }
.cell .lab { font-size: 11px; text-align: center; line-height: 1.2; word-break: keep-all; }
.cell .cnt { position: absolute; right: 3px; bottom: 3px; background: var(--gold); color: #000; font-weight: 700; border-radius: 8px; padding: 0 6px; font-size: 12px; }
.sup { position: absolute; left: 3px; top: 3px; font-size: 10px; border-radius: 6px; padding: 0 4px; background: rgba(0,0,0,.75); }
.sup.partial { color: #fab387; }
.sup.none { color: var(--rose); }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.lines { display: grid; gap: 6px; }
.line { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 10px; padding: 4px 6px; --card-w: 40px; --card-h: 56px; }
.line .t { flex: 1; font-size: 13px; }
.line .t small { color: var(--muted); display: block; }
.line .n { font-weight: 700; width: 28px; text-align: center; }
.ratio { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; font-size: 12px; }

/* v0.89.0 카드 이미지를 끈 때의 자체 카드 틀 (이름 · Lv · 코스트 · 색) — 공개 정적 웹 */
.card.frame { background: var(--fc, #334155); border-color: rgba(255,255,255,.25); }
.card.frame .nm { display: block; background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(2,6,23,.82) 55%); color: #f8fafc; padding-top: 16px; font-weight: 600; }
.card.frame .cost { position: absolute; top: 2px; left: 2px; min-width: 15px; height: 15px; border-radius: 50%; background: rgba(2,6,23,.85); color: #fff; font-size: 10px; font-weight: 700; text-align: center; line-height: 15px; }
.card.frame.c-Red { --fc: #b91c1c; } .card.frame.c-Blue { --fc: #1d4ed8; } .card.frame.c-Yellow { --fc: #ca8a04; } .card.frame.c-Green { --fc: #15803d; }
.card.frame.c-Black { --fc: #3f3f46; } .card.frame.c-Purple { --fc: #7e22ce; } .card.frame.c-White { --fc: #94a3b8; }
.zoom .big .card.frame { width: 100%; height: 100%; border-radius: 12px; }
.zoom .big .card.frame .nm { font-size: 16px; padding: 28px 10px 10px; }
.zoom .big .card.frame .cost { width: 26px; height: 26px; line-height: 26px; font-size: 15px; }
.about p { margin: 6px 0; line-height: 1.55; font-size: 13px; }
.about .legal { font-size: 12px; color: #cbd5e1; background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
