:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #5d687b;
  --line: #d9e1ec;
  --paper: #fbfcff;
  --panel: #ffffff;
  --accent: #0e7c7b;
  --accent-strong: #075f5e;
  --rose: #d94f70;
  --yellow: #f3b43f;
  --blue: #4d80d8;
  --green: #40a66f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
}

.site-header {
  align-items: center;
  background: rgba(251, 252, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--accent-strong);
  font-size: 1.25rem;
  font-weight: 800;
  text-decoration: none;
}

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

nav a {
  border-radius: 6px;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 12px;
  text-decoration: none;
}

nav a:hover,
nav a[aria-current="page"] {
  background: #e9f6f5;
  color: var(--accent-strong);
}

main {
  min-height: calc(100vh - 68px);
}

.hero,
.game-layout,
.login-shell,
.portal-hero,
.player-summary,
.scoreboard-shell,
.content-band,
.narrow {
  margin: 0 auto;
  max-width: 1120px;
  padding: 56px 32px;
}

.hero,
.game-layout,
.login-shell,
.portal-hero {
  align-items: center;
  display: grid;
  gap: 40px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
}

.hero {
  min-height: 520px;
}

.eyebrow {
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 12px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
  margin-bottom: 18px;
}

h2 {
  font-size: 2rem;
  margin-bottom: 20px;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

code,
pre {
  background: #eef3f8;
  border: 1px solid var(--line);
  border-radius: 6px;
}

code {
  padding: 2px 6px;
}

pre {
  color: #273246;
  max-width: 100%;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
}

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

.button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 900;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  text-decoration: none;
}

.button:hover {
  background: var(--accent-strong);
}

.button.secondary {
  background: #e9f6f5;
  color: var(--accent-strong);
}

.pixel-scene {
  aspect-ratio: 1;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, 1fr);
}

.pixel-scene span,
.tile {
  border: 2px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

.pixel-scene span:nth-child(4n + 1) { background: var(--accent); }
.pixel-scene span:nth-child(4n + 2) { background: var(--yellow); }
.pixel-scene span:nth-child(4n + 3) { background: var(--blue); }
.pixel-scene span:nth-child(4n) { background: var(--rose); }
.pixel-scene span:nth-child(5n) { background: var(--green); }

.content-band {
  border-top: 1px solid var(--line);
}

.content-band.compact {
  padding-top: 28px;
}

.article-grid,
.panel-grid,
.leaderboard-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

article,
.panel,
.stat-tile,
.leaderboard-card,
.game-panel,
.login-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 35px rgba(23, 32, 51, 0.06);
  padding: 22px;
}

.player-summary {
  align-items: stretch;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  padding-top: 0;
}

.stat-tile {
  box-shadow: none;
}

.stat-tile span,
.leaderboard-card-header span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.stat-tile strong {
  display: block;
  font-size: 1.35rem;
}

.player-summary .button {
  align-self: center;
  min-width: 190px;
}

.scoreboard-shell {
  padding-top: 0;
}

.section-heading {
  margin-bottom: 18px;
}

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

.leaderboard-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.leaderboard-card-header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.leaderboard-card-header h3 {
  margin-bottom: 0;
}

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

.leaderboard-list li {
  align-items: center;
  background: #f5f8fc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  min-height: 62px;
  padding: 10px 12px;
}

.rank {
  align-items: center;
  background: var(--ink);
  border-radius: 50%;
  color: white;
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.player {
  min-width: 0;
}

.player strong,
.player small {
  display: block;
}

.player small {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.points {
  color: var(--accent-strong);
  font-size: 1.4rem;
  font-weight: 900;
}

.game-copy h1,
.login-shell h1,
.portal-hero h1,
.narrow h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.scorebar {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
}

.scorebar div {
  background: #f5f8fc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.scorebar span,
dt {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.scorebar strong,
dd {
  font-weight: 900;
  margin: 0 0 12px;
}

.tiles {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.tile {
  aspect-ratio: 1;
  cursor: pointer;
  min-width: 0;
}

.tile:focus {
  outline: 3px solid #172033;
  outline-offset: 3px;
}

.login-form {
  display: grid;
  gap: 16px;
}

label {
  color: var(--ink);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 44px;
  padding: 10px 12px;
}

.narrow {
  max-width: 820px;
}

@media (max-width: 820px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 16px 20px;
  }

  nav {
    justify-content: flex-start;
  }

  .hero,
  .game-layout,
  .login-shell,
  .portal-hero,
  .player-summary {
    grid-template-columns: 1fr;
  }

  .hero,
  .game-layout,
  .login-shell,
  .portal-hero,
  .player-summary,
  .scoreboard-shell,
  .content-band,
  .narrow {
    padding: 36px 20px;
  }

  .article-grid,
  .panel-grid,
  .leaderboard-grid {
    grid-template-columns: 1fr;
  }

  .player-summary .button {
    width: 100%;
  }

  .pixel-scene {
    max-width: 360px;
  }
}
