:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.page {
  width: min(800px, 90vw);
  height: min(800px, 90vh);
  background: rgba(0, 0, 0, 0.7);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  justify-items: center;
  align-items: center;
}

.page h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.5rem);
}

.page[data-page="instructions"] h1 {
  color: #ff0000;
}

.subtitle {
  font-size: 1.1rem;
  margin: 0;
  max-width: 640px;
}

.actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.action-button,
.toolbar a,
.link-secondary {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  background: #ff0000;
  color: #ffffff;
  border: 2px solid #c3c3c3;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.action-button:hover,
.toolbar a:hover,
.link-secondary:hover {
  transform: translateY(-2px);
  background: #c30000;
  box-shadow: 0 6px 14px rgba(255, 255, 255, 0.15);
}

.username-form {
  display: inline-flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.username-form input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #c3c3c3;
  background: #000000;
  color: #ffffff;
  font-size: 1rem;
}

.username-form input::placeholder {
  color: #c3c3c3;
}

.username-form input:focus {
  outline: 2px solid #ff0000;
}

.username-form button {
  padding: 10px 18px;
  border-radius: 8px;
  border: 2px solid #c3c3c3;
  background: #ff0000;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.username-form button:hover {
  background: #c30000;
}

.instruction-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
  font-size: 1.1rem;
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
  background: rgba(10, 10, 10, 0.6);
}

.leaderboard th,
.leaderboard td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.leaderboard thead {
  background: rgba(255, 255, 255, 0.08);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toolbar {
  align-self: stretch;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar a {
  color: #ffcc00;
  text-decoration: none;
  font-weight: 600;
}

.toolbar a:hover {
  text-decoration: underline;
}

.game-page {
  background: rgba(0, 0, 0, 0.3);
}

.game-root canvas {
  width: 100%;
  height: auto;
  max-width: 800px;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.2);
  border-radius: 12px;
}

.layout-top {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  width: 100%;
  align-self: start;
  margin-top: 48px;
}

.username-section {
  grid-row: 2;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: auto;
  max-width: calc(100% - 120px);
  text-align: center;
}

.nav-section {
  grid-row: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  align-self: end;
  margin-bottom: 64px;
}

.nav-section .actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
