@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #1c2130;
  --ink-soft: #3a4152;
  --muted: #6b7280;
  --gold: #a8863d;
  --gold-soft: rgba(168, 134, 61, 0.14);
  --good: #3f9a68;
  --bad: #c05621;
  --page: #f6f4ef;
  --card-bg: #ffffff;
  --hairline: rgba(28, 33, 48, 0.09);
  --grid-line: rgba(28, 33, 48, 0.18);
  --shadow: 0 1px 2px rgba(28, 33, 48, 0.04), 0 12px 32px rgba(28, 33, 48, 0.07);
  --radius: 16px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15.5px;
  color: var(--ink);
  background: linear-gradient(180deg, #f8f6f2 0%, var(--page) 40%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold-soft); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 32px;
  background: rgba(248, 246, 242, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}
.logo span { color: var(--gold); font-style: italic; }
.nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.nav > a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
}
.nav > a:hover { color: var(--ink); }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.88rem;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px 14px 4px 5px;
}
.user-chip img { width: 26px; height: 26px; border-radius: 50%; }

/* Site-wide player picker + pending-rewards badge */
.player-picker { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.player-picker label {
  font-size: 0.72rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.player-picker select {
  font-family: var(--font-body); font-size: 0.88rem; color: var(--ink);
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.player-picker select:hover { border-color: var(--gold); }
.pending-dot {
  display: inline-block; background: var(--gold); color: #fff;
  font-size: 0.7rem; font-weight: 700; border-radius: 999px;
  padding: 1px 7px; vertical-align: middle;
}

/* ---------- Layout ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px 72px; }
.card {
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
h2 { margin: 0 0 14px; }
.muted { color: var(--muted); }
.note p { margin: 0; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: #2a3145; transform: translateY(-1px); }
.btn-small { font-size: 0.83rem; padding: 7px 16px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid rgba(28, 33, 48, 0.22); }
.btn-ghost:hover { background: rgba(28, 33, 48, 0.04); }

/* ---------- Controls ---------- */
.game-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.control-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}
.control-group select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: #fbfaf8;
  border: 1px solid rgba(28, 33, 48, 0.18);
  border-radius: 10px;
  padding: 9px 12px;
}
.timer {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Board ---------- */
.board-wrap { position: relative; }
.grid {
  display: grid;
  gap: 0;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  aspect-ratio: 1;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.cell {
  font-family: var(--font-body);
  font-weight: 500;
  color: #3556b8;
  background: #fff;
  border: none;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  padding: 0;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.08s ease;
}
.size-4 .cell { font-size: 2rem; }
.size-6 .cell { font-size: 1.6rem; }
.size-9 .cell { font-size: 1.25rem; }
.cell.given { color: var(--ink); font-weight: 600; }
.cell.b-right { border-right: 2.5px solid var(--ink); }
.cell.b-bottom { border-bottom: 2.5px solid var(--ink); }
.cell.peer { background: #f6f4ee; }
.cell.same { background: #ece5d2; }
.cell.sel { background: var(--gold-soft); outline: 2px solid var(--gold); outline-offset: -2px; }
.cell.conflict { color: var(--bad); }
.cell.wrong { background: rgba(192, 86, 33, 0.18); }
.cell .notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 8%;
  align-items: center;
}
.cell .notes i {
  font-style: normal;
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

/* ---------- Win banner ---------- */
.win-banner[hidden] { display: none; }
.win-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(248, 246, 242, 0.94);
  border-radius: 10px;
  text-align: center;
  padding: 20px;
}
.win-banner h2 { font-size: 2rem; margin: 0; }
.win-banner p { margin: 0 0 10px; color: var(--ink-soft); }
.win-actions { margin-bottom: 6px; }
.btn-star {
  background: var(--gold);
  border-color: var(--gold);
}
.btn-star:hover { background: #93742f; }
.btn-star:disabled { opacity: 0.85; cursor: default; transform: none; }

/* ---------- Number pad & tools ---------- */
.pad-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 12px;
}
.pad-btn {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  background: #fbfaf8;
  border: 1px solid rgba(28, 33, 48, 0.18);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
.pad-btn:hover { background: var(--gold-soft); border-color: var(--gold); transform: translateY(-1px); }

.tool-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tool-btn {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(28, 33, 48, 0.05);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
}
.tool-btn:hover { background: var(--gold-soft); border-color: var(--gold); }
#notesState { color: var(--gold); }

/* ---------- Records ---------- */
.records-table { width: 100%; border-collapse: collapse; }
.records-table th, .records-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
}
.records-table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.records-table td { font-size: 0.93rem; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--muted); padding: 24px; font-size: 0.85rem; }
