:root {
  --bg: #f5f6f1;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --ink: #141414;
  --muted: #656b68;
  --line: #d9ded8;
  --green: #00a78e;
  --red: #f25f4c;
  --yellow: #ffca3a;
  --blue: #4b6bfb;
  --shadow: 0 18px 44px rgba(20, 20, 20, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 241, 0.92);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 850;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 15px;
}

.filter-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.chip {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  padding: 0 14px;
  font-weight: 750;
}

.chip.is-active {
  background: var(--ink);
  color: #fff;
}

.status-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.arcade-view {
  display: block;
}

.catalog-column,
.game-page,
.admin-main {
  min-width: 0;
}

.section-head,
.play-head,
.leaderboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.section-copy {
  max-width: 640px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.search-box {
  width: min(310px, 42vw);
  height: 44px;
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-icon {
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  position: relative;
}

.search-icon::after {
  content: "";
  width: 7px;
  height: 2px;
  background: var(--muted);
  position: absolute;
  right: -6px;
  bottom: -3px;
  transform: rotate(45deg);
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.filter-row {
  margin: 22px 0;
}

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

.game-card {
  display: grid;
  gap: 12px;
  min-height: 320px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 24px 54px rgba(20, 20, 20, 0.12);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.game-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.game-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.game-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 202, 58, 0.95), rgba(0, 167, 142, 0.72)),
    var(--surface);
  color: var(--ink);
  font-size: 36px;
  font-weight: 900;
}

.game-card h2 {
  font-size: 21px;
}

.source-badge {
  display: flex;
  align-items: center;
  min-height: 28px;
}

.source-badge span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.game-card p {
  min-height: 44px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.42;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-row span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

.primary-button,
.secondary-button,
.text-button,
.play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 850;
}

.primary-button,
.play-button {
  border: 2px solid var(--ink);
  background: var(--green);
  color: #071411;
  box-shadow: 3px 3px 0 var(--ink);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0 4px;
}

.game-page-layout {
  display: grid;
  gap: 16px;
  width: min(1080px, 100%);
  margin: 0 auto;
}

.game-detail {
  display: grid;
  gap: 14px;
}

.back-link {
  width: max-content;
  color: var(--blue);
  font-weight: 850;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
}

.game-summary {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.game-info-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.15fr);
  gap: 18px;
  align-items: start;
}

.source-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.leaderboard,
.source-primary,
.source-form,
.source-suggestions {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.leaderboard {
  align-content: start;
}

.source-primary h2,
.source-form h2 {
  font-size: 22px;
}

.source-primary p,
.source-form p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.source-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.source-meta span {
  color: var(--muted);
  font-weight: 850;
}

.source-link,
.source-suggestions a {
  color: var(--blue);
  font-weight: 850;
  text-decoration: none;
}

.source-link:hover,
.source-link:focus-visible,
.source-suggestions a:hover,
.source-suggestions a:focus-visible {
  text-decoration: underline;
}

.source-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.source-form input,
.source-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  outline: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgb(7 20 17 / 58%);
  padding: 20px;
}

.source-modal {
  width: min(620px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  box-shadow: 8px 8px 0 var(--ink);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2 {
  margin-top: 2px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.has-modal {
  overflow: hidden;
}

.score-box {
  min-width: 86px;
  display: grid;
  justify-items: end;
  gap: 2px;
}

.score-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.score-box strong {
  font-size: 30px;
}

.game-stage {
  aspect-ratio: 16 / 9;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #101210;
  box-shadow: 8px 8px 0 var(--ink);
  overflow: hidden;
}

.game-stage iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #101210;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
}

.leaderboard ol {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.source-suggestions ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-suggestions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.source-suggestions li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.source-suggestions li div {
  display: grid;
  gap: 3px;
}

.source-suggestions li span,
.source-suggestions li p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.leaderboard li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-view {
  display: block;
}

.is-hidden {
  display: none;
}

.admin-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.admin-token-card,
.admin-game-editor label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.admin-token-card[hidden] {
  display: none;
}

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

.admin-stats div,
.admin-list-panel,
.admin-game-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.admin-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

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

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(360px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.admin-list-panel,
.admin-game-editor {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.admin-list-panel h2,
.admin-game-editor h2 {
  font-size: 22px;
}

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

.admin-game-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
}

.admin-game-row.is-selected {
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.admin-game-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.admin-game-main strong,
.admin-game-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-game-main small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}

.admin-game-thumb {
  width: 52px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  overflow: hidden;
}

.admin-game-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-game-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill.is-live {
  background: var(--green);
  color: #071411;
}

.status-pill.is-draft {
  background: var(--surface);
  color: var(--muted);
}

.admin-game-editor {
  align-content: start;
}

.admin-game-editor textarea {
  resize: vertical;
}

.admin-game-editor input,
.admin-game-editor textarea,
.admin-game-editor select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  outline: 0;
}

.token-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151716;
  color: #eaf6ef;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .game-info-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .topbar {
    height: auto;
    padding: 14px;
  }

  .workspace {
    padding: 16px;
  }

  .section-head,
  .play-head {
    align-items: start;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .game-grid,
  .form-row,
  .token-row,
  .admin-stats,
  .admin-game-row {
    grid-template-columns: 1fr;
  }

  .admin-game-actions {
    justify-content: space-between;
  }

  .game-card {
    min-height: 0;
  }

  .game-stage {
    aspect-ratio: 4 / 5;
    box-shadow: 5px 5px 0 var(--ink);
  }
}
