/* =============================================
   Fun Paint Coloring App - Main Stylesheet
   Font: Fredoka One (headers) + Nunito (body)
   ============================================= */

:root {
  --pink:    #FF6B9D;
  --purple:  #C44EFF;
  --yellow:  #FFD93D;
  --teal:    #4ECDC4;
  --blue:    #45B7D1;
  --green:   #96CEB4;
  --orange:  #FF9142;
  --bg:      #F0F4FF;
  --card-bg: #FFFFFF;
  --text:    #2D2D4E;
  --sub:     #7A7A9D;
  --border:  #E8EAFF;
  --shadow:  0 4px 20px rgba(100,80,200,0.12);
  --radius:  18px;
  --radius-sm: 12px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'Nunito', sans-serif;
  color: var(--text);
  overflow-x: hidden;
}

/* ---- TYPOGRAPHY ---- */
h1, h2, h3, .app-name, .modal-title {
  font-family: 'Fredoka One', cursive;
  letter-spacing: 0.3px;
}

/* ---- APP SHELL ---- */
#app {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  transition: filter 0.3s;
}
#app.blurred { filter: blur(4px) brightness(0.8); pointer-events: none; }

/* ---- HEADER ---- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: white;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 12px rgba(100,80,200,0.07);
}
.header-left { display: flex; align-items: center; gap: 8px; }
.app-logo { font-size: 28px; }
.app-name {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.user-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--sub);
  background: var(--bg);
  padding: 5px 12px;
  border-radius: 20px;
}
.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--bg); }
.btn-primary-sm {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

/* ---- VIEWS ---- */
.view { display: none; }
.view.active { display: block; }

/* ---- HERO BANNER ---- */
.hero-banner {
  background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
  margin: 16px;
  border-radius: 24px;
  padding: 28px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.hero-banner::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 150px; height: 150px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.hero-text h1 {
  font-size: 32px;
  color: white;
  line-height: 1.15;
}
.hero-text p {
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  margin-top: 6px;
  font-weight: 600;
}
.hero-art { font-size: 72px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2)); animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---- SECTIONS ---- */
.section { padding: 0 16px 20px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-title { font-size: 20px; margin-bottom: 14px; }
.btn-link {
  background: none; border: none; cursor: pointer;
  color: var(--pink); font-weight: 700; font-size: 14px;
  font-family: 'Nunito', sans-serif;
}

/* ---- CATEGORY GRID ---- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.category-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid var(--border);
  text-decoration: none;
}
.category-card:hover, .category-card:active {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(100,80,200,0.18);
}
.cat-icon-wrap {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.cat-name {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: var(--text);
}

/* ---- DRAWINGS GRID ---- */
.drawings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.drawings-grid.padded { padding: 0 16px 20px; }
.drawing-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  border: 2px solid var(--border);
}
.drawing-card:hover { transform: translateY(-4px); }
.drawing-thumb {
  height: 130px;
  display: flex; align-items: center; justify-content: center;
  font-size: 50px;
  position: relative;
  overflow: hidden;
}
.drawing-thumb svg {
  width: 100%; height: 100%;
  object-fit: contain;
}
.drawing-thumb .preview-svg {
  transform: scale(0.55);
  transform-origin: top center;
  width: 180%;
  height: 180%;
  margin: -30px;
}
.drawing-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--yellow);
  color: #555;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.drawing-badge.premium {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
}
.drawing-info { padding: 10px 12px 12px; }
.drawing-title { font-family: 'Fredoka One', cursive; font-size: 15px; color: var(--text); }
.drawing-diff {
  font-size: 11px; font-weight: 700; margin-top: 3px;
  display: flex; align-items: center; gap: 4px;
}
.diff-easy   { color: var(--green); }
.diff-medium { color: var(--orange); }
.diff-hard   { color: var(--pink); }

/* ---- SKELETONS ---- */
.skeleton-card {
  background: white;
  border-radius: var(--radius);
  height: 68px;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%,100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---- GALLERY VIEW ---- */
.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.view-header h2 { font-size: 20px; }
.back-btn {
  background: var(--bg); border: none;
  width: 38px; height: 38px;
  border-radius: 12px;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.load-more-wrap { padding: 10px 16px 24px; text-align: center; }
.btn-outline {
  background: white; border: 2px solid var(--purple);
  color: var(--purple); padding: 10px 32px;
  border-radius: 20px; cursor: pointer;
  font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 15px;
}

/* ---- CANVAS VIEW ---- */
.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: white;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.canvas-preview-thumb {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.canvas-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border: 2px solid var(--border);
  background: white; border-radius: 12px;
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s;
}
.icon-btn:hover { background: var(--bg); transform: scale(1.05); }
.icon-btn:active { transform: scale(0.95); }

.canvas-wrap {
  overflow: auto;
  padding: 16px;
  min-height: calc(100vh - 200px);
  background: #fafafe;
}
.svg-container {
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.svg-container svg {
  width: 100%;
  height: auto;
  display: block;
}

/* SVG path hover/click effects */
.coloring-svg .colorable {
  cursor: pointer;
  transition: filter 0.15s;
}
.coloring-svg .colorable:hover {
  filter: brightness(0.9);
}
.coloring-svg .colorable.selected {
  filter: drop-shadow(0 0 6px rgba(100,80,200,0.5));
}

/* ---- COLOR TRAY ---- */
.color-tray {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: white;
  border-top: 2px solid var(--border);
  padding: 12px 14px 20px;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(100,80,200,0.1);
}
.color-tray-inner {
  display: flex; align-items: center; gap: 10px;
}
.color-palette {
  display: flex; gap: 8px; overflow-x: auto;
  flex: 1; padding-bottom: 2px;
  scrollbar-width: none;
}
.color-palette::-webkit-scrollbar { display: none; }
.color-swatch {
  width: 36px; height: 36px;
  border-radius: 50%; flex-shrink: 0;
  cursor: pointer; border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  transform: scale(1.2);
  box-shadow: 0 0 0 3px var(--purple), 0 2px 8px rgba(0,0,0,0.15);
}
.tray-tools { display: flex; flex-direction: column; gap: 6px; }
.tool-btn {
  width: 38px; height: 38px;
  border: 2px solid var(--border);
  background: white; border-radius: 10px;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.tool-btn.active {
  background: var(--purple); border-color: var(--purple); font-size: 18px;
}

/* ---- TIMER ---- */
.timer-bar {
  position: fixed;
  top: 68px; right: 16px;
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 5px 14px;
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: var(--purple);
  box-shadow: var(--shadow);
  z-index: 100;
}

/* ---- SUBSCRIBE MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,20,80,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: white;
  border-radius: 28px;
  padding: 36px 28px 28px;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(100,80,200,0.3);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-logo { font-size: 56px; margin-bottom: 8px; }
.modal-title { font-size: 28px; line-height: 1.2; margin-bottom: 8px; }
.modal-title span {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.modal-sub { color: var(--sub); font-size: 14px; margin-bottom: 22px; font-weight: 600; }
.input-group {
  display: flex; align-items: center;
  background: var(--bg); border: 2px solid var(--border);
  border-radius: 14px; padding: 0 14px;
  transition: border-color 0.2s;
}
.input-group:focus-within { border-color: var(--purple); }
.input-icon { font-size: 20px; margin-right: 10px; }
.input-group input {
  flex: 1; background: none; border: none; outline: none;
  padding: 14px 0;
  font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600;
  color: var(--text);
}
.btn-primary {
  width: 100%; margin-top: 16px;
  background: linear-gradient(135deg, var(--pink) 0%, var(--purple) 100%);
  color: white; border: none; border-radius: 14px;
  padding: 15px; font-size: 17px; font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer; letter-spacing: 0.3px;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 6px 20px rgba(196,78,255,0.35);
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  width: 100%; margin-top: 10px;
  background: none; border: 2px solid var(--border);
  color: var(--sub); border-radius: 14px;
  padding: 12px; font-size: 15px; font-weight: 700;
  font-family: 'Nunito', sans-serif; cursor: pointer;
}
.modal-note { font-size: 12px; color: var(--sub); margin-top: 12px; }
/* OTP inputs */
.otp-desc { font-size: 14px; color: var(--sub); margin-bottom: 18px; font-weight: 600; }
.otp-inputs {
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 20px;
}
.otp-digit {
  width: 46px; height: 56px;
  border: 2.5px solid var(--border); border-radius: 14px;
  text-align: center; font-size: 24px; font-weight: 800;
  font-family: 'Fredoka One', cursive;
  color: var(--purple); outline: none;
  transition: border-color 0.2s;
}
.otp-digit:focus { border-color: var(--purple); }
.otp-hint {
  margin-top: 12px; padding: 10px 14px;
  background: #FFF8E1; border-radius: 10px;
  font-size: 13px; color: #B77800; font-weight: 700;
}
/* Modal message */
.modal-msg {
  margin-top: 14px; padding: 12px;
  border-radius: 12px; font-size: 14px; font-weight: 700;
}
.modal-msg.success { background: #E8FFE8; color: #2E7D32; }
.modal-msg.error   { background: #FFEBEE; color: #C62828; }
.hidden { display: none !important; }

/* ---- DONE MODAL ---- */
.done-overlay {
  position: fixed; inset: 0;
  background: rgba(30,20,80,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 8000; padding: 20px;
  backdrop-filter: blur(4px);
}
.done-box {
  background: white; border-radius: 28px;
  padding: 36px 28px; width: 100%; max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(100,80,200,0.3);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.done-stars { font-size: 40px; margin-bottom: 10px; }
.done-box h2 { font-size: 32px; margin-bottom: 6px; }
.done-box p { color: var(--sub); font-size: 14px; font-weight: 600; margin-bottom: 22px; }
.done-stats {
  display: flex; gap: 16px;
  justify-content: center; margin-bottom: 24px;
}
.stat-box {
  background: var(--bg); border-radius: 16px;
  padding: 14px 24px; flex: 1;
}
.stat-label { display: block; font-size: 12px; color: var(--sub); font-weight: 700; }
.stat-val { font-family: 'Fredoka One', cursive; font-size: 26px; color: var(--purple); }

/* ---- RESPONSIVE ---- */
@media (max-width: 380px) {
  .hero-text h1 { font-size: 26px; }
  .hero-art { font-size: 56px; }
  .drawings-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
