html,
body {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: #0a0b1c;
}

[hidden] {
  display: none !important;
}

/* ---------- HUD ---------- */
.pill {
  position: fixed;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.95rem;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.pill.small {
  font-size: 0.8rem;
  padding: 6px 12px;
  color: var(--muted);
}
#score {
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
}
#score b {
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
#ping {
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 46px);
}

.panel {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  width: 210px;
  padding: 10px 14px 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.panel h2 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
#boardList {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  font-size: 0.9rem;
  line-height: 1.55;
}
#boardList li {
  counter-increment: rank;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#boardList li::before {
  content: counter(rank) '.';
  display: inline-block;
  width: 1.6em;
  color: var(--muted);
}
#boardList li.me {
  color: #ffe08a;
  font-weight: 700;
}
#boardList .m {
  float: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: 8px;
}
#rank {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

#touch {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}
#touch button {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: 700 0.85rem var(--font);
  touch-action: none;
}
#touch button:active {
  background: rgba(255, 208, 67, 0.45);
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 9, 24, 0.55);
  backdrop-filter: blur(5px);
  z-index: 5;
}
.card {
  width: min(380px, 100%);
  padding: 28px 26px 22px;
  border-radius: 22px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h1 {
  font-size: 3.2rem;
  line-height: 1;
}
.card h2 {
  margin: 0;
  font-size: 1.5rem;
}
.tag {
  margin: -4px 0 4px;
  color: var(--muted);
}
.row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.notice {
  margin: 0;
  color: #ffd36b;
  font-size: 0.9rem;
}
.back {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}
.back:hover {
  color: var(--text);
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}
.stats div {
  padding: 10px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.stats dt {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stats dd {
  margin: 4px 0 0;
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .panel {
    width: 150px;
    padding: 8px 10px;
  }
  #boardList {
    font-size: 0.78rem;
  }
  #board h2 {
    font-size: 0.7rem;
  }
}
