:root {
  --bg: #eff2f6;
  --surface: #ffffff;
  --fg: #141a24;
  --muted: #4a5564;
  --line: #d9dfe8;
  --accent: #6699FF;
  --accent-fg: #0b1a33;
  --accent-soft: #e1ebff;
  --ok: #17803d;
  --ok-soft: #dff3e5;
  --warn: #a05a00;
  --warn-soft: #fdf0d9;
  --font-display: "Do Hyeon", "Noto Sans KR", system-ui, sans-serif;
  --font-body: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c;
    --surface: #1a2029;
    --fg: #e9edf3;
    --muted: #a8b3c2;
    --line: #2b3441;
    --accent: #6699FF;
    --accent-fg: #0b1a33;
    --accent-soft: #1b2a47;
    --ok: #5fd08a;
    --ok-soft: #173424;
    --warn: #f0b861;
    --warn-soft: #3a2d14;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c;
  --surface: #1a2029;
  --fg: #e9edf3;
  --muted: #a8b3c2;
  --line: #2b3441;
  --accent: #6699FF;
  --accent-fg: #0b1a33;
  --accent-soft: #1b2a47;
  --ok: #5fd08a;
  --ok-soft: #173424;
  --warn: #f0b861;
  --warn-soft: #3a2d14;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: break-word;
  padding-block: 28px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.3; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 사이트 머리글 */
.site-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.logo { font-family: var(--font-display); font-size: clamp(1.7rem, 6vw, 2.2rem); text-decoration: none; line-height: 1.2; }
.logo:hover { color: var(--accent); }
.nav { display: flex; gap: 6px; }
.nav a { text-decoration: none; padding: 6px 14px; border-radius: 999px; font-size: 0.95rem; color: var(--muted); }
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { background: var(--fg); color: var(--bg); }
.lead { color: var(--muted); max-width: 52ch; }
.sec { display: flex; flex-direction: column; gap: 14px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-head h2, .cat-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; }
.sec-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; min-width: 0; }
.desc { color: var(--muted); font-size: 0.9rem; }

/* 카테고리 기호: 도형 하나가 카테고리를 뜻한다 */
.glyph { display: inline-block; width: 12px; height: 12px; background: var(--accent); flex: none; }
.glyph.tool { border-radius: 2px; }
.glyph.pick { border-radius: 50%; }
.glyph.game { width: 0; height: 0; background: none; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 12px solid var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px; text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .cat { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--muted); }
.card h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; }
.card p { color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.empty { color: var(--muted); padding: 24px 0; }

/* 항목 화면 공통 */
.item-head { display: flex; flex-direction: column; gap: 6px; }
.item-head h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.7rem, 6vw, 2.2rem); }
.item-head p { color: var(--muted); max-width: 60ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
label { font-weight: 500; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
textarea, input[type="number"] {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 180px; line-height: 1.6; }
input[type="number"] { font-family: var(--font-mono); max-width: 140px; }
.btn {
  background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 8px;
  padding: 10px 20px; font-weight: 700; cursor: pointer; width: fit-content;
}
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); font-weight: 500; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--bg); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 0.8rem; color: var(--muted); }
.stat .v { font-family: var(--font-mono); font-size: 1.5rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); }
.bar.over > i { background: var(--warn); }
.limit-msg { font-size: 0.9rem; }
.limit-msg.over { color: var(--warn); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; width: fit-content; max-width: 100%; flex-wrap: wrap; }
.seg button { background: var(--bg); color: var(--fg); border: 0; padding: 8px 16px; cursor: pointer; font-size: 0.9rem; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

.stage {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 140px; border-radius: 10px; background: var(--bg);
  font-family: var(--font-display); font-size: clamp(1.8rem, 8vw, 2.8rem); padding: 16px; overflow-wrap: anywhere;
}
.stage.done { background: var(--accent-soft); color: var(--accent); }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.team { background: var(--bg); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.team h3 { font-size: 0.85rem; color: var(--accent); font-family: var(--font-mono); margin-bottom: 4px; }
.team ul { margin: 0; padding-left: 1.1em; }
.order { margin: 0; padding-left: 1.6em; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 20px; }

.react {
  width: 100%; min-height: 220px; border: 0; border-radius: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg); color: var(--fg); padding: 16px; text-align: center;
}
.react .big { font-family: var(--font-display); font-size: clamp(1.8rem, 8vw, 2.6rem); }
.react .sub { color: var(--muted); font-size: 0.9rem; }
.react.wait { background: var(--accent); color: var(--accent-fg); }
.react.wait .sub { color: var(--accent-fg); opacity: 0.85; }
.react.go { background: var(--ok); color: #fff; }
.react.go .sub { color: #fff; opacity: 0.9; }
.react.early { background: var(--warn-soft); color: var(--warn); }
.dots { display: flex; gap: 8px; flex-wrap: wrap; }
.dots span { font-family: var(--font-mono); font-size: 0.85rem; background: var(--bg); border-radius: 6px; padding: 4px 10px; font-variant-numeric: tabular-nums; }

.preview { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-height: 64px; line-height: 1.8; }
.hrow { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: center; }
.hrow .hl { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); }
.hrow input[type="text"] { font-family: var(--font-mono); font-size: 0.8rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; min-width: 0; }
.hrow .btn { padding: 8px 14px; font-size: 0.85rem; }
.cmp-input { font-family: var(--font-mono); font-size: 0.85rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; min-width: 0; }
.ok-msg { color: var(--ok); font-weight: 500; }
select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; max-width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.df-add { background: var(--ok-soft); color: var(--ok); border-radius: 3px; text-decoration: underline; }
.df-del { background: var(--warn-soft); color: var(--warn); border-radius: 3px; text-decoration: line-through; }
.symgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.symbtn { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; font-family: var(--font-body); font-size: 1.2rem; line-height: 1.4; padding: 6px 0; cursor: pointer; }
.symbtn:hover { border-color: var(--accent); color: var(--accent); }
.qr-img { display: block; width: 260px; max-width: 100%; height: auto; background: #fff; padding: 12px; border-radius: 8px; border: 1px solid var(--line); image-rendering: pixelated; }
.qr-box { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.qr-side { display: flex; flex-direction: column; gap: 10px; flex: 1 1 220px; min-width: 0; }
.pw-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.die { width: 76px; height: 76px; border-radius: 14px; background: var(--surface); border: 2px solid var(--fg); display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); place-items: center; padding: 10px; flex: none; }
.die.num { display: flex; align-items: center; justify-content: center; padding: 0; font-family: var(--font-display); font-size: 1.7rem; }
.pip { width: 13px; height: 13px; border-radius: 50%; background: var(--fg); }
.dice-row { display: flex; flex-wrap: wrap; gap: 12px; min-height: 76px; }
.sum { font-family: var(--font-mono); font-size: 1.3rem; margin: 0; }
.ball { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 500; font-size: 1.05rem; flex: none; }
.lotto-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lotto-row .lab { font-family: var(--font-mono); width: 1.6em; color: var(--muted); }
.wheel { display: block; width: min(100%, 360px); height: auto; margin: 0 auto; }
.lad { display: grid; }
.lad-cell { min-width: 0; padding: 0 2px; text-align: center; }
.lad-btn { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 2px; font-size: 0.82rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lad-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.lad-res { font-size: 0.82rem; min-height: 2.4em; overflow-wrap: anywhere; line-height: 1.3; padding-top: 6px; }
.lad-canvas { display: block; width: 100%; height: auto; }
.plain { margin: 0; padding-left: 1.2em; }
.li-wrap { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; width: 100%; }
.li-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.li-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.li-input { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; min-width: 0; }
.li-del { background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; width: 40px; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.li-del:hover { color: var(--accent); border-color: var(--accent); }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip small { opacity: 0.7; margin-left: 4px; font-family: var(--font-mono); font-size: 0.72rem; }
.symgrid { max-height: 420px; overflow-y: auto; }
@media (max-width: 620px) { .two { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .hrow { grid-template-columns: 1fr auto; } .hrow .hl { grid-column: 1 / -1; } }
.lead, .card p, .item-head p, .hint, .desc, .limit-msg, footer { font-weight: 500; }
footer { color: var(--muted); font-size: 0.86rem; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 18px; }

@media (max-width: 520px) { .panel { padding: 16px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } .card:hover { transform: none; } }

/* 설명 글 (검색에 잡히고, 사용법을 알려주는 부분) */
.article { display: flex; flex-direction: column; gap: 22px; border-top: 1px solid var(--line); padding-top: 26px; }
.article h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; margin-bottom: 8px; }
.article p, .article li, .doc p, .doc li { font-weight: 500; line-height: 1.8; }
.article ol, .article ul, .doc ul { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.article details { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 12px 16px; }
.article details + details { margin-top: 8px; }
.article summary { cursor: pointer; font-weight: 700; }
.article details p { margin-top: 8px; color: var(--muted); }
.doc { display: flex; flex-direction: column; gap: 16px; }
.doc h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.7rem, 6vw, 2.2rem); }
.doc h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; margin-top: 10px; }
.doc a, .foot-links a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.foot-links { display: flex; gap: 8px; flex-wrap: wrap; }
.intro h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.9rem, 7vw, 2.6rem); }
.js-warn { color: var(--muted); }
[hidden] { display: none !important; }