*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue';
  margin: 2rem auto;
  padding: 0 1.5rem 8rem;
  color: #2d2d2d;
  background: #fef9f0;
}

.updated-at {
  font-size: 0.8rem;
  color: #999;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

h1 {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue';
  font-size: 2.25rem;
  margin-bottom: 1.5rem;
  color: #d4621a;
  letter-spacing: 0.01em;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.12);
  display: inline-block;
  max-width: 100%;
}

table.results-table,
table.guess-table {
  border-collapse: collapse;
  background: #fff;
  font-size: 0.92rem;
}

thead th a,
button.day-select-btn {
  color: inherit;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

thead th a:hover,
button.day-select-btn:hover {
  text-decoration: underline;
}

thead th {
  padding: 0.65rem 0.85rem;
  background: #fff3e0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #7a4a1e;
  text-align: center;
  white-space: nowrap;
}

tbody td {
  padding: 0.5rem 0.85rem;
  text-align: center;
}

/* Sticky username column */
th.col-user {
  text-align: left;
  padding: 0.5rem 1rem;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff3e0;
}

tbody th.col-user {
  background: #fff;
  font-weight: 600;
  z-index: 1;
}

/* ── Borders ────────────────────────────────── */

/* After header row */
thead { border-bottom: 2px solid #f5cfa0; }

/* After username column */
.col-user { border-right: 1px solid #f5cfa0; }

/* Before first summary column (Mean) */
.col-sep { border-left: 1px solid #f5cfa0; }

/* Before first summary row (Daily Mean) */
tr.row-sep td,
tr.row-sep th { border-top: 1px solid #f5cfa0; }

/* ── Guess Breakdown ─────────────────────── */

h2 {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue';
  font-size: 1.5rem;
  color: #d4621a;
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

#day-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

#day-nav button {
  padding: 0.3rem 0.75rem;
  border: 1px solid #f5cfa0;
  border-radius: 6px;
  background: #fff3e0;
  color: #7a4a1e;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

#day-nav button:hover:not(:disabled) { background: #f5cfa0; }
#day-nav button:disabled { opacity: 0.35; cursor: default; }

#day-label {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #d4621a;
}

#day-input {
  width: 4ch;
  border: none;
  border-bottom: 1.5px solid #d4621a;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

#day-input::-webkit-outer-spin-button,
#day-input::-webkit-inner-spin-button { -webkit-appearance: none; }

#day-link {
  padding: 0.3rem 0.75rem;
  border: 1px solid #f5cfa0;
  border-radius: 6px;
  background: #fff3e0;
  color: #7a4a1e;
  font-family: inherit;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
}

#day-link:hover { background: #f5cfa0; }

.show-answers-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid #f5cfa0;
  border-radius: 6px;
  background: #fff3e0;
  color: #7a4a1e;
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

.show-answers-label:hover { background: #f5cfa0; }

.guess-hit  { background-color: hsl(120, 60%, 75%); }
.guess-miss { background-color: hsl(0,   60%, 78%); }
.guess-half { background-color: hsl(50,  80%, 75%); }

.most-in-sync {
  margin-top: 0.75rem;
  font-size: 0.92rem;
  color: #7a4a1e;
}

.best-pull {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  color: #7a4a1e;
}

.spoiler {
  background: #2d2d2d;
  color: transparent;
  border-radius: 3px;
  user-select: none;
  cursor: pointer;
}

/* ── Mobile ──────────────────────────────────── */

@media (max-width: 600px) {
  body {
    margin: 1rem auto;
    padding: 0 1.5rem 4rem;
  }

  h1 { font-size: 1.6rem; }

  .table-wrap {
    display: block;
    width: 98vw;
    max-width: none;
    margin-left: calc(1vw - 1.5rem);
    border-radius: 4px;
  }

  #day-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

.mogging-table tbody tr:nth-child(even) { background: #fff8f0; }
.mogging-table tbody tr:nth-child(odd)  { background: #ffffff; }

.chart-wrap {
  max-width: 860px;
  margin-bottom: 2rem;
  overflow-x: auto;
}

.chart-inner {
  min-height: 400px;
  position: relative;
}

/* ── Modal ───────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #fef9f0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  padding: 1.25rem 1.5rem 1.5rem;
  max-width: 560px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 1rem;
  color: #7a4a1e;
  margin-bottom: 1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #7a4a1e;
  padding: 0 0.25rem;
}

.modal-close:hover { color: #d4621a; }

.modal-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
}

.modal-col-heading {
  font-size: 0.85rem;
  font-weight: 700;
  color: #7a4a1e;
  margin: 0 0 0.5rem;
}

.modal-article {
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.modal-article a {
  color: #2d2d2d;
  text-decoration: none;
}

.modal-article a:hover { text-decoration: underline; }

.modal-partial {
  font-size: 0.78rem;
  color: #999;
}

.modal-empty {
  font-size: 0.88rem;
  color: #bbb;
  font-style: italic;
}

/* ── Category charts ─────────────────────────── */

.cat-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem 2rem;
  margin-bottom: 2rem;
}

.cat-chart-wrap {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  padding: 0.75rem 1rem 0.5rem;
}

.cat-chart-title {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue';
  font-size: 0.95rem;
  font-weight: 700;
  color: #7a4a1e;
  margin: 0 0 0.5rem;
}

/* Rotated article-name headers in the guess breakdown table */
table.guess-table thead th.col-answer {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  white-space: nowrap;
  height: 8rem;
  padding: 0.5rem 0.4rem;
  vertical-align: bottom;
  font-size: 0.8rem;
}

.small-text {
  font-size: 0.85rem;
  color: #7a4a1e;
}