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

html, body {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(#cfe9ff, #fff4d6);
  font-family: system-ui, sans-serif;
  /* Stop long-press menus, text selection and rubber-band scrolling on iPad. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.screen {
  height: 100%;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.screen[hidden] { display: none; }

.grid {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  overflow-y: auto;
  align-content: start;
}

.card {
  aspect-ratio: 1;
  background: #fff;
  border-radius: 32px;
  padding: 16px;
  box-shadow: 0 6px 0 #0001;
  transition: transform 0.1s;
}

.card:active { transform: scale(0.94); }
.card svg { width: 100%; height: 100%; }

#draw {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  gap: 16px;
}

.toolbar, .palette {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
}

.tool {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: #fff;
  font-size: 44px;
  box-shadow: 0 5px 0 #0002;
}

.tool.active, .swatch.active { outline: 6px solid #007aff; outline-offset: 3px; }

.swatch {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 5px solid #fff;
  box-shadow: 0 4px 0 #0002;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.canvas-wrap { position: relative; }

canvas {
  display: block;
  border-radius: 24px;
  touch-action: none;
}

#paint { box-shadow: 0 8px 0 #0001; }

#outline {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Portrait iPad: tools on top, colours on the bottom. */
@media (orientation: portrait) {
  #draw {
    grid-template-columns: 1fr;
    grid-template-rows: 96px 1fr 96px;
  }

  .toolbar, .palette { flex-direction: row; }
}
