:root {
  --ink: #eae6da;
  --ink-dim: #a9a496;
  --field: #14150f;
  --field-raised: #1d1f16;
  --line: #33362a;
  --brass: #b8924f;
  --brass-bright: #d9b06c;
  --hit: #7c9a6a;
  --miss: #a5584a;
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--field);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  line-height: 1.5;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

header.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 32px;
}

header.masthead h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

header.masthead nav a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 14px;
  margin-left: 20px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
header.masthead nav a:hover, header.masthead nav a.active { color: var(--brass-bright); }

h2.section-title {
  font-size: 15px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--brass);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin: 40px 0 18px;
  font-weight: 400;
}
h2.section-title:first-of-type { margin-top: 0; }

.card {
  background: var(--field-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

label { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }

input[type=text], input[type=number], select {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
}
input[type=text]:focus, input[type=number]:focus, select:focus {
  outline: none;
  border-color: var(--brass);
}

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }

button {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0.3px;
  background: var(--brass);
  color: #171710;
  border: none;
  padding: 11px 18px;
  border-radius: var(--radius);
  cursor: pointer;
}
button:hover { background: var(--brass-bright); }
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.secondary:hover { border-color: var(--brass); color: var(--brass-bright); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.stage {
  position: relative;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  display: none;
}
.stage.active { display: block; }
.stage img {
  width: 100%;
  display: block;
}
.stage canvas { position: absolute; top: 0; left: 0; pointer-events: none; }

.camera-button {
  display: block;
  text-align: center;
  margin-top: 20px;
  padding: 22px;
  background: var(--brass);
  color: #171710;
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.camera-button:hover { background: var(--brass-bright); }
.camera-button.busy {
  background: var(--field);
  color: var(--ink-dim);
  border: 1px solid var(--line);
  cursor: wait;
}

.result { margin-top: 10px; }

.hint {
  font-size: 13px;
  color: var(--ink-dim);
  margin-top: 10px;
  min-height: 18px;
}
.hint.active-step { color: var(--brass-bright); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-dim); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 400; font-size: 12px; }
td.num, th.num { text-align: right; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
tr:hover td { background: rgba(184, 146, 79, 0.06); }

.score-tally {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.score-chip {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  padding: 4px 9px;
  border-radius: var(--radius);
  background: var(--field);
  border: 1px solid var(--line);
}
.score-chip.zero { color: var(--miss); border-color: var(--miss); }
.score-chip.high { color: var(--hit); border-color: var(--hit); }

.total-line {
  margin-top: 16px;
  font-size: 22px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--brass-bright);
}
.total-line span { color: var(--ink-dim); font-size: 13px; margin-left: 8px; }

.empty {
  color: var(--ink-dim);
  font-size: 14px;
  padding: 20px 0;
  text-align: center;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

canvas.chart { width: 100%; height: 220px; }
