:root {
  --bg: #f5f7f4;
  --card: #ffffff;
  --ink: #26302a;
  --muted: #79857e;
  --accent: #2f9e63;
  --accent-soft: #e3f3ea;
  --gold: #f0a90a;
  --gold-soft: #fdf4dd;
  --line: #e2e8e3;
  --danger: #d24d43;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  word-break: keep-all;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 56px; }

header h1 { font-size: 22px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.empty {
  margin-top: 40px; text-align: center; color: var(--muted);
  background: var(--card); border: 1px dashed var(--line);
  border-radius: 12px; padding: 32px 20px;
}

section { margin-top: 20px; }
h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }

/* 순위판 */
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board li {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.board li.top {
  border-color: var(--gold); background: var(--gold-soft);
}
.board .rank {
  flex: 0 0 34px; text-align: center; font-weight: 700; font-size: 18px;
}
.board .name { flex: 1; font-weight: 600; font-size: 17px; }
.board .total { font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.board .total small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 2px; }

/* 판별 기록 */
table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 14px; }
th, td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; }
thead th { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
td.best { color: var(--accent); font-weight: 700; }
td.round-no, th.round-no { color: var(--muted); font-size: 12px; }

/* 입력 화면 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px;
}
.row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.row label { flex: 1; font-weight: 600; }
input[type="text"], input[type="number"] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; width: 100%; background: #fff; color: var(--ink);
}
.row input[type="number"] { flex: 0 0 110px; text-align: right; }
input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

button {
  font: inherit; border: none; border-radius: 10px; cursor: pointer;
  padding: 10px 14px; font-weight: 600;
}
button.primary { background: var(--accent); color: #fff; width: 100%; padding: 14px; font-size: 16px; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.danger-ghost { background: transparent; color: var(--danger); border: 1px solid var(--line); }
button.small { padding: 6px 10px; font-size: 13px; }

.round-item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px;
}
.round-item .tag { font-weight: 700; color: var(--accent); flex: 0 0 auto; }
.round-item .body { flex: 1 1 200px; }
.round-item .actions { display: flex; gap: 6px; }

.share {
  margin-top: 16px; font-size: 13px; color: var(--muted);
  background: var(--accent-soft); border-radius: 10px; padding: 10px 12px;
}
.share code { user-select: all; color: var(--ink); }

.footer-actions { margin-top: 28px; display: flex; justify-content: flex-end; }
#msg { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* 세션 관리 */
.badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px;
  vertical-align: 1px;
}
details { margin-top: 12px; }
details summary {
  cursor: pointer; font-weight: 600; color: var(--accent);
  padding: 8px 0; list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details .card { margin-top: 8px; }

/* OCR 미리보기 */
#ocr-preview { margin-top: 12px; }
#ocr-preview h2 { margin-top: 0; }
.ocr-row .ocr-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ocr-row input.ocr-score { flex: 0 0 90px; text-align: right; }
.ocr-row input.warn { border-color: var(--gold); background: var(--gold-soft); }
.ocr-row select {
  flex: 0 0 110px; font: inherit; padding: 9px 6px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
