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

html,
body {
  height: 100%;
  background: #0a0a12;
  color: #e8f0ff;
  font-family: "Press Start 2P", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
}

#wrap {
  width: 800px;
  max-width: 96vw;
}

header {
  text-align: center;
  margin-bottom: 10px;
}

header h1 {
  font-size: 18px;
  letter-spacing: 2px;
  color: #5cff9a;
  text-shadow: 0 0 8px #1a8f4a;
}

.tag {
  margin-top: 8px;
  font-size: 8px;
  color: #6a7a9a;
  line-height: 1.6;
}

#hud {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  justify-content: space-between;
  font-size: 9px;
  margin-bottom: 8px;
  color: #9ab;
}

#hud b {
  color: #fff;
  margin-left: 4px;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  background: #050510;
  border: 4px solid #2a3a5a;
  box-shadow: 0 0 0 2px #0ff4, 0 0 24px #0ff2;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: none;
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 16, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#overlay.show {
  display: flex;
}

.panel {
  width: min(440px, 90vw);
  background: #101828;
  border: 4px solid #5cff9a;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 0 0 2px #0a0, 0 0 32px #5cff9a44;
}

.panel h2 {
  font-size: 16px;
  color: #5cff9a;
  margin-bottom: 16px;
}

.panel p {
  font-size: 9px;
  line-height: 1.8;
  color: #c8d4e8;
  margin-bottom: 16px;
}

.controls {
  list-style: none;
  text-align: left;
  font-size: 8px;
  line-height: 2;
  color: #9ab;
  margin: 0 auto 20px;
  max-width: 320px;
}

kbd {
  display: inline-block;
  background: #1a2840;
  border: 2px solid #4a6a9a;
  color: #8cf;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 8px;
}

#start-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 12px 28px;
  background: #5cff9a;
  color: #061208;
  border: none;
  cursor: pointer;
  box-shadow: 4px 4px 0 #1a8f4a;
}

#start-btn:hover {
  background: #8fffb8;
}

#start-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #1a8f4a;
}

.hidden {
  display: none !important;
}

#score-submit {
  margin: 12px auto 16px;
  max-width: 340px;
  text-align: left;
}

#score-submit label {
  display: block;
  font-size: 8px;
  color: #5cff9a;
  margin-bottom: 8px;
}

.submit-row {
  display: flex;
  gap: 8px;
}

#username-input {
  flex: 1;
  font-family: inherit;
  font-size: 10px;
  padding: 10px 8px;
  background: #0a1020;
  border: 3px solid #4a6a9a;
  color: #e8f0ff;
  min-width: 0;
}

#username-input:focus {
  outline: none;
  border-color: #5cff9a;
}

#submit-score-btn {
  font-family: inherit;
  font-size: 9px;
  padding: 10px 12px;
  background: #ffd84a;
  color: #061208;
  border: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 #a08020;
  white-space: nowrap;
}

#submit-score-btn:hover {
  background: #ffe680;
}

#submit-score-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.submit-status {
  margin-top: 8px;
  font-size: 8px;
  line-height: 1.5;
  color: #8cf;
  min-height: 12px;
}

.submit-status.err {
  color: #ff6688;
}

.submit-status.ok {
  color: #5cff9a;
}

#leaderboard-wrap {
  margin: 0 auto 18px;
  max-width: 360px;
  text-align: left;
}

#leaderboard-wrap h3 {
  font-size: 10px;
  color: #ffd84a;
  margin-bottom: 10px;
  text-align: center;
}

.leaderboard {
  list-style: none;
  max-height: 160px;
  overflow-y: auto;
  border: 2px solid #2a3a5a;
  background: #0a1020;
  padding: 6px 8px;
  font-size: 8px;
  line-height: 1.7;
  color: #9ab;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid #1a2840;
}

.leaderboard li:last-child {
  border-bottom: none;
}

.leaderboard .rank {
  color: #6a7a9a;
}

.leaderboard .name {
  color: #e8f0ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .pts {
  color: #5cff9a;
}

.leaderboard li.me .name {
  color: #ffd84a;
}

.leaderboard .empty {
  display: block;
  text-align: center;
  color: #6a7a9a;
  padding: 12px 0;
}

.panel {
  max-height: 90vh;
  overflow-y: auto;
}
