:root {
  --bg: #121416;
  --bg-raised: #1b1e21;
  --bg-card: #202428;
  --line: #2e3338;
  --text: #e9ecef;
  --text-dim: #9aa3ab;
  --accent: #6cc24a;      /* grass */
  --accent-dark: #3f7d2a;
  --dirt: #7a5233;
  --nether: #d8553f;
  --end: #b68ce0;
  --radius: 6px;
  --gutter: 16px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

body.no-scroll { overflow: hidden; }

a { color: var(--accent); }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- header ------------------------------------------------------------------ */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(18, 20, 22, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.top::before {
  /* grass and dirt strip, crisp pixels */
  content: "";
  display: block;
  height: 6px;
  background:
    linear-gradient(90deg, var(--accent) 0 12px, var(--accent-dark) 12px 16px, var(--accent) 16px 28px, #58a83a 28px 32px) 0 0 / 32px 4px repeat-x,
    var(--dirt);
}

.top-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px var(--gutter) 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-block {
  flex: none;
  width: 32px;
  height: 32px;
  background: url("/static/favicon.svg") center / cover;
  image-rendering: pixelated;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 19px; letter-spacing: 0.01em; }
.brand-sub { color: var(--text-dim); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

.counter { margin: 0; color: var(--text-dim); font-size: 13px; white-space: nowrap; }

.filters {
  max-width: 1600px;
  margin: 0 auto;
  padding: 6px var(--gutter) 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover { color: var(--text); border-color: #454b52; }
.chip.is-active { background: var(--accent-dark); border-color: var(--accent); color: #fff; }
.chip .count { font-size: 12px; opacity: 0.75; font-variant-numeric: tabular-nums; }

/* --- grid -------------------------------------------------------------------- */

main { max-width: 1600px; margin: 0 auto; padding: var(--gutter); }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}

.tile { position: relative; }

.tile-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 16 / 9;
  position: relative;
}

.tile-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s, transform 0.4s ease;
}
.tile-button img.is-loaded { opacity: 1; }
.tile-button:hover img { transform: scale(1.03); }

.tile-meta {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 24px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  color: #fff;
  font-size: 13px;
  text-align: left;
  pointer-events: none;
}
.tile-meta .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta .when { margin-left: auto; opacity: 0.8; white-space: nowrap; font-size: 12px; }

.avatar {
  flex: none;
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 2px;
  background: #3a3f45;      /* while loading */
  image-rendering: pixelated;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.avatar-sm { width: 16px; height: 16px; border-radius: 2px; }

.dim-dot {
  width: 8px; height: 8px; border-radius: 2px; flex: none;
  background: var(--accent);
}
.dim-dot.nether { background: var(--nether); }
.dim-dot.end { background: var(--end); }
.dim-dot.other { background: #c9a84a; }

.status { text-align: center; color: var(--text-dim); margin: 32px 0; min-height: 1.5em; }
.status .button { margin-top: 12px; }
.sentinel { height: 1px; }

.skeleton .tile-button { cursor: default; background: linear-gradient(100deg, var(--bg-card) 40%, #2a2f34 50%, var(--bg-card) 60%) 0 0 / 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- large view -------------------------------------------------------------- */

.viewer { position: fixed; inset: 0; z-index: 100; }
.viewer[hidden] { display: none; }

.viewer-backdrop { position: absolute; inset: 0; background: rgba(6, 7, 8, 0.94); }

.viewer-body {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.viewer-stage {
  position: relative;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 0;
  touch-action: pan-y;
}

.viewer-stage img {
  width: auto;
  height: auto;
  object-fit: contain;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s;
}
.viewer-stage img.is-loading { opacity: 0.35; }

.viewer-spinner {
  position: absolute;
  width: 28px; height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.viewer-spinner.is-on { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 64px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}
.nav:hover { opacity: 1; background: rgba(0, 0, 0, 0.7); }
.nav[disabled] { visibility: hidden; }
.nav-prev { left: 12px; }
.nav-next { right: 12px; }

.viewer-info {
  background: var(--bg-raised);
  border-left: 1px solid var(--line);
  padding: 20px;
  overflow-y: auto;
}

.viewer-head { display: flex; align-items: center; gap: 12px; }
.viewer-head .avatar { width: 40px; height: 40px; border-radius: 3px; }
.viewer-head h2 { margin: 0; font-size: 18px; line-height: 1.2; word-break: break-word; }
.viewer-head time { color: var(--text-dim); font-size: 13px; }

.close {
  margin-left: auto;
  align-self: flex-start;
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.close:hover { background: var(--bg-card); }

.caption { margin: 18px 0 0; font-size: 16px; white-space: pre-wrap; word-break: break-word; }
.caption:empty { display: none; }

.facts {
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  font-size: 14px;
}
.facts dt { color: var(--text-dim); }
.facts dd { margin: 0; display: flex; align-items: center; gap: 6px; word-break: break-word; }
.facts .mono { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }

.button {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--accent-dark);
  border: 1px solid var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.button:hover { background: #4b9433; }
.button-ghost { background: transparent; border-color: var(--line); color: var(--text); box-shadow: none; }
.button-ghost:hover { background: var(--bg-card); }

/* --- phone ------------------------------------------------------------------- */

@media (max-width: 860px) {
  .viewer-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
  .viewer-stage { padding: 56px 0 12px; }
  .viewer-stage img { max-height: 62vh; border-radius: 0; }
  .viewer-info { border-left: 0; border-top: 1px solid var(--line); }
  .nav { width: 38px; height: 52px; font-size: 28px; }
  .nav-prev { left: 6px; }
  .nav-next { right: 6px; }
  .viewer-head .close { position: fixed; top: 10px; right: 10px; background: rgba(0, 0, 0, 0.6); }
}

@media (max-width: 520px) {
  .grid { gap: 8px; }
  .brand-title { font-size: 17px; }
  .counter { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
