:root {
  --ink: #172033;
  --paper: #fffdf5;
  --paper-soft: #fff6db;
  --panel: #ffffff;
  --line: #182134;
  --shadow: 0 18px 40px rgba(31, 41, 73, .17);
  --selected: #ffce2e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 214, 78, .44), transparent 23rem),
    radial-gradient(circle at 82% 11%, rgba(88, 213, 255, .38), transparent 24rem),
    radial-gradient(circle at 76% 82%, rgba(255, 102, 163, .28), transparent 22rem),
    linear-gradient(135deg, #78d9ff 0%, #ffe86f 47%, #ff99c9 100%);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 24px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
}

.stage,
.palette-panel {
  border: 5px solid var(--line);
  background: rgba(255, 253, 245, .92);
  box-shadow: var(--shadow);
}

.stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  overflow: hidden;
}

.topbar {
  min-height: 84px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .98), rgba(255, 246, 219, .95)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255, 206, 46, .16) 12px 24px);
  border-bottom: 5px solid var(--line);
}

.kicker {
  margin: 0 0 2px;
  font-size: .9rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2.35rem;
  line-height: .96;
}

h2 {
  font-size: 1.28rem;
  line-height: 1;
}

.status {
  min-height: 54px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 4px solid var(--line);
  border-radius: 18px;
  background: #fff;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 6px 0 #172033;
}

.status-dot,
.paint-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: inline-block;
  border: 4px solid var(--line);
  border-radius: 50%;
  background: var(--selected);
}

.scene-wrap {
  position: relative;
  flex: 1;
  min-height: 500px;
  padding: 12px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(#ffffff 0 0) padding-box,
    repeating-linear-gradient(90deg, rgba(23, 32, 51, .06) 0 2px, transparent 2px 42px),
    repeating-linear-gradient(0deg, rgba(23, 32, 51, .06) 0 2px, transparent 2px 42px);
}

.city-scene {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 130px);
  min-height: 492px;
  display: block;
  border-radius: 18px;
  background: var(--paper);
  touch-action: manipulation;
}

.colorable {
  stroke: var(--line);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill .18s ease, transform .18s ease, filter .18s ease;
  transform-box: fill-box;
  transform-origin: center;
}

.colorable:hover,
.colorable:focus {
  filter: drop-shadow(0 0 7px rgba(255, 206, 46, .95));
}

.colorable:active,
.colorable.pop {
  transform: scale(1.035);
}

.colorable.wide {
  stroke-width: 6;
}

.colorable.small {
  stroke-width: 6;
}

.colorable.backdrop {
  stroke: none;
}

.sun-rays,
.clock-hands,
.road-line,
.playground-lines,
.balloon-string,
.friend-lines,
.track {
  fill: none;
  stroke: var(--line);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.road-line {
  stroke: #fff7b8;
  stroke-width: 10;
  stroke-dasharray: 1 1;
}

.sidewalk-dots {
  fill: url(#sidewalkDots);
  pointer-events: none;
}

.palette-panel {
  border-radius: 24px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    linear-gradient(180deg, #fff 0%, #fff8dd 100%);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, 1fr));
  gap: 8px;
}

.color-button,
.tool-button,
.stamp-button {
  border: 4px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 0 #172033;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
  touch-action: manipulation;
}

.color-button {
  min-height: 62px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  position: relative;
}

.color-button::before {
  content: "";
  width: 36px;
  height: 36px;
  border: 4px solid var(--line);
  border-radius: 50%;
  background: var(--swatch);
}

.color-button.is-selected {
  outline: 4px solid #ff3f8d;
  outline-offset: 3px;
  background: #fff3a8;
  transform: translateY(2px);
  box-shadow: 0 3px 0 #172033;
}

.tool-stack {
  display: grid;
  gap: 10px;
}

.tool-button {
  min-height: 48px;
  border-radius: 16px;
  font-weight: 950;
  font-size: 1rem;
}

.rainbow-button {
  color: #11182a;
  background: linear-gradient(90deg, #ff4e8a, #ffd83d, #4ee870, #46d7ff, #b982ff);
}

.color-button:active,
.tool-button:active,
.stamp-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #172033;
}

.stamp-box {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.stamp-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stamp-button {
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 16px;
  position: relative;
}

.stamp-button[data-stamp="star"]::before,
.sparkle.star {
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.stamp-button[data-stamp="heart"]::before,
.sparkle.heart {
  clip-path: polygon(50% 88%, 14% 55%, 6% 34%, 10% 18%, 24% 8%, 39% 12%, 50% 27%, 61% 12%, 76% 8%, 90% 18%, 94% 34%, 86% 55%);
}

.stamp-button[data-stamp="circle"]::before,
.sparkle.circle {
  border-radius: 50%;
}

.stamp-button::before {
  content: "";
  position: absolute;
  inset: 15px;
  background: var(--selected);
  border: 3px solid var(--line);
}

.sparkle-layer {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  overflow: hidden;
  border-radius: 18px;
  z-index: 2;
}

.sparkle {
  position: absolute;
  width: 30px;
  height: 30px;
  background: var(--sparkle-color);
  border: 3px solid var(--line);
  animation: popAway .9s ease-out forwards;
}

@keyframes popAway {
  0% {
    transform: translate(-50%, -50%) scale(.25) rotate(0deg);
    opacity: 0;
  }
  28% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.35) rotate(var(--spin));
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 16px, 720px);
    margin: 8px auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 138px;
  }

  h1 {
    font-size: 2.15rem;
  }

  .status {
    width: 100%;
    max-width: none;
  }

  .scene-wrap {
    min-height: 420px;
    padding: 8px;
  }

  .city-scene {
    min-height: 390px;
    max-height: 58vh;
  }

  .palette-panel {
    position: sticky;
    bottom: 8px;
    z-index: 3;
  }

  .palette-grid {
    grid-template-columns: repeat(4, minmax(62px, 1fr));
  }

  .tool-stack {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: calc(100vw - 10px);
    min-height: calc(100vh - 10px);
    margin: 5px auto;
    gap: 8px;
  }

  .stage,
  .palette-panel {
    border-width: 4px;
    border-radius: 18px;
  }

  .topbar {
    padding: 12px;
  }

  h1 {
    font-size: 1.82rem;
  }

  .status {
    min-height: 48px;
    font-size: .9rem;
    box-shadow: 0 4px 0 #172033;
  }

  .scene-wrap {
    min-height: 330px;
  }

  .city-scene {
    min-height: 320px;
    max-height: 50vh;
  }

  .palette-panel {
    padding: 12px;
    gap: 10px;
  }

  .palette-grid {
    grid-template-columns: repeat(4, minmax(54px, 1fr));
    gap: 8px;
  }

  .color-button {
    min-height: 58px;
    border-radius: 14px;
  }

  .color-button::before {
    width: 34px;
    height: 34px;
  }

  .tool-button {
    min-height: 48px;
    font-size: .86rem;
    border-radius: 14px;
  }

  .stamp-box {
    display: none;
  }
}
