:root {
  --bg: #0f1424;
  --bg2: #131a2e;
  --panel: #18203a;
  --panel2: #1f2946;
  --panel3: #27335a;
  --line: rgba(242, 193, 78, 0.16);
  --line2: rgba(255, 255, 255, 0.08);
  --gold: #f2c14e;
  --gold2: #c9962e;
  --ink: #f3ecdb;
  --dim: #a3abc2;
  --dim2: #6f7896;
  --good: #8fd88a;
  --bad: #ff8a7a;
  --blue: #7fb8ff;
  --purple: #c49cff;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --serif: 'Noto Serif KR', 'AppleMyungjo', 'Nanum Myeongjo', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; padding: 0; }
input { font: inherit; }
[hidden] { display: none !important; }
img { -webkit-user-drag: none; }
.dim { color: var(--dim); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.gold { color: var(--gold); }
.small { font-size: 12px; }
.serif { font-family: var(--serif); }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ── 상단 ── */
#top { padding: calc(6px + var(--st)) 8px 6px; background: linear-gradient(180deg, #1a2240, #121a30); border-bottom: 1px solid var(--line); position: relative; z-index: 3; box-shadow: 0 4px 18px rgba(0,0,0,0.35); }
.tline { display: flex; align-items: center; gap: 8px; }
#crest { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; text-align: left; }
#crest > img { width: 30px; height: 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
#crest span { display: flex; flex-direction: column; min-width: 0; }
#crest b { font-family: var(--serif); font-size: 16px; font-weight: 900; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.02em; }
#crest small { font-size: 11px; color: var(--dim); }
#date { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
#date b { font-family: var(--serif); font-size: 13px; }
#date small { font-size: 11px; color: var(--dim); }
#monBtn { position: relative; width: 40px; height: 40px; border-radius: 12px; overflow: hidden; border: 1.5px solid var(--gold2); flex: none; }
#monBtn img { width: 100%; height: 100%; display: block; }
#monBtn i { position: absolute; right: 0; bottom: 0; font-style: normal; font-size: 9.5px; background: rgba(0,0,0,0.7); padding: 0 3px; border-top-left-radius: 5px; }
#resbar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px 4px; margin-top: 6px; }
.rc { display: flex; align-items: center; gap: 3px; padding: 3px 4px; border-radius: 8px; background: rgba(255,255,255,0.045); min-width: 0; position: relative; }
.rc img { width: 17px; height: 17px; flex: none; }
.rc .v { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.rc b { font-size: 12px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rc small { font-size: 9.5px; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rc small.neg { color: var(--bad); }
.rc.full b { color: #ffd27a; }
.rc .capbar { position: absolute; left: 4px; right: 4px; bottom: 1px; height: 2px; border-radius: 2px; background: rgba(255,255,255,0.06); overflow: hidden; }
.rc .capbar i { display: block; height: 100%; background: var(--gold2); }
.rc.full .capbar i { background: var(--bad); }

/* ── 본문 ── */
#view { flex: 1; position: relative; overflow: hidden; }
.tab { position: absolute; inset: 0; display: none; flex-direction: column; }
.tab.on { display: flex; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#mapHud { position: absolute; inset: 0; pointer-events: none; }
#mapHud > * { pointer-events: auto; }
.sub { display: flex; gap: 4px; padding: 8px 10px 6px; overflow-x: auto; scrollbar-width: none; flex: none; background: var(--bg2); border-bottom: 1px solid var(--line2); }
.sub::-webkit-scrollbar { display: none; }
.sub button { flex: none; padding: 7px 12px; border-radius: 10px; color: var(--dim); font-weight: 600; font-size: 13px; position: relative; background: rgba(255,255,255,0.03); }
.sub button.on { background: linear-gradient(180deg, rgba(242,193,78,0.25), rgba(242,193,78,0.12)); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(242,193,78,0.35); }
.sub button i { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; border-radius: 8px; background: #e04a3a; color: #fff; font-style: normal; font-size: 10px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 10px calc(24px); }

/* ── 하단 탭 ── */
#bottom { display: grid; grid-template-columns: repeat(5, 1fr); background: linear-gradient(180deg, #151c33, #0e1324); border-top: 1px solid var(--line); padding-bottom: var(--sb); position: relative; z-index: 3; }
#bottom button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; color: var(--dim); position: relative; font-size: 11px; font-weight: 600; }
#bottom button img { width: 25px; height: 25px; opacity: 0.6; filter: saturate(0.6); transition: transform .15s; }
#bottom button.on { color: var(--gold); }
#bottom button.on img { opacity: 1; filter: none; transform: translateY(-1px) scale(1.08); }
#bottom button.on::before { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--gold); border-radius: 2px; }
.badge { position: absolute; top: 3px; left: calc(50% + 7px); min-width: 17px; height: 17px; border-radius: 9px; background: #e04a3a; color: #fff; font-style: normal; font-size: 10.5px; font-weight: 700; display: none; align-items: center; justify-content: center; padding: 0 4px; box-shadow: 0 0 0 2px #121a30; }
.badge.show { display: flex; }
.badge.dot { min-width: 10px; height: 10px; padding: 0; }

/* ── 카드 ── */
.card { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line2); border-radius: 16px; padding: 12px; margin-bottom: 10px; position: relative; }
.card.gold { border-color: rgba(242,193,78,0.45); box-shadow: 0 0 0 1px rgba(242,193,78,0.12), 0 6px 20px rgba(0,0,0,0.25); }
.card.warn { border-color: rgba(255,120,100,0.5); background: linear-gradient(180deg, #3a2030, #24182a); }
.card h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.card h4 { margin: 10px 0 6px; font-size: 13px; color: var(--dim); font-weight: 600; }
.card p { margin: 4px 0; line-height: 1.55; font-size: 13px; color: #d9d3c4; }
.sec { margin: 16px 2px 8px; font-family: var(--serif); font-size: 14px; color: var(--gold); display: flex; align-items: center; gap: 8px; font-weight: 700; }
.sec::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 9px 13px; border-radius: 11px; background: var(--panel3); font-weight: 650; font-size: 13px; border: 1px solid rgba(255,255,255,0.06); min-height: 38px; }
.btn:active { transform: translateY(1px); filter: brightness(1.1); }
.btn.pri { background: linear-gradient(180deg, #f6cf6a, #d49a2e); color: #2a1a05; border: 0; box-shadow: 0 2px 10px rgba(242,193,78,0.25); }
.btn.red { background: linear-gradient(180deg, #d4554a, #a83a30); color: #fff; border: 0; }
.btn.blue { background: linear-gradient(180deg, #4a7fd4, #2f5fa8); color: #fff; border: 0; }
.btn.ghost { background: rgba(255,255,255,0.04); }
.btn.sm { padding: 6px 10px; min-height: 30px; font-size: 12px; border-radius: 9px; }
.btn.wide { width: 100%; }
.btn[disabled], .btn.off { opacity: 0.42; pointer-events: none; }
.btn.no { opacity: 0.55; }
.btn .cost { font-weight: 600; }

.cost { display: inline-flex; flex-wrap: wrap; gap: 3px 7px; align-items: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.cost span { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.cost img { width: 14px; height: 14px; }
.cost .miss { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 11.5px; padding: 3px 7px; border-radius: 7px; background: rgba(255,255,255,0.06); color: #d9d3c4; white-space: nowrap; }
.chip.g { background: rgba(143,216,138,0.13); color: var(--good); }
.chip.b { background: rgba(255,138,122,0.13); color: var(--bad); }
.chip.y { background: rgba(242,193,78,0.14); color: var(--gold); }
.chip.p { background: rgba(196,156,255,0.14); color: var(--purple); }
.chip.u { background: rgba(127,184,255,0.13); color: var(--blue); }
.bar { height: 7px; background: rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); border-radius: 4px; transition: width .3s; }
.bar.g i { background: linear-gradient(90deg, #4fa84a, var(--good)); }
.bar.b i { background: linear-gradient(90deg, #b8443a, var(--bad)); }
.bar.u i { background: linear-gradient(90deg, #3a6ab8, var(--blue)); }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed rgba(255,255,255,0.06); }
.kv:last-child { border: 0; }
.kv span:first-child { color: var(--dim); }

/* 초상 */
.pt { width: 56px; height: 56px; border-radius: 12px; flex: none; border: 1.5px solid rgba(242,193,78,0.35); display: block; }
.pt.lg { width: 76px; height: 76px; border-radius: 16px; border-width: 2px; }
.pt.sm { width: 40px; height: 40px; border-radius: 10px; }

/* ── 지도 HUD ── */
.hud-quest { position: absolute; top: 8px; left: 8px; right: 60px; background: rgba(15,20,36,0.86); border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); text-align: left; }
.hud-quest b { font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-quest small { font-size: 11px; color: var(--dim); }
.hud-quest.done { border-color: var(--gold); box-shadow: 0 0 14px rgba(242,193,78,0.3); }
.hud-quest .bar { margin-top: 4px; height: 4px; }
.hud-btns { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 8px; }
.hbtn { width: 44px; height: 44px; border-radius: 13px; background: rgba(15,20,36,0.86); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; position: relative; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.hbtn > img { width: 26px; height: 26px; }
.hbtn .badge { top: -4px; left: auto; right: -4px; }
.hbtn.pulse { animation: pulse 1.6s infinite; border-color: var(--gold); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,193,78,0.5); } 50% { box-shadow: 0 0 0 7px rgba(242,193,78,0); } }
.hud-raid { position: absolute; left: 8px; right: 8px; bottom: 10px; background: linear-gradient(90deg, rgba(120,30,30,0.92), rgba(70,20,30,0.92)); border: 1px solid rgba(255,120,100,0.6); border-radius: 12px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; animation: raidglow 1.4s infinite; }
@keyframes raidglow { 50% { box-shadow: 0 0 18px rgba(255,80,60,0.45); } }
.hud-raid b { font-size: 13px; }
.hud-raid small { display: block; font-size: 11.5px; color: #ffd0c8; }
.hud-zoom { position: absolute; right: 8px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.hud-zoom.up { bottom: 74px; }

/* ── 시트 ── */
#sheetWrap { position: fixed; inset: 0; z-index: 20; background: rgba(5,8,16,0.35); display: flex; align-items: flex-end; }
#sheet { width: 100%; max-height: 78%; background: linear-gradient(180deg, #1d2644, #151c33); border-top-left-radius: 22px; border-top-right-radius: 22px; border-top: 1px solid var(--line); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); display: flex; flex-direction: column; animation: sheetIn .22s cubic-bezier(.2,.9,.3,1.1); padding-bottom: var(--sb); }
@keyframes sheetIn { from { transform: translateY(40%); opacity: 0.5; } }
#sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.2); margin: 8px auto 2px; flex: none; }
#sheetBody { overflow-y: auto; padding: 6px 14px 16px; -webkit-overflow-scrolling: touch; }
.sh-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.sh-head img.big { width: 60px; height: 60px; border-radius: 14px; background: radial-gradient(circle at 50% 60%, #2c3a64, #1a2240); flex: none; }
.sh-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; }
.sh-head p { margin: 2px 0 0; font-size: 12px; color: var(--dim); }
.sh-x { margin-left: auto; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.06); font-size: 18px; flex: none; }

/* 건설 목록 */
.blist { display: grid; grid-template-columns: 1fr; gap: 7px; }
.bcard { display: grid; grid-template-columns: 54px 1fr auto; gap: 9px; align-items: center; padding: 8px; border-radius: 13px; background: rgba(255,255,255,0.04); border: 1px solid var(--line2); text-align: left; width: 100%; }
.bcard > img { width: 54px; height: 54px; border-radius: 11px; background: radial-gradient(circle at 50% 65%, #34466e, #1d2848); }
.bcard b { font-size: 14px; display: block; }
.bcard .out { font-size: 12px; color: var(--good); margin: 1px 0 3px; }
.bcard .desc { font-size: 11.5px; color: var(--dim); line-height: 1.4; }
.bcard.lock { opacity: 0.5; }
.bcard.cant .cost { opacity: 0.9; }
.bcard .go { font-size: 20px; color: var(--gold); padding: 0 4px; }

/* ── 모달 ── */
#modalWrap { position: fixed; inset: 0; z-index: 30; background: rgba(5,8,16,0.72); display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--st)) 14px calc(16px + var(--sb)); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#modal { width: min(440px, 100%); max-height: 100%; overflow-y: auto; background: linear-gradient(180deg, #222c4e, #161d36); border: 1px solid rgba(242,193,78,0.35); border-radius: 20px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); animation: popIn .25s cubic-bezier(.2,.9,.3,1.2); }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } }
#modal h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 20px; text-align: center; color: var(--gold); }
#modal .lead { text-align: center; color: #e6dfcd; line-height: 1.65; font-size: 14px; margin: 8px 0 12px; }
#modal .mbtns { display: flex; gap: 8px; margin-top: 14px; }
#modal .mbtns .btn { flex: 1; }
.ornament { text-align: center; color: var(--gold2); letter-spacing: 0.4em; font-size: 12px; margin: 4px 0; }
.banner { text-align: center; padding: 16px 8px 8px; }
.banner .pt { margin: 0 auto; display: block; }
.banner > img { width: 64px; height: 64px; filter: drop-shadow(0 4px 16px rgba(242,193,78,0.5)); }
.banner .t1 { font-family: var(--serif); font-size: 13px; color: var(--dim); letter-spacing: 0.2em; }
.banner .t2 { font-family: var(--serif); font-size: 26px; font-weight: 900; color: var(--gold); margin: 4px 0; }
.advisor { display: flex; gap: 10px; align-items: flex-start; background: rgba(0,0,0,0.2); border-radius: 14px; padding: 10px; margin: 8px 0; }
.advisor p { margin: 0; font-size: 13.5px; line-height: 1.65; color: #e6dfcd; }
.advisor b { font-size: 12px; color: var(--gold); display: block; margin-bottom: 2px; }

/* ── 청원 ── */
.pet { padding: 0; overflow: hidden; }
.pet .ph { display: flex; gap: 10px; padding: 12px 12px 6px; }
.pet .ph h3 { margin: 2px 0 2px; }
.pet .ph small { color: var(--dim); font-size: 11.5px; }
.pet .txt { padding: 0 12px 6px; font-size: 13.5px; line-height: 1.65; color: #e9e2d0; font-family: var(--serif); font-weight: 600; }
.pet .chs { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 12px; background: rgba(0,0,0,0.15); border-top: 1px solid var(--line2); }
.choice { text-align: left; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid rgba(242,193,78,0.18); }
.choice b { font-size: 13.5px; display: block; }
.choice .chips { margin-top: 4px; }
.choice.no { opacity: 0.45; }
.choice:active { background: rgba(242,193,78,0.12); }

/* 세력 */
.favs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.fav { background: rgba(255,255,255,0.04); border-radius: 11px; padding: 7px; text-align: center; }
.fav b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.fav small { font-size: 11px; color: var(--dim); }
.fav .bar { height: 4px; margin-top: 4px; }
.fav.hi b { color: var(--good); }
.fav.lo b { color: var(--bad); }

/* 왕가 */
.stat4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.stat4 div { background: rgba(0,0,0,0.2); border-radius: 8px; padding: 4px; text-align: center; }
.stat4 b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat4 small { font-size: 10.5px; color: var(--dim); }
.trait { font-size: 11.5px; padding: 3px 8px; border-radius: 7px; background: rgba(143,216,138,0.12); color: var(--good); }
.trait.bad { background: rgba(255,138,122,0.12); color: var(--bad); }
.chron { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line2); }
.chron:last-child { border: 0; }
.chron .gen { font-family: var(--serif); color: var(--gold2); font-size: 12px; width: 30px; flex: none; text-align: center; padding-top: 4px; }
.chron b { font-family: var(--serif); }
.chron em { font-style: normal; color: var(--gold); font-family: var(--serif); }

/* 연구 */
.tech { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 13px; background: rgba(255,255,255,0.035); border: 1px solid var(--line2); margin-bottom: 7px; width: 100%; text-align: left; }
.tech .tb { width: 6px; align-self: stretch; border-radius: 3px; flex: none; }
.tech b { font-size: 14px; }
.tech.done { opacity: 0.55; }
.tech.avail { border-color: rgba(242,193,78,0.4); background: rgba(242,193,78,0.06); }
.tech.lock { opacity: 0.45; }
.tier { font-family: var(--serif); font-size: 13px; color: var(--dim); margin: 14px 2px 6px; }

/* 군사 */
.unit { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; }
.unit > img { width: 52px; height: 52px; border-radius: 11px; background: radial-gradient(circle at 50% 70%, #34466e, #1d2848); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 34px; height: 32px; border-radius: 9px; background: var(--panel3); font-weight: 700; }
.stepper b { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
#world { width: 100%; display: block; border-radius: 16px; touch-action: manipulation; }
.wc { font-family: var(--serif); font-size: 26px; font-weight: 900; text-align: center; }
.foes { display: flex; flex-wrap: wrap; gap: 6px; }
.foe { display: flex; align-items: center; gap: 4px; background: rgba(255,120,100,0.08); border-radius: 9px; padding: 3px 8px 3px 3px; font-size: 12px; }
.foe > img { width: 30px; height: 30px; }
.hero { display: grid; grid-template-columns: 76px 1fr; gap: 10px; }
.uimg { width: 36px; height: 36px; }
.ic { width: 15px; height: 15px; vertical-align: -3px; }
.rar { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid currentColor; }
#battleCv { width: 100%; height: 230px; display: block; border-radius: 14px; background: #1a2238; }

/* 교역 */
.mkt { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.mkt > img { width: 26px; height: 26px; }

/* 보물·업적 */
.relics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.relic { background: rgba(255,255,255,0.04); border: 1px solid var(--line2); border-radius: 12px; padding: 8px; text-align: center; min-height: 86px; }
.relic .gem { font-size: 26px; height: 32px; }
.relic b { font-size: 11.5px; display: block; line-height: 1.3; }
.relic.no { opacity: 0.35; }
.ach { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.ach .medal { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.05); font-size: 17px; flex: none; }
.ach.on .medal { background: radial-gradient(circle, #ffe08a, #c9962e); color: #3a2405; }
.ach.off { opacity: 0.5; }

/* 기록 */
.log { font-size: 12.5px; padding: 6px 2px; border-bottom: 1px solid var(--line2); display: flex; gap: 8px; line-height: 1.5; }
.log time { color: var(--dim2); font-size: 11px; flex: none; width: 66px; padding-top: 1px; }
.log.royal { color: #e8c8ff; }
.log.war { color: #ffc0b0; }
.log.good { color: #c8f0c0; }
.log.bad { color: #ffaaa0; }

/* ── 토스트 ── */
#toasts { position: fixed; bottom: calc(150px + var(--sb)); left: 0; right: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(20,26,46,0.95); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; font-size: 13px; max-width: 88%; box-shadow: 0 6px 20px rgba(0,0,0,0.4); animation: tIn .3s ease, tOut .4s ease 2.6s forwards; text-align: center; }
.toast.good { border-color: rgba(143,216,138,0.5); }
.toast.bad { border-color: rgba(255,138,122,0.6); }
@keyframes tIn { from { transform: translateY(10px); opacity: 0; } }
@keyframes tOut { to { transform: translateY(-8px); opacity: 0; } }
.floaty { position: fixed; z-index: 35; pointer-events: none; font-weight: 800; font-size: 14px; color: var(--gold); text-shadow: 0 2px 6px #000; animation: floaty 1.2s ease-out forwards; }
@keyframes floaty { to { transform: translateY(-40px); opacity: 0; } }

/* ── 타이틀 ── */
#title { position: fixed; inset: 0; z-index: 50; background: #0b1020; display: flex; align-items: center; justify-content: center; }
#titleBg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; filter: saturate(0.9); }
#title::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, rgba(11,16,32,0.25), rgba(11,16,32,0.9) 75%); pointer-events: none; }
.tinner { position: relative; z-index: 2; width: min(360px, 92%); text-align: center; padding-bottom: var(--sb); }
.tlogo img { width: 76px; height: 76px; filter: drop-shadow(0 6px 22px rgba(242,193,78,0.55)); }
.tlogo h1 { margin: 4px 0 0; font-family: var(--serif); font-weight: 900; font-size: 52px; letter-spacing: 0.08em; margin-right: -0.08em;
  background: linear-gradient(180deg, #fff6d6, #f2c14e 50%, #b07a22); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 18px rgba(0,0,0,0.6)); }
.tlogo p { margin: 2px 0 0; letter-spacing: 0.5em; margin-right: -0.5em; font-size: 11px; color: var(--dim); }
.ttag { font-family: var(--serif); color: #e6dfcd; line-height: 1.7; margin: 18px 0 22px; text-shadow: 0 2px 10px #000; font-size: 14.5px; }
.tmenu { display: flex; flex-direction: column; gap: 10px; }
.tmenu .btn { padding: 14px; font-size: 16px; border-radius: 14px; }
.tfoot { font-size: 11.5px; color: var(--dim2); margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; text-align: left; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--dim); }
.field input { background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--ink); font-size: 15px; user-select: text; -webkit-user-select: text; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.opt { padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line2); text-align: left; font-size: 12px; }
.opt b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.opt.on { border-color: var(--gold); background: rgba(242,193,78,0.1); }
.opt.lock { opacity: 0.35; pointer-events: none; }
.toggle { width: 46px; height: 27px; border-radius: 14px; background: rgba(255,255,255,0.12); position: relative; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--gold2); }
.toggle.on::after { left: 22px; }
textarea { width: 100%; min-height: 80px; background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); padding: 8px; font-size: 11px; user-select: text; -webkit-user-select: text; }

@media (min-width: 700px) {
  #app { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line2); border-right: 1px solid var(--line2); }
  #sheet { max-width: 520px; margin: 0 auto; }
}

.out img, .chips img, .kv img { width: 14px; height: 14px; vertical-align: -2px; }
