:root,
[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0a0a0a;
  --bg-card: #111111;
  --bg-input: #0c0c0c;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(225, 6, 0, 0.55);
  --text: #f7f7f7;
  --muted: #9a9a9a;
  --accent: #e10600;
  --accent-strong: #ff1f14;
  --accent-soft: rgba(225, 6, 0, 0.14);
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #e10600;
  --chip-bg: rgba(0, 0, 0, 0.55);
  --code-bg: #050505;
  --glass: rgba(10, 10, 10, 0.82);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --radius-lg: 28px;
  --radius-xl: 36px;
  --radius-pill: 999px;
  --font: 'Fredoka', system-ui, sans-serif;
  --display: 'Fredoka', system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --status-working: #22c55e;
  --status-update: #f59e0b;
  --status-patched: #e10600;
  --invert: #e10600;
  --invert-text: #ffffff;
}

[data-theme="light"] {
  --bg: #f2f2f2;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(225, 6, 0, 0.45);
  --text: #0a0a0a;
  --muted: #666666;
  --accent: #e10600;
  --accent-strong: #c10500;
  --accent-soft: rgba(225, 6, 0, 0.1);
  --chip-bg: rgba(255, 255, 255, 0.9);
  --code-bg: #0a0a0a;
  --glass: rgba(255, 255, 255, 0.9);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
  --invert: #e10600;
  --invert-text: #ffffff;
}

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

html {
  scroll-behavior: smooth;
}

::selection {
  background: var(--accent);
  color: #fff;
}

[data-theme="light"] ::selection {
  background: var(--accent);
  color: #fff;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  background: var(--bg);
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 45% at 15% -5%, rgba(225, 6, 0, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 10%, rgba(225, 6, 0, 0.1), transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 100%, rgba(225, 6, 0, 0.06), transparent 60%);
}

[data-theme="light"] .atmosphere {
  background:
    radial-gradient(ellipse 70% 45% at 15% -5%, rgba(225, 6, 0, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 10%, rgba(225, 6, 0, 0.06), transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 100%, rgba(225, 6, 0, 0.04), transparent 60%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(225, 6, 0, 0.45);
  border-radius: var(--radius-pill);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(225, 6, 0, 0.35);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  z-index: 2;
}

.lang-btn {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: #1c1c1c;
  color: #fff;
  min-width: 3rem;
  height: 2.25rem;
  padding: 0 0.9rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: var(--radius-pill);
  transition: 0.2s var(--ease);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.lang-btn.is-active,
.lang-btn:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(225, 6, 0, 0.35);
}

[data-theme="light"] .lang-btn {
  background: #fff;
  color: #111;
  border-color: rgba(0, 0, 0, 0.2);
}

button,
input,
textarea,
select {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* —— Topbar —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.35rem;
  margin: 0.75rem auto 0;
  width: min(1120px, calc(100% - 1.5rem));
  background: color-mix(in srgb, var(--glass) 92%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1 1 0;
  padding-right: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-self: start;
  flex-shrink: 0;
}

.topbar > .lang-switch {
  justify-self: start;
}

.brand-logo {
  height: 2.35rem;
  width: auto;
  display: block;
  border-radius: 12px;
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 14px;
}

.brand-text {
  font-size: 1.45rem;
  font-family: var(--display);
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 0.15rem;
  justify-content: center;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  position: static;
  transform: none;
  max-width: none;
  margin: 0;
  padding: 0.15rem;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 4%, transparent);
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 1;
}

.nav::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 0.5rem 0.95rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: var(--font);
  text-transform: uppercase;
  border: 0;
  border-radius: var(--radius-pill);
  transition: 0.2s var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-link.is-active {
  color: #fff;
  background: var(--accent);
}

.top-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex: 1 1 0;
  flex-wrap: nowrap;
  min-width: max-content;
  margin-left: 0;
  flex-shrink: 0;
  justify-content: flex-end;
}

.live-stats {
  display: flex;
  gap: 0.4rem;
  margin-right: 0.35rem;
  flex-shrink: 1;
}

.stat-pill {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.32rem 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
}

.stat-pill b {
  color: var(--text);
  font-weight: 700;
}

.icon-btn {
  width: 2.45rem;
  height: 2.45rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.2s;
  border-radius: var(--radius-pill);
}

.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

.icon-btn svg {
  width: 1.05rem;
  height: 1.05rem;
}

[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon {
  display: none;
}

.btn {
  border: 1px solid transparent;
  min-height: 2.5rem;
  padding: 0.55rem 1.15rem;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: 0.2s var(--ease);
  border-radius: var(--radius-pill);
  font-family: var(--display);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.lang-btn:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(225, 6, 0, 0.28);
}

.btn.primary:hover {
  background: var(--accent-strong);
  opacity: 1;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn.ghost:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(225, 6, 0, 0.4);
}

.btn.sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.72rem;
}

.btn.full {
  width: 100%;
}

.btn.is-active {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

main {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 4rem;
}

.view {
  display: none;
  animation: rise 0.45s var(--ease) both;
}

.view.is-visible {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* —— Hero composition —— */
.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 2rem;
  align-items: end;
  min-height: min(58vh, 520px);
  padding: 2.5rem 0 1.5rem;
  border-bottom: 0;
}

.hero-copy {
  animation: rise 0.5s var(--ease) both;
}

.hero-eyebrow {
  margin: 0 0 1rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-brand {
  margin: 0;
  line-height: 0;
}

.hero-logo {
  width: min(100%, clamp(11rem, 34vw, 20rem));
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 40px rgba(225, 6, 0, 0.25));
}

.hero-sub {
  margin: 1.25rem 0 0;
  max-width: 22rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.35rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  animation: rise 0.55s 0.05s var(--ease) both;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  border-radius: var(--radius-pill);
}

.status-chip:hover,
.status-chip.is-active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}

.swatch {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.swatch.working {
  background: var(--status-working);
  box-shadow: 0 0 8px var(--status-working);
}

.swatch.update {
  background: var(--status-update);
  box-shadow: 0 0 8px var(--status-update);
}

.swatch.patched {
  background: var(--status-patched);
  box-shadow: 0 0 8px var(--status-patched);
}

.search-wrap {
  position: relative;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-input);
  transition: 0.2s;
  border-radius: var(--radius-pill);
}

.search-bar:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--muted);
  flex-shrink: 0;
}

.search-icon svg,
.filter-toggle svg {
  width: 100%;
  height: 100%;
}

.search-bar input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 0.65rem 0.35rem;
  min-width: 0;
}

.suggest-box {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  z-index: 20;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.suggest-item {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.suggest-item:hover {
  background: var(--accent-soft);
}

.suggest-type {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.strict-toggle,
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.strict-toggle input,
.check-inline input {
  accent-color: var(--text);
}

kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
}

.filters-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.filters-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.filters-row select {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  min-width: 8.5rem;
}

/* —— Info rail —— */
.rail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 1.75rem 0 2rem;
  border: 1px solid var(--border);
}

.rail-item {
  display: flex;
  gap: 0.9rem;
  padding: 1.15rem 1.2rem;
  border-right: 1px solid var(--border);
}

.rail-item:last-child {
  border-right: 0;
}

.rail-k {
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.rail-item strong {
  display: block;
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}

.rail-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.library-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.library-head.tight {
  margin-top: 2.5rem;
}

.section-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.library-head h1,
.library-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface-2, rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}

.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;
}

.games-search-wrap {
  display: block;
  margin: 0 0 1.25rem;
}

.games-search {
  width: 100%;
  max-width: 28rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: var(--surface, rgba(255, 255, 255, 0.04));
  color: inherit;
  font: inherit;
}

.games-search:focus {
  outline: 2px solid rgba(225, 6, 0, 0.45);
  outline-offset: 1px;
}

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

/* —— Cards —— */
.scripts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.script-card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  isolation: isolate;
  transition: transform 0.35s var(--ease), border-color 0.25s, box-shadow 0.25s;
  animation: rise 0.45s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
  border-radius: var(--radius-lg);
}

.script-card:hover {
  transform: translateY(-6px) scale(1.01);
  border-color: var(--border-strong);
  box-shadow: 0 18px 40px rgba(225, 6, 0, 0.18);
}

.script-card .card-under {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #1a1a1a, #000);
  z-index: 0;
}

.script-card img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  opacity: 0.75;
  transition: transform 0.5s var(--ease), filter 0.35s, opacity 0.35s;
}

.script-card:hover img {
  transform: scale(1.06);
  filter: grayscale(0) contrast(1.08);
  opacity: 1;
}

.play-btn {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 3rem;
  height: 3rem;
  margin: -1.5rem 0 0 -1.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #000;
  opacity: 0.85;
  transform: scale(0.92);
  transition: 0.3s var(--ease);
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.play-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  margin-left: 2px;
}

.script-card:hover .play-btn {
  opacity: 1;
  transform: scale(1.05);
}

.detail-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
}

.detail-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.detail-media img[hidden],
.detail-video[hidden] {
  display: none !important;
}

.detail-media:has(.detail-video:not([hidden])) .detail-media-overlay,
.detail-media:has(.detail-video:not([hidden])) .badges {
  z-index: 2;
}

.script-card .shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.12) 50%, transparent 65%);
  transform: translateX(-130%);
  transition: transform 0.65s var(--ease);
  pointer-events: none;
}

.script-card:hover .shine {
  transform: translateX(130%);
}

.script-card .overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.35) 40%, rgba(0, 0, 0, 0.92) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.7rem;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  padding: 0.22rem 0.55rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--chip-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  backdrop-filter: blur(8px);
  border-radius: var(--radius-pill);
}

.card-badges {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
  justify-content: flex-start;
}

.badge {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.22rem 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: var(--radius-pill);
}

.badge.key {
  background: rgba(255, 255, 255, 0.12);
}

.badge.featured {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.badge.status.working {
  background: rgba(34, 197, 94, 0.95);
  border-color: transparent;
  color: #04120a;
}

.badge.status.update {
  background: rgba(245, 158, 11, 0.95);
  border-color: transparent;
  color: #1a0f00;
}

.badge.status.patched {
  background: rgba(239, 68, 68, 0.95);
  border-color: transparent;
  color: #fff;
}

.card-title-wrap {
  color: #fff;
}

.card-game {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.card-title {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  border: 1px dashed var(--border);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.back-link {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-bottom: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
}

.back-link:hover {
  color: var(--text);
}

/* —— Detail —— */
.detail {
  display: grid;
  grid-template-columns: 1.05fr 1.15fr;
  gap: 1.5rem;
  align-items: start;
}

.detail-media {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 11;
  background: #000;
}

.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.4);
}

.detail-media-overlay {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
}

.detail-media .badges {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.detail-body h1 {
  margin: 0.15rem 0 0.75rem;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.game-label {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-desc {
  color: var(--muted);
  margin: 0 0 1rem;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.88rem;
}

.status-banner.working {
  border-color: rgba(34, 197, 94, 0.45);
  color: var(--status-working);
}

.status-banner.update {
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--status-update);
}

.status-banner.patched {
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--status-patched);
}

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

.tag {
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: transparent;
}

.tag:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.detail-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.metric {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.code-block {
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--code-bg);
}

.code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #9a9a9a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  max-height: 400px;
}

.code-block code {
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre;
  color: #e8e8e8;
  line-height: 1.55;
}

.tok-kw {
  color: #fff;
  font-weight: 600;
}

.tok-str {
  color: #b0b0b0;
}

.tok-num {
  color: #d0d0d0;
}

.tok-cm {
  color: #666;
  font-style: italic;
}

.tok-fn {
  color: #f0f0f0;
}

/* —— Auth / Admin —— */
.auth-card,
.admin-wrap {
  width: min(720px, 100%);
  margin: 1.5rem auto 0;
  padding: 1.75rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.auth-card {
  width: min(400px, 100%);
  text-align: left;
}

.auth-card h1,
.admin-wrap h1 {
  margin: 0;
  font-family: var(--display);
  letter-spacing: -0.03em;
}

.admin-wrap.wide {
  width: min(900px, 100%);
}

.admin-tabs {
  display: flex;
  gap: 0;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tab:last-child {
  border-right: 0;
}

.tab.is-active {
  color: var(--invert-text);
  background: var(--invert);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
  animation: rise 0.3s var(--ease);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.form input,
.form textarea,
.form select {
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  padding: 0.7rem 0.8rem;
  outline: none;
  resize: vertical;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
  border-color: var(--border-strong);
}

.code-input {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

.ok {
  color: var(--success);
  font-size: 0.85rem;
  margin: 0;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  background: var(--bg-input);
}

.admin-row strong {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.admin-row span {
  color: var(--muted);
  font-size: 0.76rem;
}

.admin-row .row-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-top: 1px solid var(--border);
}

.footer span:first-child {
  color: var(--text);
  font-family: var(--display);
  font-weight: 700;
  text-transform: none;
  letter-spacing: -0.03em;
  font-size: 0.95rem;
}

.footer-sep {
  opacity: 0.4;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--invert);
  color: var(--invert-text);
  border: 1px solid var(--invert);
  padding: 0.7rem 1.1rem;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: rise 0.3s var(--ease);
}

.mobile-only {
  display: none !important;
}

/* —— Responsive / mobile —— */
@media (max-width: 1100px) {
  .live-stats {
    display: none;
  }
}

@media (max-width: 1100px) {
  .mobile-only {
    display: grid !important;
  }

  body.is-mobile {
    --tap: 44px;
  }

  .topbar {
    width: calc(100% - 0.5rem);
    margin: 0.5rem auto 0;
    padding: 0.55rem 0.7rem;
    gap: 0.45rem;
    border-radius: 22px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    position: relative;
  }

  .topbar-left {
    gap: 0.4rem;
  }

  .brand-logo {
    height: 1.85rem;
  }

  .lang-btn {
    min-width: 2.5rem;
    height: 2rem;
    padding: 0 0.65rem;
    font-size: 0.72rem;
  }

  .nav {
    display: none;
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    right: 0;
    transform: none;
    max-width: none;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.55rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    z-index: 60;
  }

  .nav.is-open {
    display: flex;
  }

  .nav-link {
    width: 100%;
    text-align: left;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
  }

  .top-actions .btn.ghost#btn-login,
  .top-actions .btn.ghost#btn-logout {
    padding: 0.45rem 0.7rem;
    font-size: 0.72rem;
  }

  #btn-menu {
    width: var(--tap, 44px);
    height: var(--tap, 44px);
  }

  main {
    width: min(1200px, calc(100% - 1rem));
    padding: 0.75rem 0 3.5rem;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 1.1rem;
    padding: 1.25rem 0 1rem;
    text-align: center;
  }

  .hero-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .hero-logo {
    width: min(100%, 14rem);
    margin: 0 auto;
  }

  .hero-sub {
    max-width: 28rem;
  }

  .hero-panel {
    padding: 1rem;
  }

  .status-legend {
    justify-content: center;
  }

  .search-bar {
    flex-wrap: wrap;
  }

  .search-btn {
    width: 100%;
  }

  .scripts-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .detail,
  .rail {
    grid-template-columns: 1fr;
  }

  .rail-item {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .rail-item:last-child {
    border-bottom: 0;
  }

  .detail-actions {
    flex-wrap: wrap;
  }

  .detail-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .admin-tabs {
    flex-wrap: wrap;
  }

  .tab {
    flex: 1 1 45%;
    min-height: 44px;
  }

  .admin-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .footer {
    padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
    font-size: 0.78rem;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .topbar-left .lang-switch {
    gap: 0.3rem;
  }

  .live-stats,
  .kbd-hint {
    display: none !important;
  }

  .hero-eyebrow {
    font-size: 0.65rem;
  }

  .rail {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  .btn,
  .nav-link,
  .lang-btn,
  .status-chip,
  .script-card,
  .icon-btn {
    -webkit-tap-highlight-color: transparent;
  }

  .script-card:hover {
    transform: none;
  }

  .script-card:active {
    transform: scale(0.985);
  }
}

/* —— Support —— */
.support-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1.75rem 2.5rem;
  align-items: start;
  padding: 2rem 0 3rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.support-hero {
  grid-column: 1 / -1;
  min-width: 0;
}

.support-hero h1 {
  margin: 0.35rem 0 0.75rem;
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.support-hero .muted {
  max-width: 52ch;
  margin-bottom: 1.25rem;
}

.discord-btn {
  display: inline-flex;
  flex-shrink: 0;
}

.discord-hint {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.discord-widget-panel {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  padding: 1.35rem 1.35rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.discord-widget-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  min-width: 0;
}

.discord-widget-head > div {
  min-width: 0;
  flex: 1 1 14rem;
}

.discord-widget-head h2 {
  margin: 0.25rem 0 0.4rem;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.discord-widget-head .muted {
  margin: 0;
  max-width: 48ch;
}

.discord-widget-panel .discord-hint {
  margin: 0;
}

.support-card {
  border: 1px solid var(--border);
  padding: 1.5rem 1.35rem 1.75rem;
  background: var(--glass);
  backdrop-filter: blur(10px);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

.support-card h2 {
  margin: 0.25rem 0 0.75rem;
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.support-card .form label.full {
  grid-column: 1 / -1;
}

.chat-intro {
  margin: 0 0 1rem;
  font-size: 0.92rem;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.chat-messages {
  min-height: 220px;
  max-height: 340px;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  -webkit-overflow-scrolling: touch;
}

[data-theme="light"] .chat-messages {
  background: rgba(255, 255, 255, 0.55);
}

.chat-bubble {
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid var(--border);
  animation: rise 0.25s var(--ease);
}

.chat-bubble.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--invert);
  color: var(--invert-text);
  border-color: transparent;
}

.chat-bubble.typing {
  opacity: 0.7;
  font-style: italic;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chat-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-chip:hover {
  color: var(--invert-text);
  background: var(--invert);
  border-color: transparent;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
  align-items: stretch;
}

.chat-form input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  padding: 0.7rem 0.8rem;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--border-strong);
}

.chat-mode {
  margin: 0;
  font-size: 0.72rem;
}

.tab-badge {
  display: inline-block;
  margin-left: 0.35rem;
  min-width: 1.15rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--invert);
  color: var(--invert-text);
  font-size: 0.65rem;
  font-weight: 800;
  vertical-align: middle;
}

.report-row .report-message {
  margin: 0.45rem 0 0;
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0.88;
  white-space: pre-wrap;
  line-height: 1.45;
}

.report-type {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.12rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}

.report-type.bug {
  border-color: #ef4444;
  color: #ef4444;
}

.report-type.suggestion {
  border-color: #22c55e;
  color: #22c55e;
}

.report-row.done {
  opacity: 0.55;
}

.footer-logo {
  height: 1.35rem;
  width: auto;
  border-radius: 8px;
  display: block;
}

.topbar,
.support-card,
.hero-panel,
.script-card,
.auth-card,
.admin-wrap,
.detail,
.filters-panel {
  backdrop-filter: blur(6px);
}

/* —— Global rounded UI pass —— */
.count-pill,
.filters-panel,
.rail-item,
.tag,
.form input,
.form textarea,
.form select,
.code-block,
.code-input,
.auth-card,
.admin-tabs,
.tab,
.admin-row,
.detail,
.detail-media,
.status-banner,
.support-card,
.chat-messages,
.chat-bubble,
.chat-chip,
.chat-form input,
.toast,
.report-type {
  border-radius: var(--radius) !important;
}

.filters-panel,
.auth-card,
.support-card,
.code-block,
.detail-media,
.chat-messages {
  border-radius: var(--radius-lg) !important;
}

.chat-bubble.user {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.chat-chip:hover {
  background: var(--accent) !important;
  color: #fff !important;
}

.tab.is-active {
  background: var(--accent) !important;
  color: #fff !important;
}

.footer {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 2rem 1rem 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-sep {
  opacity: 0.4;
}

/* Support responsive — must come after base .support-* rules */
@media (max-width: 1100px) {
  .support-layout {
    grid-template-columns: 1fr;
    gap: 1.15rem;
    padding: 1rem 0 calc(1.75rem + env(safe-area-inset-bottom, 0px));
  }

  .support-hero,
  .discord-widget-panel,
  .support-card {
    grid-column: 1 / -1;
  }

  .support-hero h1 {
    font-size: clamp(1.85rem, 9vw, 2.6rem);
  }

  .support-hero .muted,
  .discord-widget-head .muted,
  .chat-intro {
    max-width: none;
  }

  .discord-widget-panel {
    padding: 1rem;
    gap: 0.85rem;
  }

  .discord-widget-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .discord-widget-head > div {
    flex: 1 1 auto;
  }

  .discord-btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .support-card {
    padding: 1.1rem 1rem 1.35rem;
  }

  .support-card h2 {
    font-size: clamp(1.2rem, 5vw, 1.4rem);
  }

  .chat-messages {
    min-height: 170px;
    max-height: min(280px, 42vh);
  }

  .chat-suggestions {
    gap: 0.45rem;
  }

  .chat-chip {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    border-radius: var(--radius) !important;
  }

  .chat-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .chat-form input {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .chat-form .btn {
    width: 100%;
    min-height: 44px;
  }

  .support-card .form input,
  .support-card .form textarea,
  .support-card .form select {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
    box-sizing: border-box;
  }

  .support-card .form textarea {
    min-height: 7.5rem;
  }

  .support-card .form .btn {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .support-layout {
    gap: 0.95rem;
    padding: 0.75rem 0 calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }

  .discord-widget-panel,
  .support-card {
    padding: 0.95rem 0.85rem 1.15rem;
  }

  .chat-bubble {
    max-width: 100%;
    font-size: 0.88rem;
  }

  .discord-widget-head h2 {
    font-size: clamp(1.35rem, 7vw, 1.75rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
