/* Paint It — game-specific layout. Base look comes from ../common.css. */
body { background: #fff3e0; }

.screen {
  position: fixed;
  inset: 0;
  padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
           calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}

/* ---- Picker ---- */
.home-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
#picker {
  overflow-y: auto;
  touch-action: pan-y;   /* the picker is the one place that scrolls */
}
.heading {
  color: #6d4c41;
  font-size: clamp(22px, 5vw, 36px);
  text-align: center;
  margin: 12px 0 16px;
  padding: 0 70px;   /* room for the 🏠 button */
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto 24px;
}
.grid.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.card {
  border: none;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 4px 0 #ffcc80, 0 6px 14px rgba(0, 0, 0, 0.08);
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #6d4c41;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
}
.card:active { transform: translateY(3px); box-shadow: 0 1px 0 #ffcc80; }
.card canvas, .card img { width: 100%; aspect-ratio: 1; border-radius: 16px; display: block; }

/* ---- Studio ---- */
#studio { display: flex; flex-direction: column; gap: 10px; }
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar .title {
  flex: 1;
  text-align: center;
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 700;
  color: #6d4c41;
  white-space: nowrap;
  overflow: hidden;
}
.middle { flex: 1; min-height: 0; display: flex; gap: 10px; }
/* the canvas sits absolutely in a wrapper, so its pixel size never feeds back into the layout */
.stage-wrap { flex: 1; min-width: 0; min-height: 0; position: relative; }
#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: #fffaf3;
  touch-action: none;
}
.tools {   /* a column of tools; --rows (set by resizeStage) wraps it into more columns on short screens */
  display: grid;
  grid-template-rows: repeat(var(--rows, 8), 60px);
  grid-auto-flow: column;
  gap: 10px;
}
.tools .ctrl-btn { width: 60px; height: 60px; font-size: 28px; border-radius: 18px; flex-shrink: 0; }

.bottom { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.row:empty { display: none; }

.swatch {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}
.swatch.on { transform: scale(1.18); box-shadow: 0 0 0 4px #6d4c41; }

.opt {
  min-width: 52px;
  height: 52px;
  padding: 0 10px;
  border: none;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  font-size: 28px;
  color: #6d4c41;
  display: flex;
  align-items: center;
  justify-content: center;
}
.opt.on { background: #ffe082; box-shadow: 0 0 0 3px #ffb300; }
.text-in {
  width: 220px;
  height: 52px;
  font-size: 24px;
  padding: 0 16px;
  border: 3px solid #ffb300;
  border-radius: 16px;
  outline: none;
  color: #6d4c41;
  -webkit-user-select: text;   /* typing needs selection, despite the app-wide no-select */
  user-select: text;
  touch-action: auto;
}
.opt .dot { display: block; border-radius: 50%; background: #6d4c41; }

/* Phones in portrait: tools go in a row above the stage. */
@media (max-aspect-ratio: 3/4) {
  .middle { flex-direction: column; }
  .tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .tools .ctrl-btn { width: 46px; height: 46px; font-size: 22px; border-radius: 14px; }
  /* options (stickers…) scroll sideways instead of eating the stage */
  #options { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; touch-action: pan-x; padding: 4px; }
  #options .opt { flex-shrink: 0; }
  .swatch { width: 40px; height: 40px; }
}

/* ---- Viewer ---- */
#viewer-img { max-width: min(80vw, 70vh); max-height: 70vh; border-radius: 24px; background: #fff; }
