:root {
  --bg: #f1f8ec;
  --ink: #2d2a3e;
  --muted: #6b6682;
  --card: #fcfffa;
  --line: #d6e5cb;
  --accent: #9be26b;
  --accent-d: #5fae35;
  --g: #2f9e3b;
  --y: #e0a500;
  --r: #dc4b44;
  --off: #b3b0bf;
  --gutter: 12px;
}

* { 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.45;
  word-break: keep-all;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
#app { max-width: 480px; margin: 0 auto; padding: 0 var(--gutter); }

/* 버튼 */
.btn {
  display: 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; text-align: center; text-decoration: none;
  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: default; }
.btn.primary { background: var(--accent); }
.btn.red { background: var(--r); color: #fff; }
.btn.daily { background: #ffe08a; }
.nextday { font-size: .9rem; margin-top: 2px; }
.help-daily { margin-top: 10px; font-size: .93rem; }
.sharetext { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-weight: 700; user-select: all; overflow-wrap: anywhere; }
.k:disabled { opacity: .45; }
.field { display: block; font-weight: 800; margin-top: 4px; }
.field input { display: block; width: 100%; height: 50px; margin-top: 5px; padding: 0 14px; font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 14px; }
.divider { border-top: 2px dashed var(--line); margin-top: 16px; }
.dailyyest { margin-top: 10px; }
.dailyyest:empty { display: none; }
.btn.small { display: inline-flex; min-height: 38px; padding: 4px 14px; font-size: .88rem; }

/* 오늘의 순위표: 어제 · 오늘 두 칸 (낱말사냥과 같은 모양) */
.dailyleader { text-align: center; font-size: .82rem; font-weight: 600; margin-top: 10px; }
.boardsplit { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
.boardhalf { min-width: 0; }
.boardtitle { margin: 2px 0; font-weight: 800; font-size: .9rem; }
.boardlist { list-style: none; margin: 0; padding: 0; text-align: left; }
.boardlist.open { max-height: 14rem; overflow-y: auto; }
.boardlist li { padding: 2px 3px; overflow-wrap: anywhere; }
.boardlist li.me { background: #fff3c4; border-radius: 6px; }
.boardnone { margin: 2px 0; opacity: .75; }
.boardmore { margin-top: 6px; }
.done .dailyleader { margin-top: 16px; }
.btn.big { min-height: 54px; font-size: 1.08rem; width: 100%; margin-top: 14px; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; text-decoration: underline; width: 100%; color: var(--muted); margin-top: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 홈 */
.home { padding-bottom: 28px; }
.sitebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 10px; }
.sitelink { 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; gap: 4px; }
.logo { text-align: center; padding: 34px 0 14px; }
.logo h1 { font-size: 2.3rem; letter-spacing: -1px; }
.logo p { color: var(--muted); font-weight: 700; font-size: .95rem; margin-top: 2px; }
.lights { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }
.lights i { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); }
.lights .r { background: var(--r); } .lights .y { background: var(--y); } .lights .g { background: var(--g); }
.solonote { text-align: center; color: var(--muted); font-size: .9rem; font-weight: 600; margin-top: 10px; }

/* 게임: 위(제목) · 가운데(낸 수식, 넘치면 여기만 넘겨 봄) · 아래(숫자판) */
.game { display: flex; flex-direction: column; height: 100dvh; }
.top { display: flex; align-items: center; gap: 8px; padding: 10px 0 8px; }
.top .mid { flex: 1; font-weight: 800; line-height: 1.2; }
.top .mid small { display: block; color: var(--muted); font-size: .8rem; }
.icon-btn { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; border: 2px solid var(--ink); background: var(--card); font-weight: 900; font-size: 1.1rem; cursor: pointer; }
.quit { min-height: 44px; border: 2px solid var(--ink); border-radius: 12px; background: #ffe3e1; font-weight: 800; font-size: .85rem; padding: 0 10px; cursor: pointer; }
.history { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 0 8px; }
.history { scrollbar-width: none; } /* 막대가 9번째 칸을 가리지 않게 */
.history::-webkit-scrollbar { display: none; }
.history > * { flex: 0 0 auto; }
.empty { text-align: center; color: var(--muted); font-weight: 600; font-size: .92rem; padding: 14px 0 8px; }

.cells { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.cell { height: 44px; padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1.3rem; }
button.cell { cursor: pointer; }
.cell.in { border-color: var(--ink); }
.cell.cur { border: 3px solid var(--accent-d); background: #e6f8da; }
.cell.g { background: var(--g); border-color: var(--g); color: #fff; }
.cell.y { background: var(--y); border-color: var(--y); color: #fff; }
.cell.r { background: var(--r); border-color: var(--r); color: #fff; }

.pad { display: flex; flex-direction: column; gap: 7px; padding: 6px 0 calc(10px + env(safe-area-inset-bottom)); }
.keys { display: grid; gap: 6px; }
.keys.five { grid-template-columns: repeat(5, 1fr); }
.keys.six { grid-template-columns: repeat(6, 1fr); }
.keys.actions { grid-template-columns: 1fr 2fr; }
.k { height: 48px; padding: 0; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font-size: 1.45rem; font-weight: 900; cursor: pointer; user-select: none; }
.k:active { transform: translateY(2px); }
.k.g { background: var(--g); color: #fff; }
.k.y { background: var(--y); color: #fff; }
.k.r { background: var(--off); color: #fff; border-color: #8d899c; }
.k.wide { font-size: 1.05rem; }
.k.send { background: var(--accent); }

/* 키가 작은 화면 */
@media (max-height: 640px) {
  .k { height: 40px; font-size: 1.25rem; }
  .cell { height: 36px; font-size: 1.15rem; }
  .pad { gap: 5px; }
}

/* 결과 */
.done { padding-bottom: 24px; }
.done h3 { font-size: .95rem; margin: 18px 0 6px; }
.done .list { display: flex; flex-direction: column; gap: 6px; }
.result { text-align: center; padding-top: 22px; }
.result h2 { font-size: 1.9rem; }
.result p { color: var(--muted); font-weight: 700; }
.after { margin-top: 10px; }

/* 같이 하기 */
.row2.gap { margin-top: 14px; }
.sec { display: flex; align-items: center; justify-content: space-between; font-weight: 800; margin: 18px 0 8px; }
.rooms { display: flex; flex-direction: column; border: 2px solid var(--line); border-radius: 14px; background: var(--card); max-height: 15rem; overflow-y: auto; text-align: center; }
.rooms > p { padding: 12px; font-size: .9rem; font-weight: 600; }
.roomrow { display: flex; flex: 0 0 auto; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px; padding: 8px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--line); font-weight: 700; font-size: .92rem; text-align: left; cursor: pointer; }
.roomrow:last-child { border-bottom: 0; }
.roomrow b { white-space: nowrap; border: 2px solid var(--ink); border-radius: 10px; padding: 1px 10px; background: var(--accent); font-size: .85rem; }
.roomrow:disabled { cursor: default; color: var(--muted); }
.roomrow:disabled b { background: transparent; border-color: var(--line); }
.top .mid.center { text-align: center; }
.seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn.on { background: var(--ink); color: #fff; }
.seg .btn.on:disabled { opacity: 1; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-block; padding: 5px 14px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; font-weight: 800; }
.pill.me { background: var(--accent); }
.pill.off { opacity: .5; }
.solonote.strong { font-size: 1rem; color: var(--ink); margin-top: 18px; }
.rules { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: .86rem; font-weight: 600; }
.timer { font-size: 1.35rem; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 3.4em; text-align: center; }
.ok { text-align: center; font-weight: 800; color: #217a2c; padding: 4px 0; }
.ok.bad { color: #b3261e; }
.ok.wait { color: var(--muted); }
.notice { background: #fff3c4; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 12px; font-weight: 700; font-size: .9rem; text-align: center; }
.drawline { font-size: .85rem; margin-top: 2px; }
.opp { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 6px 10px 8px; margin-bottom: 6px; }
.opp > p { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; margin-bottom: 4px; }
.opp > p span { color: var(--muted); font-weight: 700; white-space: nowrap; }
.mini { display: flex; flex-direction: column; gap: 3px; max-height: 39px; overflow-y: auto; scrollbar-width: none; }
.mini div { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; padding: 0 48px; flex: 0 0 11px; }
.mini i { border-radius: 3px; }
.mini i.g { background: var(--g); } .mini i.y { background: var(--y); } .mini i.r { background: var(--r); }
.mini p { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; }
.mine { text-align: center; font-size: .86rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.mine b { color: var(--ink); letter-spacing: 1px; }
.mine small { display: block; font-size: .75rem; }
.banner { position: fixed; top: 0; left: 0; right: 0; background: var(--ink); color: #fff; text-align: center; padding: 6px; font-size: .9rem; z-index: 100; }

.home footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 16px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.home footer .footlink { color: var(--muted); font-size: .8rem; }
.devmark { display: inline-block; padding: 0 7px; border-radius: 999px; background: #1f2a44; color: #fff; font-size: .72rem; font-weight: 800; vertical-align: middle; white-space: nowrap; }

/* 팝업 */
.modal { position: fixed; inset: 0; background: rgba(45, 42, 62, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--card); width: 100%; max-width: 480px; max-height: 88dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px var(--gutter) calc(20px + env(safe-area-inset-bottom)); border: 2px solid var(--ink); border-bottom: 0; }
.modal h2 { margin-bottom: 10px; font-size: 1.3rem; }
.modal ol { padding-left: 22px; margin: 0 0 10px; }
.modal li { margin-bottom: 7px; }
.modal .tip { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: .93rem; }
.modal .tip ul { padding-left: 18px; margin: 6px 0 0; }
.legend { list-style: none; padding: 0; margin: 0 0 12px; }
.legend li { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .93rem; }
.swatch { flex: 0 0 46px; text-align: center; color: #fff; border-radius: 8px; padding: 3px 0; font-size: .85rem; }
.swatch.g { background: var(--g); } .swatch.y { background: var(--y); } .swatch.r { background: var(--r); }
.confirm-body { color: var(--muted); font-weight: 600; }
.roomlist { display: flex; flex-direction: column; gap: 8px; }
.roomitem { display: block; border: 2px solid var(--ink); border-radius: 14px; background: #fff; padding: 9px 12px; text-decoration: none; color: inherit; }
.roomitem small { display: block; color: var(--muted); font-weight: 600; }
.roomitem.here { opacity: .55; }

.toast { position: fixed; left: 50%; top: 66px; transform: translateX(-50%) translateY(-10px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 120; max-width: 90vw; text-align: center; font-weight: 700; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
