@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #14181a;
  --surface: #1c2220;
  --surface-raised: #232a27;
  --border: #313a36;
  --text: #ece7dd;
  --text-muted: #8f9993;
  --gold: #c9a227;
  --green: #4c956c;
  --gray-x: #6b655f;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

header.masthead {
  border-bottom: 1px solid var(--border);
  padding: 14px 0 10px;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

header.masthead .title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

header.masthead .title span {
  color: var(--gold);
}

nav.tabs {
  display: flex;
  gap: 4px;
}

nav.tabs a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius);
  transition: background 0.15s ease, color 0.15s ease;
}

nav.tabs a:hover {
  background: var(--surface-raised);
  color: var(--text);
}

nav.tabs a.active {
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
}

h1.page-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 17px;
  margin: 0 0 3px;
}

p.page-sub {
  color: var(--text-muted);
  margin: 0 0 12px;
  font-size: 13px;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash.error {
  background: #2c1c1a;
  border-color: #5a332c;
  color: #e8a898;
}

.flash.success {
  background: #1a2620;
  border-color: #2e4a3a;
  color: #a8d8bb;
}

.range-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.range-form input[type="number"] {
  width: 76px;
}

.range-form a.reset {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

input, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 14px;
}

input:focus, textarea:focus, button:focus, a:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

textarea {
  width: 100%;
  min-height: 220px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  resize: vertical;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field {
  margin-bottom: 16px;
}

button, .btn {
  background: var(--gold);
  color: #1a1a16;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover, .btn:hover {
  filter: brightness(1.08);
}

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

button.danger {
  background: transparent;
  color: #c96f5f;
  border: 1px solid #4a332e;
  font-weight: 500;
  padding: 4px 9px;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 8px 6px;
  border-bottom: 1px solid var(--border);
}

th.num, td.num {
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
}

td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

td.username {
  font-weight: 500;
}

td.username a {
  color: var(--text);
  text-decoration: none;
}

td.username a:hover {
  text-decoration: underline;
}

.crown {
  color: var(--gold);
}

.rank {
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  width: 28px;
}

.score-cell {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: var(--gold);
}

.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: var(--radius);
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  font-size: 12px;
  border: 1px solid var(--border);
}

.tile.solved { background: rgba(76, 149, 108, 0.18); border-color: var(--green); color: #a8d8bb; }
.tile.unsolved { background: rgba(107, 101, 95, 0.18); border-color: var(--gray-x); color: #b8b2ab; }

.puzzle-list-table a { color: var(--text); text-decoration: none; }
.puzzle-list-table a:hover { text-decoration: underline; }

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.player-row:last-child { border-bottom: none; }

.player-row .uid {
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

.empty-state {
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
  font-size: 14px;
}

.warning-box {
  background: #2c2214;
  border: 1px solid #5a4a2c;
  color: #e8cf98;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
}

.inline-form {
  display: inline;
}

.add-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.add-form .field { margin-bottom: 0; }
.add-form input[type="text"], .add-form input[type="number"] { width: 130px; }
.add-form .checkbox-field { display: flex; align-items: center; gap: 6px; }
.add-form .checkbox-field label { margin: 0; }