/* Consolas for the back button only (fonts/Consolas.ttf). */
@font-face {
  font-family: 'ConsolasBack';
  src: url('fonts/Consolas.ttf'), local('Consolas');
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Cascadia Code', monospace;
}
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000000;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* The game canvas covers the whole window (black bars included). */
canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* All HTML UI lives in a fixed-size "stage" (width set by game.js, always 1080 tall) that is scaled
   to fit the window, so the menus scale together with the game world. */
#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  transform-origin: 0 0;
}

/* PERF: no backdrop-filter here. A blur behind an element that sits on top of an
   animating canvas forces the GPU to re-blur that region every single frame. */
#ui {
  position: absolute;
  top: 28px;
  right: 28px;
  background: rgba(18, 18, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 18px 36px 20px 36px;
  border-radius: 18px;
  pointer-events: none;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  contain: layout paint style;
}
.score-label {
  font-size: 26px;
  letter-spacing: 1.5px;
  color: #cbd5e1;
  text-transform: none;
  font-weight: 400;
  line-height: 1;
}
.score-val {
  font-size: 52px;
  font-weight: 800;
  color: #a5f3fc;
  line-height: 1;
  margin-top: 18px;
}

/* PERF: no backdrop-filter; slightly more opaque instead. When hidden it is taken
   out of rendering completely (visibility) rather than left as an invisible layer. */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}
.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.btn {
  background: linear-gradient(135deg, #f472b6, #c084fc);
  border: none;
  color: #000000;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 2px;
  padding: 28px 72px;
  border-radius: 45px;
  cursor: pointer;
  box-shadow: 0 0 35px rgba(244, 114, 182, 0.45);
  transition: box-shadow 0.15s ease;
  text-transform: none;
}
.btn:hover {
  box-shadow: 0 0 50px rgba(244, 114, 182, 0.65);
}
.btn:active {
  transform: scale(0.97);
}

/* ---- Play screen: name + PIN ------------------------------------------------------- */
.fields {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  row-gap: 14px;
  font-size: 26px;
  letter-spacing: 1.5px;
  font-weight: 400;
  color: #cbd5e1;
}
.fields label {
  white-space: pre;
  text-align: right; /* "Name: " and "PIN: " end at the same x, so the colons line up */
}
/* Invisible input: only the caret and a white underline. */
#nameInput {
  width: 240px;
  background: transparent;
  border: none;
  border-bottom: 2px solid #fff;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  padding: 0 0 4px 0;
  font-size: inherit;
  letter-spacing: inherit;
  font-weight: 400;
  color: #a5f3fc;
  caret-color: #fff;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
}
/* PIN: the real digits live in JS; the box only ever shows asterisks.
   Four separate white underline segments, one per digit position. */
#pinInput {
  width: 8.4ch;
  justify-self: start;
  background: repeating-linear-gradient(to right, #fff 0, #fff 1.4ch, transparent 1.4ch, transparent 2ch) left bottom / 8ch 2px no-repeat;
  border: none;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  padding: 0 0 6px 0.2ch;
  font-size: inherit;
  letter-spacing: 1ch;
  font-weight: 400;
  /* Cascadia Code has programming ligatures: "**" and "***" get redrawn/shifted as a group,
     which pushed the asterisks out of their slots (only "****" was left alone). Turn them off. */
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0, "clig" 0;
  color: #a5f3fc;
  caret-color: #fff;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
}
#nameError {
  min-height: 26px;
  margin-top: 8px;
  margin-bottom: 20px;
  font-size: 20px;
  letter-spacing: 1px;
  color: #f472b6;
  text-align: center;
}
.high-score {
  margin-top: 55px;
  font-size: 26px;
  letter-spacing: 1.5px;
  font-weight: 400;
}

/* ---- Leaderboard: same panel look as the Score box ---------------------------------- */
.leaderboard {
  margin-top: 40px;
  min-width: 380px;
  background: rgba(18, 18, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 18px 36px 20px 36px;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.lb-head {
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 2px solid #fff; /* white line under the title */
  margin-bottom: 14px;
}
/* Title text uses the same gradient as the Play button. */
.lb-title {
  display: inline-block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1.5px;
  line-height: 1.2;
  background: linear-gradient(135deg, #f472b6, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.lb-list {
  list-style: none;
  display: grid;
  row-gap: 8px;
  font-size: 22px;
  letter-spacing: 1px;
}
.lb-list li {
  display: grid;
  grid-template-columns: 3ch 1fr auto;
  column-gap: 18px;
  align-items: baseline;
  color: #cbd5e1;
}
.lb-rank { color: #94a3b8; text-align: right; }
.lb-score { color: #a5f3fc; font-weight: 800; }
.lb-list li.lb-msg {
  display: block;
  text-align: center;
  color: #94a3b8;
}

/* ---- Pause / game over screens: same dark overlay and Play-style button as the play screen. */
.screen-title {
  font-size: 26px;
  letter-spacing: 1.5px;
  font-weight: 400;
  color: #cbd5e1;
  margin-bottom: 36px;
}
/* Back ("<") button: same panel look as the Score box, top-left. */
#backBtn {
  position: absolute;
  top: 28px;
  left: 28px;
  z-index: 20;
  background: rgba(18, 18, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 34px 16px 34px;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  color: #a5f3fc;
  font-family: 'ConsolasBack', Consolas, monospace;
  font-size: 96px;
  font-weight: 800;
  -webkit-text-stroke: 3px #a5f3fc; /* makes it properly bold even if the font has no bold face */
  line-height: 1;
  cursor: pointer;
}
#backBtn:active {
  transform: scale(0.97);
}
#backBtn.gone {
  display: none;
}
