:root {
  --bg: #17122A; --bg2: #211A3E; --panel: #241C42; --panel2: #2E2555;
  --line: #40376A; --text: #ECE6F5; --muted: #9E93BE; --gold: #E9C45C;
  --accent: #C061D6; --win: #63E6A2; --loss: #E86A78;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; background: var(--bg); color: var(--text); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px; }
h1 { font-size: 20px; color: var(--gold); margin: 0 0 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.msg { font-size: 13px; margin-top: 8px; }
.msg.err { color: var(--loss); }
.msg.ok { color: var(--win); }
.hidden { display: none !important; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* top bar */
.top-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.top-bar .spacer { flex: 1; }
.status { font-size: 12px; color: var(--muted); }
.status.saving { color: var(--gold); }

/* monster tiles */
.mon { width: 62px; text-align: center; }
.mon img { width: 54px; height: 54px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); object-fit: cover; }
.mon.leader img { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.mon .mon-name { font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.2; height: 24px; overflow: hidden; }

/* unit picker */
.uc-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0 2px; }
.uc-x:hover { color: var(--loss); }
.uc-panel { }
.uc-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.uc-item:hover { background: var(--panel2); }
.uc-item img { width: 30px; height: 30px; border-radius: 6px; }
.uc-item-name { flex: 1; }
.uc-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* organizer */
.gd-intro { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.gd-ds-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.gd-def { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px; margin-bottom: 14px; }
.gd-def-head { display: flex; align-items: center; margin-bottom: 8px; }
.gd-def-title { flex: 1; }
.gd-label { color: var(--gold); font-weight: 700; }
.gd-x { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.gd-mini { display: flex; gap: 6px; }
.gd-mini .mon { width: 52px; }
.gd-offs { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.gd-off { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); flex-wrap: wrap; }
.gd-off-actions { display: flex; gap: 6px; }
.gd-guide-img { max-height: 140px; border-radius: 6px; cursor: pointer; margin-left: auto; border: 1px solid var(--line); }
.gd-adder { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: flex-start; }
.gd-slot { position: relative; width: 140px; }
.gd-unit-input { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; }
.gd-slot .uc-panel { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; max-height: 260px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; margin-top: 2px; }
.gd-chosen { display: flex; align-items: center; gap: 4px; }
.gd-chosen .mon { width: 52px; }
.gd-register { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.gd-register h2 { font-size: 14px; color: var(--gold); margin: 0 0 8px; }
.btn { background: var(--gold); color: #1a0f22; border: none; border-radius: 6px; padding: 8px 18px; cursor: pointer; font-weight: 700; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-sm { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.btn-sm.ghost { color: var(--muted); }

/* editor modal */
.gd-modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 24px; overflow: auto; }
.gd-modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; max-width: 1000px; width: 100%; max-height: calc(100vh - 48px); overflow-y: auto; }
.gd-editor-bar { display: flex; align-items: center; margin-bottom: 12px; }
.gd-editor-title { flex: 1; font-weight: 700; color: var(--gold); font-size: 16px; }
.gd-editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.gd-unit-edit { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel2); min-width: 0; }
.gd-unit-name { font-weight: 700; color: var(--text); margin-bottom: 6px; }
.gd-runes { display: flex; gap: 4px; margin-bottom: 6px; }
.gd-runes select { flex: 1 1 0; min-width: 0; }
.gd-runes select, .gd-field select, .gd-field input, .gd-field textarea { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; width: 100%; font-size: 12px; }
.gd-field { margin-bottom: 6px; }
.gd-field.sm { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 6px; }
.gd-field label { color: var(--muted); font-size: 12px; }
.gd-field textarea { min-height: 46px; resize: vertical; }
.gd-guide-key { margin-top: 12px; color: var(--muted); font-size: 12px; word-break: break-all; }
.gd-preview { width: 100%; max-width: 100%; height: 600px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; background: #130c08; }
.gd-editor-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.gd-full-img { max-width: 100%; display: block; margin-top: 10px; }
.gd-toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel2); color: var(--text); border: 1px solid var(--gold); border-radius: 8px; padding: 10px 18px; opacity: 0; transition: all .3s; z-index: 60; }
.gd-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* tabs */
.tabs { display: flex; gap: 6px; }
.tab-btn { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 8px 16px; cursor: pointer; font-size: 14px; }
.tab-btn.active { background: var(--panel); color: var(--gold); font-weight: 700; border-bottom-color: var(--panel); }

/* guide list */
.gd-list-row { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.gd-list-decks { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.gd-list-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.gd-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-right: 4px; }
.gd-badge.draft { background: rgba(233,196,92,.18); color: var(--gold); border: 1px solid var(--gold); }
.gd-badge.dup { background: rgba(232,106,120,.18); color: var(--loss); border: 1px solid var(--loss); }
.gd-badge.universal { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.gd-universal { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-left: 0; }

/* defense card (list tab: 방덱 지정/변경) */
.gd-defcard { display: flex; flex-direction: column; gap: 12px; }
.gd-defcard .gd-adder { margin-top: 0; }
.gd-list-row .gd-off-actions { flex-wrap: wrap; }

/* --- mobile (phones): stack rows, bigger touch targets, no iOS zoom --- */
@media (max-width: 680px) {
  .wrap { padding: 12px; }
  input, select, .gd-unit-input, textarea { font-size: 16px; }   /* >=16px stops iOS auto-zoom */
  .top-bar { flex-wrap: wrap; }
  .tabs { flex-wrap: wrap; }
  .tab-btn { flex: 1 1 auto; text-align: center; }
  .btn, .btn-sm, .tab-btn, .gd-x { min-height: 44px; }
  .gd-list-row { flex-direction: column; align-items: stretch; }
  .gd-list-decks { flex-direction: column; gap: 12px; }
  .gd-guide-img { margin-left: 0; align-self: flex-start; max-height: 220px; }
  .gd-off-actions { width: 100%; flex-wrap: wrap; }
  .gd-off-actions .btn-sm { flex: 1 1 40%; min-width: 0; }   /* ~2 per row, wrap (no overflow) */
  .gd-adder { flex-direction: column; }
  .gd-slot { width: 100%; }
  .gd-modal { padding: 8px; }
  .gd-preview { height: 70vh; }
}
