*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #000;
  color: #e0e0e0;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 300;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  text-align: center;
  padding: 1.2rem 1rem 0.8rem;
}

.wordmark {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: #999;
  margin-bottom: 0.2rem;
}

.wordmark-sub {
  font-weight: 400;
  font-size: 1.2rem;
  color: #888;
  margin-bottom: 0.3rem;
}

header p {
  opacity: 0.5;
  font-size: 0.85rem;
}

/* ── Site nav ── compact, top, square, white border ── */
.site-nav {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
  padding: 0.35rem 0.8rem;
  background: #000;
  border: 2px solid #fff;
  width: fit-content;
  max-width: 95vw;
  margin: 0 auto 1rem;
  flex-wrap: wrap;
}

.site-nav .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #ccc;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 400;
  padding: 0.3rem 0.7rem;
  border: 1px solid #555;
  transition: all 0.15s ease;
}

.site-nav .back-link:hover {
  border-color: #fff;
  color: #fff;
}

.site-nav .back-link .arrow {
  font-size: 0.85rem;
}

/* ── Divider ── */
.divider {
  height: 3px;
  margin: 0.5rem auto 1.5rem;
  width: 100%;
  max-width: 600px;
  background: #fff;
  opacity: 0.4;
}

/* Tip bubble */
.tip-bubble {
  display: inline-block;
  background: #000;
  border: 1px solid #555;
  padding: 0.3rem 1rem;
  margin: 0 auto 0.5rem;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
}

main {
  width: 100%;
  max-width: 900px;
  padding: 0 1rem 3rem;
  flex: 1;
}

/* ── Card grid ── momoura-style: horizontal cards, white border ── */
#card-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 80%;
  margin: 0 auto;
}

.card {
  background: #000;
  display: flex;
  border: 2px solid #fff;
  /* no border-radius — square, retro */
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: #aaa;
}

.card img {
  max-width: 200px;
  width: auto;
  height: auto;
  display: block;
  cursor: pointer;
  background: #000;
  flex-shrink: 0;
  object-fit: contain;
}

.card-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card h3 {
  font-weight: 500;
  margin-bottom: 0.6rem;
  font-size: 1.2rem;
  color: #fff;
}

.card p {
  opacity: 0.8;
  font-size: 0.88rem;
  margin-bottom: 0.8rem;
  line-height: 1.6;
}

.card .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0;
}

.card .tag {
  background: #000;
  color: #999;
  padding: 0.15rem 0.5rem;
  border: 1px solid #555;
  font-size: 0.7rem;
}

/* NSFW */
.card.nsfw {
  position: relative;
}

.card.nsfw::before {
  content: "NSFW";
  position: absolute;
  top: 8px;
  right: 8px;
  background: #000;
  color: #faa;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border: 1px solid #faa;
  z-index: 2;
  pointer-events: none;
}

.card.nsfw img.blurred {
  filter: blur(16px);
  cursor: pointer;
  transition: filter 0.3s ease;
}

.card.nsfw img.revealed {
  filter: none;
}

.error {
  text-align: center;
  padding: 3rem 1rem;
  opacity: 0.7;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.3s, opacity 0.3s;
}

.lightbox.active {
  visibility: visible;
  opacity: 1;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 2rem;
  cursor: pointer;
}

footer {
  text-align: center;
  padding: 1.5rem;
  opacity: 0.5;
  font-size: 0.8rem;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #000;
}

::-webkit-scrollbar-thumb {
  background: #1a1a1a;
}

/* ── Search ── square, retro ── */
.search-wrapper {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 1rem;
  padding: 0 1rem;
}

.search-bar {
  display: block;
  width: 100%;
  padding: 0.5rem 0.8rem;
  background: #000;
  border: 2px solid #555;
  color: #e0e0e0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-bar::placeholder {
  color: #555;
}

.search-bar:focus {
  border-color: #fff;
}

/* ── Guide page ── */
.guide-page {
  align-items: flex-start;
}

.guide-content {
  max-width: 720px;
  margin: 0 auto;
}

.guide-content section {
  margin-bottom: 2.5rem;
}

.guide-content h2 {
  font-weight: 500;
  font-size: 1.4rem;
  margin-bottom: 0.8rem;
  color: #fff;
}

.guide-content p {
  opacity: 0.85;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  line-height: 1.7;
}

.guide-content a {
  color: #ccc;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.guide-content a:hover {
  color: #fff;
}

.guide-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid #555;
}

.guide-nav .back-link,
.guide-content .back-link,
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.5rem 1.2rem;
  border: 2px solid #555;
  transition: all 0.15s ease;
}

.guide-nav .back-link:hover,
.guide-content .back-link:hover,
.back-link:hover {
  border-color: #fff;
  color: #fff;
}

.back-link .arrow {
  font-size: 1rem;
  transition: transform 0.15s ease;
}

.back-link:hover .arrow {
  transform: translateX(-4px);
}

/* Quick Start */
.quick-start {
  background: #000;
  border: 2px solid #555;
  padding: 1.5rem;
  margin-bottom: 2.5rem;
}

.quick-start h2 {
  margin-bottom: 1rem;
}

.quick-start .link-group {
  margin-bottom: 1.2rem;
}

.quick-start .link-group:last-child {
  margin-bottom: 0;
}

.quick-start .link-label {
  display: inline-block;
  background: #000;
  color: #aaa;
  padding: 0.1rem 0.5rem;
  border: 1px solid #555;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.quick-start .link-label.required {
  color: #ccc;
  border-color: #888;
}

.quick-start .link-label.optional {
  color: #aaa;
}

.quick-start ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-start ul li a {
  display: inline-block;
  color: #ccc;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid #555;
  transition: all 0.15s ease;
}

.quick-start ul li a:hover {
  border-color: #fff;
  color: #fff;
}

/* Webring widget in nav */
.webring-container {
  flex-shrink: 0;
}

/* ── Mobile ── */
@media (max-width: 600px) {
  .site-nav .back-link:not(:first-of-type) {
    display: none;
  }

  header {
    padding: 1rem 0.8rem 0.5rem;
  }

  .wordmark {
    font-size: 1.4rem;
  }

  .guide-content {
    padding: 0 1.2rem 2rem;
  }

  .card {
    flex-direction: column;
  }

  .card img {
    max-width: 100%;
    width: 100%;
  }

  .card-content {
    padding: 12px 14px;
  }

  #card-grid {
    max-width: 95%;
  }
}

/* ── Chaos Button ── square retro ── */
.chaos-button {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  background: #000;
  color: #888;
  border: 2px solid #555;
  padding: 0.35rem 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.chaos-button:hover {
  border-color: #fff;
  color: #fff;
}

.chaos-button.active {
  opacity: 0.5;
  pointer-events: none;
}

/* Word fragments for chaos effects */
.word-fragment {
  display: inline-block;
  white-space: pre;
  position: relative;
  transition: none;
}

.guide-content.chaos-active {
  position: relative;
}

@keyframes rainbow-cycle {
  0%   { color: #ff0000; }
  16%  { color: #ff8800; }
  33%  { color: #ffff00; }
  50%  { color: #00ff00; }
  66%  { color: #0088ff; }
  83%  { color: #8800ff; }
  100% { color: #ff0000; }
}

@keyframes melt-drip {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  60%  { transform: translateY(60px) rotate(15deg); opacity: 0.6; }
  100% { transform: translateY(150px) rotate(30deg); opacity: 0; }
}

@keyframes glitch-flicker {
  0%   { transform: translate(0); opacity: 1; }
  10%  { transform: translate(-3px, 2px); opacity: 0.8; }
  20%  { transform: translate(3px, -1px); opacity: 1; }
  30%  { transform: translate(-1px, -3px); opacity: 0.5; }
  40%  { transform: translate(2px, 1px); opacity: 0.9; }
  50%  { transform: translate(-2px, -2px); opacity: 0.3; }
  60%  { transform: translate(0); opacity: 1; }
  70%  { transform: translate(3px, 3px); opacity: 0.7; }
  80%  { transform: translate(-3px, 1px); opacity: 1; }
  90%  { transform: translate(1px, -1px); opacity: 0.4; }
  100% { transform: translate(0); opacity: 1; }
}

@keyframes shred-tear {
  0%   { transform: skew(0deg, 0deg) rotate(0deg); clip-path: inset(0 0 0 0); }
  25%  { transform: skew(15deg, -5deg) rotate(8deg); clip-path: inset(10% 5% 0 0); }
  50%  { transform: skew(-10deg, 8deg) rotate(-5deg); clip-path: inset(0 0 15% 5%); }
  75%  { transform: skew(25deg, 3deg) rotate(12deg); clip-path: inset(5% 10% 5% 0); }
  100% { transform: skew(0deg, 0deg) rotate(0deg); clip-path: inset(0 0 0 0); }
}

/* ── Download buttons ── */
.download-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #aaa;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.25rem 0.7rem;
  border: 1px solid #555;
  transition: all 0.15s ease;
  cursor: pointer;
}

.dl-btn:hover {
  border-color: #fff;
  color: #fff;
}

.dl-btn::before {
  content: '⬇';
  font-size: 0.65rem;
}

.download-all-wrapper {
  width: 100%;
  max-width: 400px;
  margin: 0 auto 1.2rem;
  padding: 0 1rem;
  display: flex;
  justify-content: center;
}

.download-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #ccc;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.55rem 1.5rem;
  border: 2px solid #555;
  transition: all 0.15s ease;
}

.download-all-btn:hover {
  border-color: #fff;
  color: #fff;
}

.download-all-btn .dl-icon {
  font-size: 0.9rem;
}

/* ── Changelog sidebar ── */
.changelog-toggle {
  position: fixed;
  bottom: 4.5rem;
  right: 1.5rem;
  z-index: 1001;
  background: #000;
  color: #888;
  border: 2px solid #555;
  padding: 0.3rem 0.7rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.changelog-toggle:hover {
  border-color: #fff;
  color: #fff;
}

.changelog-box {
  position: fixed;
  top: 0;
  right: 0;
  width: 240px;
  height: 100vh;
  background: #000;
  border-left: 2px solid #555;
  z-index: 1000;
  overflow-y: auto;
  padding: 1.2rem 1rem;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.changelog-box.open {
  transform: translateX(0);
}

.changelog-box h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #333;
}

.changelog-entry {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #1a1a1a;
}

.changelog-entry:last-child {
  border-bottom: none;
}

.changelog-date {
  font-size: 0.6rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}

.changelog-msg {
  font-size: 0.72rem;
  color: #999;
  line-height: 1.4;
}

.changelog-box::-webkit-scrollbar {
  width: 4px;
}

.changelog-box::-webkit-scrollbar-thumb {
  background: #1a1a1a;
}

/* ── Old version notice ── */
.stale-warning {
  background: #000;
  border: 1px solid #555;
  color: #777;
  text-align: center;
  padding: 0.35rem 1rem;
  font-size: 0.7rem;
  margin: 0 auto 0.5rem;
  max-width: 500px;
  width: fit-content;
  line-height: 1.4;
}

.stale-warning code {
  background: #111;
  padding: 0.1rem 0.3rem;
  font-size: 0.65rem;
  color: #999;
}
