/* Simple, mobile-friendly styling with automatic dark mode. */

:root {
  --bg: #f6f6f3;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6e6e68;
  --border: #e2e2dc;
  --accent: #3b6fd8;
  --solved: #e3f4e5;
  --solved-text: #1f6b2c;
  --failed: #fbe7e5;
  --failed-text: #a3302a;
  --hidden: #ececea;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --card: #222220;
    --text: #ededea;
    --muted: #9a9a93;
    --border: #353532;
    --accent: #7ea2ff;
    --solved: #1f3a24;
    --solved-text: #9be0a6;
    --failed: #45221f;
    --failed-text: #ffaaa3;
    --hidden: #2e2e2b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0; }
h2 a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Navigation bar */
nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
nav .brand { font-weight: 700; color: var(--text); }
nav .spacer { flex: 1; }

main { max-width: 960px; margin: 0 auto; padding: 1rem; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.card > header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.more, .pager { margin: 0.5rem 0 0; font-size: 0.875rem; display: flex; gap: 1rem; }

/* Flash messages */
.flash {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: var(--hidden);
}
.flash.success { background: var(--solved); color: var(--solved-text); }
.flash.error { background: var(--failed); color: var(--failed-text); }
.flash.password { font-family: ui-monospace, monospace; background: var(--solved); color: var(--solved-text); }

/* Result tables */
.table-wrap { overflow-x: auto; }
table.results { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
table.results th, table.results td {
  padding: 0.4rem 0.6rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.results th:first-child, table.results td:first-child { text-align: left; }
table.results thead th { color: var(--muted); font-weight: 600; }
td.solved { background: var(--solved); color: var(--solved-text); }
td.failed { background: var(--failed); color: var(--failed-text); }
td.hidden { background: var(--hidden); color: var(--muted); cursor: help; }
td.empty { color: var(--muted); }
table.results td { white-space: pre-line; } /* multi-line summaries, e.g. LoLdle */
td.mine { font-weight: 700; }
td.actions { text-align: right; }
table.stats td { vertical-align: top; }

/* Stats distribution bars */
.bar-row { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; min-width: 5rem; }
.bar-label { width: 1.5rem; text-align: right; color: var(--muted); }
.bar {
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 0 0.3rem;
  min-width: 1.4rem;
  text-align: right;
}

/* Puzzle page: everybody's share text */
.share-grid .card { margin: 0; }
.share-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.share pre {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}
.share footer { font-size: 0.8rem; display: flex; justify-content: space-between; }
.badge { padding: 0.1rem 0.5rem; border-radius: 99px; font-size: 0.85rem; background: var(--hidden); }
.badge.solved { background: var(--solved); color: var(--solved-text); }
.badge.failed { background: var(--failed); color: var(--failed-text); }

/* Forms */
form label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--muted); }
form label.check { display: flex; gap: 0.5rem; align-items: center; color: var(--text); }
input:not([type=checkbox]), select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
textarea { margin-bottom: 0.75rem; resize: vertical; }
button, .button {
  display: inline-block;
  padding: 0.5rem 1rem;
  font: inherit;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.button:hover { text-decoration: none; opacity: 0.9; }
button.link {
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: inherit;
}
button.danger { color: var(--failed-text); }
form.inline { display: inline; }
