@font-face { font-family: Geist; font-weight: 100 900; font-display: swap; src: url(/fonts/geist.woff2) format("woff2"); }
@font-face { font-family: "Geist Mono"; font-weight: 100 900; font-display: swap; src: url(/fonts/geist-mono.woff2) format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-weight: 400 700; font-display: swap; src: url(/fonts/pixelify.woff2) format("woff2"); }
@font-face { font-family: "Noto Color Emoji Flags"; font-display: swap; src: url(/fonts/flags.woff2) format("woff2"); unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006E, U+E0073-E0074, U+E007F; }

/* ---------- theme (same daisyUI palettes as the game) ---------- */
:root, [data-theme=custom-winter] {
  color-scheme: light;
  --b1: oklch(100% 0 0); --b2: oklch(97.466% .011 259.822); --b3: oklch(93.268% .016 262.751); --bc: oklch(41.886% .053 255.824);
  --p: oklch(56.86% .255 257.57); --pc: oklch(100% .051 257.57); --s: oklch(42.551% .161 282.339); --a: oklch(59.939% .191 335.171);
  --n: oklch(19.616% .063 257.651); --nc: oklch(83.923% .012 257.651);
  --info: oklch(88.127% .085 214.515); --success: oklch(52% .12 197.823); --warning: oklch(55% .14 71.47); --error: oklch(58% .16 20.076);
}
[data-theme=dark] {
  color-scheme: dark;
  --b1: oklch(30.857% .023 264.149); --b2: oklch(28.036% .019 264.182); --b3: oklch(26.346% .018 262.177); --bc: oklch(97.807% .029 256.847);
  --p: oklch(58% .233 277.117); --pc: oklch(96% .018 272.314); --s: oklch(65% .241 354.308); --a: oklch(77% .152 181.912);
  --n: oklch(14% .005 285.823); --nc: oklch(92% .004 286.32);
  --info: oklch(74% .16 232.661); --success: oklch(76% .177 163.223); --warning: oklch(82% .189 84.429); --error: oklch(71% .194 13.428);
}
:root {
  --muted: color-mix(in oklab, var(--bc) 62%, transparent);
  --line: var(--b3);
  --r-box: 1.25rem; --r-field: 999px;
  --font: Geist, "Noto Color Emoji Flags", system-ui, "Segoe UI", sans-serif;
  --pixel: "Pixelify Sans", Geist, "Noto Color Emoji Flags", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, Consolas, monospace;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
body { margin: 0; background: var(--b2); color: var(--bc); font: 14px/1.5 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--p); text-decoration: none; } a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--p); outline-offset: 2px; border-radius: 6px; }
main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 22px 20px 40px; flex: 1; }
footer { text-align: center; color: var(--muted); padding: 22px; font-size: 12px; max-width: 900px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--pixel); font-weight: 600; margin: 0; letter-spacing: .01em; }
h1 { font-size: 30px; overflow-wrap: anywhere; } h2 { font-size: 19px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; } .nowrap { white-space: nowrap; } .small { font-size: 12px; }
.up { color: var(--success); } .down { color: var(--error); } .sp { flex: 1; }
code { font-family: var(--mono); background: var(--b3); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.idtag { font-size: 16px; }
.info { display: inline-grid; place-items: center; color: var(--muted); cursor: help; vertical-align: middle; } .info .ic { width: 14px; height: 14px; margin: 0; }
/* pixel-art icons (pixelarticons): crisp, colour follows the text */
.ic { width: 1.15em; height: 1.15em; fill: currentColor; flex: none; vertical-align: -0.2em; margin-right: .35em; shape-rendering: crispEdges; }
h2 .ic { color: var(--p); margin-right: 0; width: 22px; height: 22px; }
.btn .ic, .tabs .ic, .badge .ic, .flexgap .ic { margin-right: 0; }
.badge .ic { width: 14px; height: 14px; }
.ticon .ic { margin: 0; color: var(--p); }
#themeBtn .ic { margin: 0; width: 20px; height: 20px; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- nav ---------- */
.nav { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--b1); border-bottom: 2px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: 22px; font-weight: 700; color: var(--bc); white-space: nowrap; }
.brand:hover { text-decoration: none; } .logo { width: 34px; height: 34px; image-rendering: pixelated; display: block; }
.links { display: flex; gap: 4px; }
.links a { color: var(--muted); padding: 6px 12px; border-radius: var(--r-field); font-weight: 500; white-space: nowrap; }
.links a:hover { background: var(--b2); color: var(--bc); text-decoration: none; } .links a.on { background: var(--p); color: var(--pc); }
.searchwrap { margin-left: auto; position: relative; flex: 1; max-width: 460px; }
#q { width: 100%; padding: 9px 16px; border-radius: var(--r-field); border: 2px solid var(--line); background: var(--b2); color: var(--bc); font: inherit; outline: none; }
#q:focus { border-color: var(--p); background: var(--b1); }
.suggest { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--b1); border: 2px solid var(--line); border-radius: var(--r-box); box-shadow: 0 12px 30px rgb(0 0 0 / .18); max-height: 70vh; overflow: auto; padding: 6px; }
.suggest h4 { margin: 8px 10px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.suggest a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 12px; color: var(--bc); }
.suggest a:hover, .suggest a.sel { background: var(--b2); text-decoration: none; }
.suggest .sub { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; } .suggest .all { justify-content: center; color: var(--p); }

/* ---------- controls ---------- */
.btn { font: inherit; font-weight: 600; cursor: pointer; border: 2px solid var(--line); background: var(--b1); color: var(--bc); padding: 7px 16px; border-radius: var(--r-field); transition: .12s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none !important; }
.btn:hover { border-color: var(--p); } .btn:disabled { opacity: .5; cursor: wait; }
.btn-sm { padding: 4px 12px; font-size: 13px; } .btn-ghost { border-color: transparent; background: transparent; }
.btn-primary, .btn.on { background: var(--p); border-color: var(--p); color: var(--pc); } .btn-primary:hover { filter: brightness(1.08); }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--b3); border-radius: var(--r-field); margin: 8px 8px 8px 0; }
.tabs a, .tabs button { font: inherit; border: 0; background: transparent; color: var(--muted); padding: 5px 14px; border-radius: var(--r-field); cursor: pointer; font-weight: 500; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--bc); } .tabs .on { background: var(--b1); color: var(--bc); box-shadow: 0 1px 3px rgb(0 0 0 / .12); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0 10px; }
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select, .input { font: inherit; background: var(--b1); color: var(--bc); border: 2px solid var(--line); border-radius: var(--r-field); padding: 6px 14px; outline: none; min-width: 0; }
select:focus, .input:focus { border-color: var(--p); }
.form { display: flex; flex-wrap: wrap; gap: 8px; } .form .input { flex: 1 1 160px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: var(--r-field); background: var(--b3); color: var(--bc); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.badge.p { background: color-mix(in oklab, var(--s) 14%, var(--b1)); color: var(--s); } .badge.ok { background: color-mix(in oklab, var(--success) 18%, var(--b1)); color: var(--success); }
.badge.warn { background: color-mix(in oklab, var(--warning) 20%, var(--b1)); color: var(--warning); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--success); } .dot.bad { background: var(--error); } .dot.wait { background: var(--warning); }

/* ---------- layout blocks ---------- */
.card { background: var(--b1); border: 2px solid var(--line); border-radius: var(--r-box); padding: 16px 18px; margin-bottom: 16px; container-type: inline-size; min-width: 0; }
.card.flat { padding: 0; overflow: hidden; } .card .pad { padding: 16px 18px 4px; } .card .pad:empty { display: none; }
.card.narrow { max-width: 520px; margin: 40px auto; }
.hero-card { text-align: center; padding: 34px 20px; } .hero-card h1 { font-size: 40px; } .hero-card p { max-width: 640px; margin: 10px auto 0; }
.actions { margin-top: 18px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); margin-bottom: 16px; } .grid > .card, .grid > div > .card { margin-bottom: 0; }
.grid3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-bottom: 16px; } .grid3 > .card { margin-bottom: 0; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.region-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); } .region-top .stats { margin-top: 0; }
.hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-family: var(--pixel); font-size: 30px; color: #fff; flex: none; border: 2px solid var(--line); }
.avatar.sm { width: 26px; height: 26px; font-size: 13px; border-radius: 8px; border-width: 1px; }
.titleblock { min-width: 0; flex: 1; } .titleblock .meta, .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.stats.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-top: -4px; } .stats.compact .stat b { font-size: 18px; }
.stat { background: var(--b1); border: 2px solid var(--line); border-radius: var(--r-box); padding: 12px 16px; min-width: 0; }
.stat b { display: block; font-family: var(--font); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 26px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .stat span { color: var(--muted); font-size: 12px; }
.stat.hl { border-color: var(--p); background: color-mix(in oklab, var(--p) 8%, var(--b1)); }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.callout { background: color-mix(in oklab, var(--info) 22%, var(--b1)); border: 2px solid color-mix(in oklab, var(--info) 55%, var(--b1)); border-radius: var(--r-box); padding: 10px 14px; margin: 0 0 14px; font-size: 13px; }
.callout.bad { background: color-mix(in oklab, var(--error) 14%, var(--b1)); border-color: color-mix(in oklab, var(--error) 50%, var(--b1)); }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.results { display: grid; gap: 8px; }
.defs dt { margin-top: 10px; } .defs dd { margin: 2px 0 0 0; color: var(--muted); }
.toolgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- tables: never scroll sideways on desktop; drop low-priority columns when the card is narrow ---------- */
.tools { display: flex; gap: 8px; align-items: center; padding: 10px 14px 4px; flex-wrap: wrap; } .tools .input { padding: 5px 14px; flex: 0 1 220px; }
.tbl { width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
td.grow, th.grow { white-space: normal; width: 100%; overflow-wrap: anywhere; min-width: 9em; } /* never squeezed into a column of single letters */
td[style*="min-width"], th[style*="min-width"] { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: var(--b1); user-select: none; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--bc); } th.sorted { color: var(--p); }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; } th.n { font-family: var(--font); }
tbody tr:hover td { background: color-mix(in oklab, var(--p) 6%, var(--b1)); } tbody tr:last-child td { border-bottom: 0; }
table.mini td { padding: 6px 4px; } table.mini th { padding: 6px 4px; }
.more { text-align: center; padding: 10px; border-top: 1px solid var(--line); }
.rank { font-family: var(--pixel); color: var(--muted); display: inline-block; min-width: 22px; } .rank.top1 { color: #d9a400; } .rank.top2 { color: #8e9aaa; } .rank.top3 { color: #b0702e; }
.bar { height: 8px; background: var(--b3); border-radius: 99px; overflow: hidden; width: 110px; } .bar i { display: block; height: 100%; background: var(--p); border-radius: 99px; }
.namecell { display: flex; align-items: center; gap: 8px; min-width: 0; } .namecell .nm { min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 760px) { .h-md { display: none; } }
@container (max-width: 520px) { .h-sm { display: none; } th, td { padding: 7px 8px; } }

/* ---------- charts & maps ---------- */
.chartbox { position: relative; height: 240px; } .chartbox.tall { height: 320px; } .chartbox canvas { max-width: 100%; }
.leaflet-container canvas { max-width: none !important; }
.mapwrap { position: relative; }
.maptools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; } .crumb { font-size: 13px; }
.mapbody { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; }
@container (max-width: 700px) { .mapbody { grid-template-columns: 1fr; } .maplist { max-height: 240px; } }
.mapcv { position: relative; height: 420px; border: 2px solid var(--line); border-radius: var(--r-box); overflow: hidden; z-index: 0; }
.mapcv.small, .mapwrap.small .mapcv { height: 260px; }
.mapcv.leaflet-container { background: color-mix(in oklab, var(--info) 14%, var(--b1)); font: inherit; }
.leaflet-tooltip.maptip { background: var(--n); color: var(--nc); border: 0; border-radius: 12px; padding: 8px 12px; font-size: 12px; line-height: 1.4; box-shadow: 0 6px 18px rgb(0 0 0 / .25); }
.leaflet-tooltip.maptip::before { display: none; }
.leaflet-control-zoom a { background: var(--b1) !important; color: var(--bc) !important; border-color: var(--line) !important; }
.maplist { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow: auto; }
.maplist a { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 10px; border-radius: 12px; color: var(--bc); } .maplist a:hover { background: var(--b2); text-decoration: none; }
.maplist .mlbl small { display: block; color: var(--muted); font-size: 11px; } .maplist .bar { grid-column: 1 / -1; height: 5px; width: auto; } .maplist .bar i { background: #ef4444; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; } .legend .lgl { width: 100px; height: 10px; border-radius: 4px; background: linear-gradient(90deg, #fee0d2, #ef4444, #7f1d1d); display: inline-block; }
.slider { flex: 1 1 200px; accent-color: #ef4444; }

/* ---------- lists ---------- */
.feed { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow: auto; } .feed li { padding: 8px 4px; border-bottom: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; } .feed li:last-child { border: 0; }
.timeline { list-style: none; padding: 0; margin: 0; max-height: 460px; overflow: auto; }
.timeline li { display: flex; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); } .timeline li:last-child { border: 0; }
.ticon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; background: var(--b2); border-radius: 10px; }
.daylist { max-height: 460px; overflow: auto; } .dayblock { padding: 8px 0; border-bottom: 1px solid var(--line); } .dayblock:last-child { border: 0; }
.dayhead { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; } .dayrow { display: flex; gap: 6px; padding: 2px 0 0 12px; align-items: baseline; flex-wrap: wrap; }

/* ---------- modal / share ---------- */
.modal { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--b1); border: 2px solid var(--line); border-radius: var(--r-box); padding: 16px 18px; width: min(820px, 100%); max-height: 92vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.share-img img { width: 100%; border-radius: 14px; border: 1px solid var(--line); display: block; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.share-text { white-space: pre-wrap; font: 12px/1.5 var(--mono); background: var(--b2); padding: 12px; border-radius: 12px; max-height: 220px; overflow: auto; margin: 0; }

/* ---------- loading & toast ---------- */
.sk { background: linear-gradient(90deg, var(--b3), var(--b2), var(--b3)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--r-box); margin-bottom: 16px; }
@keyframes sk { to { background-position: -200% 0; } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--n); color: var(--nc); padding: 10px 20px; border-radius: var(--r-field); z-index: 3000; font-weight: 500; max-width: 90vw; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .nav { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .links { order: 5; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .searchwrap { max-width: none; }
  .region-top { grid-template-columns: 1fr; }
  main { padding: 16px 12px 32px; }
}
@media (max-width: 640px) {
  h1 { font-size: 24px; } .hero-card h1 { font-size: 28px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .stat { padding: 10px 12px; } .stat b { font-size: 20px; }
  .avatar { width: 48px; height: 48px; font-size: 22px; border-radius: 14px; }
  .mapcv { height: 320px; }
  /* tables become stacked cards */
  .tbl thead { display: none; }
  .tbl table, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 8px 14px; border-bottom: 1px solid var(--line); }
  .tbl td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; white-space: normal; text-align: right; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .tbl td[data-label=""]::before, .tbl td[data-label="#"]::before { content: none; }
  .tbl td.grow { font-weight: 600; text-align: left; justify-content: flex-start; }
  .tbl td.grow::before { content: none; }
  .tbl td.h-md, .tbl td.h-sm { display: none; }
  .tbl td:has(.bar) { display: none; }
}

/* timelapse viewer */
.tl-view { position: relative; height: min(72vh, 760px); border-radius: 8px; overflow: hidden; touch-action: none;
  background: repeating-conic-gradient(#d9dde3 0 25%, #f3f4f6 0 50%) 0 0 / 16px 16px; }
.tl-view canvas { display: block; cursor: grab; }
.tl-view canvas:active { cursor: grabbing; }
.tl-load { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.65); color: #fff; padding: 4px 10px; border-radius: 6px; font-size: 13px; }
.tl-coord { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 12px; pointer-events: none; }
.tl-coord:empty { display: none; }
.tl-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tl-bar input[type=range] { flex: 1; min-width: 160px; }
.tl-info { margin-top: 6px; font-size: 13px; }

/* ---------- game UI: pixel bevels, taken from wplace.live's own "game UI" stylesheet ---------- */
:root, [data-theme=custom-winter] {
  --pixel-ink: #1b2a44; --pixel-title: #1b2a44; --pixel-button: #e3e9f4; --pixel-button-frame: #8090a8;
  --pixel-button-light: #fff; --pixel-button-shade: #aebbd0; --pixel-primary: #0069ff; --pixel-primary-light: #5a9dff; --pixel-primary-shade: #003f9e;
  --pixel-well: #e3e9f4; --pixel-well-shade: #c5cfdf; --pixel-field-shade: #d3dcea; --pixel-shadow: #0214314d; --pixel-thumb: #fff;
}
[data-theme=dark] {
  --pixel-ink: #0b0e14; --pixel-title: #ecf9ff; --pixel-button: #3a4252; --pixel-button-frame: #0b0e14;
  --pixel-button-light: #4d5669; --pixel-button-shade: #262c36; --pixel-primary: #605dff; --pixel-primary-light: #8f8cff; --pixel-primary-shade: #3431b8;
  --pixel-well: #1f242d; --pixel-well-shade: #15181e; --pixel-field-shade: #1c2028; --pixel-shadow: #00000073; --pixel-thumb: #dbe3ee;
}

/* buttons: square, 2–3 px frame drawn with gradients so the corners stay notched, light top-left / dark bottom-right bevel */
.btn {
  --bevel-fw: 2px; --bevel-depth: 4px;
  --bevel-frame: var(--pixel-button-frame); --bevel-color: var(--pixel-button); --bevel-fill: var(--bevel-color);
  --bevel-top: var(--pixel-button-light); --bevel-bottom: var(--pixel-button-shade);
  --bevel-inner: calc(100% - var(--bevel-fw) * 2);
  background:
    linear-gradient(var(--bevel-frame), var(--bevel-frame)) top center / var(--bevel-inner) var(--bevel-fw),
    linear-gradient(var(--bevel-frame), var(--bevel-frame)) bottom center / var(--bevel-inner) var(--bevel-fw),
    linear-gradient(var(--bevel-frame), var(--bevel-frame)) left center / var(--bevel-fw) var(--bevel-inner),
    linear-gradient(var(--bevel-frame), var(--bevel-frame)) right center / var(--bevel-fw) var(--bevel-inner),
    linear-gradient(var(--bevel-top), var(--bevel-top)) left var(--bevel-fw) top var(--bevel-fw) / var(--bevel-inner) calc(var(--bevel-depth) - var(--bevel-fw)),
    linear-gradient(var(--bevel-top), var(--bevel-top)) left var(--bevel-fw) top var(--bevel-fw) / calc(var(--bevel-depth) - var(--bevel-fw)) var(--bevel-inner),
    linear-gradient(var(--bevel-bottom), var(--bevel-bottom)) right var(--bevel-fw) bottom var(--bevel-fw) / var(--bevel-inner) calc(var(--bevel-depth) - var(--bevel-fw)),
    linear-gradient(var(--bevel-bottom), var(--bevel-bottom)) right var(--bevel-fw) bottom var(--bevel-fw) / calc(var(--bevel-depth) - var(--bevel-fw)) var(--bevel-inner),
    linear-gradient(var(--bevel-fill), var(--bevel-fill)) center / var(--bevel-inner) 100%,
    linear-gradient(var(--bevel-fill), var(--bevel-fill)) center / 100% var(--bevel-inner);
  background-repeat: no-repeat; background-origin: border-box; background-clip: border-box;
  border: 2px solid transparent; border-radius: 0; box-shadow: none; text-shadow: none;
  color: var(--pixel-title); font-family: var(--pixel); font-weight: 600; transition-property: color, opacity;
}
.btn:hover { border-color: transparent; --bevel-fill: color-mix(in srgb, var(--bevel-color) 90%, white); }
.btn:active, .btn.on, .btn[aria-pressed=true] { --bevel-top: var(--pixel-button-shade); --bevel-bottom: var(--pixel-button-light); }
.btn-primary, .btn.on {
  --bevel-frame: var(--pixel-ink); --bevel-color: var(--pixel-primary);
  --bevel-top: var(--pixel-primary-light); --bevel-bottom: var(--pixel-primary-shade); color: #fff; filter: none !important;
}
.btn-primary:active, .btn-primary.on { --bevel-top: var(--pixel-primary-shade); --bevel-bottom: var(--pixel-primary-light); }
.btn-ghost { background: transparent; }
.btn:disabled { --bevel-top: transparent; --bevel-bottom: transparent; --bevel-fill: var(--b2); opacity: .6; }
.btn:focus-visible { outline: 2px solid var(--p); outline-offset: 2px; border-radius: 0; }

/* tab strips: a sunken well with a raised selected tab */
.tabs { border: 2px solid var(--pixel-ink); background: var(--pixel-well); box-shadow: inset 3px 3px 0 var(--pixel-well-shade); border-radius: 0; }
.tabs a, .tabs button { border: 2px solid transparent; border-radius: 0; font-family: var(--pixel); }
.tabs .on { border-color: var(--pixel-ink); background: var(--b1); box-shadow: inset -2px -2px 0 var(--pixel-well-shade); color: var(--pixel-title); }

.badge { border: 2px solid var(--pixel-ink); border-radius: 0; padding: 1px 8px; }

/* fields */
.input, input[type=search], input[type=text], select, textarea {
  border: 2px solid var(--pixel-ink) !important; border-radius: 0 !important; background-color: var(--b1); color: var(--bc);
  box-shadow: inset 3px 3px 0 var(--pixel-field-shade);
}
select { background-color: var(--pixel-button); box-shadow: inset 2px 2px 0 var(--pixel-button-light), inset -2px -2px 0 var(--pixel-button-shade); font-family: var(--pixel); padding: 5px 8px; cursor: pointer; }
input[type=range] { appearance: none; background: transparent; height: 18px; }
input[type=range]::-webkit-slider-runnable-track { box-sizing: border-box; height: 8px; border: 2px solid var(--pixel-ink); background: var(--pixel-well-shade); }
input[type=range]::-moz-range-track { box-sizing: border-box; height: 8px; border: 2px solid var(--pixel-ink); background: var(--pixel-well-shade); }
input[type=range]::-moz-range-progress { height: 4px; background: var(--pixel-primary); }
input[type=range]::-webkit-slider-thumb { appearance: none; box-sizing: border-box; width: 16px; height: 16px; margin-top: -6px; border: 2px solid var(--pixel-ink); background: var(--pixel-thumb); box-shadow: inset -2px -2px 0 var(--pixel-button-shade); border-radius: 0; }
input[type=range]::-moz-range-thumb { box-sizing: border-box; width: 16px; height: 16px; border: 2px solid var(--pixel-ink); background: var(--pixel-thumb); box-shadow: inset -2px -2px 0 var(--pixel-button-shade); border-radius: 0; }

/* panels: hard 2 px ink frame and a flat offset shadow */
.card { border: 2px solid var(--pixel-ink); border-radius: 0; box-shadow: 4px 4px 0 var(--pixel-shadow); }
.suggest { border-radius: 0 !important; border: 2px solid var(--pixel-ink) !important; box-shadow: 4px 4px 0 var(--pixel-shadow) !important; }
.tl-view { border: 2px solid var(--pixel-ink); border-radius: 0; box-shadow: inset 3px 3px 0 var(--pixel-well-shade); }
.tl-load, .tl-coord { border-radius: 0; border: 2px solid var(--pixel-ink); }
.tl-bar .btn { min-width: 40px; justify-content: center; }

/* region page: the location map fills its card, which is stretched to the height of the stats column */
.region-top > .card:first-child { display: flex; flex-direction: column; }
.region-top > .card:first-child .mapwrap { flex: 1; display: flex; flex-direction: column; min-height: 260px; }
.region-top > .card:first-child .mapcv { flex: 1; height: auto; min-height: 260px; }


/* activity heatmap */
.heat { overflow-x: auto; }
.heat table { border-collapse: separate; border-spacing: 2px; width: 100%; min-width: 560px; }
.heat th { font-size: 11px; font-weight: 500; color: var(--muted); text-align: left; padding: 0 4px 0 0; white-space: nowrap; }
.heat thead th { text-align: left; padding: 0; }
.heat td { height: 18px; background: color-mix(in oklab, var(--p) calc(var(--a) * 100%), var(--b3)); }
.heat td:hover { outline: 2px solid var(--pixel-ink); }

/* icon inside a header square: centred, no inline spacing */
.avatar .ic { margin: 0; width: 34px; height: 34px; vertical-align: 0; display: block; }

/* region control bar */
.cbar { display: flex; height: 28px; border: 2px solid var(--pixel-ink); overflow: hidden; }
.cbar span { min-width: 2px; }
.clegend { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; font-size: 13px; }
.clegend li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.clegend i { width: 12px; height: 12px; flex: none; border: 1px solid var(--pixel-ink); }
.clegend b { margin-left: auto; }

.avatar.flagav { background: var(--b3); font-size: 38px; }

/* chart view switcher */
.cmodes { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin: -4px 0 8px; }
.cmodes button { font: 600 11px var(--pixel); color: var(--muted); background: var(--pixel-well); border: 2px solid transparent; padding: 2px 8px; cursor: pointer; }
.cmodes button:hover { color: var(--bc); }
.cmodes button.on { color: var(--pixel-title); background: var(--b1); border-color: var(--pixel-ink); box-shadow: inset -2px -2px 0 var(--pixel-well-shade); }

/* paged lists */
[data-pi][hidden] { display: none !important; }
.pmore { padding: 8px 0 2px; }
ul.paged { list-style: none; padding-left: 0; margin: 0; }

/* status page */
.badge.err { background: color-mix(in oklab, var(--error) 20%, var(--b1)); color: var(--error); }
.statusbanner { border-left-width: 8px; }
.statusbanner.ok { border-left-color: var(--success); } .statusbanner.warn { border-left-color: var(--warning); } .statusbanner.err { border-left-color: var(--error); }
.sb-title { display: flex; align-items: center; gap: 10px; font-size: 22px; }
.dot { width: 14px; height: 14px; display: inline-block; border: 2px solid var(--pixel-ink); }
.dot.ok { background: var(--success); } .dot.warn { background: var(--warning); } .dot.err { background: var(--error); }

/* compare page */
.cmp-pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 4px 0 16px; }
.vs { font-family: var(--pixel); color: var(--muted); }
.picker { position: relative; display: flex; align-items: center; gap: 8px; }
.picker .input { flex: 1; min-width: 0; padding: 8px 10px; }
.picker .suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 320px; overflow: auto; }
.pdot { width: 12px; height: 12px; flex: none; display: inline-block; border: 2px solid var(--pixel-ink); margin-right: 6px; vertical-align: -1px; }
.picker .pdot { margin: 0; }
table.cmp { width: 100%; border-collapse: collapse; }
table.cmp th, table.cmp td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.cmp tbody th { font-weight: 500; color: var(--muted); width: 34%; }
table.cmp thead th { font-family: var(--pixel); font-size: 16px; }
table.cmp td { font-variant-numeric: tabular-nums; }
.cwin { font-weight: 700; color: var(--success); }
@media (max-width: 640px) { .cmp-pick { grid-template-columns: 1fr; } .vs { text-align: center; } }

/* notifications / account */
.nt-rules { display: grid; gap: 8px; margin-bottom: 14px; }
.nt-rule { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 2px solid var(--line); background: var(--b1); }
.nt-rule.off { opacity: .55; } .nt-rule .grow { flex: 1; min-width: 0; } .small { font-size: 12px; }
.nt-add { margin: 6px 0 12px; max-width: 420px; }
.nt-editor { border: 2px solid var(--pixel-ink, var(--line)); padding: 14px; margin-top: 10px; background: var(--b2); }
.nt-editor h3 { margin: 0 0 4px; font-family: var(--pixel); }
.nt-fields { display: grid; gap: 18px 22px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 16px 0 18px; }
.nt-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.nt-field > label { font-weight: 600; font-size: 13px; color: var(--bc); }
.nt-field .input, .nt-field select, .nt-field input[type=number] { width: 100%; min-width: 0; box-sizing: border-box; }
.nt-field .note { margin: 0; }
.nt-field .nt-chips { margin: 0; }
.nt-checks { display: flex; gap: 12px; flex-wrap: wrap; } .nt-chk { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.nt-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.nt-chip { display: inline-flex; gap: 6px; align-items: center; padding: 2px 4px 2px 10px; background: var(--b3); border: 2px solid var(--pixel-ink, var(--line)); font-size: 13px; }
.nt-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.nt-pickwrap { position: relative; }
.nt-pickres { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: var(--b1); border: 2px solid var(--pixel-ink, var(--line)); max-height: 240px; overflow: auto; box-shadow: 4px 4px 0 var(--pixel-shadow, #0003); }
.nt-pickres button { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: transparent; color: inherit; font: inherit; padding: 7px 10px; cursor: pointer; }
.nt-pickres button:hover { background: var(--b2); }

/* user menu */
.usr-box { position: relative; display: flex; align-items: center; }
.usr-box[hidden] { display: none; }
.usr-btn { border: 2px solid var(--pixel-ink, var(--line)); background: var(--b2); padding: 0; cursor: pointer; display: grid; place-items: center; width: 36px; height: 36px; }
.usr-btn:hover { border-color: var(--p); }
.usr-pic { width: 28px; height: 28px; display: block; }
.usr-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 250px; background: var(--b1); border: 2px solid var(--pixel-ink, var(--line)); box-shadow: 4px 4px 0 var(--pixel-shadow, #0003); z-index: 1500; padding: 6px; }
.usr-menu[hidden] { display: none; }
.usr-menu .usr-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px 10px; border-bottom: 2px solid var(--line); margin-bottom: 4px; }
.usr-menu .usr-head .usr-pic, .usr-menu .usr-head .avatar { width: 36px; height: 36px; flex: none; }
.usr-menu button { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; border: 0; background: transparent; color: inherit; font: inherit; padding: 8px 10px; cursor: pointer; }
.usr-menu button:hover { background: var(--b2); }
@media (max-width: 640px) { #userbox .lbl { display: none; } }

/* notification window: one frame, a fixed title bar, and a body that scrolls inside it (the scrollbar never crosses the border) */
.modal-box.win { display: flex; flex-direction: column; padding: 0; overflow: hidden; width: min(860px, 100%); max-height: min(92vh, 920px); border-radius: var(--r-box); }
.modal-box.win .modal-head { flex: none; padding: 10px 14px 10px 18px; border-bottom: 2px solid var(--line); background: var(--b2); }
.modal-box.win .modal-head h2 { margin: 0; font-family: var(--pixel); font-size: 20px; display: flex; gap: 8px; align-items: center; }
.modal-box.win .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px 18px 6px; scrollbar-width: thin; scrollbar-color: var(--pixel-button-frame, #8090a8) transparent; scrollbar-gutter: stable; }
.modal-box.win .modal-body::-webkit-scrollbar { width: 10px; }
.modal-box.win .modal-body::-webkit-scrollbar-thumb { background: var(--pixel-button-frame, #8090a8); border: 2px solid var(--b1); }
.modal-box.win .modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-box.win .card { border: 0; box-shadow: none; background: transparent; padding: 0; margin: 0 0 22px; }
.modal-box.win .card h2 { font-size: 18px; margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.modal-box.win .nt-rule { flex-wrap: wrap; }
.modal-box.win .nt-rule .grow { flex: 1 1 220px; }
.modal-box.win .nt-pickres { position: static; margin-top: 4px; max-height: 200px; box-shadow: none; }
.modal-box.win .nt-editor { margin-top: 12px; }
.modal-box.win .callout { margin: 10px 0; }
.modal-box.win details summary { cursor: pointer; margin: 6px 0; }
.modal-box.win select.input, .modal-box.win .nt-add { max-width: 100%; }
[data-theme] .modal-box.win { border: 2px solid var(--pixel-ink); box-shadow: 6px 6px 0 var(--pixel-shadow); border-radius: 0; }

.modal-box.win .modal-body { padding: 20px 24px 8px; }
.modal-box.win .card { margin: 0 0 30px; }
.modal-box.win .card h2 { margin: 0 0 14px; }
.modal-box.win .nt-rules { gap: 10px; margin-bottom: 18px; }
.modal-box.win .nt-rule { padding: 12px 14px; gap: 14px; }
.modal-box.win .nt-add { margin: 4px 0 16px; }
.modal-box.win .nt-editor { padding: 18px 20px; margin-top: 16px; }
.modal-box.win .nt-editor h3 { margin-bottom: 6px; }
.modal-box.win .nt-editor > p:last-child { margin: 4px 0 0; display: flex; gap: 10px; }
.modal-box.win .note { line-height: 1.45; }
.modal-box.win .form { gap: 10px; margin: 12px 0; }
.modal-box.win .card > p { margin: 14px 0 0; }
.modal-box.win .callout + p { margin-top: 14px; }

.usr-menu button.danger { color: var(--error); }

body.locked .links, body.locked .searchwrap { display: none; }
.wh-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.wh-rule { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 2px solid var(--line); }
.wh-rule:last-child { border-bottom: 0; } .wh-rule .grow { flex: 1; min-width: 0; }
code { font-family: var(--mono); }

/* ===================================================================== phones, tablets and touch */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.tbl td .cv { display: contents; }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } * { scroll-behavior: auto !important; } }

/* safe areas (notches, home indicator) */
.nav { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); padding-top: max(10px, env(safe-area-inset-top)); }
main { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
.toast { bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px)); }

@media (max-width: 900px) {
  .nav { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .brand span { font-size: 20px; }
  .searchwrap { order: 4; flex: 1 1 100%; margin-left: 0; }
  .suggest { max-height: 60vh; max-height: 60dvh; }
  .usr-menu { width: min(92vw, 320px); }
  .hero { flex-wrap: wrap; }
  .hero-actions { width: 100%; }
}

/* tables turned into cards: the cell content is one block, never a row of squeezed pieces */
@media (max-width: 640px) {
  .tbl td .cv { display: block; min-width: 0; overflow-wrap: anywhere; text-align: right; }
  .tbl td.grow .cv { text-align: left; }
  .tbl td[style*="min-width"], .tbl td.grow { min-width: 0 !important; width: 100%; }
  .tbl td { align-items: flex-start; }
  .tbl td .wh-actions { justify-content: flex-end; }
  .tbl td::before { padding-top: 2px; max-width: 40%; }
  .card, .card.flat { border-radius: var(--r-box); }
  .tabs { max-width: 100%; }
  .toolbar { gap: 8px; }
  .toolbar .field, .field { flex-wrap: wrap; }
  /* sheets instead of floating windows */
  .modal { padding: 0; align-items: end; place-items: end stretch; }
  .modal-box, .modal-box.win { width: 100%; max-width: none; max-height: 94vh; max-height: 94dvh; border-radius: 16px 16px 0 0 !important; }
  .modal-box.win { height: 94vh; height: 94dvh; }
  .modal-box.win .modal-body { padding: 14px 14px 6px; }
  .modal-box.win .modal-head { padding: 10px 12px 10px 14px; }
  .nt-fields { grid-template-columns: 1fr; }
  .modal-box.win .nt-editor { padding: 14px; }
  .toast { max-width: calc(100vw - 24px); text-align: center; }
}

/* fingers: comfortable targets, and inputs that do not make iOS zoom in */
@media (pointer: coarse), (max-width: 900px) {
  .btn { min-height: 40px; }
  .btn-sm { min-height: 38px; padding: 6px 14px; }
  .links a { padding: 10px 14px; }
  .tabs a, .tabs button { padding: 9px 14px; min-height: 40px; }
  select, .input, #q, textarea, input[type=search], input[type=text], input[type=number] { font-size: 16px; min-height: 42px; }
  .nt-field .input, .nt-field select { min-height: 44px; }
  .nt-chk, label.nt-sw { min-height: 40px; }
  .nt-chk input, label.nt-sw input, input[type=checkbox] { width: 20px; height: 20px; }
  .nt-chip button { min-width: 32px; min-height: 32px; font-size: 20px; }
  .usr-menu button { min-height: 46px; }
  .usr-btn { width: 42px; height: 42px; }
  #themeBtn { min-width: 42px; min-height: 42px; }
  .nt-pickres button { min-height: 46px; }
  .info { min-width: 28px; min-height: 28px; }
  th.sortable { padding-top: 12px; padding-bottom: 12px; }
}
@media (hover: none) { .info { cursor: pointer; } }

@media (pointer: coarse), (max-width: 900px) {
  .cmodes { gap: 6px; }
  .cmodes button { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .slider { min-height: 36px; }
  input[type=checkbox], input[type=radio] { min-width: 20px; min-height: 20px; }
}

/* map list: a very long name must wrap inside its own column and never squeeze the number next to it */
.maplist a { grid-template-columns: minmax(0, 1fr) auto; }
.maplist .mlbl { min-width: 0; overflow-wrap: anywhere; }
.maplist .mono { white-space: nowrap; }

/* names come from the game and can be long and without spaces: a cell that holds a name wraps it inside the cell instead of stretching the page.
   Numbers, dates and headers keep their single line. */
td:has(a):not(.n), td:has(.namecell), td:has(.nm), td:has(b):not(.n), td.grow { white-space: normal; overflow-wrap: anywhere; }
td:has(a):not(.n):not(.grow), td:has(.namecell), td:has(.nm) { min-width: 8em; }
table.cmp { table-layout: fixed; }
table.cmp th, table.cmp td { white-space: normal; overflow-wrap: anywhere; }
td.ui-wrap, th.ui-wrap { white-space: normal; overflow-wrap: anywhere; min-width: 8em; }
.tbl, .card.flat { max-width: 100%; }
