/* Pixel Maker — Mignuti Kids
 * Paint on a pixel board; finished pictures can be ordered as a real plug-in pixel picture on pixel.mignuti.com.
 * Mirrors the Banana Berry palette and the pill buttons used across the other games.
 */

:root {
  --color-cream: #fff8e7;
  --color-cream-warm: #ffe9c7;
  --color-sky: #4ecdc4;
  --color-banana: #ffd93d;
  --color-berry: #de1c56;
  --color-leaf: #4aa84f;
  --color-ink: #2c2c2c;
  --board: #24242c;
  --shadow-card: 0 8px 24px rgba(44, 44, 44, 0.18);
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: linear-gradient(180deg, #fff8e7 0%, #ffe9c7 70%, #ffd9a8 100%);
  color: var(--color-ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  overflow: hidden;
}

.app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 2.5vw, 18px);
  padding-top: max(clamp(10px, 2.5vw, 18px), env(safe-area-inset-top));
  padding-bottom: max(clamp(10px, 2.5vw, 18px), env(safe-area-inset-bottom));
  animation: fadeIn 180ms ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

/* ================== Start screen ================== */

.screen--start {
  overflow-y: auto;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.start__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 0;
  font-size: clamp(26px, 6vw, 38px);
  font-weight: 900;
  color: var(--color-berry);
}

/* 2 × 2 pixel logo */
.start__logo {
  width: 30px;
  height: 30px;
  background:
    linear-gradient(var(--color-berry), var(--color-berry)) 0 0 / 13px 13px no-repeat,
    linear-gradient(var(--color-banana), var(--color-banana)) 17px 0 / 13px 13px no-repeat,
    linear-gradient(var(--color-sky), var(--color-sky)) 0 17px / 13px 13px no-repeat,
    linear-gradient(var(--color-leaf), var(--color-leaf)) 17px 17px / 13px 13px no-repeat;
}

.start__sub {
  margin: 0 0 6px;
  font-size: clamp(15px, 3.4vw, 18px);
  font-weight: 700;
  opacity: 0.85;
}

.start__continue {
  margin: 4px 0;
}

.start__label {
  margin: 10px 0 4px;
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.size-row,
.motif-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 96px;
  padding: 10px 12px 8px;
  border: 3px solid var(--color-ink);
  border-radius: 20px;
  background: #fff;
  color: var(--color-ink);
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--color-ink);
  transition:
    transform 100ms ease,
    box-shadow 100ms ease;
}

.card-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-ink);
}

.card-btn:focus-visible {
  outline: 3px solid var(--color-banana);
  outline-offset: 3px;
}

.card-btn canvas {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  image-rendering: pixelated;
}

.card-btn small {
  font-weight: 700;
  opacity: 0.65;
}

/* ================== Paint screen ================== */

.screen--paint {
  gap: 10px;
}

.paint__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.paint__history {
  display: flex;
  gap: 8px;
}

.paint__body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}

/* Landscape: board left, dock right */
@media (min-aspect-ratio: 1/1) {
  .paint__body {
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  }

  .dock {
    align-content: center;
  }
}

.board-wrap {
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
}

.board {
  display: block;
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  touch-action: none;
  cursor: crosshair;
}

.board:focus-visible {
  outline: 3px solid var(--color-banana);
  outline-offset: 4px;
}

.dock {
  display: grid;
  gap: 10px;
}

.toolbar,
.tools {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.toolbar {
  flex-wrap: wrap;
}

.tool {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid var(--color-ink);
  border-radius: 16px;
  background: #fff;
  color: var(--color-ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--color-ink);
}

/* Mirror / clear: separated a little from the paint tools */
#mirrorBtn {
  margin-left: 6px;
}

.tool svg {
  width: 28px;
  height: 28px;
}

.tool[aria-checked="true"],
.tool[aria-pressed="true"] {
  background: var(--color-banana);
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-ink);
}

.tool:focus-visible,
.swatch:focus-visible {
  outline: 3px solid var(--color-berry);
  outline-offset: 3px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 40px));
  gap: 8px;
  justify-content: center;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid var(--color-ink);
  border-radius: 10px;
  cursor: pointer;
  /* round stud on top, like a real pixel */
  background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.28) 0 30%, transparent 32%);
}

.swatch[aria-checked="true"] {
  transform: scale(1.12);
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 6px var(--color-ink);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border: 3px solid var(--color-ink);
  border-radius: 999px;
  background: #fff;
  color: var(--color-ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--color-ink);
  transition:
    transform 100ms ease,
    box-shadow 100ms ease;
}

.pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-ink);
}

.pill-btn:focus-visible {
  outline: 3px solid var(--color-banana);
  outline-offset: 3px;
}

.pill-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: 0 2px 0 var(--color-ink);
}

.pill-btn[aria-pressed="true"] {
  background: var(--color-banana);
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--color-ink);
}

.pill-btn--primary {
  background: var(--color-leaf);
  color: #fff;
  border-color: #2f7b33;
  box-shadow: 0 4px 0 #2f7b33;
}

.pill-btn--primary:active {
  box-shadow: 0 1px 0 #2f7b33;
}

.pill-btn--secondary {
  background: var(--color-banana);
}

.pill-btn--danger {
  background: var(--color-berry);
  color: #fff;
  border-color: #8a1236;
  box-shadow: 0 4px 0 #8a1236;
}

.pill-btn--icon {
  padding: 0;
  width: 44px;
  height: 44px;
  font-size: 22px;
  line-height: 1;
}

/* ================== Overlays ================== */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(44, 44, 44, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 14px;
  z-index: 10;
  overflow-y: auto;
  animation: fadeIn 160ms ease both;
}

.overlay-card {
  background: var(--color-cream);
  border: 4px solid var(--color-leaf);
  border-radius: 28px;
  padding: clamp(16px, 4vw, 26px) clamp(16px, 5vw, 30px);
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.overlay-title {
  margin: 0 0 10px;
  font-size: clamp(22px, 5vw, 28px);
  color: var(--color-berry);
  font-weight: 900;
}

.overlay-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.done-card {
  border-color: var(--color-banana);
}

.done-preview {
  display: block;
  width: min(220px, 38vh);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto 6px;
  border-radius: 12px;
}

.done-count {
  margin: 0 0 12px;
  font-weight: 800;
  opacity: 0.75;
}

.real {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 3px dashed rgba(44, 44, 44, 0.2);
}

.real__lead {
  margin: 0 0 10px;
  font-weight: 700;
  line-height: 1.35;
}

.real__btn {
  width: 100%;
}

.real__note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.7;
}

/* Small screens (phone, portrait game frame): compact dock so the board gets the space */
@media (max-width: 480px) {
  .screen--paint {
    gap: 8px;
  }

  .paint__body {
    gap: 8px;
  }

  .dock {
    gap: 8px;
  }

  .tool {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .tool svg {
    width: 22px;
    height: 22px;
  }

  .toolbar,
  .tools {
    gap: 6px;
  }

  #mirrorBtn {
    margin-left: 4px;
  }

  .palette {
    gap: 6px;
  }

  .swatch {
    border-width: 2px;
    border-radius: 8px;
  }

  .pill-btn {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .overlay-card {
    padding: 14px;
    border-radius: 22px;
  }

  .done-preview {
    width: min(150px, 30vh);
  }

  .real {
    margin-top: 10px;
    padding-top: 10px;
  }

  .real__lead {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
