* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  background: #fff7d6;
  color: #253047;
}

.app {
  width: min(100% - 32px, 900px);
  margin: 0 auto;
  padding: 18px 0;
}

header {
  text-align: center;
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 4px;
  font-size: clamp(1.8rem, 5vw, 3rem);
  color: #d93662;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

p {
  margin: 0;
  font-size: 1.2rem;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding: 6px 4px 8px;
}

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

.color-area {
  flex: 0 0 auto;
}

button {
  min-height: 44px;
  border: 3px solid #253047;
  border-radius: 14px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  color: #253047;
  background: white;
  cursor: pointer;
  box-shadow: 0 4px 0 #253047;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #253047;
}

.color-button {
  display: flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.color-dot {
  width: 28px;
  height: 28px;
  border: 2px solid #253047;
  border-radius: 50%;
}

.color-name,
.hidden-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.active {
  outline: 4px solid #31c4ff;
  outline-offset: 2px;
}

.buttons {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
}

#eraserButton.active {
  background: #aee8ff;
}

#randomButton {
  background: #ffe66d;
}

#clearButton {
  background: #ff9aa2;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  padding: 10px;
  border: 4px solid #253047;
  border-radius: 18px;
  background: #8bd3dd;
}

.field {
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 3px solid #253047;
  border-radius: 10px;
  padding: 0;
  background: #eeeeee;
  cursor: pointer;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12);
}

.field:hover {
  filter: brightness(1.05);
}

@media (min-width: 700px) {
  .controls {
    flex-wrap: nowrap;
  }
}

@media (max-width: 520px) {
  .app {
    width: min(100% - 20px, 900px);
  }

  p {
    font-size: 1rem;
  }

  button {
    min-height: 40px;
    padding: 7px 10px;
    font-size: 0.95rem;
  }

  .color-button {
    width: 42px;
    height: 42px;
    padding: 5px;
  }

  .color-dot {
    width: 26px;
    height: 26px;
  }

  .grid {
    gap: 4px;
    padding: 6px;
  }

  .field {
    border-width: 2px;
    border-radius: 7px;
  }
}
