/* Forever Salt: dark stone page, gold headings, red-to-green ratings.
   Theme tokens first; every page shares them. The grain is stone.svg (a static file, so the
   Content-Security-Policy's img-src 'self' allows it) laid over --bg with a soft vignette. */
:root {
  --bg: #17181a;
  --panel: #1e1f22;
  --panel-2: #17181a;
  --border: #34353a;
  --border-2: #3a3a41;
  --text: #e8e6e1;
  --muted: #a4a19a;
  --gold: #f0b54a;
  --link: #f0c96a;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: system-ui, "Segoe UI", sans-serif;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 85% 80% at 50% 45%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.5) 100%),
    url("stone.svg");
  background-repeat: no-repeat, repeat;
  background-size: cover, 512px 512px;
  background-attachment: fixed, scroll;
}
a { color: var(--link); }
h1, h2, h3 { color: var(--gold); margin: 0 0 14px; line-height: 1.2; }
h2 { font-size: 1.7em; }
h3 { color: #fff; font-size: 1.9em; }
p { margin: 0 0 8px; }
code { background: #2a2a2f; padding: 3px 8px; border-radius: 5px; word-break: break-all; }
button, .button-link {
  display: inline-block; background: transparent; color: var(--text); border: 1px solid #6a6870;
  padding: 8px 20px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 1.02em;
  text-decoration: none; line-height: 1.4;
}
button:hover, .button-link:hover { border-color: var(--gold); color: #fff; }
input[type="search"], input[type="text"], textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 8px; padding: 10px 14px; font: inherit;
}
input[type="search"]:focus, input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--gold); }
input::placeholder, textarea::placeholder { color: #8a8882; }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px 44px; padding: 14px 40px; flex-wrap: wrap;
  background: rgba(20, 21, 23, 0.55); border-bottom: 1px solid #2c2d31;
}
.brand { display: flex; align-items: center; gap: 18px; text-decoration: none; }
.brand img {
  width: 64px; height: 64px; border-radius: 8px;
  border: 1px solid rgba(240, 181, 74, 0.55); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.brand-name { display: block; color: var(--gold); font-size: 2em; font-weight: 700; line-height: 1.1; }
.tagline { display: block; color: var(--muted); font-size: 0.9em; margin-top: 2px; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 40px; }
.topbar nav a { color: var(--text); text-decoration: none; font-size: 1.35em; }
.topbar nav a:hover { color: var(--gold); }
.topbar .topsearch { position: relative; margin: 0 0 0 auto; flex: 1 1 300px; max-width: 440px; }
.topbar .topsearch input[type="search"] {
  width: 100%; padding: 12px 16px 12px 50px; font-size: 1.1em; border-radius: 10px;
  background: #26272b; border-color: var(--border-2);
}
.topbar .topsearch .search-icon { left: 17px; width: 22px; height: 22px; }

main { max-width: 1440px; margin: 0 auto; padding: 32px 40px 8px; }
footer {
  max-width: 1440px; margin: 40px auto 0; padding: 22px 40px 36px; border-top: 1px solid var(--border);
  color: var(--muted); text-align: center; font-size: 1.05em;
}

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 26px 28px; margin-bottom: 22px; box-shadow: var(--shadow);
}

/* Home and search */
.card > p { font-size: 1.1em; }
.bigsearch { display: flex; gap: 12px; margin-top: 16px; }
.bigsearch input { flex: 1; min-width: 0; font-size: 1.25em; padding: 14px 20px; border-radius: 10px; }
.bigsearch button { padding: 12px 30px; font-size: 1.15em; border-radius: 10px; flex-shrink: 0; }
.results { list-style: none; padding: 0; margin: 0 0 24px; }
.results li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 1.1em; }
.results li:last-child { border-bottom: 0; }
.results a { font-weight: 600; }
.results .muted { margin-left: 10px; }
.card .results:last-child { margin-bottom: 0; }
.card h2 + .results { margin-top: -4px; }
.card .results + h2 { margin-top: 20px; }

/* Player page */
.player { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 28px; align-items: start; }
.player > * { min-width: 0; }
.avatar { display: block; width: 100%; border-radius: 10px; margin-bottom: 18px; }
.profile p { margin: 0 0 4px; font-size: 1.1em; overflow-wrap: anywhere; }
.profile h3 { margin-bottom: 10px; }
.armory-link { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px; }

.summary { display: flex; gap: 30px; align-items: center; flex-wrap: wrap; }
/* A quiet tile: deep fill, a muted border (about 45% of the number colour), the number carries the colour. */
.badge { min-width: 216px; padding: 18px 26px 20px; border-radius: 14px; text-align: center; border: 2px solid; }
.badge-number { display: block; font-size: 3.6em; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.badge-count { color: var(--text); font-size: 1.15em; }
.badge-count b { color: #fff; }
.facts { flex: 1; min-width: 240px; }
.facts p { font-size: 1.15em; margin: 0 0 8px; }
.facts p:last-child { margin-bottom: 0; }
.facts b { color: #fff; }
.label { color: var(--muted); font-weight: 600; margin-right: 14px; }

.tags { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 12px; }
.tag { padding: 8px 18px; border-radius: 10px; border: 1px solid; font-size: 1.1em; line-height: 1.3; }
.tag b { margin-left: 4px; }
.tag-bad { background: #46201f; border-color: #7a3833; color: #f3e4e1; }
.tag-bad b { color: #ff5a4a; }
.tag-good { background: #1d3a21; border-color: #3d6e40; color: #e3f1e0; }
.tag-good b { color: #6fdc55; }

.record > h2 { font-size: 2em; margin: 26px 0 16px; }
.note { display: flex; gap: 24px; align-items: center; padding: 22px 28px; }
.note-body { flex: 1; min-width: 0; }
.note-head { color: var(--muted); font-size: 1.05em; margin-bottom: 2px; }
.note-head .sep { margin: 0 10px; color: #55555c; }
.note-head b { font-size: 1.05em; }
.note-text { font-size: 1.25em; color: #fff; white-space: pre-line; overflow-wrap: anywhere; margin: 0 0 4px; }
.note-body > .muted { margin: 0; }
.report { flex-shrink: 0; text-align: right; }
.report summary {
  display: inline-block; list-style: none; cursor: pointer; user-select: none;
  color: var(--text); border: 1px solid #6a6870; border-radius: 8px; padding: 8px 22px; font-size: 1.05em; line-height: 1.4;
}
.report summary::-webkit-details-marker { display: none; }
.report summary:hover, .report[open] summary { border-color: var(--gold); color: var(--gold); }
.report form { display: flex; flex-direction: column; gap: 8px; width: 240px; margin-top: 10px; text-align: left; }
.reply { margin: 12px 0 0 16px; padding-left: 14px; border-left: 2px solid var(--muted); }
.reply .note-text { font-size: 1.1em; }
.reply-form { display: flex; gap: 8px; margin-top: 12px; }
.reply-form textarea { flex: 1; min-width: 0; }
.notice { font-weight: bold; }
.claim { margin-top: 14px; }
.mod-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.mod-actions form { display: flex; gap: 8px; }

/* Ratings: -5..-1 red shades, 0 grey, 1..5 green shades (text for notes, fill for the badge). */
.r-n5 { color: #ff3b30; }
.r-n4 { color: #ff5a2e; }
.r-n3 { color: #ff7a2b; }
.r-n2 { color: #ffa21f; }
.r-n1 { color: #ffd60a; }
.r-0 { color: #a8a6a0; }
.r-p1 { color: #c6e86a; }
.r-p2 { color: #a6dc5a; }
.r-p3 { color: #7fd34a; }
.r-p4 { color: #5fcf3c; }
.r-p5 { color: #34c759; }
.badge.r-n5 { background: #3f1416; border-color: #7a2b27; }
.badge.r-n4 { background: #3e1912; border-color: #7a3626; }
.badge.r-n3 { background: #3d1e10; border-color: #7a4526; }
.badge.r-n2 { background: #39260d; border-color: #7a5522; }
.badge.r-n1 { background: #342d0b; border-color: #766a1e; }
.badge.r-0 { background: #27272b; border-color: #4e4e54; }
.badge.r-p1 { background: #273012; border-color: #5e6e2c; }
.badge.r-p2 { background: #223011; border-color: #4f6b2a; }
.badge.r-p3 { background: #1c3113; border-color: #3f6a28; }
.badge.r-p4 { background: #173312; border-color: #336a26; }
.badge.r-p5 { background: #11341b; border-color: #28652f; }

/* Prose pages: about, download, install, privacy */
.prose h2 { margin-top: 26px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { font-size: 1.08em; }
.prose li { margin-bottom: 6px; }
.prose ul, .prose ol { padding-left: 26px; }

/* Logged-in badge in the top bar */
.topbar nav a.nav-user { display: inline-flex; align-items: center; gap: 10px; color: var(--gold); }
/* dot-* classes, not role-*: the .role-* pill rules below would repaint the dot. */
.nav-dot { width: 10px; height: 10px; border-radius: 50%; background: #7fd36a; }
.dot-user { background: #7fd36a; box-shadow: 0 0 6px rgba(127, 211, 106, 0.6); }
.dot-moderator { background: #d9a93c; box-shadow: 0 0 6px rgba(217, 169, 60, 0.6); }
.dot-owner { background: var(--gold); box-shadow: 0 0 6px rgba(240, 181, 74, 0.6); }

/* Account page */
.profile-head { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.profile-actions { display: flex; gap: 14px; align-items: center; }
.button-danger { border-color: #a0453a; color: #ff7a6b; }
button.button-danger:hover, .button-link.button-danger:hover { border-color: #ff3b30; color: #ff7a6b; }
footer .sep { margin: 0 8px; }
.steps > li { margin-bottom: 12px; }
.role { display: inline-block; padding: 2px 10px; border-radius: 999px; border: 1px solid; font-size: 0.85em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.role-user { color: #a8a6a0; border-color: #5c5c64; background: #2a2a2e; }
.role-moderator { color: #8fc0f5; border-color: #3d6a9c; background: #1c2a3a; }
.role-owner { color: var(--gold); border-color: #8a6a2c; background: #33281a; }
.role-banned { color: #ff6a5e; border-color: #7a3236; background: #3a1c1e; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.char-list { list-style: none; padding: 0; margin: 0; }
.char-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.char-row:last-child { border-bottom: 0; }
.char-ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.char-portrait { width: 48px; height: 48px; border-radius: 8px; flex-shrink: 0; object-fit: cover; }
.char-portrait-empty { display: flex; align-items: center; justify-content: center; background: #2a2a2e; border: 1px solid #5c5c64; color: #a8a6a0; font-weight: 700; font-size: 1.3em; box-sizing: border-box; }
.char-main { display: flex; flex-direction: column; min-width: 0; }
.char-notes { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--muted); }
.char-notes .badge-small { min-width: 0; font-size: 0.95em; padding: 2px 8px; }
.char-name { color: var(--gold); font-weight: 700; font-size: 1.1em; overflow-wrap: anywhere; }
.char-actions { display: flex; align-items: center; gap: 12px; }
.claimed { color: #7fd36a; font-weight: 600; }
.badge-small { min-width: 52px; padding: 4px 8px; border-radius: 8px; border-width: 2px; font-weight: 800; font-size: 1.1em; flex-shrink: 0; }
.mod-hidden { margin-left: 8px; padding: 1px 8px; border-radius: 999px; border: 1px solid #5c5c64; background: #2a2a2e; color: #a8a6a0; font-size: 0.85em; }

/* Account panel: fixed-size, three tabs (account.js switches them; without it all show) */
main:has(> .acct) { max-width: 1260px; }
.acct { max-width: 1180px; height: 640px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.acct:not(.tabs-js) { height: auto; }
.acct-tabs { display: flex; gap: 8px; margin: 0 24px; padding-top: 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.acct-tab { padding: 10px 18px 12px; color: #c9c6bf; text-decoration: none; font-size: 1.3em; font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.acct-tab:hover { color: var(--text); }
.acct-tab.is-active { color: var(--gold); font-weight: 700; border-bottom-color: var(--gold); }
.acct-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; }
.acct.tabs-js .acct-pane:not(.is-active) { display: none; }
.acct-block { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Notes tab: the list on the left, the editor on the right */
.acct-notes { display: grid; grid-template-columns: 340px 1fr; padding: 0; overflow: hidden; }
.notes-col { display: flex; flex-direction: column; min-height: 0; margin: 20px 0 16px; padding: 4px 22px 0 24px; border-right: 1px solid var(--border); }
.search-field { position: relative; margin-bottom: 14px; flex-shrink: 0; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #c9c6bf; pointer-events: none; }
.search-field input[type="search"] { width: 100%; padding: 9px 12px 9px 40px; }
.notes-count { color: var(--gold); font-size: 1.3em; font-weight: 700; margin: 0 0 8px; }
.notes-cap { font-size: 0.9em; margin-bottom: 6px; }
.note-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.note-row { padding: 9px 14px 10px; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; cursor: pointer; }
.note-row:hover { background: #25252b; }
/* The selected row: a gold outline all the way round (the left bar's 3px becomes padding). */
.note-row.is-selected { background: #2a2a31; border-left-color: var(--gold); border-radius: 4px; }
.note-row[hidden] { display: none; }
.note-row .mod-hidden { margin-left: 0; }
.note-row-head { display: flex; flex-direction: column; align-items: flex-start; }
.note-name { max-width: 100%; color: #fff; font-weight: 700; font-size: 1.1em; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.note-name:hover { text-decoration: underline; }
.note-pick { display: block; color: #c9c6bf; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars { flex-shrink: 0; font-size: 20px; line-height: 1.2; letter-spacing: 2px; }
.star { color: #55555d; }
.star-on { color: inherit; }

.editor-col { min-height: 0; overflow-y: auto; padding: 22px 26px 18px 30px; }
.editor-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 24px; margin-bottom: 18px; }
.editor-name { color: var(--gold); font-size: 2em; font-weight: 700; line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
.editor-link { color: var(--gold); font-size: 1.1em; text-decoration: underline; text-underline-offset: 3px; }
.editor-link[hidden] { display: none; }
.editor-head .mod-hidden { margin-left: 0; }
.note-editor fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.rate-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 10px 12px; }
.rate, .chip { position: relative; }
.rate input, .chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.rate span { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 10px; font-size: 1.1em; font-weight: 700; color: var(--text); background: #2a2a2e; border: 2px solid #77757c; cursor: pointer; }
.rate[class*="r-n"] span { background: #3a1a1a; border-color: #b8433a; }
.rate[class*="r-p"] span { background: #1b301b; border-color: #4a9a3a; }
.rate span:hover { filter: brightness(1.25); }
.rate input:checked + span { color: #fff; font-weight: 800; background: #6a6870; border-color: #a8a6a0; }
.rate[class*="r-n"] input:checked + span { background: #c0392b; border-color: #ff5a4a; }
.rate[class*="r-p"] input:checked + span { background: #3a9d2f; border-color: #6fdc55; }
.chip span { display: inline-block; padding: 6px 18px; color: var(--text); background: var(--panel-2); border: 1px solid #5c5c64; border-radius: 10px; cursor: pointer; }
.chip span:hover { border-color: #8a8890; }
.chip-good input:checked + span { color: #fff; background: #2a6a24; border-color: #4ca237; }
.chip-bad input:checked + span { color: #fff; background: #8a2a22; border-color: #c0553a; }
.rate input:focus-visible + span, .chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.note-editor textarea { display: block; width: 100%; min-height: 128px; padding: 12px 16px; font-size: 1.1em; border-color: #5c5c64; resize: vertical; }
.note-editor textarea:focus { border-color: var(--gold); }
.note-counter { text-align: right; color: var(--muted); font-size: 0.9em; margin: 6px 2px 10px; }
.editor-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; }
.editor-meta { color: #c9c6bf; margin: 0; }
.editor-meta .sep { margin: 0 4px; }
.editor-actions { display: flex; gap: 18px; margin-left: auto; }
.editor-actions button { min-width: 112px; padding: 8px 24px; font-size: 1.1em; border-radius: 8px; }
.button-gold { background: var(--gold); color: #1b1610; border-color: var(--gold); font-weight: 700; }
.button-gold:hover { background: #f6c76a; border-color: #f6c76a; color: #1b1610; }
.editor-actions .button-danger { background: #2a1517; border-color: #a0453a; color: #ff6a5e; }
.editor-actions .button-danger:hover { border-color: #ff3b30; }
.editor-hint { color: var(--muted); font-size: 0.9em; margin: 14px 0 0; }

/* Phones and narrow windows */
@media (max-width: 1000px) {
  .player { grid-template-columns: 300px minmax(0, 1fr); gap: 22px; }
  .topbar { gap: 12px 28px; padding: 12px 24px; }
  main, footer { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 760px) {
  body { background-attachment: scroll, scroll; }
  .topbar { gap: 10px 20px; padding: 12px 16px; }
  .brand { gap: 12px; }
  .brand img { width: 48px; height: 48px; }
  .brand-name { font-size: 1.5em; }
  .topbar nav { gap: 0 18px; }
  .topbar nav a { font-size: 1.1em; padding: 8px 0; }
  .topbar .topsearch { flex: 1 1 100%; width: 100%; min-width: 0; margin-left: 0; }
  .topbar .topsearch input[type="search"] { font-size: 1em; padding: 10px 14px 10px 44px; }
  main { padding: 20px 16px 8px; }
  footer { padding: 18px 16px 28px; margin-top: 28px; font-size: 0.95em; }
  .card { padding: 20px 18px; border-radius: 10px; }
  h2 { font-size: 1.45em; }
  h3 { font-size: 1.6em; }
  .player { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .summary { gap: 18px; }
  .badge { min-width: 0; width: 100%; }
  .badge-number { font-size: 3em; }
  .record > h2 { font-size: 1.7em; margin-top: 18px; }
  .note { flex-wrap: wrap; gap: 14px; padding: 18px; }
  .note-text { font-size: 1.15em; }
  .report { width: 100%; text-align: left; }
  .report form { width: 100%; }
  .bigsearch { flex-wrap: wrap; }
  .bigsearch input { font-size: 1.1em; padding: 12px 14px; }
  .bigsearch button { width: 100%; }
  .acct { height: auto; }
  .acct-tabs { margin: 0 12px; }
  .acct-pane { overflow: visible; padding: 16px; }
  .acct-notes { grid-template-columns: 1fr; padding: 0; }
  .notes-col { max-height: 50vh; margin: 16px 0 0; padding: 0 16px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .editor-col { padding: 18px 16px; }
  .acct-tab { padding: 8px 10px 10px; font-size: 1.1em; }
  .editor-name { font-size: 1.6em; }
  .rate-pick { gap: 6px; }
  .rate span { width: 40px; height: 40px; font-size: 0.95em; border-radius: 8px; }
  .mod-actions form { flex-wrap: wrap; width: 100%; }
  .mod-actions form input { flex: 1 1 100%; }
  .mod-actions form button { width: 100%; }
}
