:root {
  color-scheme: light;
  --ink: #182230;
  --muted: #667085;
  --line: #e4e7ec;
  --paper: #ffffff;
  --soft: #f6f8fb;
  --blue: #2563eb;
  --teal: #11a69a;
  --red: #e64646;
  --yellow: #f6b73c;
  --green: #25a55f;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--soft);
}

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

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(223, 229, 238, 0.86);
  backdrop-filter: blur(12px);
}

.top-search {
  flex: 1;
  max-width: 520px;
}

.top-search input {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  color: var(--ink);
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: #1d4ed8;
  box-shadow: none;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand small,
.muted,
.hint {
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 8px;
}

.nav a,
.secondary,
.primary,
.controls button,
.challenge button,
.filter,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.nav a {
  padding: 9px 12px;
  color: #344054;
}

.nav a:hover,
.secondary:hover,
.filter:hover,
.icon-button:hover,
.controls button:hover,
.challenge button:hover {
  border-color: rgba(23, 105, 224, 0.45);
  transform: translateY(-1px);
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  width: min(1220px, calc(100% - 32px));
  min-height: 360px;
  margin: 0 auto;
  padding: clamp(34px, 6vw, 76px) 0 clamp(26px, 5vw, 54px);
  overflow: hidden;
}

.quick-strip {
  position: sticky;
  top: 71px;
  z-index: 15;
  display: none;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  overflow-x: auto;
  background: rgba(246, 248, 251, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  scrollbar-width: none;
}

.quick-strip::-webkit-scrollbar {
  display: none;
}

.quick-filter {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  color: #344054;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.quick-filter.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.desktop-shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto 52px;
}

.content-flow {
  min-width: 0;
}

.side-rail {
  position: sticky;
  top: 88px;
  align-self: start;
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-rail strong {
  padding: 4px 8px 8px;
}

.side-rail button,
.side-rail a {
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
  color: #475467;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.side-rail button.active,
.side-rail button:hover,
.side-rail a:hover {
  color: #fff;
  background: var(--ink);
}

.featured-row {
  margin-bottom: 22px;
}

.steam-hot-row {
  margin-bottom: 22px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.steam-more {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  color: #fff;
  font-weight: 900;
  background: var(--ink);
  border-radius: 8px;
}

.steam-hot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.steam-hot-card {
  display: grid;
  gap: 8px;
  min-height: 188px;
  padding: 16px;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, filter 160ms ease;
}

.steam-hot-card:hover {
  filter: saturate(1.08);
  transform: translateY(-2px);
}

.steam-hot-card span {
  width: fit-content;
  padding: 6px 9px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.steam-hot-card strong {
  font-size: 22px;
  line-height: 1.2;
}

.steam-hot-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.55;
}

.steam-hot-card.tone-a {
  background: linear-gradient(135deg, #0f172a, #0f9f8f);
}

.steam-hot-card.tone-b {
  background: linear-gradient(135deg, #182230, #7c3aed);
}

.steam-hot-card.tone-c {
  background: linear-gradient(135deg, #124c3b, #f97316);
}

.steam-hot-card.tone-d {
  background: linear-gradient(135deg, #1d4ed8, #e64646);
}

.featured-card {
  display: grid;
  gap: 8px;
  min-height: 172px;
  padding: 16px;
  text-align: left;
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.featured-card.tone-0 {
  background: linear-gradient(135deg, #2563eb, #11a69a);
}

.featured-card.tone-1 {
  background: linear-gradient(135deg, #182230, #2563eb);
}

.featured-card.tone-2 {
  background: linear-gradient(135deg, #ef4444, #f59e0b);
}

.featured-card span,
.featured-card small,
.featured-card em {
  color: rgba(255, 255, 255, 0.86);
}

.featured-card strong {
  font-size: 26px;
}

.featured-card small {
  line-height: 1.5;
}

.featured-card em {
  align-self: end;
  width: fit-content;
  padding: 6px 10px;
  font-style: normal;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 670px;
  color: var(--ink);
  text-shadow: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(44px, 8vw, 92px);
  line-height: 1;
}

h2 {
  font-size: clamp(26px, 4vw, 42px);
}

.hero-copy p:not(.eyebrow) {
  max-width: 580px;
  margin: 18px 0 0;
  color: #475467;
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.primary,
.secondary,
.challenge button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
}

.primary,
.challenge button,
.controls button:first-child {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--teal));
}

.secondary {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-stats span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-height: 34px;
  padding: 0 11px;
  color: #475467;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hero-stats strong {
  color: var(--ink);
}

.hero-preview {
  display: grid;
  gap: 12px;
  align-self: stretch;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(17, 166, 154, 0.1)),
    #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(228, 231, 236, 0.9);
  border-radius: 8px;
}

.preview-card strong {
  color: var(--muted);
  font-size: 13px;
}

.preview-card em {
  color: var(--ink);
  font-size: 26px;
  font-style: normal;
  font-weight: 900;
}

.main-preview {
  min-height: 180px;
  justify-content: end;
  background:
    radial-gradient(circle at 78% 22%, rgba(246, 183, 60, 0.34), transparent 24%),
    linear-gradient(135deg, #1d4ed8, #11a69a);
}

.main-preview strong,
.main-preview em {
  color: #fff;
}

.preview-dot {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 54px 34px 0 rgba(255, 255, 255, 0.2), 112px -10px 0 rgba(255, 255, 255, 0.16);
}

.play-section,
.library,
.challenge,
.ad-band,
.analytics-strip {
  width: 100%;
  margin: 28px auto;
}

.play-section {
  display: grid;
  grid-template-columns: minmax(260px, 350px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.game-panel,
.stage-wrap,
.challenge,
.ad-band,
.analytics-strip,
.admin-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-panel {
  padding: 18px;
}

.game-title-row,
.section-head,
.challenge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 20px;
  font-weight: 900;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.stats-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbff;
}

.stats-grid span,
.game-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.player-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.player-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.player-field input,
.admin-card input,
.admin-card textarea,
.admin-card select {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--ink);
  background: #f9fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.leaderboard-mini {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mini-head button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--blue);
  background: #eef4ff;
  border: 1px solid #c9dafd;
  border-radius: 8px;
  cursor: pointer;
}

#leaderboard {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding-left: 22px;
}

#leaderboard li {
  color: var(--muted);
  line-height: 1.4;
}

.controls button {
  min-height: 40px;
  font-weight: 800;
}

.hint {
  margin: 14px 0 0;
  line-height: 1.55;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  min-height: 360px;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #111827;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: auto 18px 18px;
  display: grid;
  gap: 4px;
  width: min(360px, calc(100% - 36px));
  padding: 14px;
  color: #fff;
  background: rgba(10, 17, 31, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.overlay.hidden {
  display: none;
}

.library {
  padding-top: 28px;
}

.section-head {
  align-items: flex-end;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter {
  padding: 9px 12px;
  font-weight: 800;
  color: #344054;
}

.filter.active {
  color: #fff;
  border-color: transparent;
  background: var(--ink);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.game-card {
  display: grid;
  gap: 10px;
  min-height: 174px;
  padding: 14px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(21, 33, 54, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.game-card mark {
  color: inherit;
  background: #fef08a;
  border-radius: 4px;
}

.result-summary {
  margin: -6px 0 14px;
  color: var(--muted);
}

.mobile-tabs {
  display: none;
}

.game-card:hover,
.game-card.active {
  border-color: rgba(23, 105, 224, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(16, 24, 40, 0.12);
}

.game-card strong {
  font-size: 18px;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #1f2937;
  font-size: 12px;
  font-weight: 800;
  background: #eef4ff;
  border-radius: 999px;
}

.play-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 30px;
  padding: 0 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  background: var(--ink);
  border-radius: 8px;
}

.game-card.active .play-chip,
.game-card:hover .play-chip {
  background: linear-gradient(135deg, var(--blue), var(--teal));
}

.swatch {
  width: 42px;
  height: 28px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.challenge {
  padding: 22px;
  margin-bottom: 52px;
}

.challenge p {
  margin: 10px 0 0;
  line-height: 1.7;
}

.ad-band {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(246, 183, 60, 0.16), rgba(15, 159, 143, 0.12)),
    var(--paper);
}

.ad-band span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  color: #7a4c00;
  font-size: 12px;
  font-weight: 900;
  background: #fff4d6;
  border-radius: 999px;
}

.ad-band p {
  grid-column: 2;
  margin: 0;
  color: var(--muted);
}

.ad-band a {
  grid-row: 1 / span 2;
  grid-column: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  color: #fff;
  font-weight: 900;
  background: var(--ink);
  border-radius: 8px;
}

.analytics-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
  margin-bottom: 52px;
}

.analytics-strip div {
  padding: 14px;
  background: #f9fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.analytics-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.analytics-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.admin-main {
  width: min(1220px, calc(100% - 32px));
  margin: 28px auto 60px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-card {
  padding: 18px;
}

.hidden {
  display: none !important;
}

.login-card {
  width: min(520px, 100%);
  margin: 48px auto;
}

.login-card h1 {
  margin-bottom: 12px;
  font-size: 36px;
}

.admin-card h2 {
  margin-bottom: 14px;
  font-size: 24px;
}

.admin-form {
  display: grid;
  gap: 10px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
}

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

.admin-table th,
.admin-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions button,
.admin-form button {
  min-height: 40px;
  padding: 0 13px;
  color: #fff;
  font-weight: 900;
  background: var(--blue);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.admin-metrics {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0;
}

.dashboard {
  display: grid;
  gap: 18px;
}

@media (max-width: 860px) {
  .topbar {
    position: sticky;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .nav {
    display: none;
  }

  .top-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .quick-strip {
    display: flex;
    top: 119px;
  }

  .hero {
    grid-template-columns: 1fr;
    width: min(100% - 24px, 1220px);
    min-height: auto;
    gap: 16px;
    padding-top: 20px;
    padding-bottom: 18px;
  }

  .play-section {
    grid-template-columns: 1fr;
  }

  .stage-wrap {
    order: -1;
  }

  #gameCanvas {
    min-height: 360px;
  }

  .section-head,
  .challenge {
    align-items: stretch;
    flex-direction: column;
  }

  .desktop-shell {
    display: block;
    width: min(100% - 20px, 1220px);
    margin-bottom: 84px;
  }

  .side-rail {
    display: none;
  }

  .featured-grid {
    display: flex;
    gap: 10px;
    margin-inline: -2px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .featured-grid::-webkit-scrollbar {
    display: none;
  }

  .steam-hot-grid {
    display: flex;
    gap: 10px;
    margin-inline: -2px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .steam-hot-grid::-webkit-scrollbar {
    display: none;
  }

  .featured-card {
    flex: 0 0 78%;
    scroll-snap-align: start;
  }

  .steam-hot-card {
    flex: 0 0 80%;
    scroll-snap-align: start;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .game-card {
    min-height: 160px;
    padding: 12px;
  }

  .game-card strong {
    font-size: 16px;
  }

  .game-card p {
    display: -webkit-box;
    min-height: 44px;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .mobile-tabs {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
  }

  .mobile-tabs a {
    display: grid;
    place-items: center;
    min-height: 38px;
    color: #475467;
    font-size: 13px;
    font-weight: 900;
    border-radius: 8px;
  }

  .mobile-tabs a:hover {
    color: #fff;
    background: var(--ink);
  }

  .filters {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .play-section,
  .library,
  .challenge,
  .ad-band,
  .analytics-strip,
  .admin-main {
    width: 100%;
  }

  .hero {
    padding-inline: 0;
  }

  h1 {
    font-size: 42px;
  }

  .hero-copy p:not(.eyebrow) {
    margin-top: 12px;
    font-size: 15px;
  }

  .hero-preview {
    display: none;
  }

  .preview-card em {
    font-size: 22px;
  }

  .main-preview {
    min-height: 130px;
  }

  .hero-actions {
    margin-top: 16px;
  }

  .steam-more {
    width: 100%;
    justify-content: center;
  }

  .hero-stats {
    margin-top: 12px;
  }

  .hero-stats span {
    min-height: 30px;
    padding-inline: 9px;
    font-size: 13px;
  }

  #gameCanvas {
    min-height: 330px;
  }

  .stats-grid,
  .analytics-strip,
  .admin-metrics,
  .admin-grid {
    grid-template-columns: 1fr;
  }

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

  .ad-band {
    grid-template-columns: 1fr;
  }

  .ad-band p,
  .ad-band a {
    grid-column: auto;
    grid-row: auto;
  }
}
