:root {
  color-scheme: light;
  --ink: #16181d;
  --muted: #68707d;
  --line: #d9dee7;
  --paper: #f6f7fb;
  --surface: #ffffff;
  --surface-strong: #eef2f6;
  --teal: #0a8f8a;
  --teal-dark: #056461;
  --coral: #f45b4f;
  --yellow: #f4b23e;
  --green: #2fa85f;
  --violet: #7556d6;
  --shadow: 0 18px 50px rgba(22, 24, 29, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(10, 143, 138, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(117, 86, 214, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(244, 178, 62, 0.85);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px 18px;
  color: #f7fafc;
  background: #16181d;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #101217;
  background: var(--yellow);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  color: rgba(247, 250, 252, 0.72);
  text-decoration: none;
  border-radius: 8px;
}

.rail-link:hover,
.rail-link.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
}

.nav-icon,
[data-icon] {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  flex: 0 0 auto;
}

[data-icon] svg {
  width: 100%;
  height: 100%;
  stroke-width: 2.4;
}

.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.mini-stats div {
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.mini-stats span {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
}

.mini-stats small {
  color: rgba(247, 250, 252, 0.64);
}

.library {
  display: grid;
  gap: 28px;
  align-content: start;
  width: 100%;
  max-width: 1420px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2.2rem;
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.5rem;
  line-height: 1.12;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.2;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(440px, 44vw);
  min-height: 46px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(22, 24, 29, 0.06);
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.featured-band {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1fr);
  gap: 24px;
  align-items: stretch;
  min-height: 340px;
  overflow: hidden;
  color: #ffffff;
  background: #20242c;
  border: 1px solid rgba(22, 24, 29, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.featured-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 34px;
}

.featured-copy .section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-bottom: 20px;
  color: #ffd46d;
  font-weight: 800;
}

.featured-copy h2 {
  max-width: 14ch;
  margin-bottom: 12px;
  font-size: 3rem;
  line-height: 0.98;
}

.featured-copy p {
  max-width: 46ch;
  margin-bottom: 28px;
  color: rgba(255, 255, 255, 0.74);
}

.featured-media {
  position: relative;
  min-height: 300px;
  background:
    linear-gradient(135deg, rgba(10, 143, 138, 0.22), transparent 42%),
    linear-gradient(45deg, rgba(244, 91, 79, 0.2), transparent 48%),
    #2a303a;
}

.featured-media canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-action,
.secondary-action,
.icon-button,
.tab,
.cover-button,
.touch-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
}

.primary-action,
.secondary-action,
.tab {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-action {
  color: #101217;
  background: var(--yellow);
}

.primary-action:hover {
  background: #ffc95c;
}

.secondary-action {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.secondary-action:hover {
  border-color: #bbc4d0;
}

.secondary-action.is-voted,
.icon-button.is-voted {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

.prototype-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.tab {
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.tab.is-active,
.tab:hover {
  color: #ffffff;
  background: var(--ink);
  border-color: var(--ink);
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.sort-control select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.game-section {
  display: grid;
  gap: 18px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading > span {
  color: var(--muted);
  font-weight: 800;
}

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

.info-section {
  display: grid;
  gap: 18px;
  padding-top: 4px;
  scroll-margin-top: 24px;
}

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

.info-block {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(22, 24, 29, 0.06);
}

.info-block p {
  margin-bottom: 0;
}

.info-block a,
.contact-band a {
  color: inherit;
}

.contact-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  color: #ffffff;
  background: #20242c;
  border: 1px solid rgba(22, 24, 29, 0.1);
  border-radius: 8px;
}

.contact-band p {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
}

.game-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(22, 24, 29, 0.07);
}

.cover-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: #20242c;
  border-radius: 0;
}

.cover-button canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.cover-button::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(22, 24, 29, 0);
  transition: background 160ms ease;
}

.cover-button:hover::after {
  background: rgba(22, 24, 29, 0.12);
}

.status-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 5px 8px;
  color: #101217;
  background: #ffffff;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.card-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.card-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: start;
}

.card-title-row p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 0.9rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid transparent;
}

.icon-button:hover {
  border-color: var(--line);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.genre-pill,
.stat-box {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  background: var(--surface-strong);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
}

.genre-pill {
  color: var(--muted);
  border-radius: 999px;
}

.stat-box {
  color: var(--ink);
}

.vote-stat {
  background: rgba(10, 143, 138, 0.11);
  border-color: rgba(10, 143, 138, 0.2);
}

.play-stat {
  background: rgba(244, 178, 62, 0.14);
  border-color: rgba(244, 178, 62, 0.28);
}

.stat-label {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0;
}

.player-modal {
  width: min(1120px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: hidden;
  background: #111317;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.player-modal.is-expanded {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  border-radius: 0;
}

.player-modal::backdrop {
  background: rgba(12, 14, 18, 0.74);
}

.player-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: #ffffff;
}

.player-modal.is-expanded .player-shell,
.player-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #111317;
}

.player-header,
.player-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #181b20;
}

.player-header h2,
.player-header p {
  margin-bottom: 0;
}

.player-header .eyebrow {
  color: #ffd46d;
}

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

.player-actions .icon-button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
}

.game-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background: #08090c;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(64vh, 620px);
  aspect-ratio: 16 / 9;
  touch-action: none;
}

.player-modal.is-expanded .game-stage,
.player-shell:fullscreen .game-stage {
  height: 100%;
  min-height: 0;
}

.player-modal.is-expanded #game-canvas,
.player-shell:fullscreen #game-canvas {
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

@media (orientation: landscape) {
  .player-modal.is-expanded #game-canvas,
  .player-shell:fullscreen #game-canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }
}

.leaderboard-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 9, 12, 0.78);
}

.leaderboard-panel[hidden] {
  display: none;
}

.leaderboard-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(260px, 1fr);
  gap: 16px;
  width: min(760px, 100%);
  max-height: min(500px, 88%);
  padding: 16px;
  color: #ffffff;
  background: #181b20;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.leaderboard-summary {
  display: grid;
  align-content: center;
  gap: 14px;
}

.leaderboard-summary .eyebrow {
  color: #ffd46d;
}

.leaderboard-summary h3 {
  margin: 0;
  font-size: 1.35rem;
}

.score-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-strip div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.score-strip span,
.leaderboard-list-head small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-strip strong {
  font-size: 1.6rem;
}

.player-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.player-name-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.player-name-row span,
.name-form label,
.name-form small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.player-name-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-edit-button {
  min-height: 34px;
  padding: 0 12px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.name-form {
  display: grid;
  gap: 8px;
}

.name-form[hidden] {
  display: none;
}

.name-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.name-form input {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.leaderboard-list-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.leaderboard-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.leaderboard-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 0.9rem;
}

.leaderboard-row.is-empty {
  grid-template-columns: 1fr;
  color: rgba(255, 255, 255, 0.68);
}

.leaderboard-rank {
  color: #ffd46d;
  font-weight: 800;
}

.leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.touch-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 10px;
}

.touch-controls button {
  flex-direction: column;
  width: auto;
  min-width: 68px;
  height: 54px;
  padding: 6px 10px;
  color: #101217;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.touch-controls button [data-icon] {
  width: 18px;
  height: 18px;
}

.control-label {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.touch-controls button:active {
  transform: translateY(1px);
}

.player-footer {
  color: rgba(255, 255, 255, 0.76);
}

.player-stat {
  display: grid;
  min-width: 92px;
  min-height: 46px;
  align-content: center;
  justify-items: start;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.player-stat span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
}

.player-footer strong {
  color: #ffffff;
  font-size: 1.1rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #ffffff;
  background: #16181d;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    padding: 14px;
  }

  .rail-nav {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  }

  .rail-link {
    justify-content: center;
  }

  .mini-stats {
    display: none;
  }

  .library {
    padding: 20px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-wrap {
    width: 100%;
  }

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

  .featured-copy {
    padding: 26px;
  }

  .featured-copy h2 {
    font-size: 2.3rem;
  }

  .featured-media {
    min-height: 260px;
  }

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

  .contact-band {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .rail {
    gap: 14px;
  }

  .brand {
    justify-content: center;
  }

  .rail-link {
    padding: 0 8px;
    font-size: 0.86rem;
  }

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

  .prototype-tools,
  .section-heading,
  .player-header,
  .player-footer,
  .leaderboard-card {
    align-items: stretch;
    flex-direction: column;
  }

  .leaderboard-card {
    grid-template-columns: 1fr;
    max-height: 92%;
  }

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

  .sort-control {
    width: 100%;
    justify-content: space-between;
  }

  .sort-control select {
    flex: 1;
  }

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

  .touch-controls {
    right: 12px;
    bottom: 12px;
  }

  .touch-controls button {
    min-width: 62px;
    height: 48px;
    padding: 5px 8px;
  }
}
