* {
  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;
}

#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-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  width: 100%;
  max-width: 800px;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 4px;
}

.toolbar-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

#move-counter,
#timer-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
}

#timer-display {
  justify-content: flex-end;
}

#new-game-btn {
  background: #3c4043;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #e8eaed;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

#new-game-btn:hover {
  background: #5f6368;
}

#new-game-btn:active {
  transform: scale(0.95);
}

/* Difficulty */
#difficulty-bar {
  display: flex;
  gap: 6px;
  background: #292a2d;
  padding: 4px;
  border-radius: 12px;
}

.diff-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #9aa0a6;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.diff-btn:hover {
  color: #e8eaed;
}

.diff-btn.active {
  background: #ef6c00;
  color: #fff;
}

#optimal-display {
  font-size: 14px;
  color: #9aa0a6;
}

/* Canvas */
#game-canvas {
  border-radius: 12px;
  cursor: pointer;
  max-width: 100%;
}

#peg-labels {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 720px;
  margin-top: -8px;
}

#peg-labels span {
  font-size: 16px;
  font-weight: 700;
  color: #5f6368;
  width: 33.33%;
  text-align: center;
}

/* Actions bar */
#actions-bar {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #9aa0a6;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.action-btn:hover {
  background: #3c4043;
  color: #e8eaed;
}

.action-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

#hint-text {
  font-size: 13px;
  color: #5f6368;
  margin-top: 4px;
}

/* Win overlay */
#win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

#win-overlay .win-box {
  background: #303134;
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#win-overlay h2 {
  font-size: 28px;
  margin-bottom: 8px;
  color: #ef6c00;
}

#win-overlay p {
  font-size: 16px;
  color: #9aa0a6;
  margin-bottom: 20px;
}

#win-overlay button {
  background: #ef6c00;
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

#win-overlay button:hover {
  background: #f57c00;
}

@media (max-width: 640px) {
  #game-container {
    padding: 12px;
  }

  .diff-btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .action-btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  #peg-labels span {
    font-size: 14px;
  }
}
