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

body {
  background: #0a0f1e;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Arial Black', Arial, sans-serif;
}

#game-wrapper {
  position: relative;
  width: 480px;
  height: 640px;
  transform-origin: center center;
}

#canvas {
  display: block;
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(100, 160, 255, 0.18), 0 20px 60px rgba(0,0,0,0.7);
  transition: filter 0.05s ease-out;
}

/* Pause button */
.pause-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.42);
  border: 1.5px solid rgba(255,255,255,0.28);
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: background 0.15s;
  z-index: 10;
}
.pause-btn:hover { background: rgba(0,0,0,0.62); }
.hidden { display: none !important; }

/* ── Toast notifications ───────────────────────── */
#toast-container {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 20;
}
.toast {
  background: rgba(0,0,0,0.72);
  color: #FFD700;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255,215,0,0.4);
  animation: toastIn 0.2s ease-out, toastOut 0.4s ease-in 1.4s forwards;
  white-space: nowrap;
}
@keyframes toastIn  { from { opacity:0; transform:translateY(-10px) scale(0.88); } to   { opacity:1; transform:translateY(0)     scale(1);    } }
@keyframes toastOut { from { opacity:1; transform:translateY(0) scale(1); }        to   { opacity:0; transform:translateY(-8px) scale(0.9); } }

/* ── Modal overlay ─────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal-panel {
  background: linear-gradient(160deg, #0d1f3c 0%, #071428 100%);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 20px;
  padding: 32px 36px 28px;
  min-width: 300px;
  text-align: center;
  box-shadow: 0 8px 60px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.08);
  animation: slideUp 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes slideUp { from { transform:translateY(40px); opacity:0; } to { transform:translateY(0); opacity:1; } }

.modal-panel.wide { min-width: 360px; }

.modal-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  margin-bottom: 22px;
  text-shadow: 0 0 20px rgba(255,200,0,0.4);
}

.score-rows { display: flex; gap: 14px; justify-content: center; margin-bottom: 18px; }
.score-row {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.score-label { font-size: 10px; letter-spacing: 2px; color: rgba(255,255,255,0.44); }
.score-val   { font-size: 28px; font-weight: 900; color: #fff; }
.score-val.gold { color: #f5c518; }

/* New record badge */
#new-record-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f5c518, #ff8f00);
  color: #000;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
  animation: pulse 0.7s ease-in-out infinite alternate;
}
@keyframes pulse { from { transform:scale(1); } to { transform:scale(1.06); } }

.name-entry { margin-bottom: 18px; }
.name-entry label {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.44);
  margin-bottom: 8px;
}
.name-entry input {
  width: 100%;
  padding: 11px 16px;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.name-entry input:focus { border-color: #f5c518; }

.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #f5c518 0%, #ff8f00 100%);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 4px 18px rgba(245,197,24,0.35);
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(245,197,24,0.5); }
.btn-primary:active { transform: translateY(0);    box-shadow: 0 2px 10px rgba(245,197,24,0.3); }

/* ── Leaderboard table ─────────────────────────── */
.lb-scroll { max-height: 310px; overflow-y: auto; margin-bottom: 18px; }
.lb-scroll::-webkit-scrollbar { width: 4px; }
.lb-scroll::-webkit-scrollbar-track { background: transparent; }
.lb-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  font-size: 10px; letter-spacing: 2px; color: rgba(255,255,255,0.38);
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.lb-table td { padding: 8px 8px; font-size: 14px; color: rgba(255,255,255,0.78); }
.lb-table tr + tr td { border-top: 1px solid rgba(255,255,255,0.06); }
.left { text-align: left; }
.td-rank  { font-size: 16px; width: 38px; text-align: center; }
.td-name  { font-weight: 700; }
.td-score { font-weight: 900; color: #fff; text-align: right; }
.td-date  { font-size: 11px; color: rgba(255,255,255,0.32); text-align: right; }

.rank-gold   td { color: #f5c518; }
.rank-silver td { color: #c0c0c0; }
.rank-bronze td { color: #cd7f32; }

.new-entry td { animation: entryPulse 0.6s ease-out; }
@keyframes entryPulse {
  0%   { background: rgba(245,197,24,0.3); }
  100% { background: transparent; }
}
