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

body {
  background: #202124;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8eaed;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

#back-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  z-index: 20;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #5f6368;
  transition: background 0.2s;
  line-height: 1;
}

#back-btn:hover {
  background: #80868b;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  padding: 0 4px;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#high-score-display {
  color: #9aa0a6;
}

#canvas-wrap {
  position: relative;
}

#game-canvas {
  display: block;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* Overlay */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
}

#overlay.visible {
  display: flex;
}

#overlay-content {
  text-align: center;
  background: rgba(32, 33, 36, 0.94);
  padding: 40px 52px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#overlay-content h1 {
  font-size: 40px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #40e0d0;
}

#overlay-message {
  font-size: 15px;
  color: #9aa0a6;
  margin-bottom: 22px;
  line-height: 1.5;
}

#difficulty-select {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.diff-btn {
  background: #3c4043;
  color: #9aa0a6;
  border: 2px solid transparent;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.diff-btn:hover {
  background: #4a4d50;
}

.diff-btn.selected {
  border-color: #40e0d0;
  color: #40e0d0;
  background: rgba(64, 224, 208, 0.1);
}

.diff-btn[data-diff="0"].selected {
  border-color: #66bb6a;
  color: #66bb6a;
  background: rgba(102, 187, 106, 0.1);
}

.diff-btn[data-diff="1"].selected {
  border-color: #ffa726;
  color: #ffa726;
  background: rgba(255, 167, 38, 0.1);
}

.diff-btn[data-diff="2"].selected {
  border-color: #ef5350;
  color: #ef5350;
  background: rgba(239, 83, 80, 0.1);
}

#start-btn {
  background: #40e0d0;
  color: #1a1a2e;
  border: none;
  padding: 13px 48px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#start-btn:hover {
  background: #33ccbb;
  transform: scale(1.04);
}

#start-btn:active {
  transform: scale(0.97);
}

@media (max-width: 500px) {
  #overlay-content {
    padding: 28px 24px;
  }

  #overlay-content h1 {
    font-size: 28px;
  }

  .diff-btn {
    padding: 8px 16px;
    font-size: 13px;
  }

  #hud {
    font-size: 15px;
  }
}
