:root {
  --header-height: 71px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

.page-container {
  min-height: fit-content;
}

#game-ui {
  display: flex;
  flex-direction: column;
  width: 100vw;
  margin: 0;
  padding: 0;
}

#game-container {
  position: relative;
  width: 100vw;
  height: calc(100vh - var(--header-height, 0px) - var(--bottom-nav-height, 0px));
  height: calc(100dvh - var(--header-height, 0px) - var(--bottom-nav-height, 0px));
  overflow: hidden;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

canvas#gameCanvas.fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  background: #08151f;
}

/* .content-container is a flex column with align-items:center, which collapses
   empty children like <hr> to zero width. Stretch it back across the container. */
.content-container hr {
  align-self: stretch;
  margin: 18px 0 14px;
}

.music-credit {
  align-self: stretch;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.6;
  opacity: 0.85;
}

/* ===== Leaderboards + instructions ===== */
.flexy-container {
  display: flex;
  gap: 2em;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  flex-wrap: wrap;
}

.leaderboard {
  min-width: 200px;
  max-width: 300px;
  flex: 1 0 220px;
  background: #ffffff;
  border: 2px solid #0b74bf;
  border-radius: 12px;
  padding: 1em 1.2em;
  box-shadow: 4px 4px 0 #0b74bf;
}

html.dark-mode .leaderboard {
  background: #1f3b57;
  border-color: #bada55;
  box-shadow: 4px 4px 0 #bada55;
}

.leaderboard h2 {
  text-align: center;
  margin: 0 0 0.5em;
}

.leaderboard ol {
  list-style: none;
  counter-reset: rank;
  margin: 0;
  padding: 0;
}

.leaderboard li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid rgba(11, 116, 191, 0.15);
}

html.dark-mode .leaderboard li {
  border-bottom-color: rgba(186, 218, 85, 0.18);
}

.leaderboard li:last-child {
  border-bottom: none;
}

.leaderboard li::before {
  content: counter(rank);
  flex: 0 0 1.5em;
  text-align: center;
  color: #0b74bf;
  font-weight: 700;
}

html.dark-mode .leaderboard li::before {
  color: #bada55;
}

.leaderboard .nickname {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .score {
  font-weight: 700;
  color: #0b74bf;
}

html.dark-mode .leaderboard .score {
  color: #fff84f;
}

.leaderboard li.empty {
  justify-content: center;
  color: #888;
}

.leaderboard li.empty::before {
  content: "";
  flex: 0;
}

.instructions {
  flex: 2 1 320px;
  min-width: 240px;
  padding: 0 0 0 1em;
}

.instructions p {
  margin-bottom: 0.8em;
}

@media (max-width: 700px) {
  .flexy-container {
    flex-direction: column;
    gap: 1.2em;
    align-items: stretch;
    text-align: center;
  }
  .instructions {
    padding: 1em 0 0.5em 0;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    text-align: left;
  }
  .leaderboard {
    max-width: 100%;
  }
}

.content-container,
.affiliate-desc,
.affiliate-note {
  color: #1f3b57;
}

html.dark-mode .content-container,
html.dark-mode .affiliate-desc,
html.dark-mode .affiliate-note {
  color: #fff;
}
