/* =====================================================================
   theme-d.css — D안 "정통 판타지" 디자인 테마 (2026-09-28)
   ---------------------------------------------------------------------
   · 짙은 남색 바탕 + 금테 한 겹. 색/글꼴/모양 규칙은 프로젝트 루트 DESIGN.md 참고.
   · 기존 base.css / screens.css / card-big.css 위에 "덮어쓰기"로 동작합니다.
     → 이 파일의 <link> 한 줄을 빼면 예전 디자인으로 즉시 되돌아갑니다.
   · 구성: 0 토큰  1 바탕  2 버튼  3 모달  4 메인 메뉴  5 서브 화면
           6 작은 카드  7 큰 카드  8 경기 화면  9 도감/상점/덱  10 기타
   ===================================================================== */

/* ── 0. 글꼴 + 디자인 토큰 ─────────────────────────────────────────── */
@font-face {
  font-family: 'Efreeta Serif';
  src: url('../fonts/efreeta-serif-800.woff2') format('woff2');
  font-weight: 700 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Efreeta Sans';
  src: url('../fonts/efreeta-sans-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --navy: #0D1428;
  --navy-deep: #070B18;
  --navy-raised: #111A33;
  --navy-card: #0B1122;
  --gold: #D4AF5A;
  --gold-light: #F0D48E;
  --gold-button: #C39B45;
  --gold-dark: #8C6A26;
  --gold-line: #3A3320;
  --parchment: #EDE3C8;
  --muted: #9DA3B8;
  --ink-on-gold: #1C1405;
  --hp-red: #A3242B;
  --hp-blue: #1E5FB8;
  --mana-red: #C8332B;
  --mana-blue: #2A62C9;
  --mana-green: #2E8B4E;
  --mana-black: #5B3A86;
  --mana-white: #E9DDB4;
  --mana-colorless: #6C7288;
  --rune: #9A7BE0;
  --serif: 'Efreeta Serif', 'Nanum Myeongjo', serif;
  --sans: 'Efreeta Sans', 'Gowun Dodum', 'Malgun Gothic', sans-serif;
  --shadow-card: 0 6px 14px rgba(0,0,0,0.45);
  --glow-gold: 0 0 16px rgba(240,212,142,0.55);
  --btn-gold-shadow: inset 0 2px 0 rgba(255,240,200,0.55), inset 0 -4px 0 rgba(90,60,10,0.45), 0 6px 18px rgba(0,0,0,0.4);
}

/* ── 1. 바탕 ───────────────────────────────────────────────────────── */
body {
  background: var(--navy) !important;
  color: var(--parchment);
  font-family: var(--sans);
}
#bg-layer {
  background: var(--navy) url('../img/base_img_title.webp') no-repeat center top;
  background-size: 100% auto;
}
#bg-layer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(13,20,40,0) 0%, rgba(13,20,40,0) 34%, rgba(13,20,40,0.85) 52%, var(--navy) 62%);
}
::selection { background: var(--gold-dark); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: var(--gold-dark) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 3px; }
*::-webkit-scrollbar-track { background: transparent; }
button, input, select, textarea { font-family: var(--sans); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

/* ── 2. 버튼 ───────────────────────────────────────────────────────── */
.btn {
  font-family: var(--serif); font-weight: 800;
  border-radius: 10px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--gold-dark); background: var(--navy-raised); color: var(--parchment);
  box-shadow: none; transition: transform .12s, box-shadow .2s, background .2s;
}
.btn:hover:not(:disabled) { background: #16213F; border-color: var(--gold); transform: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn-primary, .card-draw-btn, .att-claim-btn, .synth-go-btn {
  background: var(--gold-button) !important; color: var(--ink-on-gold) !important;
  border: 2px solid var(--gold-light) !important; box-shadow: var(--btn-gold-shadow) !important;
}
.btn-primary:hover:not(:disabled), .card-draw-btn:hover:not(:disabled) { background: #CFA84F !important; }
.btn-secondary, .btn-cancel {
  background: var(--navy-raised) !important; color: var(--parchment) !important;
  border: 1px solid var(--gold-dark) !important;
}
.btn-warning {
  background: #1A2444 !important; color: var(--gold-light) !important; border: 1px solid var(--gold) !important;
}
.btn-danger {
  background: #3A1418 !important; color: #FFD9D6 !important; border: 1px solid #A3242B !important;
}
.btn-blue {
  background: #16254A !important; color: #CFE0FF !important; border: 1px solid var(--hp-blue) !important;
}
.card-draw-btn.btn-skip {
  background: var(--navy-raised) !important; color: var(--gold-light) !important;
  border: 1px solid var(--gold) !important; box-shadow: none !important;
}

/* ── 3. 모달 · 팝업 공통 ───────────────────────────────────────────── */
.modal, .mulligan-modal, .deck-picker-modal, .sacrifice-box, .shop-modal-box,
.saved-decks-modal-inner,
#action-choice-popup .action-box, #unit-action-popup .action-box,
#overload-popup .overload-box {
  background: var(--navy-raised) !important;
  border: 2px solid var(--gold) !important;
  border-radius: 16px !important;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6) !important;
  color: var(--parchment);
}
.modal h2, .mulligan-modal h2, .deck-picker-modal h2, .sacrifice-box h3,
.saved-decks-modal-title,
#action-choice-popup .action-box h3, #unit-action-popup .action-box h3, #overload-popup .overload-box h3 {
  font-family: var(--serif) !important; font-weight: 800 !important;
  color: var(--gold-light) !important; letter-spacing: 0;
}
.modal p, .mulligan-modal p, .sacrifice-box p { color: var(--muted) !important; }
#overlay, #mulligan-overlay, #ability-picker-overlay, #game-mode-overlay, #deck-picker-overlay,
#sacrifice-popup, #card-detail-overlay, #action-choice-popup, #unit-action-popup {
  background: rgba(5,8,18,0.82) !important;
}
.deck-pick-item, .saved-deck-item {
  background: var(--navy-card) !important; border: 1px solid var(--gold-line) !important;
  border-radius: 10px !important; color: var(--parchment) !important;
}
.deck-pick-item.selected, .saved-deck-item.selected, .deck-pick-item:hover {
  border-color: var(--gold) !important; box-shadow: var(--glow-gold);
}

/* 온라인 대전 로비 (online.js 가 만든 화면) */
#online-overlay { background: rgba(5,8,18,0.86) !important; }
#online-overlay input, #online-overlay select {
  background: var(--navy-deep) !important; border: 1px solid var(--gold-dark) !important;
  color: var(--parchment) !important; border-radius: 10px !important; min-height: 42px;
}
#online-overlay label { color: var(--muted) !important; }
#online-overlay #online-room-code { color: var(--gold-light) !important; font-family: var(--serif); }
#online-overlay #online-login-stats { color: var(--gold-light) !important; }
#online-overlay #online-login-info { background: var(--navy-deep) !important; border-color: var(--gold-line) !important; }
#online-overlay .ol-spinner { border-color: var(--gold-line) !important; border-top-color: var(--gold) !important; }

/* 작은 목록형 버튼(menu-btn) — 모달 안에서 재사용 */
.menu-btn {
  background: var(--navy-card) !important; border: 1px solid var(--gold-dark) !important;
  border-radius: 12px !important; color: var(--parchment) !important;
  font-family: var(--serif); font-weight: 800; min-height: 52px;
}
.menu-btn:hover { transform: none !important; border-color: var(--gold) !important; box-shadow: var(--glow-gold) !important; }
.menu-btn .btn-icon { display: none; }
.menu-btn .btn-arrow { color: var(--gold) !important; }

/* ── 4. 메인 메뉴 (D안) ───────────────────────────────────────────── */
#screen-menu.dm {
  position: relative; justify-content: flex-start; align-items: stretch;
  gap: 0; padding: 0; background: transparent; text-align: left;
  min-height: 100vh; height: 100vh; overflow: hidden;
}
.dm-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px 0;
  position: relative; z-index: 5;
}
.dm-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border-radius: 20px;
  background: rgba(7,11,24,0.78); border: 1px solid var(--gold-dark);
}
.dm-avatar {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--gold);
  background: url('../img/base_img_title.webp') center 20% / cover no-repeat;
}
.dm-name { font-family: var(--serif); font-weight: 800; font-size: 14px; color: var(--parchment); }
#screen-menu .menu-currency-hud {
  position: static !important; margin: 0; padding: 6px 12px; border-radius: 20px;
  background: rgba(7,11,24,0.78) !important; border: 1px solid var(--gold-dark) !important;
  font-size: 13px; gap: 12px;
}
#screen-menu .daily-bonus-icons {
  top: calc(max(12px, env(safe-area-inset-top, 0px)) + 46px); left: auto; right: 12px;
  flex-direction: row; gap: 8px;
}
.daily-bonus-icon {
  width: 48px !important; height: 48px !important; border-radius: 12px !important;
  background: rgba(7,11,24,0.82) !important; border: 1px solid var(--gold-dark) !important;
  color: var(--gold-light) !important; box-shadow: none !important;
}
#att-icon-btn:not(.claimed), #daily-ad-icon-btn:not(.claimed) {
  border-color: var(--gold) !important; box-shadow: var(--glow-gold) !important;
}
.daily-bonus-icon .dbi-emoji { display: flex; }
.daily-bonus-icon .dbi-emoji svg { width: 20px; height: 20px; }
.daily-bonus-icon .dbi-label { color: var(--parchment) !important; font-size: 10px; }
.dm-spacer { flex: 1 1 auto; min-height: 120px; }
.dm-panel {
  margin: 0 16px; padding: 14px 16px; border: 1px solid var(--gold-dark); border-radius: 12px;
  background: var(--navy-raised); box-shadow: 0 10px 24px rgba(0,0,0,0.45);
  display: flex; align-items: center; gap: 14px;
}
.dm-panel svg { flex-shrink: 0; }
.dm-panel-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.dm-panel-title { font-family: var(--serif); font-weight: 800; font-size: 20px; color: var(--gold-light); }
.dm-panel-sub { font-size: 12px; color: var(--muted); }
.dm-panel-bar { height: 8px; border-radius: 4px; background: var(--navy-deep); border: 1px solid var(--gold-line); overflow: hidden; }
.dm-panel-bar > span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.dm-actions { display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 0; }
.dm-btn-primary {
  height: 68px; border-radius: 10px; cursor: pointer;
  background: var(--gold-button); border: 2px solid var(--gold-light); box-shadow: var(--btn-gold-shadow);
  color: var(--ink-on-gold); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.dm-btn-primary:active { transform: translateY(1px); }
.dm-btn-title { font-family: var(--serif); font-weight: 800; font-size: 23px; }
.dm-btn-sub { font-size: 12px; color: #3A2A0A; }
.dm-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dm-btn {
  height: 52px; border-radius: 10px; cursor: pointer;
  background: var(--navy-raised); border: 1px solid var(--gold-dark); color: var(--parchment);
  font-family: var(--serif); font-weight: 800; font-size: 16px;
}
.dm-btn:active { transform: translateY(1px); }
.dm-links {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); padding: 4px 0 10px;
}
.dm-links button {
  background: none; border: 0; color: var(--gold); font-size: 12px; cursor: pointer;
  padding: 8px 6px; min-height: 36px;
}
.dm-links #app-version-label { color: var(--muted); }
.dm-nav {
  flex-shrink: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
  height: calc(66px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--navy-deep); border-top: 1px solid var(--gold-line);
}
.dm-nav button {
  background: none; border: 0; cursor: pointer; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; color: #8C92A8;
}
.dm-nav button.on { color: var(--gold); }
.dm-nav svg { width: 22px; height: 22px; }

/* 통화 표시 (모든 화면) */
.currency-hud { font-family: var(--sans); color: var(--parchment); }
.currency-hud .currency-gold, .currency-hud .currency-diamond { color: var(--parchment) !important; }
.ico-gold { width: 12px; height: 12px; border-radius: 50%; background: var(--gold); box-shadow: inset 0 0 0 2px var(--gold-dark); display: inline-block; flex-shrink: 0; }
.ico-dia { width: 9px; height: 9px; background: var(--rune); transform: rotate(45deg); display: inline-block; flex-shrink: 0; margin: 0 2px; }

/* ── 5. 서브 화면 공통 ─────────────────────────────────────────────── */
.subscreen {
  background: var(--navy) !important; backdrop-filter: none !important;
  padding: 12px 14px !important;
}
.subscreen-header {
  border-bottom: 1px solid var(--gold-line) !important; padding-bottom: 10px !important; margin-bottom: 12px !important;
  gap: 8px !important;
}
.subscreen-title { font-family: var(--serif) !important; font-weight: 800 !important; font-size: 19px !important; color: var(--parchment) !important; }
.back-btn {
  min-height: 40px; padding: 6px 12px !important; border-radius: 10px !important;
  background: var(--navy-raised) !important; border: 1px solid var(--gold-dark) !important;
  color: var(--gold-light) !important; font-size: 13px !important;
}
.filter-btn, .sort-btn, .coll-mode-btn, .coll-own-btn, .coll-filter-btn, .log-filter-btn, .synth-tier-btn {
  min-height: 32px; padding: 4px 12px !important; border-radius: 16px !important;
  background: var(--navy-raised) !important; border: 1px solid var(--gold-dark) !important;
  color: var(--parchment) !important; font-size: 12px !important;
}
.filter-btn.active, .sort-btn.active, .coll-mode-btn.active, .coll-own-btn.active, .coll-filter-btn.active,
.log-filter-btn.active, .synth-tier-btn.active {
  background: var(--gold-button) !important; color: var(--ink-on-gold) !important; border-color: var(--gold-light) !important; font-weight: 700;
}
.form-input, .deck-name-input, .cost-input, select.form-input {
  background: var(--navy-deep) !important; border: 1px solid var(--gold-dark) !important;
  color: var(--parchment) !important; border-radius: 10px !important;
}
.form-label { color: var(--muted) !important; }

/* 색 보석 (필터 버튼 등) */
.gem { width: 13px; height: 13px; display: inline-block; transform: rotate(45deg); border: 1px solid rgba(255,255,255,0.45); vertical-align: middle; }
.gem-red { background: var(--mana-red); } .gem-blue { background: var(--mana-blue); } .gem-green { background: var(--mana-green); }
.gem-black { background: var(--mana-black); } .gem-white { background: var(--mana-white); }

/* ── 6. 작은 카드 (손패 · 전장 · 도감 · 덱빌더 공용) ───────────────── */
.card {
  background: var(--navy-card) !important;
  border: 1.5px solid var(--gold) !important;
  border-radius: 8px !important;
  box-shadow: 0 0 0 1px rgba(7,11,24,0.9), var(--shadow-card) !important;
  overflow: visible !important;
  position: relative;
}
.card > .card-img { order: 1; border-radius: 6px 6px 0 0; overflow: hidden; background: #EEE7DA; flex: 0 0 50% !important; min-height: 0 !important; max-height: none !important; }
.card > .card-img img { object-position: center 30%; }
.card > .card-mini-header {
  order: 2; background: var(--navy-raised) !important; border-bottom: 0 !important; border-top: 1px solid var(--gold-dark) !important;
  justify-content: center !important; padding: 0 4px !important; flex: 0 0 auto !important; min-height: 17px !important;
}
.card .card-name {
  color: var(--parchment) !important; font-family: var(--serif); font-weight: 800;
  font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; max-width: 100%;
}
.card .card-name span { color: inherit !important; }
.card .card-cost {
  position: absolute; top: 3px; left: 3px; z-index: 3;
  display: flex; gap: 1px; flex: none !important; justify-content: flex-start !important;
}
.cost-gem {
  min-width: 17px; height: 17px; padding: 0 3px; border-radius: 9px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 800; font-size: 10px; line-height: 1; color: #fff;
  border: 1.5px solid var(--navy-deep); box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.cost-gem.cost-red { background: var(--mana-red); } .cost-gem.cost-blue { background: var(--mana-blue); }
.cost-gem.cost-green { background: var(--mana-green); } .cost-gem.cost-black { background: var(--mana-black); }
.cost-gem.cost-white { background: var(--mana-white); color: #2A2410; } .cost-gem.cost-colorless { background: var(--mana-colorless); }
.card > .card-type-badge {
  order: 3; background: transparent !important; border: 0 !important; color: var(--muted) !important;
  font-size: 7.5px !important; text-align: center; padding: 1px 0 0 !important; flex: 0 0 auto !important; min-height: 0 !important;
}
.card > .card-text {
  order: 4; color: var(--parchment) !important; opacity: .88;
  font-size: 7.5px !important; line-height: 1.25 !important; text-align: center; padding: 1px 5px !important;
  flex: 1 1 auto !important; min-height: 0 !important; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.card > .card-stats {
  order: 5; background: transparent !important; border: 0 !important;
  flex: 0 0 0 !important; min-height: 0 !important; height: 0; padding: 0 !important; position: static;
}
.card .card-stats .stat-atk, .card .card-stats .stat-hp {
  position: absolute; bottom: 3px; z-index: 3;
  min-width: 21px; height: 21px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 800; font-size: 12px; line-height: 1;
  border: 2px solid var(--navy-deep);
}
.card .card-stats .stat-atk { left: 3px; border-radius: 50%; background: var(--gold); color: var(--ink-on-gold) !important; }
.card .card-stats .stat-hp { right: 3px; border-radius: 4px 4px 11px 11px; background: var(--hp-red); color: #fff !important; }
.card .card-stats .stat-atk.stat-buffed { background: #6FCF97; color: #0B2416 !important; }
.card .card-stats .stat-atk.stat-debuffed { background: #7A6A55; color: #fff !important; }
.card .card-stats .stat-hp.stat-damaged { background: #5E1016; color: #FFB4AE !important; }
.card .card-stats .stat-sick {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); z-index: 3;
  font-size: 8px; padding: 1px 5px; border-radius: 8px; background: var(--navy-deep); color: var(--muted);
  border: 1px solid var(--gold-line); white-space: nowrap;
}
/* 카드 상태 */
.card:hover { transform: translateY(-2px); }
.card.selected { transform: translateY(-8px) !important; box-shadow: var(--glow-gold), var(--shadow-card) !important; border-color: var(--gold-light) !important; }
.card.attacker { box-shadow: 0 0 0 2px var(--gold-light), 0 0 18px rgba(240,212,142,0.8) !important; transform: translateY(-6px) !important; }
.card.blocker-selected, .card.valid-blocker { box-shadow: 0 0 0 2px var(--hp-blue), 0 0 16px rgba(30,95,184,0.8) !important; }
.card.valid-target { animation: dm-pulse 1s infinite alternate !important; border-color: var(--gold-light) !important; }
@keyframes dm-pulse { from { box-shadow: 0 0 6px rgba(240,212,142,0.35); } to { box-shadow: 0 0 18px rgba(240,212,142,0.85); } }
.card.summon-sick { opacity: .82; }
.card.tapped { transform: rotate(6deg); opacity: .75; }

/* 스탯 원 자리 확보 (유닛 아닌 카드도 높이 통일) */
.card > .card-text { margin-bottom: 20px; }
.card.card-tile > .card-text { margin-bottom: 22cqw; }
#card-detail-overlay .card > .card-text { margin-bottom: 26px; }
/* 덱 편집기 헤더: 제목 한 줄, 색 필터는 아래 줄 */
#screen-deck .subscreen-header { flex-wrap: wrap !important; }
#screen-deck .subscreen-title { white-space: nowrap; }
#screen-deck .deck-header-filter { flex-basis: 100%; display: flex; gap: 6px; flex-wrap: wrap; }
.back-btn { white-space: nowrap; }

/* 손패 · 전장 카드는 그림 + 이름 위주 (효과는 눌러서 크게 보기) */
.card:not(.card-tile) > .card-text { display: none !important; }
.card:not(.card-tile) > .card-type-badge { margin-bottom: 22px; }
#card-detail-overlay .card > .card-text { display: -webkit-box !important; }
#card-detail-overlay .card > div:not([class]) { order: 5; font-size: 12px !important; color: var(--muted) !important; font-style: normal !important; padding: 0 14px 30px !important; line-height: 1.5; }
#card-detail-overlay .card > .card-type-badge { margin-bottom: 0; }

/* 손패 카드 */
.card.hand-card { width: 78px !important; height: 116px !important; min-height: 116px !important; max-height: 116px !important; }
.card.hand-card > .card-img { flex: 0 0 60px !important; }
/* 도감 · 덱빌더 타일 */
.card.card-tile > .card-img { flex: 0 0 52% !important; }
.card.card-tile .card-name { font-size: 10cqw !important; }
.card.card-tile > .card-text { font-size: 7.5cqw !important; }
.card.card-tile > .card-type-badge { font-size: 7cqw !important; }
.card.card-tile .cost-gem { min-width: 18cqw; height: 18cqw; font-size: 11cqw; border-radius: 9cqw; }
.card.card-tile .card-stats .stat-atk, .card.card-tile .card-stats .stat-hp { min-width: 24cqw; height: 24cqw; font-size: 13cqw; }
/* 마법진 (원형 금테 창) */
.enchant-slot { background: transparent !important; border: 1px dashed var(--gold-line) !important; border-radius: 12px !important; }
.enchant-slot-label { color: var(--muted) !important; opacity: 1 !important; }
.enchant-slot .card { width: 64px !important; min-height: 64px !important; }
.card.enchant-card { border-style: solid !important; }
/* 카드 크게 보기 */
#card-detail-overlay .card {
  width: 240px !important; min-height: 360px !important; height: auto !important;
  border-width: 2px !important; border-radius: 14px !important; overflow: visible !important;
}
#card-detail-overlay .card > .card-img { flex: 0 0 200px !important; border-radius: 12px 12px 0 0; }
#card-detail-overlay .card-name { font-size: 17px !important; }
#card-detail-overlay .card > .card-mini-header { min-height: 34px !important; }
#card-detail-overlay .card > .card-type-badge { font-size: 11px !important; padding-top: 6px !important; }
#card-detail-overlay .card > .card-text { font-size: 13px !important; line-height: 1.45 !important; -webkit-line-clamp: 6; padding: 6px 14px !important; }
#card-detail-overlay .card > .card-stats { flex: 0 0 26px !important; height: 26px; }
#card-detail-overlay .cost-gem { min-width: 30px; height: 30px; font-size: 15px; border-radius: 15px; border-width: 2px; }
#card-detail-overlay .card .card-cost { top: -12px; left: -12px; }
#card-detail-overlay .card-stats .stat-atk, #card-detail-overlay .card-stats .stat-hp { min-width: 42px; height: 42px; font-size: 20px; bottom: -14px; border-width: 3px; }
#card-detail-overlay .card-stats .stat-atk { left: -12px; }
#card-detail-overlay .card-stats .stat-hp { right: -12px; border-radius: 6px 6px 21px 21px; }

/* ── 7. 큰 카드 (카드 상세 · 뽑기 · 상점 미리보기, 280×400) ──────── */
.card-big {
  background: var(--gold-button) !important; border: 0 !important; border-radius: 16px !important;
  padding: 6px !important; box-sizing: border-box;
  box-shadow: inset 0 0 0 2px var(--gold-light), 0 0 0 2px var(--gold-line), 0 18px 40px rgba(0,0,0,0.6) !important;
  display: flex !important; flex-direction: column !important; position: relative; overflow: visible !important;
  font-family: var(--sans);
}
.card-big > * { background-color: var(--navy-card) !important; }
.card-big .cb-image {
  order: 1; flex: 0 0 214px !important; height: 214px !important; border-radius: 11px 11px 0 0 !important; overflow: hidden;
  border: 2px solid var(--gold-dark); border-bottom: 0; background: #EEE7DA !important;
}
.card-big .cb-image::after { display: none !important; }
.card-big .cb-image img { width: 100%; height: 100%; object-fit: cover; object-position: center 35%; }
.card-big .cb-header {
  order: 2; position: relative; z-index: 2; margin: -18px 12px 0 !important; min-height: 38px;
  border: 2px solid var(--gold) !important; border-radius: 6px !important; background: var(--navy-raised) !important;
  display: flex; align-items: center; justify-content: center; padding: 0 8px !important;
}
.card-big .cb-header::after { display: none !important; }
.card-big .cb-name {
  font-family: var(--serif) !important; font-weight: 800 !important; font-size: 19px !important; color: var(--gold-light) !important;
  text-shadow: none !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-big > .cb-mana {
  position: absolute !important; top: -12px; left: -12px; z-index: 4; display: flex !important; gap: 3px;
  background: transparent !important; width: auto !important; padding: 0 !important; border: 0 !important;
}
.cb-gem {
  width: auto !important; min-width: 32px; height: 32px !important; padding: 0 5px; margin: 0 !important; border-radius: 16px !important;
  display: flex !important; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 800; font-size: 16px !important; color: #fff !important;
  border: 2.5px solid var(--gold-light) !important; box-shadow: 0 3px 8px rgba(0,0,0,0.5) !important;
}
.cb-gem-red { background: var(--mana-red) !important; } .cb-gem-blue { background: var(--mana-blue) !important; }
.cb-gem-green { background: var(--mana-green) !important; } .cb-gem-black { background: var(--mana-black) !important; }
.cb-gem-white { background: var(--mana-white) !important; color: #2A2410 !important; }
.cb-gem-colorless { background: var(--mana-colorless) !important; }
.card-big .cb-type-band {
  order: 3; background: var(--navy-card) !important; border: 0 !important; justify-content: center !important; padding: 6px 0 0 !important;
  border-left: 2px solid var(--gold-dark) !important; border-right: 2px solid var(--gold-dark) !important;
}
.card-big .cb-type-label { color: var(--muted) !important; font-size: 11px !important; background: transparent !important; border: 0 !important; padding: 0 !important; }
.card-big .cb-keywords { display: none !important; }
.card-big .cb-text-area {
  order: 4; flex: 1 1 auto !important; background: var(--navy-card) !important; border: 2px solid var(--gold-dark) !important; border-top: 0 !important;
  border-radius: 0 0 11px 11px !important; padding: 8px 16px 30px !important; text-align: center;
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.card-big .cb-effect { color: var(--parchment) !important; font-size: 14px !important; line-height: 1.45 !important; background: transparent !important; border: 0 !important; padding: 0 !important; }
.card-big .cb-flavor { color: var(--muted) !important; font-size: 12px !important; line-height: 1.5 !important; font-style: normal !important; background: transparent !important; border: 0 !important; }
.card-big .cb-stats { position: absolute !important; left: 0; right: 0; bottom: 0; height: 0; background: transparent !important; border: 0 !important; padding: 0 !important; }
.card-big .cb-stat-box { display: contents !important; }
.card-big .cb-atk, .card-big .cb-hp {
  position: absolute; bottom: -12px; min-width: 46px; height: 46px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 800; font-size: 22px; border: 3px solid var(--navy-deep);
}
.card-big .cb-atk { left: -12px; border-radius: 50%; background: var(--gold); color: var(--ink-on-gold); }
.card-big .cb-hp { right: -12px; border-radius: 6px 6px 23px 23px; background: var(--hp-red); color: #fff; }
.card-big:hover { transform: none !important; }

/* 등급 배지 */
.grade-badge, .buy-grade-badge, .shop-pack-grade-badge, .pack-reveal-grade-badge {
  border-radius: 10px !important; font-family: var(--sans) !important;
}

/* ── 8. 경기 화면 ─────────────────────────────────────────────────── */
#screen-game { background: var(--navy) !important; }
#game-wrap { gap: 6px !important; padding: 6px 8px !important; }
.player-zone {
  background: var(--navy-deep) !important; border: 0 !important; border-radius: 12px !important;
  border-bottom: 1px solid var(--gold-line) !important;
}
#player-zone-header { border-top: 1px solid var(--gold-line) !important; border-bottom: 0 !important; }
.player-name { font-family: var(--serif) !important; font-weight: 800 !important; font-size: 14px !important; color: var(--parchment) !important; }
.player-name.ai { color: #D9C8FF !important; }
.hp-badge {
  min-width: 38px; height: 42px; box-sizing: border-box; padding: 0 4px !important;
  display: inline-flex !important; align-items: center; justify-content: center;
  font-family: var(--serif) !important; font-weight: 800 !important; font-size: 17px !important; color: #fff !important;
  background: var(--hp-blue) !important; border: 2px solid var(--gold) !important; border-radius: 6px 6px 19px 19px !important;
}
.hp-badge.ai { background: var(--hp-red) !important; }
.hp-bar-wrap { background: var(--navy-card) !important; border: 1px solid var(--gold-line); height: 5px !important; border-radius: 3px; margin-top: 4px; }
.hp-bar { background: var(--gold) !important; }
.hp-bar.low { background: var(--hp-red) !important; }
.deck-count, .hand-count-badge {
  font-size: 11px !important; color: var(--muted) !important; background: transparent !important; border: 0 !important; padding: 0 !important;
}
#turn-indicator { color: var(--gold-light) !important; font-family: var(--serif); font-size: 12px !important; }
#ai-stats-zone, #player-stats-zone { background: transparent !important; padding: 2px 4px !important; }
#ai-ability-display { color: #D9C8FF !important; font-size: 11px !important; }
.mana-row { gap: 6px !important; }
.mana-gem {
  background: var(--navy-card) !important; border: 1px solid var(--gold-line) !important; border-radius: 12px !important;
  padding: 2px 8px 2px 4px !important; font-size: 12px !important; color: var(--parchment) !important;
  display: inline-flex !important; align-items: center; gap: 6px;
}
.mana-gem .mana-icon { display: none !important; }
.mana-gem .gem { width: 11px; height: 11px; margin: 0 2px; }
.mana-gem.zero { opacity: .45; }
.battlefield {
  background: rgba(7,11,24,0.55) !important; border: 1px solid var(--gold-line) !important; border-radius: 12px !important;
  padding: 14px 10px 12px !important; gap: 14px !important;
}
.bf-label { color: var(--muted) !important; font-size: 10px !important; }
#player-battlefield { background: rgba(17,26,51,0.65) !important; }
#player-hand-area { background: transparent !important; border: 0 !important; padding: 10px 8px 6px !important; }
#hand-row { gap: 6px !important; padding: 10px 4px 12px !important; }
#phase-bar { gap: 4px !important; }
.phase-pip {
  background: var(--navy-raised) !important; border: 1px solid var(--gold-line) !important; color: var(--muted) !important;
  border-radius: 12px !important; font-size: 11px !important; padding: 4px 10px !important;
}
.phase-pip.active { background: var(--gold-button) !important; color: var(--ink-on-gold) !important; border-color: var(--gold-light) !important; font-weight: 700; }
#action-bar .btn { min-height: 36px; font-size: 13px !important; padding: 6px 12px !important; }
#btn-hero-ability { min-height: 30px; font-size: 11px !important; }
#log-panel { background: var(--navy-deep) !important; border-top: 1px solid var(--gold-line) !important; }
#log-title { color: var(--muted) !important; }
#log-title span { background: var(--navy-raised) !important; color: var(--gold-light) !important; }
#log-status { background: var(--navy-raised) !important; color: var(--gold-light) !important; border: 1px solid var(--gold-line); }
#btn-forfeit-game { background: #2A1216 !important; border-color: #6E2A30 !important; color: #FFD9D6 !important; }
#log-latest-msg { color: var(--muted) !important; }
#target-banner, #block-banner {
  background: var(--navy-raised) !important; border: 1px solid var(--gold) !important; color: var(--gold-light) !important;
}
.color-btn { border-radius: 12px !important; border: 2px solid var(--gold-dark) !important; }
.color-btn.red { background: var(--mana-red) !important; } .color-btn.blue { background: var(--mana-blue) !important; }
.color-btn.green { background: var(--mana-green) !important; } .color-btn.black { background: var(--mana-black) !important; }
.color-btn.white { background: var(--mana-white) !important; color: #2A2410 !important; }
#ai-indicator { background: var(--navy-raised) !important; border: 1px solid var(--gold) !important; color: var(--gold-light) !important; }
.log-entry { color: var(--parchment); }

/* ── 9. 도감 · 상점 · 덱빌더 · 뽑기 ───────────────────────────────── */
.coll-card-item { border: 0 !important; background: transparent !important; box-shadow: none !important; }
.coll-card-item .card.card-tile { border-color: var(--gold) !important; }
.coll-card-count { background: rgba(7,11,24,0.88) !important; color: var(--gold-light) !important; border: 1px solid var(--gold-dark) !important; border-radius: 8px !important; }
.coll-stats-bar, .coll-stat { color: var(--muted) !important; }
.shop-tabs { border-bottom: 1px solid var(--gold-line) !important; background: transparent !important; }
.shop-tab { font-family: var(--serif) !important; font-weight: 800 !important; color: var(--muted) !important; background: transparent !important; border: 0 !important; min-height: 44px; }
.shop-tab.active { color: var(--gold-light) !important; box-shadow: inset 0 -2px 0 var(--gold) !important; }
.shop-pack-item, .shop-buy-row {
  background: var(--navy-raised) !important; border: 1px solid var(--gold-dark) !important; border-radius: 12px !important;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35) !important;
}
.shop-pack-item.rare { border: 2px solid var(--gold) !important; }
.shop-pack-name, .buy-info-name { font-family: var(--serif) !important; font-weight: 800 !important; color: var(--gold-light) !important; }
.shop-pack-desc, .buy-info-meta, .buy-info-effect, .buy-info-stat, .shop-buy-timer-row { color: var(--muted) !important; }
.shop-pack-price, .buy-info-price, .price-gold, .shop-price-gold { color: var(--parchment) !important; }
.price-diamond, .shop-price-diamond { color: #CDBDF5 !important; }
.shop-pack-btn {
  background: var(--gold-button) !important; color: var(--ink-on-gold) !important; border: 2px solid var(--gold-light) !important;
  border-radius: 10px !important; font-family: var(--serif); font-weight: 800; min-height: 40px; box-shadow: var(--btn-gold-shadow) !important;
}
.shop-refresh-btn { background: var(--navy-raised) !important; border: 1px solid var(--gold) !important; color: var(--gold-light) !important; border-radius: 10px !important; min-height: 40px; }
.shop-toast { background: var(--navy-raised) !important; border: 1px solid var(--gold) !important; color: var(--parchment) !important; }
.deck-section-label, .deck-section-header { color: var(--muted) !important; }
.deck-bottom-bar { background: var(--navy-deep) !important; border-top: 1px solid var(--gold-dark) !important; }
.deck-count-badge { border-radius: 12px !important; font-family: var(--serif); }
.deck-count-badge.valid { background: #1E3A2A !important; color: #BDF0CF !important; border-color: #3E9E62 !important; }
.deck-count-badge.invalid { background: #3A1418 !important; color: #FFD9D6 !important; border-color: var(--hp-red) !important; }
.deck-card-count-badge { background: var(--gold-button) !important; color: var(--ink-on-gold) !important; border: 1px solid var(--gold-light) !important;
  top: 3px !important; right: 3px !important; bottom: auto !important; left: auto !important; z-index: 4; }
#screen-deck { background: var(--navy) !important; }
.diff-card { background: var(--navy-raised) !important; border: 1px solid var(--gold-dark) !important; border-radius: 12px !important; }
.diff-card.selected { border: 2px solid var(--gold) !important; box-shadow: var(--glow-gold) !important; }
.diff-card .diff-name { font-family: var(--serif); font-weight: 800; color: var(--gold-light) !important; }
.diff-card .diff-desc { color: var(--muted) !important; }
.diff-card .diff-icon { display: none !important; }
#card-draw-overlay { background: rgba(7,11,24,0.96) !important; }
.card-draw-bg-glow { background: radial-gradient(circle at center, rgba(212,175,90,0.18), transparent 60%) !important; }
.card-draw-title { font-family: var(--serif) !important; font-weight: 800 !important; color: var(--gold-light) !important; background: none !important; -webkit-text-fill-color: currentColor !important; }
.card-draw-subtitle, .card-draw-progress { color: var(--muted) !important; }
.att-cell { background: var(--navy-card) !important; border: 1px solid var(--gold-line) !important; border-radius: 10px !important; }
.att-cell.att-today { border: 2px solid var(--gold) !important; box-shadow: var(--glow-gold) !important; }
#attendance-modal > div, #purchase-confirm-modal > div { background: var(--navy-raised) !important; border: 2px solid var(--gold) !important; border-radius: 16px !important; }

/* ── 10. 기타 ─────────────────────────────────────────────────────── */
.reward-notice { background: var(--navy-card) !important; border: 1px solid var(--gold) !important; color: var(--gold-light) !important; border-radius: 10px !important; }
.custom-badge { background: var(--navy-deep) !important; color: var(--gold-light) !important; border: 1px solid var(--gold-dark) !important; }
@media (prefers-reduced-motion: reduce) {
  .card, .dm-panel-bar > span, .btn { transition: none !important; animation: none !important; }
}

/* ── 11. 웹/앱 분기 + 계정 동기화 (cloud-save.js) ─────────────────── */
.is-web .only-app { display: none !important; }
.is-app .only-web { display: none !important; }
.is-web #daily-ad-icon-btn, .is-web .shop-refresh-row, .is-web .shop-refresh-btn { display: none !important; }
button.dm-chip { cursor: pointer; font: inherit; color: inherit; text-align: left; }
.dm-chip-text { display: flex; flex-direction: column; line-height: 1.15; }
#dm-cloud-state { font-size: 10px; color: var(--muted); }
#dm-cloud-state[data-state="ok"] { color: #BDF0CF; }
#dm-cloud-state[data-state="error"], #dm-cloud-state[data-state="choosing"] { color: #FFB4AE; }
#dm-cloud-state[data-state="syncing"] { color: var(--gold-light); }
#cloud-choice-overlay {
  position: fixed; inset: 0; z-index: 100000; background: rgba(5,8,18,0.86);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.cloud-choice-box {
  width: 100%; max-width: 380px; background: var(--navy-raised); border: 2px solid var(--gold); border-radius: 16px;
  padding: 20px 16px; box-shadow: 0 18px 40px rgba(0,0,0,0.6); display: flex; flex-direction: column; gap: 10px;
}
.cloud-choice-box h2 { font-family: var(--serif); font-weight: 800; color: var(--gold-light); font-size: 20px; margin: 0; text-align: center; }
.cloud-choice-box p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 4px; text-align: center; }
.cloud-choice-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; cursor: pointer;
  background: var(--navy-card); border: 1px solid var(--gold-dark); border-radius: 12px; padding: 12px 14px; color: var(--parchment); min-height: 64px;
}
.cloud-choice-opt:hover, .cloud-choice-opt:focus-visible { border-color: var(--gold); box-shadow: var(--glow-gold); }
.cloud-choice-opt b { font-family: var(--serif); font-weight: 800; font-size: 16px; color: var(--gold-light); }
.cloud-choice-opt span { font-size: 12px; color: var(--muted); }
#cloud-toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100001;
  background: var(--navy-raised); border: 1px solid var(--gold); color: var(--parchment); border-radius: 12px;
  padding: 10px 16px; font-size: 13px; transition: opacity .25s, transform .25s; max-width: calc(100vw - 32px);
}
#cloud-toast.show { opacity: 1; transform: translate(-50%, 0); }
/* 넓은 화면(PC 웹): 게임을 휴대폰 폭으로 가운데 정렬 */
@media (min-width: 700px) {
  .is-web body { align-items: center; background: #05080F !important; }
  .is-web body > .screen { max-width: 480px; margin: 0 auto; box-shadow: 0 0 0 1px var(--gold-line), 0 0 60px rgba(0,0,0,0.6); }
  .is-web #bg-layer { left: 50%; right: auto; width: 480px; transform: translateX(-50%); }
}


/* =====================================================================
   12. 첫 실행 로그인 화면 (인트로 → 로그인/게스트 → 카드 뽑기)
   ===================================================================== */
#first-login-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center; padding: 20px 16px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(212,175,90,0.16), transparent 60%),
    linear-gradient(180deg, rgba(7,11,24,0.82), rgba(7,11,24,0.96)),
    var(--navy-deep) url('../img/base_img_title.webp') no-repeat center top / cover;
  animation: frFade .35s ease-out;
}
@keyframes frFade { from { opacity: 0; } to { opacity: 1; } }
.fr-box {
  width: 100%; max-width: 360px; text-align: center; word-break: keep-all;
  background: linear-gradient(180deg, var(--navy-raised), var(--navy-card));
  border: 1px solid var(--gold-dark); border-radius: 14px;
  box-shadow: 0 0 0 3px var(--navy-deep), 0 0 0 4px var(--gold-line), 0 18px 40px rgba(0,0,0,0.55);
  padding: 26px 22px 20px;
}
.fr-crest {
  width: 46px; height: 46px; margin: 0 auto 10px; transform: rotate(45deg);
  border: 2px solid var(--gold); background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  box-shadow: var(--glow-gold);
}
.fr-box h1 { font-family: var(--serif); font-weight: 800; color: var(--gold-light); font-size: 26px; margin: 0 0 6px; letter-spacing: .02em; }
.fr-lead { color: var(--parchment); font-size: 15px; margin: 0 0 8px; }
.fr-desc { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 0 0 18px; }
.fr-btns { display: flex; flex-direction: column; gap: 10px; }
.fr-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; border-radius: 10px; font-family: var(--sans); font-size: 15px; font-weight: 700;
  cursor: pointer; border: 1px solid transparent;
}
.fr-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.fr-kakao  { background: #FEE500; color: #191919; }
.fr-ico {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; background: rgba(0,0,0,0.08);
}
.fr-btn:focus-visible, .fr-guest:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
.fr-btn:disabled, .fr-guest:disabled { opacity: .55; cursor: default; }
.fr-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 12px; }
.fr-or::before, .fr-or::after { content: ''; flex: 1; height: 1px; background: var(--gold-line); }
.fr-guest {
  width: 100%; min-height: 44px; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--gold-light); border: 1px solid var(--gold-dark);
  font-family: var(--sans); font-size: 14px;
}
.fr-guest:hover { background: rgba(212,175,90,0.08); }
.fr-note { color: var(--muted); font-size: 11.5px; line-height: 1.55; margin: 10px 0 0; }
.fr-status { min-height: 18px; margin: 12px 0 0; font-size: 13px; color: var(--gold-light); }
.fr-status.is-error { color: #F08A8A; }
@media (prefers-reduced-motion: reduce) { #first-login-overlay { animation: none; } }
