* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

body {
  background-color: #f0f0f0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

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

#game {
  position: relative;
  width: 400px;
  height: 600px;
  background-color: #fff;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

#legend {
  width: 400px;
  margin-top: 12px;
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

#legend h3 {
  font-size: 16px;
  color: #333;
  margin-bottom: 8px;
}

.legend-list {
  display: flex;
  gap: 16px;
}

.legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.legend-item span {
  font-size: 12px;
  color: #666;
  line-height: 1;
}

/* canvas-based swatches rendered by game code */
.legend-canvas {
  width: 60px;
  height: 16px;
  image-rendering: pixelated;
  border-radius: 2px;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  /* Prevent default gestures (long-press, double-tap zoom, etc.) in game area */
  touch-action: none;
}

#score {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 24px;
  font-weight: bold;
  color: #333;
  z-index: 2;
}

#start-screen,
#game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 3;
  text-align: center;
  padding: 20px;
}

/* Settings overlay */
#settings-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  background-color: rgba(255, 255, 255, 0.95);
  z-index: 4;
  padding: 20px;
}

#settings-screen h2 {
  text-align: center;
  margin-bottom: 12px;
}

.settings-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.settings-group label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: #333;
}

.settings-group input[type="range"] {
  width: 100%;
}

.settings-group .value {
  color: #888;
  font-size: 12px;
}

.settings-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.settings-presets {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.settings-presets button {
  padding: 6px 10px;
  font-size: 14px;
}

/* Disable text selection and iOS callouts within the game area to avoid long-press selection */
#game,
#game * {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

h1,
h2 {
  color: #4caf50;
  margin-bottom: 20px;
}

button {
  padding: 10px 20px;
  font-size: 18px;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 10px 0;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #45a049;
}

p {
  margin: 15px 0;
  color: #555;
  font-size: 16px;
  line-height: 1.5;
}

/* Start screen options */
.option-row {
  margin: 8px 0 2px;
}

label.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #333;
  user-select: none;
}

label.checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
}
