*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { touch-action: manipulation; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fff9f0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.screen { display: none; width: 100%; height: 100vh; height: 100dvh; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* START SCREEN */
.start-card {
  background: #fff9f0;
  border: 3px solid #ffb347;
  border-radius: 20px;
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.logo { margin-bottom: 12px; }
.app-name { font-size: 32px; font-weight: 900; color: #1a1a1a; margin-bottom: 12px; }
.tagline-1 { font-size: 15px; color: #555; font-weight: 600; margin-bottom: 6px; }
.tagline-2 { font-size: 14px; color: #ff6b35; font-weight: 700; margin-bottom: 36px; }

.btn-cta {
  background: #ff6b35;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 48px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 #c94a1a;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-cta:active { transform: translateY(2px); box-shadow: 0 2px 0 #c94a1a; }

/* GAME SCREEN */
#screen-game {
  justify-content: flex-start;
  padding: 0 0 80px 0;
  position: relative;
}

.timer-bar-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 6px;
  background: #fff9f0;
  flex-shrink: 0;
}
.timer-display { font-size: 22px; font-weight: 900; color: #e91e63; min-width: 52px; }
.timer-track {
  flex: 1;
  height: 10px;
  background: #ffe0ec;
  border-radius: 5px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff6b35, #e91e63);
  border-radius: 5px;
  transition: width 1s linear;
}

#game-canvas {
  flex: 1;
  width: 100%;
  display: block;
  touch-action: none;
}

/* UNDO BUTTON — fixed bottom-left */
#undo-wrap {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
}
.btn-undo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ff6b35;
  color: white;
  border: none;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #c94a1a;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-undo:active { transform: translateY(2px); box-shadow: 0 2px 0 #c94a1a; }

/* DONE BUTTON — fixed bottom-right, separate from toolbar */
#done-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
}

/* TOOLBAR — brush + colour only, centred */
.toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 50px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 100;
}
.toolbar-collapsed { display: flex; align-items: center; gap: 12px; }

.brush-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  border: 2px solid #eee;
}
.colour-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #111;
  cursor: pointer;
  border: 2px solid #eee;
}
.btn-done {
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-done-mobile {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #4caf50;
  color: white;
  border: none;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.flyout {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}
.flyout.hidden { display: none; }

.size-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid #eee;
  background: white;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.size-btn.active { border-color: #111; background: #111; color: white; }

.colour-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.colour-btn.active { border-color: #111; }
.colour-custom { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #eee; cursor: pointer; padding: 0; font-size: 16px; touch-action: manipulation; }

/* GALLERY SCREEN */
#screen-gallery { justify-content: flex-start; padding: 32px 20px; gap: 24px; overflow-y: auto; }
.gallery-header { text-align: center; }
.gallery-header h2 { font-size: 26px; font-weight: 900; color: #1a1a1a; }
.gallery-header p { font-size: 14px; color: #666; margin-top: 4px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; width: 100%; max-width: 700px; }
.gallery-card { background: white; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); overflow: hidden; }
.gallery-card img { width: 100%; display: block; }
.btn-play-again { margin-top: 8px; flex-shrink: 0; }

@media (max-width: 480px) {
  .btn-done { display: none; }
  .btn-done-mobile { display: flex; align-items: center; justify-content: center; }
}

/* GALLERY — drawing name caption */
.drawing-name {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #555;
  padding: 6px 8px 8px;
  text-transform: capitalize;
}

/* SCORE SECTION */
.score-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 0 4px;
  flex-shrink: 0;
  width: 100%;
  max-width: 700px;
}
.score-current {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
}
.score-badge {
  font-size: 16px;
  font-weight: 900;
  color: #e91e63;
}
.score-best {
  font-size: 14px;
  color: #888;
  font-weight: 600;
}

