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

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #1a0a2e;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

#layout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}

#leaderboard {
  position: absolute;
  left: calc(50% - 340px - 160px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 160px;
}

@media (max-width: 800px) {
  #leaderboard {
    display: none;
  }
}

.leaderboard-title {
  color: #c084fc;
  font-family: 'Courier New', monospace;
  font-size: 20px;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: bold;
  text-shadow: 0 0 20px rgba(192, 132, 252, 0.6);
}

#leaderboard-list {
  list-style: none;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #aaa;
  font-family: 'Courier New', monospace;
  font-size: 15px;
  padding: 6px 10px;
  border-radius: 4px;
  background: #2a1a4e44;
}

#leaderboard-list li.top {
  color: #c084fc;
  background: #2a1a4e;
}

#leaderboard-list li span.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

#leaderboard-list li span.lb-score {
  font-weight: bold;
  color: white;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 8px;
}

#score {
  color: white;
  font-size: 52px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 2px;
}

#timer {
  color: #f0a500;
  font-size: 52px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

#game-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#canvas {
  cursor: pointer;
  border: 3px solid #3d1a6e;
  box-shadow: 0 0 40px rgba(120, 40, 200, 0.4);
}

#highscore {
  position: absolute;
  left: calc(100% + 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

@media (max-width: 800px) {
  #highscore {
    display: none;
  }
}

#highscore .label {
  font-size: 20px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #c084fc;
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

#highscore .value {
  font-size: 64px;
  font-weight: bold;
  color: #c084fc;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 20px rgba(192, 132, 252, 0.6);
}

#message {
  color: #aaa;
  font-size: 18px;
  font-family: monospace;
  min-height: 24px;
  text-align: center;
}

#name-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#name-input {
  background: #2a1a4e;
  border: 2px solid #7c3aed;
  color: white;
  font-size: 24px;
  font-family: 'Courier New', monospace;
  padding: 8px 16px;
  border-radius: 4px;
  text-align: center;
  outline: none;
  width: 300px;
}

#name-input:focus {
  border-color: #c084fc;
}

#name-hint {
  color: #7c3aed;
  font-size: 14px;
  font-family: monospace;
}

#submit-btn {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 10px 24px;
  font-size: 16px;
  font-family: monospace;
  border-radius: 4px;
  cursor: pointer;
  display: none;
}

#restart-btn {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 14px 32px;
  font-size: 20px;
  font-family: monospace;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

@media (max-width: 800px) {
  #score { font-size: 36px; }
  #timer { font-size: 36px; }
  #message { font-size: 14px; }
}
#start-btn {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 16px 48px;
  font-size: 24px;
  font-family: monospace;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

#stats-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #2a1a4e;
  color: #c084fc;
  border: 2px solid #7c3aed;
  padding: 10px 20px;
  font-size: 16px;
  font-family: monospace;
  border-radius: 4px;
  cursor: pointer;
}

#stats-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#stats-content {
  background: #1a0a2e;
  border: 2px solid #7c3aed;
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: white;
  font-family: 'Courier New', monospace;
}

#stats-content h2 {
  color: #c084fc;
  font-size: 16px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

#modal-highscore {
  font-size: 48px;
  font-weight: bold;
  color: #c084fc;
  text-shadow: 0 0 20px rgba(192, 132, 252, 0.6);
}

#modal-leaderboard-list {
  list-style: none;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#modal-leaderboard-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #aaa;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 4px;
  background: #2a1a4e44;
}

#modal-leaderboard-list li.top {
  color: #c084fc;
  background: #2a1a4e;
}

#close-modal {
  background: #7c3aed;
  color: white;
  border: none;
  padding: 10px 32px;
  font-size: 16px;
  font-family: monospace;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
}