/* 앱여정 추천덱 (afk2.textverse.kr) — Stargazer 전술 다크 레이아웃 + 레드·골드 포인트 */
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1c2430;
  --surface-3: #242e3d;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f0f4f8;
  --text-sub: #a9b5c4;
  --text-dim: #738091;
  --accent: #e53935;
  --accent-hover: #f04844;
  --accent-soft: rgba(229, 57, 53, 0.16);
  --gold: #eab308;
  --gold-soft: rgba(234, 179, 8, 0.16);
  --emerald: #22c55e;
  --emerald-soft: rgba(34, 197, 94, 0.16);
  --violet: #a855f7;
  --cyan: #38bdf8;
  --f-lightbearer: #60a5fa;
  --f-wilder: #4ade80;
  --f-mauler: #fb923c;
  --f-graveborn: #2dd4bf;
  --f-celestial: #facc15;
  --f-hypogean: #c084fc;
  --f-dimensional: #818cf8;
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; overflow-x: clip; font-variant-numeric: tabular-nums; word-break: keep-all; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.32; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 17, 23, 0.94);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-icon { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-strong); background: #000; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }

.topnav { display: none; align-items: center; gap: 4px; margin-left: 12px; }
.nav-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-sub);
  padding: 7px 13px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  transition: background-color 140ms ease, color 140ms ease;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn[aria-current="page"] {
  background: var(--accent-soft); border-color: rgba(229, 57, 53, 0.42); color: #fff;
}

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  padding: 7px 13px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-accent { background: var(--surface-2); border-color: rgba(234, 179, 8, 0.4); color: var(--gold); }
.btn-accent:hover:not(:disabled) { background: var(--gold-soft); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-sub); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; padding: 10px 14px; }

/* Status line */
.status-bar {
  max-width: 1120px; margin: 0 auto; padding: 8px 16px;
  font-size: 13px; color: var(--text-sub); border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.status-bar.ok { color: var(--emerald); }
.status-bar.err { color: #f87171; }
.status-bar.warn { color: var(--gold); }

/* Auth Drawer (compact anchored panel) */
.auth-drawer {
  max-width: 1120px; margin: 12px auto 0; padding: 0 16px;
  display: flex; justify-content: flex-end;
}
.auth-card {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 12px;
}
.auth-head { display: flex; align-items: center; justify-content: space-between; }
.icon-close { border: 0; background: transparent; color: var(--text-sub); font-size: 20px; line-height: 1; padding: 2px 6px; }
.icon-close:hover { color: var(--text); }
.auth-form { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--text-sub); }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; color: var(--text); font-size: 14px;
}
.auth-msg { font-size: 12px; color: #f87171; min-height: 16px; }
.auth-note { margin: 0; font-size: 12px; color: var(--text-dim); }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg-btn { border: 0; background: transparent; color: var(--text-sub); padding: 5px 12px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.seg-btn[aria-pressed="true"] { background: var(--surface-3); color: #fff; }

/* Main Container */
.main {
  max-width: 1120px; margin: 0 auto;
  padding: 16px 16px 88px;
  display: grid; gap: 16px;
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; }
.page-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-sub); }

/* Panels */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 12px;
}
.panel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-row.between { justify-content: space-between; }

/* Filter Chips */
.chip-group { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text-sub);
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(229, 57, 53, 0.55); color: #fff; }

.search-input {
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: 13px; color: var(--text); width: 170px; max-width: 100%;
}

/* Roster Stats Strip */
.stat-strip { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-sub); }
.stat-strip b { color: var(--text); font-weight: 700; }

/* Stargazer-Style Hero Portrait Grid */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.hero-card {
  position: relative; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 8px; padding: 0; overflow: hidden; text-align: left;
  display: flex; flex-direction: column;
  transition: border-color 120ms ease;
}
.hero-card:hover { border-color: var(--border-strong); }
.hero-card.is-x { opacity: 0.48; }
.hero-card.is-x .hero-img { filter: grayscale(0.75); }
.hero-card.tier-p0 { border-color: rgba(234, 179, 8, 0.45); }
.hero-card.tier-p1, .hero-card.tier-p2 { border-color: rgba(168, 85, 247, 0.55); }
.hero-card.tier-p3, .hero-card.tier-p4 { border-color: rgba(229, 57, 53, 0.75); }

.hero-fac-bar { height: 3px; width: 100%; background: var(--fac, #64748b); }
.hero-portrait-wrap { position: relative; width: 100%; aspect-ratio: 100 / 122; background: #0c0f14; overflow: hidden; }
.hero-img { width: 100%; height: 100%; object-fit: cover; }
.hero-fallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-sub); padding: 4px; text-align: center;
}
.hero-badges {
  position: absolute; top: 4px; left: 4px; right: 4px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 3px; pointer-events: none;
}
.badge-p, .badge-r {
  padding: 1px 5px; border-radius: 4px; font-size: 11px; font-weight: 700; line-height: 1.3;
  background: rgba(10, 12, 16, 0.86); color: #fff; border: 1px solid rgba(255,255,255,0.14);
}
.badge-p.is-x { color: var(--text-dim); }
.badge-p.is-p0 { color: #fde047; border-color: rgba(234, 179, 8, 0.5); }
.badge-p.is-p1, .badge-p.is-p2 { color: #d8b4fe; border-color: rgba(168, 85, 247, 0.55); }
.badge-p.is-p3, .badge-p.is-p4 { color: #fca5a5; border-color: rgba(229, 57, 53, 0.65); }
.badge-r { color: #7dd3fc; border-color: rgba(56, 189, 248, 0.45); }

.hero-name {
  padding: 4px 5px; font-size: 11px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
  background: var(--surface);
}

/* Floating Hero Picker Popover (mobile-ui-float-detail compliant: <= 300px, anchored near card) */
.hero-popover {
  position: fixed; z-index: 90; width: 292px; max-width: calc(100vw - 20px);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 12px; display: grid; gap: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.58);
}
.pop-head { display: flex; align-items: center; gap: 10px; }
.pop-thumb { width: 38px; height: 46px; border-radius: 6px; object-fit: cover; background: #000; flex: none; }
.pop-meta { min-width: 0; flex: 1; }
.pop-name { font-size: 14px; font-weight: 700; }
.pop-sub { font-size: 12px; color: var(--text-sub); }
.pop-row-label { font-size: 11px; font-weight: 700; color: var(--text-sub); margin-bottom: 4px; display: flex; justify-content: space-between; }
.pop-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.pop-grid.r-grid { grid-template-columns: repeat(5, 1fr); }
.tier-btn {
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text-sub);
  padding: 6px 2px; border-radius: 6px; font-size: 12px; font-weight: 700; text-align: center;
}
.tier-btn:hover:not(:disabled) { color: #fff; border-color: var(--gold); }
.tier-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tier-btn.r-btn[aria-pressed="true"] { background: #0284c7; border-color: #38bdf8; color: #fff; }

/* Map Selector Cards */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
.map-card {
  border: 1px solid var(--border); background: var(--bg); border-radius: 8px;
  padding: 10px; text-align: left; display: grid; gap: 4px;
}
.map-card:hover { border-color: var(--border-strong); }
.map-card[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(229, 57, 53, 0.7); }
.map-card-title { font-size: 13px; font-weight: 700; color: var(--text); }
.map-card-desc { font-size: 11px; color: var(--text-sub); }

.map-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.map-info-item {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px;
  display: grid; gap: 3px;
}
.map-info-item strong { font-size: 12px; color: var(--text); }
.map-info-item span { font-size: 11px; color: var(--text-sub); }
.tag-rule { color: #fbbf24 !important; font-weight: 600; }

/* Progress Bar */
.progress-wrap { display: grid; gap: 6px; }
.progress-track { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 160ms linear; }
.progress-text { font-size: 12px; color: var(--text-sub); display: flex; justify-content: space-between; }

/* Recommendation Summary & Team Cards */
.summary-band {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 12px 16px;
}
.sum-kpi { display: grid; gap: 2px; }
.sum-kpi span { font-size: 11px; color: var(--text-sub); }
.sum-kpi strong { font-size: 20px; font-weight: 800; color: var(--gold); }

.team-list { display: grid; gap: 14px; }
.team-card {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 12px;
}
.team-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.team-title-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.team-rank { background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 5px; }
.team-map-lbl { font-size: 13px; font-weight: 700; color: var(--text); }
.team-wr { font-size: 17px; font-weight: 800; color: var(--emerald); }

.team-body {
  display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start;
}
.team-heroes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.mini-hero {
  background: var(--bg); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; text-align: center;
}
.mini-hero-imgwrap { position: relative; aspect-ratio: 100 / 120; background: #0b0e13; }
.mini-hero-imgwrap img { width: 100%; height: 100%; object-fit: cover; }
.mini-hero-name { font-size: 11px; font-weight: 600; padding: 3px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.team-meta-row { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-sub); }
.meta-pill {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; display: inline-flex; align-items: center; gap: 5px;
}
.meta-pill b { color: var(--text); }
.meta-pill.buff { border-color: rgba(234, 179, 8, 0.45); color: #fde047; }
.meta-pill.prison { border-color: rgba(168, 85, 247, 0.5); color: #e9d5ff; }

/* 45-Tile Hex Auto-Formation SVG Board */
.hex-board-box {
  background: #0a0d12; border: 1px solid var(--border); border-radius: 9px; padding: 10px;
  display: grid; gap: 6px;
}
.hex-board-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-sub); }
.hex-board-head strong { color: var(--text); }
.hex-svg { width: 100%; height: auto; max-width: 420px; margin: 0 auto; display: block; }
.hex-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--text-dim); justify-content: center; }
.leg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* Mobile Bottom Nav */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(13, 17, 23, 0.97); border-top: 1px solid var(--border-strong);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bnav-btn {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 7px 4px 6px; display: grid; justify-items: center; gap: 3px; font-size: 11px; font-weight: 600;
}
.bnav-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.bnav-btn[aria-current="page"] { color: var(--accent); }

@media (min-width: 720px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  .main { padding-bottom: 40px; }
  .hero-grid { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); }
  .team-body { grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
