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

body {
  background: #1a1a2e;
  color: #e0e0e0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

.back-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  color: #4ecca3;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.4rem 1rem;
  background: rgba(26, 26, 46, 0.8);
  border: 1px solid rgba(78, 204, 163, 0.4);
  border-radius: 20px;
  transition: all 0.3s;
}

.back-link:hover {
  background: rgba(78, 204, 163, 0.2);
  border-color: #4ecca3;
}

.container {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  max-width: 1100px;
  width: 100%;
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.game-area h1 {
  font-size: 2rem;
  color: #4ecca3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.canvas-wrapper {
  position: relative;
  width: min(92vw, 70vh, 600px);
  aspect-ratio: 1 / 1;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 4px;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(22, 33, 62, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
}

.overlay-content h2 {
  color: #4ecca3;
  font-size: 1.5rem;
}

.overlay-content p {
  color: #c0c0c0;
  font-size: 1rem;
}

#player-name {
  padding: 0.6rem 1rem;
  border: 2px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

#player-name:focus {
  border-color: #4ecca3;
}

#start-btn {
  padding: 0.7rem 2rem;
  background: #4ecca3;
  color: #1a1a2e;
  border: none;
  border-radius: 4px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

#start-btn:hover {
  background: #3ab88f;
}

.score-display {
  font-size: 1.3rem;
  color: #4ecca3;
  font-weight: bold;
}

.leaderboard {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 1.5rem;
  min-width: 220px;
  max-width: 280px;
  width: min(100%, 280px);
}

.leaderboard h2 {
  color: #4ecca3;
  font-size: 1.3rem;
  margin-bottom: 1rem;
  text-align: center;
  letter-spacing: 0.05em;
}

#leaderboard-list {
  list-style: none;
  counter-reset: leaderboard;
}

#leaderboard-list li {
  counter-increment: leaderboard;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #0f3460;
  font-size: 0.95rem;
  transition: background 0.2s;
}

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

#leaderboard-list li::before {
  content: counter(leaderboard) ".";
  color: #4ecca3;
  font-weight: bold;
  margin-right: 0.5rem;
  min-width: 1.5em;
}

#leaderboard-list li .lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#leaderboard-list li .lb-score {
  font-weight: bold;
  color: #4ecca3;
  margin-left: 0.5rem;
}

#leaderboard-list li.highlight {
  background: rgba(78, 204, 163, 0.15);
  border-radius: 4px;
}

.leaderboard .empty-msg {
  text-align: center;
  color: #666;
  font-style: italic;
  padding: 1rem 0;
}

.mobile-placeholder {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #1a1a2e;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  padding: 2rem;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}
.mobile-placeholder svg {
  width: 120px;
  height: 120px;
}
.mobile-placeholder p {
  color: #4ecca3;
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  line-height: 1.5;
}

@media (max-width: 1024px) {
  .mobile-placeholder { display: flex; }

  .container {
    flex-direction: column;
    align-items: center;
  }

  .canvas-wrapper {
    width: min(92vw, 520px);
  }

  .leaderboard {
    width: min(92vw, 520px);
    max-width: 520px;
  }
}
