* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #101827;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
}
#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}
canvas {
  height: min(100vh, 177.78vw);
  width: min(100vw, 56.25vh);
  background: #c7fbfb;
  display: block;
  image-rendering: auto;
  box-shadow: 0 0 30px rgba(0,0,0,.35);
}
#hud {
  position: absolute;
  inset: 0;
  width: min(100vw, 56.25vh);
  height: min(100vh, 177.78vw);
  margin: auto;
  pointer-events: none;
}
#score {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 900;
  color: white;
  -webkit-text-stroke: 3px #111;
  text-shadow: 0 4px 0 rgba(0,0,0,.25);
}
#rankBtn {
  position: absolute;
  top: 16px;
  right: 14px;
  width: auto;
  pointer-events: auto;
  font-weight: 900;
  border: 3px solid #111;
  border-radius: 999px;
  background: #fff;
  color: #111;
  padding: 8px 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.panel {
  position: absolute;
  width: min(86vw, 360px);
  padding: 22px;
  border: 4px solid #111;
  border-radius: 24px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 12px 0 rgba(0,0,0,.25);
  text-align: center;
}
.panel h1, .panel h2 { margin: 0 0 10px; }
.panel p { margin: 8px 0 14px; }
.hidden { display: none; }
input {
  width: 100%;
  padding: 12px 14px;
  border: 3px solid #111;
  border-radius: 14px;
  font-size: 16px;
  margin-bottom: 10px;
}
button {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border: 3px solid #111;
  border-radius: 16px;
  background: #3d4cff;
  color: white;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
}
button.ghost { background: white; color: #111; }
button:disabled { opacity: .55; cursor: not-allowed; }
small { display: block; margin-top: 12px; color: #555; }
.ranking {
  max-height: min(86vh, 690px);
  overflow: hidden;
  padding: 18px;
}
.rankingHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rankingHeader h2 { margin: 0; }
.closeBtn {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: white;
  color: #111;
}
.rankHint {
  font-size: 13px;
  color: #555;
  margin-bottom: 10px !important;
}
#topThree {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0;
}
.medal {
  border: 3px solid #111;
  border-radius: 16px;
  padding: 10px;
  font-weight: 900;
  background: #f7f7f7;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
details {
  border: 3px solid #111;
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}
summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 900;
  background: #eef2ff;
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: " ▼"; }
details[open] summary::after { content: " ▲"; }
#rankList {
  max-height: min(42vh, 310px);
  overflow-y: auto;
  text-align: left;
  padding: 0 16px 12px 42px;
  margin: 8px 0 0;
}
#rankList li {
  padding: 6px 0;
  font-weight: 750;
  border-bottom: 1px dashed rgba(0,0,0,.12);
}
