:root {
  --bg: #f3effb;
  --ink: #2d2a3e;
  --muted: #7a7590;
  --card: #fdfcff;
  --line: #ddd5ef;
  --accent: #c9b3f5;
  --accent-d: #6a46a8;
  --ok: #4cb866;
  --warn: #f7c948;
  --radius: 14px;
  --gutter: 10px;
  --sun: #f58a3c; --sea: #3d8fe0; --leaf: #4cb866; --moon: #f1eefb; --night: #6a46a8; --star: #f7c948;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 16px; line-height: 1.4; word-break: keep-all; min-height: 100dvh;
}
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
#app { max-width: 560px; margin: 0 auto; padding: 0 var(--gutter) calc(24px + env(safe-area-inset-bottom)); min-height: 100dvh; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink);
  font-weight: 800; cursor: pointer; transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); }
.btn.big { min-height: 56px; font-size: 1.1rem; width: 100%; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .92rem; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; text-decoration: underline; width: 100%; color: var(--muted); }
a.btn { text-decoration: none; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.sub { text-align: center; color: var(--muted); font-weight: 700; font-size: .92rem; }
.note { padding: 10px 12px; background: #fff; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: .9rem; }

.sitebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 10px; }
.sitelink { font: inherit; font-size: .85rem; font-weight: 800; color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 5px 12px; min-height: 36px; text-decoration: none; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; }

/* 홈 */
.logo { text-align: center; padding: 28px 0 20px; }
.logo .mark { font-size: 72px; line-height: 1; }
.logo h1 { font-size: 2.1rem; letter-spacing: -1px; margin-top: 8px; }
.logo p { color: var(--muted); margin-top: 4px; font-weight: 600; }
.soon-tag { font-size: .78rem; background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 8px; }
.menu .btn { justify-content: space-between; }
.menu .btn small { font-weight: 700; color: var(--muted); }
.opts { display: flex; gap: 8px; }
.opts .btn { flex: 1; padding: 8px; }
.opts .btn.on { background: var(--accent); }
.field-label { font-weight: 800; margin: 4px 0 6px; }
.input { flex: 1; min-width: 0; width: 100%; min-height: 48px; padding: 8px 12px; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; font: inherit; font-weight: 700; }

/* 게임 상단 */
.top { display: flex; align-items: center; gap: 8px; padding: 8px 0 6px; }
.top .turn { flex: 1; text-align: center; font-weight: 900; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 12px; background: var(--card); font-size: .98rem; }
.top .turn.mine { background: var(--accent); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--ink); background: var(--card); font-weight: 900; cursor: pointer; font-size: 1.05rem; flex: none; }
.logline { min-height: 20px; text-align: center; color: var(--muted); font-size: .85rem; font-weight: 700; margin-bottom: 6px; }

/* 단골손님 */
.patrons { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.patron { flex: 1; max-width: 86px; background: var(--card); border: 2px solid var(--ink); border-radius: 10px; padding: 3px 2px; text-align: center; font-size: .75rem; font-weight: 900; }
.patron .need { display: flex; flex-wrap: wrap; gap: 1px 3px; justify-content: center; margin-top: 1px; }
.patron .need span { display: inline-flex; align-items: center; font-size: .72rem; }
.patron .need svg { width: 13px; height: 13px; }
.patron.pick { cursor: pointer; outline: 3px solid var(--ok); }

/* 세공품 판 */
.market { display: flex; flex-direction: column; gap: 6px; }
.mrow { display: grid; grid-template-columns: 38px repeat(4, 1fr); gap: 5px; align-items: stretch; }
.deck { border: 2px dashed var(--ink); border-radius: 10px; background: #e7dff7; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: .72rem; padding: 2px; }
.deck b { font-size: 1rem; }
.deck span { font-size: .62rem; text-align: center; line-height: 1.1; }
.deck.t2 { background: #dcd0f3; }
.deck.t3 { background: #cdbcec; }
.deck.resv { cursor: pointer; }
.card {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  aspect-ratio: 3 / 4; min-width: 0; padding: 3px 3px 3px; text-align: left;
  background: var(--card); border: 2px solid var(--ink); border-radius: 10px;
  cursor: pointer; overflow: hidden;
}
.card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 26%; background: var(--cg); opacity: .55; }
.card > * { position: relative; }
.card .ch { display: flex; justify-content: space-between; align-items: center; min-height: 20px; }
.card .pts { font-size: 1.15rem; font-weight: 900; line-height: 1; text-shadow: 0 1px 0 #fff; }
.card .art { display: flex; justify-content: center; }
.card .art svg.item { width: 100%; max-width: 34px; height: auto; }
.card .cost { display: flex; flex-wrap: wrap; gap: 2px; }
.chip { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--ink); font-size: .68rem; font-weight: 900; font-style: normal; background: var(--cg); color: var(--ink); }
.chip.dark { color: #fff; }
.card.afford { box-shadow: 0 0 0 3px var(--ok); }
.card.empty { border-style: dashed; background: transparent; cursor: default; }
.card.back { background: repeating-linear-gradient(45deg, #cdbcec, #cdbcec 6px, #dcd0f3 6px, #dcd0f3 12px); cursor: default; }
.card.back::before { display: none; }
.card.sel { outline: 3px solid var(--accent-d); }

/* 보석 은행 */
.bank { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0 6px; }
.gembtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0 4px; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; cursor: pointer; min-height: 60px; font-weight: 900; }
.gembtn svg.gem { width: 28px; height: 28px; }
.gembtn small { font-size: .7rem; color: var(--muted); font-weight: 700; }
.gembtn.sel { background: var(--accent); transform: translateY(-3px); box-shadow: 0 3px 0 var(--ink); }
.gembtn .picked { position: absolute; top: -8px; right: -4px; background: var(--ink); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; font-size: .75rem; display: flex; align-items: center; justify-content: center; }
.gembtn:disabled { opacity: .35; cursor: default; }
.takebar { display: flex; gap: 8px; align-items: center; min-height: 48px; margin-bottom: 6px; }
.takebar .msg { flex: 1; font-size: .85rem; color: var(--muted); font-weight: 700; }

/* 내 보드 / 상대 */
.panel { background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); padding: 8px; margin-top: 8px; }
.panel.active { box-shadow: 0 0 0 3px var(--accent-d); }
.panel h3 { font-size: .95rem; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.panel h3 .score { background: var(--ink); color: #fff; border-radius: 999px; padding: 0 10px; font-size: .9rem; }
.wallet { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 6px; }
.wcell { display: flex; flex-direction: column; align-items: center; font-weight: 900; font-size: .9rem; border: 2px solid var(--line); border-radius: 10px; padding: 3px 0; }
.wcell svg.gem { width: 22px; height: 22px; }
.wcell small { font-size: .68rem; color: var(--muted); font-weight: 700; }
.wcell.zero { opacity: .35; }
.wcell.ret { cursor: pointer; border-color: var(--ink); background: #ffe8e0; }
.resrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.resrow .card { aspect-ratio: 3 / 3.6; }
.oppgrid { display: grid; gap: 6px; }
.opp { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; align-items: center; }
.opp .nm { font-weight: 900; font-size: .9rem; }
.opp .mini { display: flex; gap: 6px; flex-wrap: wrap; font-size: .78rem; font-weight: 800; align-items: center; grid-column: 1 / -1; }
.opp .mini span { display: inline-flex; align-items: center; gap: 1px; }
.opp .mini svg { width: 15px; height: 15px; }
.opp .mini .sep { color: var(--muted); }

/* 팝업 */
#modal .modal { position: fixed; inset: 0; background: rgba(45, 42, 62, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); border: 2px solid var(--ink); border-bottom: 0; display: flex; flex-direction: column; gap: 10px; }
.sheet h2 { font-size: 1.25rem; text-align: center; }
.sheet ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.roomitem { display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; text-decoration: none; color: var(--ink); }
.roomitem small { color: var(--muted); font-weight: 600; }
.roomitem.here { opacity: .6; }
.detail { display: flex; gap: 12px; align-items: center; justify-content: center; }
.detail .card { width: 96px; flex: none; cursor: default; }
.detail .need { display: flex; flex-direction: column; gap: 4px; font-weight: 800; }
.detail .need div { display: flex; align-items: center; gap: 6px; }
.detail .need svg { width: 22px; height: 22px; }
.score-row { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; font-weight: 800; }
.score-row.win { background: var(--accent); }
.result { text-align: center; }
.result h2 { font-size: 1.6rem; }
.pick-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: 90vw; text-align: center; font-size: .92rem; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 22px; line-height: 1.6; }
