
:root{
  --bg1:#e9f7ff;
  --bg2:#f3fff5;
  --panel:#ffffffcc;
  --shadow:0 10px 30px rgba(0,0,0,.12);
  --radius:18px;
  --ink:#151515;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--ink);
  background: radial-gradient(1200px 700px at 70% 10%, var(--bg1) 0%, #f7fbff 45%, var(--bg2) 100%);
}

.topbar{
  position:sticky;top:0;z-index:10;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:10px 12px;
  background:var(--panel);backdrop-filter:blur(10px);
  box-shadow: var(--shadow);
}
.brand{display:flex;align-items:center;gap:10px}
.logo{height:40px;width:auto;max-width:140px;object-fit:contain}
.title{font-weight:950;letter-spacing:.2px}
.sub{font-size:12px;opacity:.75}
.scoreHint{font-size:12px;opacity:.75;font-weight:800;white-space:nowrap}
.backBtn{
  text-decoration:none;
  font-weight:900;
  color:#111;
  background:#fff;
  padding:10px 12px;
  border-radius:14px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.10);
}

/* Selection page */
.selectMain{padding:12px}
.selectGrid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:12px;
}
.card{
  background:#fff;border-radius:18px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.08), 0 10px 20px rgba(0,0,0,.10);
  padding:10px;
}
.card img{
  width:100%;
  height:180px;
  object-fit:cover;
  border-radius:14px;
  display:block;
}
.card a{
  display:block;
  margin-top:10px;
  text-align:center;
  text-decoration:none;
  font-weight:950;
  background:#111;color:#fff;
  padding:12px 10px;
  border-radius:14px;
}
@media (min-width: 900px){
  .selectGrid{grid-template-columns: repeat(3, 1fr);}
  .card img{height:220px}
}

/* Painter page */
.paintBody{
  padding-bottom: calc(var(--dockH, 190px) + env(safe-area-inset-bottom));
}
.stage{padding:12px}
.canvasWrap{
  width:100%;
  height: min(62dvh, 640px);
  border-radius: 18px;
  overflow:hidden;
  background:#fff;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.08), 0 10px 25px rgba(0,0,0,.10);
  position:relative;
}
canvas{position:absolute;inset:0;width:100%;height:100%;touch-action:none}

.dock{
  position:fixed;left:0;right:0;bottom:0;z-index:20;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -14px 40px rgba(0,0,0,.18);
  padding:10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.toolRow{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
}
.pill{
  border:0;
  padding:10px 12px;
  border-radius: 14px;
  background:#fff;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.10);
  font-weight:900;
}
.pill.active{background:#111;color:#fff;box-shadow:none}
.spacer{flex:1}
.iconBtn{
  border:0;border-radius:14px;
  padding:10px 12px;
  background:#fff;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.10);
  font-weight:900;
}
.primaryBtn{
  border:0;border-radius:14px;
  padding:10px 12px;
  background:#111;color:#fff;
  font-weight:950;
}
.sizeRow{
  display:flex;align-items:center;gap:10px;
  margin-top:8px;
  font-size:13px;
}
.sizeRow input{flex:1}
.paletteWrap{margin-top:8px}
.palette{
  display:flex;gap:10px;overflow:auto;scrollbar-width:none;
  padding:6px 2px 2px;
}
.palette::-webkit-scrollbar{display:none}
.swatch{
  width:36px;height:36px;border-radius:14px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.12);
  flex:0 0 auto;
}
.swatch.active{box-shadow: inset 0 0 0 4px rgba(0,0,0,.55);}

@media (min-width: 900px){
  .paintBody{padding-bottom: 160px}
  .canvasWrap{height:min(74dvh, 760px)}
  .dock{max-width:1100px;margin:0 auto;border-radius:18px;left:0;right:0}
}


/* --- Compact UI on painting page (more space for the drawing) --- */
.paintBody .topbar{
  padding: 6px 10px;
}
.paintBody .logo{
  height: 30px;
}
.paintBody .title{ font-size: 16px; }
.paintBody .sub{ font-size: 11px; }

.paintBody .backBtn{
  padding: 8px 10px;
  border-radius: 12px;
}

.paintBody .dock{
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.paintBody .pill{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}
.paintBody .iconBtn{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}
.paintBody .primaryBtn{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}
.paintBody .sizeRow{
  margin-top: 6px;
  font-size: 12px;
}
.paintBody .paletteWrap{ margin-top: 6px; }
.paintBody .palette{ gap: 8px; padding: 4px 2px 2px; }
.paintBody .swatch{
  width: 30px; height: 30px; border-radius: 12px;
}

/* Keep tool row in one line (scroll if needed) to reduce dock height */
.paintBody .toolRow{
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.paintBody .toolRow::-webkit-scrollbar{display:none}
.paintBody .spacer{flex:0 0 8px}
