* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #10151b;
  color: #f3ede0;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, #1d2a35, #0b0f14 70%);
}

#game {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  display: block;
  image-rendering: auto;
  cursor: none;
  touch-action: none;
  box-shadow: 0 0 60px rgba(0, 0, 0, .7);
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 16, .72);
  backdrop-filter: blur(3px);
  cursor: default;
  z-index: 10;
}

.overlay.hidden { display: none; }

.panel {
  width: min(560px, 88vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 32px 32px;
  text-align: center;
  background: linear-gradient(#243140, #17202b);
  border: 2px solid #3d5266;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
}

h1 {
  font-size: clamp(34px, 6vw, 56px);
  letter-spacing: 2px;
  line-height: .95;
  color: #ffd166;
  text-shadow: 0 3px 0 #7a4a12;
}

h1 span { display: block; color: #f3ede0; text-shadow: 0 3px 0 #2b3a49; }

h2 { font-size: 30px; color: #ffd166; letter-spacing: 1px; }

h3 {
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #9db3c6;
  margin-bottom: 8px;
}

.sub { margin: 14px 0 18px; color: #c3d2df; font-size: 16px; line-height: 1.45; }

.keys {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 0 auto 16px;
  font-size: 15px;
  color: #d8e3ec;
}

.keys b { color: #ffd166; }

.hint { font-size: 14px; color: #9db3c6; margin-bottom: 22px; }

.bigscore {
  font-size: 68px;
  font-weight: bold;
  color: #ffd166;
  margin: 10px 0 4px;
  text-shadow: 0 3px 0 #7a4a12;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 18px;
  margin: 14px 0 22px;
  font-size: 15px;
  color: #c3d2df;
}

.stats .row { display: flex; justify-content: space-between; border-bottom: 1px dashed #3d5266; padding-bottom: 4px; }
.stats .row b { color: #f3ede0; }

.board { margin-bottom: 22px; }

#highscores {
  list-style: none;
  counter-reset: hs;
  display: grid;
  gap: 4px;
  font-size: 16px;
}

#highscores li {
  counter-increment: hs;
  display: flex;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255, 255, 255, .04);
  border-radius: 6px;
  color: #d8e3ec;
}

#highscores li::before { content: counter(hs) "."; color: #9db3c6; margin-right: 10px; }
#highscores li.fresh { background: rgba(255, 209, 102, .18); color: #ffd166; }
#highscores li span { margin-left: auto; font-weight: bold; }

.btn {
  font: inherit;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 13px 34px;
  color: #2a1c05;
  background: linear-gradient(#ffd166, #e8a92c);
  border: none;
  border-bottom: 4px solid #a97516;
  border-radius: 10px;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
