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

body {
  background: #0C0D14;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  padding: 12px;
  gap: 12px;
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 4px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#design-name {
  color: #ffcc00;
}

#progress {
  color: #00ff88;
  font-variant-numeric: tabular-nums;
}

#grid-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid #2a2d3a;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}

#grid-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

#palette {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  padding: 8px 0;
}

.palette-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 3px solid transparent;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 900;
  color: #000;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.3);
}

.palette-btn:hover {
  transform: scale(1.1);
}

.palette-btn.selected {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  transform: scale(1.15);
}

.palette-btn .remaining {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #888;
  white-space: nowrap;
  -webkit-text-stroke: 0;
}

#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(12, 13, 20, 0.92);
  z-index: 10;
  transition: opacity 0.3s ease;
}

#overlay.hidden {
  display: none;
}

#overlay-box {
  text-align: center;
  padding: 40px 48px;
  background: #161822;
  border: 2px solid #2a2d3a;
  border-radius: 12px;
  max-width: 90vw;
}

#overlay-box h1 {
  font-size: 36px;
  margin-bottom: 16px;
  font-weight: 700;
  color: #00ff88;
}

#overlay-box p {
  font-size: 18px;
  margin-bottom: 10px;
  color: #ccc;
}

.controls-hint {
  font-size: 14px !important;
  color: #888 !important;
  margin-bottom: 20px !important;
}

.btn {
  display: inline-block;
  margin-top: 16px;
  padding: 14px 36px;
  background: #00ff88;
  color: #0C0D14;
  border: none;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn:hover {
  background: #33ffaa;
  transform: scale(1.05);
}

.btn:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

@media (max-width: 400px) {
  #game-container {
    padding: 8px;
    gap: 8px;
  }

  #hud {
    font-size: 14px;
  }

  .palette-btn {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }

  #overlay-box {
    padding: 28px 24px;
  }

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

  #overlay-box p {
    font-size: 16px;
  }
}
