:root {
  --bg: #f6efdc; --ink: #2d2a3e; --muted: #7d7360; --card: #fffaf0; --line: #e3d6b5;
  --accent: #f2c76b; --accent-d: #9a5b12; --ok: #3ecf6b; --radius: 14px; --gutter: 10px;
}
* { 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 14px; 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; text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .4; 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 .cost { font-size: .72rem; font-weight: 700; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.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; }
.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; }

/* 게임 */
.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; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.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; }
.dice { display: inline-flex; gap: 4px; }
.die { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; background: #fff; border: 2px solid var(--ink); border-radius: 7px; font-weight: 900; font-size: .95rem; }
.scorebar { display: grid; gap: 6px; margin-bottom: 6px; grid-template-columns: repeat(2, 1fr); }
.scorebar.n3 { grid-template-columns: repeat(3, 1fr); }
.pchip { display: flex; flex-direction: column; gap: 1px; padding: 5px 8px; background: var(--card); border: 2px solid var(--line); border-radius: 12px; font-size: .8rem; font-weight: 800; min-width: 0; }
.pchip.cur { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent); }
.pchip .nm { display: flex; align-items: center; gap: 4px; font-size: .9rem; }
.pchip .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip .sc { margin-left: auto; background: var(--ink); color: #fff; border-radius: 999px; padding: 0 8px; }
.pchip .sub { color: var(--muted); font-weight: 700; display: flex; gap: 8px; flex-wrap: wrap; }
.board-wrap { background: #cfe7f6; border: 2px solid var(--ink); border-radius: 16px; overflow: hidden; }
svg.board { display: block; width: 100%; height: auto; touch-action: manipulation; }
svg.board .spot, svg.board .hex.pick { cursor: pointer; }
.logline { min-height: 20px; text-align: center; color: var(--muted); font-size: .85rem; font-weight: 700; margin: 6px 0; }
.hint { text-align: center; font-weight: 900; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px; margin-bottom: 8px; }
.hint.wait { color: var(--muted); border-color: var(--line); font-weight: 700; }
.hand { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.hcell { display: flex; flex-direction: column; align-items: center; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 4px 0 3px; font-weight: 900; }
.hcell .em { font-size: 1.3rem; line-height: 1.1; }
.hcell b { font-size: 1.15rem; line-height: 1.1; }
.hcell small { font-size: .68rem; color: var(--muted); font-weight: 700; }
.hcell.zero { opacity: .4; }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.actions .btn { flex-direction: column; gap: 0; min-height: 52px; padding: 6px 8px; }
.actions .wide { grid-column: 1 / -1; }
.actions .btn.on { background: var(--accent); }

/* 팝업 */
#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; }
.sheet .lead { text-align: center; color: var(--muted); font-weight: 700; }
.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; }
.rgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rbtn { display: flex; flex-direction: column; align-items: center; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 6px 0 4px; font-weight: 900; cursor: pointer; min-height: 62px; }
.rbtn .em { font-size: 1.3rem; line-height: 1.1; }
.rbtn small { font-size: .68rem; color: var(--muted); font-weight: 700; }
.rbtn.sel { background: var(--accent); transform: translateY(-2px); box-shadow: 0 3px 0 var(--ink); }
.rbtn:disabled { opacity: .35; cursor: default; }
.counter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.counter .c { display: flex; flex-direction: column; align-items: center; background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 4px 0; font-weight: 900; gap: 2px; }
.counter .c .em { font-size: 1.2rem; }
.counter .c .row { display: flex; align-items: center; gap: 4px; }
.counter .c button { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--ink); background: var(--accent); font-weight: 900; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.counter .c button:disabled { opacity: .3; }
.carditem { background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.carditem .tx { flex: 1; } .carditem small { color: var(--muted); font-weight: 600; display: block; }
.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; }
.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); }
.tmr { font-size: .85rem; color: var(--muted); font-weight: 800; }
.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; }
.roomitem { cursor: pointer; text-align: left; font: inherit; width: 100%; margin-top: 6px; }
.ri { display: inline-block; vertical-align: -0.15em; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 22px; }
.footer a { color: var(--muted); }
.pchip .sc { white-space: nowrap; flex: none; }
