:root {
  --bg: #080b10;
  --panel: rgba(13, 19, 28, 0.92);
  --panel-2: rgba(18, 27, 39, 0.86);
  --ink: #eef8ff;
  --muted: #86a1ad;
  --cyan: #2ef6ff;
  --red: #ff355e;
  --line: rgba(46, 246, 255, 0.22);
  --line-red: rgba(255, 53, 94, 0.34);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 53, 94, 0.22), transparent 24%),
    radial-gradient(circle at 78% 4%, rgba(46, 246, 255, 0.18), transparent 26%),
    linear-gradient(135deg, #080b10 0%, #101826 55%, #06080d 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.035), rgba(255,255,255,0.035) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: screen;
  opacity: 0.32;
}

body.has-lightbox {
  overflow: hidden;
}

.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(46,246,255,.8) 0 2px, transparent 2px),
    radial-gradient(circle, rgba(255,53,94,.75) 0 2px, transparent 2px);
  background-size: 86px 86px, 132px 132px;
  background-position: 8px 18px, 44px 40px;
  mask-image: linear-gradient(120deg, transparent, #000 20%, #000 72%, transparent);
  opacity: .18;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: #fff; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(18px, 4vw, 52px);
  background: rgba(5, 8, 13, 0.86);
  backdrop-filter: blur(14px);
}

.mark {
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: .12em;
}

nav { display: flex; gap: 18px; }
nav a { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; }

.shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 22px;
  width: min(1400px, calc(100vw - 28px));
  margin: 24px auto 36px;
}

.game-rail,
.hero-panel,
.toolbar,
.table-wrap,
.form-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.game-rail {
  position: sticky;
  top: 94px;
  align-self: start;
  max-height: calc(100vh - 118px);
  overflow: auto;
  padding: 10px;
}

.rail-title,
.brandline,
label span {
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.game-rail a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid transparent;
  padding: 10px 11px;
  color: var(--ink);
  font-size: 13px;
}

.game-rail a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-rail a strong { color: var(--muted); font-size: 12px; }
.game-rail a.active { border-color: var(--line-red); background: rgba(255, 53, 94, .12); }

.database { min-width: 0; }

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding: clamp(24px, 4vw, 46px);
  background:
    linear-gradient(110deg, rgba(255,53,94,.12), transparent 42%),
    var(--panel);
}

.landing-hero {
  min-height: 310px;
}

h1 {
  margin: 8px 0 0;
  font-size: clamp(38px, 6vw, 76px);
  line-height: .92;
  letter-spacing: -0.02em;
}

.intro {
  max-width: 650px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
  align-self: end;
}

.stats div {
  border: 1px solid var(--line);
  padding: 14px;
  background: rgba(0,0,0,.2);
}

.stats strong { display: block; color: var(--cyan); font-size: 30px; }
.stats span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 16px;
  background: var(--panel-2);
}

label { display: grid; gap: 7px; width: 100%; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(2, 6, 10, 0.82);
  font: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(46, 246, 255, .48);
  outline-offset: 2px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid rgba(46,246,255,.72);
  padding: 0 18px;
  color: #041015;
  background: var(--cyan);
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.table-wrap { margin-top: 16px; overflow-x: auto; }
.pcb-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.pcb-table th,
.pcb-table td {
  border-bottom: 1px solid rgba(46,246,255,.14);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
}
.pcb-table th {
  color: var(--cyan);
  background: rgba(46,246,255,.08);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.pcb-table tr:hover td { background: rgba(255,255,255,.035); }
.serial {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 900;
}
.muted, .empty { color: var(--muted); }
.empty { padding: 18px; margin: 0; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.info-grid article {
  border: 1px solid var(--line);
  padding: 20px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.info-grid h2,
.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.info-grid p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 0;
}

.estimate-section {
  margin-top: 16px;
}

.estimate-table td:last-child {
  min-width: 280px;
  color: var(--muted);
}

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
}

.lightbox__figure {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-width: min(1100px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  margin: 0;
  border: 1px solid rgba(46, 246, 255, 0.42);
  padding: 14px;
  background: rgba(6, 10, 16, 0.96);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.72);
}

.lightbox__figure img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 128px);
  object-fit: contain;
}

.lightbox__close {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 36px;
  border-color: rgba(255, 53, 94, 0.78);
  color: #fff;
  background: rgba(179, 23, 57, 0.94);
}

.lightbox figcaption {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.form-shell {
  width: min(760px, calc(100vw - 28px));
  margin: 28px auto 44px;
}
.form-panel { padding: clamp(22px, 4vw, 38px); }
.stack-form { display: grid; gap: 16px; margin-top: 22px; }
.notice { border: 1px solid rgba(46,246,255,.32); padding: 12px 14px; color: var(--cyan); background: rgba(46,246,255,.08); }
.notice.error { border-color: rgba(255,53,94,.46); color: #ff8ba1; background: rgba(255,53,94,.08); }
.captcha-wrap { min-height: 78px; }

.admin-shell {
  width: min(1560px, calc(100vw - 28px));
  margin: 28px auto 44px;
}

.admin-panel {
  padding: clamp(18px, 2.5vw, 28px);
}

.admin-hero {
  margin: calc(clamp(18px, 2.5vw, 28px) * -1) calc(clamp(18px, 2.5vw, 28px) * -1) 22px;
  box-shadow: none;
}

.admin-create,
.admin-game {
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.admin-create {
  margin-top: 18px;
}

.admin-section-head {
  align-items: end;
  padding: 20px;
}

.admin-hint {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.admin-create-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, .8fr) minmax(260px, 1.3fr) minmax(150px, .8fr);
  gap: 14px;
  padding: 0 20px 20px;
}

.admin-wide {
  grid-column: span 2;
}

.admin-create-actions {
  display: flex;
  align-items: end;
}

.admin-create-actions button {
  width: 100%;
}

.admin-games {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.admin-game summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 18px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.admin-game summary::-webkit-details-marker {
  display: none;
}

.admin-game summary span {
  font-size: 18px;
  font-weight: 900;
}

.admin-game summary strong {
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-game[open] summary {
  border-bottom: 1px solid var(--line);
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-edit-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
}

.admin-edit-table th,
.admin-edit-table td {
  border-bottom: 1px solid rgba(46,246,255,.14);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.admin-edit-table th {
  position: sticky;
  top: 72px;
  z-index: 2;
  color: var(--cyan);
  background: rgba(5, 8, 13, 0.98);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.admin-edit-table tr.is-pending td {
  background: rgba(255,53,94,.08);
}

.admin-edit-table td:nth-child(1) { width: 130px; }
.admin-edit-table td:nth-child(2) { width: 160px; }
.admin-edit-table td:nth-child(3) { width: 300px; }
.admin-edit-table td:nth-child(4) { width: 360px; }
.admin-edit-table td:nth-child(5) { width: 180px; }
.admin-edit-table td:nth-child(6) { width: 90px; }
.admin-edit-table td:nth-child(7) { width: 105px; }
.admin-edit-table td:nth-child(8) { width: 230px; }

.admin-edit-table input,
.admin-edit-table textarea,
.admin-edit-table select {
  min-height: 42px;
  padding: 10px;
}

.admin-edit-table textarea {
  min-height: 74px;
  resize: vertical;
}

.admin-serial-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 900;
}

.admin-photo,
.admin-no-photo,
.admin-meta {
  border: 1px solid rgba(46,246,255,.2);
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(2,6,10,.52);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-photo {
  color: var(--cyan);
}

.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
}
.danger { border-color: rgba(255,53,94,.8); color: #fff; background: #b31739; }
.ghost { color: var(--ink); background: transparent; }

footer {
  width: min(1400px, calc(100vw - 28px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .game-rail { position: relative; top: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); max-height: none; }
  .rail-title { grid-column: 1 / -1; }
  .hero-panel, .toolbar, .topbar { flex-direction: column; align-items: stretch; }
  .info-grid { grid-template-columns: 1fr; }
  .admin-create-form {
    grid-template-columns: 1fr;
  }
  .admin-wide {
    grid-column: auto;
  }
  .stats { grid-template-columns: repeat(3, 1fr); }
  nav { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  h1 { font-size: 40px; }
}
