:root {
  color-scheme: dark;
  --ink: #f3efe8;
  --muted: #a8b1aa;
  --line: rgba(243, 239, 232, 0.16);
  --panel: rgba(16, 18, 17, 0.82);
  --accent: #d6ff4d;
  --danger: #ff5b4d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #6f8586;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  height: 100dvh;
  width: 100vw;
}

.game-panel {
  position: relative;
  min-width: 0;
  background: #9fb2b2;
  overflow: hidden;
}

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

.hud {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  z-index: 4;
  pointer-events: none;
}

.hud-top {
  top: max(14px, env(safe-area-inset-top));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hud-top > div,
.leaderboard,
.best-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.hud-top > div {
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 8px;
}

.label,
.eyebrow,
.small {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.drop-button {
  position: absolute;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 5;
  width: min(220px, 58vw);
  min-height: 58px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #10120f;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

.drop-button:active {
  transform: translateX(-50%) translateY(2px);
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: max(24px, env(safe-area-inset-top)) 20px 20px;
  border-width: 0 0 0 1px;
  overflow: auto;
}

.leaderboard h2,
.dialog h1,
.dialog h2,
.leaderboard p {
  margin: 0;
}

.leaderboard h2 {
  font-size: 36px;
}

.best-card {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
}

.best-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent);
  font-size: 30px;
  line-height: 1;
}

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

li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 54px;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(214, 255, 77, 0.14);
  color: var(--accent);
  font-weight: 800;
}

.handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.points {
  color: var(--accent);
  font-weight: 800;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 9, 8, 0.56);
}

.hidden {
  display: none;
}

.dialog {
  width: min(420px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 18, 17, 0.92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.dialog h1 {
  margin-top: 8px;
  font-size: 42px;
  line-height: 0.95;
}

.dialog h2 {
  margin-top: 8px;
  font-size: 58px;
  line-height: 0.9;
}

.copy {
  color: #d9ddd5;
  line-height: 1.45;
}

.prize-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 4px;
}

.prize-strip span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.result-meta {
  margin: 10px 0 0;
  color: #d9ddd5;
  font-weight: 700;
}

.dialog label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.dialog input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  outline: 0;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin-top: 14px;
  color: #d9ddd5;
  font-size: 13px;
  line-height: 1.35;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.website-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.submit-status {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.submit-status.error {
  color: var(--danger);
}

.dialog button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #111412;
  font-weight: 800;
  cursor: pointer;
}

.dialog button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.dialog .secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 132px;
  }

  .leaderboard {
    border-width: 1px 0 0;
    padding: 10px 12px;
    gap: 8px;
  }

  .leaderboard-head {
    display: none;
  }

  .best-card {
    display: none;
  }

  ol {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
  }

  li {
    min-width: 120px;
    grid-template-columns: 26px minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 4px 8px;
    min-height: 72px;
  }

  .rank {
    width: 26px;
    height: 26px;
  }

  .points {
    grid-column: 2;
  }

  .small {
    display: none;
  }

  .hud-top > div {
    min-height: 56px;
    padding: 8px;
  }

  .hud strong {
    font-size: 19px;
  }

  .label,
  .eyebrow,
  .small {
    font-size: 11px;
  }

  .dialog h1 {
    font-size: 36px;
  }

  .prize-strip {
    grid-template-columns: 1fr;
  }
}
