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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Trebuchet MS', sans-serif;
  background: #050510;
  color: #fff;
  user-select: none;
  touch-action: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.panel {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 360px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px;
  background: rgba(10, 10, 30, 0.85);
  border: 2px solid #4af;
  border-radius: 18px;
  box-shadow: 0 0 30px rgba(74, 170, 255, 0.4);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.panel.hidden { display: none; }

h1 {
  font-size: 24px;
  margin-bottom: 16px;
  color: #4af;
  text-shadow: 0 0 12px #4af;
  text-align: center;
}

h2 {
  font-size: 16px;
  margin: 12px 0 8px;
  color: #cfd;
}

section { margin-bottom: 14px; }

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

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  outline: none;
  transition: transform 0.1s, box-shadow 0.2s;
}

button:active { transform: scale(0.95); }

.big {
  flex: 1 1 30%;
  padding: 14px 8px;
  font-size: 16px;
  font-weight: bold;
  background: #223;
  color: #fff;
  border: 2px solid #445;
  border-radius: 12px;
}

.big.active {
  background: #4af;
  border-color: #fff;
  color: #000;
  box-shadow: 0 0 14px #4af;
}

.chip {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  background: #223;
  color: #fff;
  border: 2px solid #445;
  border-radius: 10px;
}

.chip.active {
  background: #fc4;
  border-color: #fff;
  color: #000;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}

.swatch.active {
  border-color: #fff;
  box-shadow: 0 0 10px currentColor;
}

.plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 8px;
  vertical-align: middle;
  font-size: 20px;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  background: #e22;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(238, 34, 34, 0.7);
  cursor: pointer;
  padding: 0;
}

.plus:hover { background: #f44; }

.saved {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 8px;
}

.saved .preset {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 26px 6px 10px;
  background: #223;
  color: #fff;
  border: 2px solid #445;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}

.saved .preset:hover { border-color: #4af; }

.saved .preset .swatch-mini {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #fff;
  box-shadow: 0 0 6px currentColor;
}

.saved .preset .del {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 16px;
  height: 16px;
  font-size: 12px;
  line-height: 1;
  background: transparent;
  color: #f88;
  border: none;
  cursor: pointer;
  padding: 0;
}

.saved .preset .del:hover { color: #f33; }

.saved .empty {
  font-size: 12px;
  color: #889;
  font-style: italic;
}

.play {
  width: 100%;
  margin-top: 16px;
  padding: 18px;
  font-size: 22px;
  font-weight: bold;
  color: #000;
  background: linear-gradient(135deg, #4f4 0%, #4af 100%);
  border-radius: 14px;
  letter-spacing: 2px;
  box-shadow: 0 0 20px #4f4;
}

.edit {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: bold;
  background: rgba(10, 10, 30, 0.85);
  color: #4af;
  border: 2px solid #4af;
  border-radius: 10px;
  z-index: 10;
}

.edit.hidden { display: none; }

.hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 9;
  pointer-events: none;
}

.hud.hidden { display: none; }

#lives {
  display: flex;
  gap: 10px;
  font-size: 32px;
  line-height: 1;
  text-shadow: 0 0 8px #000;
}

#lives .life {
  filter: drop-shadow(0 0 4px #f33);
}

#lives .lost {
  filter: drop-shadow(0 0 4px #800);
  opacity: 0.8;
}

#score {
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  background: rgba(10, 10, 30, 0.7);
  padding: 6px 16px;
  border-radius: 10px;
  border: 2px solid #4af;
  text-shadow: 0 0 8px #4af;
}

.gameover {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 10, 30, 0.92);
  border: 2px solid #f44;
  border-radius: 18px;
  padding: 30px 40px;
  text-align: center;
  z-index: 20;
  box-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
  min-width: 280px;
}

.gameover.hidden { display: none; }

.gameover h2 {
  font-size: 32px;
  color: #f44;
  margin-bottom: 12px;
  text-shadow: 0 0 12px #f44;
}

.gameover #finalScore {
  font-size: 22px;
  margin-bottom: 20px;
  color: #fff;
}

@media (max-width: 480px) {
  .panel { width: calc(100% - 20px); top: 10px; left: 10px; padding: 14px; }
  h1 { font-size: 20px; }
  .swatches { grid-template-columns: repeat(8, 1fr); }
}
