* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101316;
  color: #f7f0dd;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: grid;
  place-items: center;
}

button {
  min-height: 44px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: #29323a;
  color: #fff5dc;
  font: 800 14px/1 system-ui, sans-serif;
  padding: 0 14px;
  cursor: pointer;
  box-shadow: 0 7px 18px rgb(0 0 0 / 24%);
}

button:active {
  transform: translateY(1px);
}

.primary {
  background: #f2bd45;
  color: #1b1710;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #0e1215;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.top-row {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, auto));
  justify-content: start;
  gap: 8px;
}

.top-row span {
  min-width: 92px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: rgb(16 19 22 / 78%);
  padding: 9px 11px;
  color: #fff8e8;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  backdrop-filter: blur(10px);
}

.bottom-row {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  pointer-events: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(rgb(16 19 22 / 36%), rgb(16 19 22 / 66%)),
    radial-gradient(circle at 30% 18%, rgb(242 189 69 / 16%), transparent 34%),
    #101316;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: rgb(20 27 31 / 88%);
  padding: clamp(18px, 4vw, 34px);
  box-shadow: 0 22px 60px rgb(0 0 0 / 44%);
}

.back-link {
  position: fixed;
  z-index: 3;
  top: 14px;
  right: 14px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: rgb(16 19 22 / 78%);
  padding: 9px 12px;
  color: #fff8e8;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  backdrop-filter: blur(10px);
}

.rank-status { min-height: 22px; margin: 12px 0 0; color: #f2bd45; font-size: 14px; }
.ranking { margin-top: 12px; border-top: 1px solid rgb(255 255 255 / 13%); padding-top: 15px; }
.ranking-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ranking h2 { margin: 0; color: #fff2ca; font-size: 18px; }
.ranking-head span { color: #9ca8a9; font-size: 11px; font-weight: 900; }
.ranking ol { max-height: 178px; margin: 12px 0 0; padding: 0; overflow: auto; list-style: none; }
.ranking li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; padding: 7px 8px; border-radius: 6px; color: #d9e0df; font-size: 13px; }
.ranking li:nth-child(odd) { background: rgb(255 255 255 / 5%); }
.ranking .rank-number { color: #f2bd45; font-weight: 900; }
.ranking .rank-time { color: #fff2ca; font-variant-numeric: tabular-nums; font-weight: 900; }
.ranking .rank-empty { display: block; color: #9ca8a9; text-align: center; }

.eyebrow {
  margin: 0 0 8px;
  color: #f2bd45;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  color: #fff2ca;
  font-size: clamp(44px, 8vw, 84px);
  line-height: 0.92;
}

p {
  max-width: 640px;
  margin: 0 0 18px;
  color: #d9e0df;
  font-size: 17px;
  line-height: 1.6;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.keys span {
  border: 1px solid rgb(255 255 255 / 13%);
  border-radius: 8px;
  background: rgb(255 255 255 / 7%);
  padding: 8px 10px;
  color: #e8eef0;
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 780px), (pointer: coarse) {
  .bottom-row {
    display: grid;
  }

  .top-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    right: 92px;
  }

  .top-row span {
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
  }
}
