:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1b;
  --muted: #787c7e;
  --border: #d3d6da;
  --green: #6aaa64;
  --amber: #c9a227;
  --red: #e03b3b;
  --cell: 54px;
  --gap: 8px;
  --radius: 8px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121213;
    --surface: #1e1e20;
    --text: #f5f5f5;
    --muted: #9a9c9e;
    --border: #3a3a3c;
  }
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
}

.app {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header { text-align: center; }
.logo {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 6px;
}
.tagline {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  max-width: 340px;
  margin: 6px auto 18px;
}
.tagline em { font-style: italic; color: var(--text); }

.meta {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.meta .date { font-variant-numeric: tabular-nums; }
.stat b { color: var(--text); font-variant-numeric: tabular-nums; }

.status {
  height: 26px;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}
.status.won { color: var(--green); }

.board {
  display: grid;
  grid-template-columns: repeat(6, var(--cell));
  grid-template-rows: repeat(6, var(--cell));
  gap: var(--gap);
  margin-bottom: 20px;
}

.cell {
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
}
.cell:hover { border-color: var(--muted); }
.cell:active { transform: scale(0.9); }
.cell .sign {
  font-size: 0.66em;
  font-weight: 800;
  margin-right: 1px;
  color: var(--green);
}
.cell.minus {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.cell.minus .sign { color: #fff; }

.target {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  font-variant-numeric: tabular-nums;
}
.target.met {
  background: var(--green);
  color: #fff;
  border-style: solid;
  border-color: var(--green);
}
.target.over {
  background: transparent;
  color: var(--amber);
  border-style: solid;
  border-color: var(--amber);
}
.target.under {
  background: var(--red);
  color: #fff;
  border-style: solid;
  border-color: var(--red);
}
.corner { background: transparent; border: none; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 22px;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.05); }

.how {
  width: 100%;
  max-width: 360px;
  font-size: 14px;
  color: var(--muted);
}
.how summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  padding: 6px 0;
}
.how ul { line-height: 1.6; padding-left: 18px; }
.how b { color: var(--text); }
.chip {
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}
.chip.green { background: var(--green); }
.chip.amber { background: var(--amber); }
.chip.red { background: var(--red); }
.chip.grey { background: var(--muted); }
.logo .pm { color: var(--red); }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: pre-line;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
