:root {
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #facc15;
  --pink: #ec4899;
  --purple: #8b5cf6;
  --orange: #fb923c;
  --red: #ef4444;
  --dark: #1f2937;
  --soft: #f8fafc;
  --card: #ffffff;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.14);
  --radius: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", Arial, sans-serif;
  color: var(--dark);
  background:
    radial-gradient(circle at top left, rgba(250, 204, 21, .25), transparent 32%),
    radial-gradient(circle at top right, rgba(59, 130, 246, .18), transparent 30%),
    linear-gradient(135deg, #fff7ed, #eff6ff 55%, #f0fdf4);
}

button, input { font: inherit; }
button { cursor: pointer; border: 0; }

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: clamp(14px, 2vw, 26px);
}

.screen { display: none; min-height: calc(100vh - 52px); }
.screen.active { display: block; }

.auth-screen, #profileScreen, .reward-screen {
  display: none;
  align-items: center;
  justify-content: center;
}
.auth-screen.active, #profileScreen.active, .reward-screen.active { display: flex; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 42px);
  border: 4px solid rgba(255,255,255,.9);
}

.auth-card, .profile-card, .reward-card { width: min(560px, 100%); text-align: center; }
.logo-bubble {
  width: 100px;
  height: 100px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 54px;
  background: linear-gradient(135deg, #fde68a, #bfdbfe);
}

h1, h2, h3 { margin: 0 0 12px; line-height: 1.1; }
h1 { font-size: clamp(2rem, 5vw, 4rem); }
h2 { font-size: clamp(1.8rem, 4vw, 3rem); }
h3 { font-size: 1.35rem; }
.helper-text, .subtitle, .message, .empty-text { font-size: 1.1rem; }

label, .label-like {
  display: block;
  text-align: left;
  font-weight: 800;
  margin: 18px 0 8px;
}

input {
  width: 100%;
  min-height: 68px;
  border: 3px solid #dbeafe;
  border-radius: 20px;
  padding: 0 18px;
  font-size: 1.2rem;
  outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 6px rgba(59,130,246,.15); }

.button-row { display: flex; gap: 14px; justify-content: center; margin-top: 18px; }
.wrap-row { flex-wrap: wrap; }
.full-width { width: 100%; }

.big-btn, .home-tile, .tool-btn, .round-btn, .size-btn {
  min-height: 64px;
  border-radius: 22px;
  font-weight: 900;
  color: var(--dark);
  box-shadow: 0 8px 0 rgba(31,41,55,.12);
  transition: transform .08s ease, filter .12s ease;
}
.big-btn:hover, .home-tile:hover, .tool-btn:hover, .round-btn:hover, .size-btn:hover { filter: brightness(.98); }
.big-btn:active, .home-tile:active, .tool-btn:active, .round-btn:active, .size-btn:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(31,41,55,.12); }

.big-btn { padding: 0 28px; font-size: 1.15rem; }
.primary { background: var(--green); color: white; }
.secondary { background: #e0f2fe; }
.danger { background: var(--red); color: white; }
.danger-soft { background: #fee2e2 !important; }
.text-btn { margin-top: 18px; color: var(--blue); background: transparent; font-weight: 900; font-size: 1.1rem; }
.message { min-height: 26px; color: #dc2626; font-weight: 800; }

.age-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.age-btn { background: #fef3c7; font-size: 1.4rem; }
.age-btn.active { outline: 5px solid var(--blue); }

.top-header, .coloring-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.top-header.compact { justify-content: flex-start; }
.round-btn { min-width: 72px; padding: 0 18px; background: #ffffff; font-size: 1.45rem; }

.home-account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.small-action-btn {
  min-height: 58px;
  padding: 0 20px;
  border: 0;
  border-radius: 22px;
  background: #ffffff;
  color: var(--blue);
  font-weight: 1000;
  font-size: 1rem;
  box-shadow: 0 6px 0 rgba(31,41,55,.12);
  cursor: pointer;
}

.small-action-btn.register-action {
  background: #dcfce7;
  color: #047857;
}

.small-action-btn:hover { filter: brightness(.98); }
.small-action-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(31,41,55,.12); }

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 28px);
}
.home-tile {
  min-height: clamp(150px, 26vh, 260px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: clamp(3rem, 8vw, 6rem);
  color: white;
}
.home-tile span { font-size: clamp(1.35rem, 3vw, 2.4rem); }
.animal-tile { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.draw-tile { background: linear-gradient(135deg, #f97316, #facc15); }
.gallery-tile { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.parent-tile { background: linear-gradient(135deg, #ec4899, #f43f5e); }

.parent-area-link-wrap {
  display: flex;
  justify-content: center;
  margin: 22px 0 4px;
}

.parent-area-link {
  color: #7c3aed;
  font-weight: 1000;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  text-decoration: underline;
  text-underline-offset: 5px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.parent-area-link:hover {
  color: #5b21b6;
}

.animal-grid, .gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
}
.animal-card, .gallery-card {
  background: white;
  border-radius: 24px;
  padding: 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.animal-card button {
  width: 100%;
  background: transparent;
  font-weight: 900;
  font-size: 1.1rem;
}
.animal-card img, .gallery-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #fff;
  border-radius: 18px;
  border: 3px dashed #dbeafe;
}


/* Keep horizontal scrolling inside controls only. The sticker row owns its scrollbar,
   while the main drawing workspace and canvas area stay fixed. */
html, body, .app-shell, .screen, .workspace {
  max-width: 100%;
  overflow-x: hidden;
}
.workspace > * { min-width: 0; }

.coloring-screen.active { display: flex; flex-direction: column; }
.coloring-header {
  background: rgba(255,255,255,.84);
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(31,41,55,.08);
}
.fact-box { margin: 0; font-weight: 900; color: #047857; }
.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 180px;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.palette-panel, .tools-panel, .canvas-wrap {
  background: rgba(255,255,255,.86);
  border-radius: 24px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(31,41,55,.08);
}
.palette-panel, .tools-panel { overflow: auto; }
.color-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 12px;
  justify-items: center;
}
.color-swatch {
  width: 78px;
  height: 78px;
  min-height: 78px;
  border-radius: 50%;
  border: 5px solid white;
  color: #111827;
  font-size: .68rem;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,.75);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4px;
}
.color-swatch.active { outline: 5px solid #111827; transform: scale(1.05); }
.tools-panel { display: flex; flex-direction: column; gap: 10px; }
.tool-btn { background: #fef3c7; padding: 0 14px; font-size: 1rem; }
.tool-btn.active, .size-btn.active { outline: 5px solid var(--blue); }
.done-btn { background: #fde047; }
.size-group, .canvas-size-group { display: grid; gap: 8px; }
.tool-group-label { font-weight: 900; text-align: center; font-size: .95rem; margin-top: 4px; }
.size-btn { background: #dcfce7; min-height: 56px; }

.brush-slider-wrap {
  display: grid;
  gap: 10px;
  background: #ecfeff;
  border: 3px solid #a5f3fc;
  border-radius: 20px;
  padding: 12px;
}
.brush-size-readout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  color: #0f172a;
}
.brush-size-readout strong {
  background: #ffffff;
  border: 3px solid #38bdf8;
  border-radius: 999px;
  min-width: 78px;
  text-align: center;
  padding: 6px 10px;
}
.brush-size-slider {
  width: 100%;
  min-height: 44px;
  accent-color: #2563eb;
  cursor: pointer;
}
.brush-size-slider::-webkit-slider-thumb {
  width: 36px;
  height: 36px;
}
.brush-size-slider::-moz-range-thumb {
  width: 36px;
  height: 36px;
}
.brush-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  font-weight: 900;
  color: #475569;
}

.canvas-action-bar {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
}
.canvas-action-bar .tool-btn {
  min-height: 58px;
  padding: 0 10px;
  font-size: .95rem;
}
.canvas-action-bar .save-status {
  min-height: 58px;
}

.save-drawing-btn { background: #bbf7d0; }
.save-status {
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px 10px;
  border-radius: 16px;
  background: #eff6ff;
  color: #1f2937;
  font-weight: 900;
  font-size: .95rem;
  border: 3px solid #dbeafe;
}
.save-status.saving { background: #fef3c7; border-color: #facc15; }
.save-status.saved { background: #dcfce7; border-color: #22c55e; color: #166534; }
.save-status.error { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

.canvas-wrap {
  display: grid;
  place-items: start center;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 260px;
  min-width: 0;
  max-width: 100%;
}
.canvas-box {
  width: 82%;
  max-width: 700px;
  transition: width .18s ease, max-width .18s ease;
}
#drawingCanvas {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  background: white;
  border: 6px solid #111827;
  border-radius: 20px;
  touch-action: none;
}

/* These classes change the visible canvas holder. MVP now has Medium and Large only. */
.canvas-wrap.canvas-medium .canvas-box { width: 82%; max-width: 700px; }
.canvas-wrap.canvas-large .canvas-box { width: 100%; max-width: 980px; }

.reward-card img { width: 100%; max-height: 45vh; object-fit: contain; border: 5px solid #dbeafe; border-radius: 20px; background: white; }
.stars { font-size: clamp(2.5rem, 8vw, 5rem); margin: 10px 0; animation: bounce .8s infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-8px); } }
.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -20px; font-size: 22px; animation: fall 2.5s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .8; } }

.gallery-upload-card {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.gallery-upload-card h3 { margin: 0 0 4px; font-size: 1.35rem; }
.gallery-upload-card .helper-text { margin: 0; }
.gallery-upload-card .message { margin: 4px 0 0; font-weight: 900; color: #047857; }
.gallery-card .gallery-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.gallery-card button, .gallery-card a {
  min-height: 50px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 900;
  color: var(--dark);
  background: #e0f2fe;
}
.gallery-card .delete-btn { background: #fee2e2; }
.empty-text { text-align: center; font-weight: 900; }
.dashboard-layout { display: grid; grid-template-columns: 330px 1fr; gap: 22px; }
.stats-card { height: fit-content; }
.gallery-grid.small { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

@media (max-width: 980px) {
  .gallery-upload-card { flex-direction: column; align-items: stretch; text-align: center; }
  .workspace { grid-template-columns: 1fr; }
  .palette-panel { order: 2; }
  .canvas-wrap { order: 1; }
  .tools-panel { order: 3; }
  .color-palette { grid-template-columns: repeat(4, minmax(66px, 1fr)); }
  .color-swatch { width: 70px; height: 70px; min-height: 70px; }
  .tools-panel { display: grid; grid-template-columns: repeat(4, 1fr); }
  .canvas-action-bar { grid-template-columns: repeat(3, 1fr); }
  .canvas-action-bar .save-status { grid-column: span 2; }
  .dashboard-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { padding: 10px; }
  .button-row, .top-header, .coloring-header { flex-direction: column; align-items: stretch; }
  .home-account-actions { justify-content: stretch; }
  .home-account-actions > * { flex: 1; }
  .home-grid { grid-template-columns: 1fr; }
  .color-palette { grid-template-columns: repeat(4, minmax(58px, 1fr)); }
  .color-swatch { width: 62px; height: 62px; min-height: 62px; font-size: .58rem; border-width: 4px; }
  .tools-panel { grid-template-columns: repeat(2, 1fr); }
  .canvas-action-bar { grid-template-columns: 1fr 1fr; }
  .canvas-action-bar .save-drawing-btn, .canvas-action-bar .save-status { grid-column: 1 / -1; }
  .big-btn, .tool-btn { width: 100%; }
}

/* Full requirements additions */
.hidden { display: none !important; }
.daily-tile { background: linear-gradient(135deg, #14b8a6, #a3e635); }
.upload-tile { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 20px;
}
.category-tile {
  min-height: 180px;
  border-radius: 28px;
  background: white;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 900;
  font-size: 1.8rem;
  color: var(--dark);
  border: 5px solid rgba(255,255,255,.9);
}
.category-tile small { font-size: 1rem; color: #64748b; }
.category-icon { font-size: 4rem; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.coloring-title-block { flex: 1; min-width: 220px; }
.sticker-strip-wrap {
  width: 100%;
  max-width: 980px;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  margin-bottom: 8px;
  border: 3px solid #ede9fe;
  border-radius: 24px;
  background: #fff;
  padding: 8px 10px 4px;
  box-shadow: 0 8px 20px rgba(31,41,55,.08);
}
.sticker-strip-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #6d28d9;
  font-weight: 1000;
  font-size: 1rem;
  padding: 0 4px 6px;
}
.sticker-strip-title span {
  color: #64748b;
  font-size: .78rem;
  font-weight: 800;
}
.sticker-picker {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px 14px;
  margin-bottom: 0;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.sticker-picker::-webkit-scrollbar { height: 10px; }
.sticker-picker::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 999px; }
.sticker-picker::-webkit-scrollbar-track { background: #f5f3ff; border-radius: 999px; }
.sticker-btn {
  flex: 0 0 68px;
  width: 68px;
  min-height: 58px;
  border-radius: 18px;
  background: #f3e8ff;
  font-size: 1.6rem;
  box-shadow: 0 6px 0 rgba(31,41,55,.1);
  scroll-snap-align: start;
}
.sticker-btn.active { outline: 4px solid var(--blue); }
.text-sticker-btn {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 900;
  background: #ffffff;
  text-shadow: 0 2px 0 rgba(255,255,255,.9);
}
.text-sticker-btn:first-child { color: #16a34a; }
.text-sticker-btn:nth-child(2) { color: #dc2626; }
.voice-btn { background: #dbeafe; }
.gallery-actions { grid-template-columns: repeat(3, 1fr) !important; }
.gallery-card .share-btn { background: #dcfce7; }
.parent-settings .big-btn { min-width: 150px; }

.big-select {
  width: 100%;
  min-height: 68px;
  border: 3px solid #dbeafe;
  border-radius: 20px;
  padding: 0 18px;
  font-size: 1.2rem;
  font-weight: 900;
  background: white;
  color: var(--dark);
  outline: none;
}
.big-select:focus { border-color: var(--blue); box-shadow: 0 0 0 6px rgba(59,130,246,.15); }
.edit-details-card { height: fit-content; }
.edit-details-card .helper-text { margin-bottom: 4px; }
.canvas-box { transition: width .18s ease, transform .18s ease; }

@media (max-width: 980px) {
  .sticker-picker { max-width: 100%; }
  .gallery-actions { grid-template-columns: 1fr !important; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .category-grid { grid-template-columns: 1fr; }
  .category-tile { min-height: 140px; }
  .header-actions { flex-direction: column; }
}

/* Admin Screen */
.admin-tile { background: linear-gradient(135deg, #6366f1, #06b6d4); }
.admin-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.admin-card h3 { margin-bottom: 16px; }
.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.admin-stat-grid div {
  min-height: 108px;
  border-radius: 22px;
  background: #f0f9ff;
  border: 3px solid #dbeafe;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 12px;
}
.admin-stat-grid strong {
  font-size: 1.9rem;
  color: var(--blue);
}
.admin-stat-grid span {
  font-weight: 900;
  font-size: .95rem;
}
.admin-actions-row { justify-content: flex-start; }
.admin-danger-card { border-color: #fee2e2; }
.admin-gallery-card { grid-column: 1 / -1; }
@media (max-width: 860px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .admin-stat-grid { grid-template-columns: 1fr; }
}

/* Separate Admin Panel */
.admin-login-card { max-width: 620px; }
.admin-panel-screen.active { display: flex; flex-direction: column; }
.admin-panel-header { align-items: center; }
.admin-panel-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.admin-sidebar {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}
.admin-tab {
  min-height: 58px;
  border-radius: 18px;
  background: #f8fafc;
  border: 3px solid #e0f2fe;
  color: var(--dark);
  font-weight: 1000;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}
.admin-tab.active {
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #fff;
  border-color: transparent;
}
.admin-content { min-width: 0; }
.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }
.admin-global-message {
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 1000;
}

.admin-gallery-message {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f0fdf4;
  color: #166534;
  font-weight: 1000;
}
.admin-gallery-message:empty {
  display: none;
}
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 14px 0;
}
.admin-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}
.admin-account-row {
  width: 100%;
  min-height: 76px;
  border-radius: 20px;
  border: 3px solid #dbeafe;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
}
.admin-account-row strong,
.admin-account-row small { display: block; }
.admin-account-row small { color: #64748b; font-weight: 900; margin-top: 3px; }
.admin-account-row.selected { border-color: var(--blue); box-shadow: 0 0 0 5px rgba(59,130,246,.12); }
.admin-account-row.active-account { background: #ecfdf5; border-color: #86efac; }
.admin-row-arrow { font-weight: 1000; color: var(--blue); white-space: nowrap; }
.compact-empty { margin: 0; padding: 14px; border-radius: 18px; background: #f8fafc; }

@media (max-width: 900px) {
  .admin-panel-layout { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 620px) {
  .admin-sidebar, .admin-form-grid { grid-template-columns: 1fr; }
  .admin-panel-header { align-items: stretch; }
}

.admin-login-link {
  margin-top: 8px;
  font-weight: 900;
  color: #6d28d9;
  text-decoration: none;
}

.admin-login-link:hover,
.admin-login-link:focus-visible {
  background: #f3e8ff;
  outline: 4px solid rgba(109, 40, 217, 0.18);
}

.mini-section-title {
  margin: 22px 0 10px;
  font-size: 1rem;
  color: #334155;
}
.compact-admin-list {
  margin-top: 8px;
}
.compact-account-row {
  min-height: 58px;
  padding: 10px 12px;
}
.small-gap {
  gap: 8px;
  margin-bottom: 10px;
}

.admin-section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.db-stat-grid strong {
  font-size: 1.1rem;
  word-break: break-word;
}
.db-details-box {
  margin: 14px 0;
  padding: 14px;
  border-radius: 18px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  font-weight: 800;
  color: #334155;
}
.db-details-box p { margin: 6px 0; }
.table-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 18px;
  border: 2px solid #e2e8f0;
}
.db-status-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: #fff;
}
.db-status-table th,
.db-status-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  font-weight: 800;
  white-space: nowrap;
}
.db-status-table th {
  background: #f1f5f9;
  color: #334155;
  font-size: .9rem;
}
.db-status-pill {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 1000;
}
.db-status-pill.ok { background: #dcfce7; color: #166534; }
.db-status-pill.bad { background: #fee2e2; color: #991b1b; }

.confetti-burst {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 18px 26px;
  border-radius: 999px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  font-size: clamp(28px, 5vw, 56px);
  pointer-events: none;
  animation: confettiPop 1.35s ease forwards;
}

@keyframes confettiPop {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(0.85); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -24px) scale(1.08); }
}

/* Multiple children manager */
.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.children-list {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}
.child-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 2px solid #e5e7eb;
  border-radius: 18px;
  background: #fff;
}
.child-profile-row.active-child {
  border-color: #22c55e;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.14);
}
.child-profile-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.child-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fef3c7;
  font-size: 1.5rem;
  flex: 0 0 auto;
}
.child-profile-main strong,
.child-profile-main span {
  display: block;
}
.child-profile-main strong {
  font-size: 1.05rem;
  color: #111827;
}
.child-profile-main span {
  color: #6b7280;
  font-size: 0.92rem;
}
.child-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}
.child-row-actions button {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  font-weight: 800;
  cursor: pointer;
  background: #eef2ff;
  color: #3730a3;
}
.child-row-actions button.active-label {
  background: #dcfce7;
  color: #166534;
  cursor: default;
}
.child-row-actions button.delete-child-btn {
  background: #fee2e2;
  color: #991b1b;
}
.add-child-form {
  padding-top: 0.75rem;
  border-top: 2px dashed #e5e7eb;
}
.add-child-form h4 {
  margin: 0 0 0.75rem;
}
@media (max-width: 700px) {
  .child-profile-row {
    align-items: stretch;
    flex-direction: column;
  }
  .child-row-actions {
    justify-content: flex-start;
  }
}

/* Simple full-screen free drawing mode: only Home + 9 brush sizes + canvas */
.simple-draw-tile { background: linear-gradient(135deg, #e0f2fe, #bfdbfe); }
.simple-draw-screen.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 52px);
  padding: 0;
  gap: 0;
  background: #f8fafc;
}
.simple-draw-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #ffffff;
  border-bottom: 3px solid #dbeafe;
  box-shadow: 0 6px 18px rgba(31,41,55,.08);
  z-index: 5;
}
.simple-home-btn,
.simple-size-btn {
  border: 0;
  border-radius: 16px;
  min-height: 54px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(31,41,55,.14);
}
.simple-home-btn {
  min-width: 120px;
  padding: 0 16px;
  background: #fef3c7;
  font-size: 1rem;
}
.simple-brush-sizes {
  display: grid;
  grid-template-columns: repeat(9, minmax(42px, 1fr));
  gap: 8px;
  flex: 1;
}
.simple-size-btn {
  background: #dcfce7;
  font-size: 1.05rem;
}
.simple-size-btn.active {
  outline: 4px solid #2563eb;
  background: #bbf7d0;
}
.simple-draw-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: #ffffff;
}
#simpleDrawCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
  touch-action: none;
  cursor: crosshair;
}
@media (max-width: 760px) {
  .simple-draw-bar { flex-direction: column; align-items: stretch; }
  .simple-home-btn { width: 100%; }
  .simple-brush-sizes { grid-template-columns: repeat(9, minmax(32px, 1fr)); }
  .simple-size-btn { min-height: 46px; border-radius: 12px; }
}


/* Gallery edit update */
.gallery-actions .edit-gallery-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  background: #e0f2fe;
  color: #075985;
  font-weight: 800;
  cursor: pointer;
}
.gallery-actions .edit-gallery-btn:hover { filter: brightness(0.98); transform: translateY(-1px); }

/* Profile setup navigation */
.profile-nav-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.profile-nav-bar .small-action-btn {
  min-width: 110px;
}

/* Parent Area All Creations action button overlap fix */
#parentGalleryGrid.gallery-grid.small {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}
#parentGalleryGrid .gallery-card {
  min-width: 0;
  overflow: hidden;
}
#parentGalleryGrid .gallery-card h3,
#parentGalleryGrid .gallery-card p {
  overflow-wrap: anywhere;
  word-break: break-word;
}
#parentGalleryGrid .gallery-actions {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)) !important;
  gap: 10px !important;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  box-sizing: border-box;
}
#parentGalleryGrid .gallery-actions button,
#parentGalleryGrid .gallery-actions a {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
  line-height: 1.15;
  padding: 10px 8px;
  text-align: center;
}

@media (max-width: 620px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: 1fr;
  }
  #parentGalleryGrid .gallery-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 380px) {
  #parentGalleryGrid .gallery-actions {
    grid-template-columns: 1fr !important;
  }
}

/* Parent Area All Creations horizontal record layout */
#parentGalleryGrid.gallery-grid.small {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 18px !important;
  overflow-x: auto !important;
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
  padding: 8px 6px 18px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
#parentGalleryGrid.gallery-grid.small .gallery-card {
  flex: 0 0 260px;
  width: 260px;
  max-width: 260px;
  scroll-snap-align: start;
}
#parentGalleryGrid.gallery-grid.small .gallery-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
}

@media (min-width: 900px) {
  #parentGalleryGrid.gallery-grid.small .gallery-card {
    flex-basis: 280px;
    width: 280px;
    max-width: 280px;
  }
}

@media (max-width: 520px) {
  #parentGalleryGrid.gallery-grid.small .gallery-card {
    flex-basis: 82vw;
    width: 82vw;
    max-width: 82vw;
  }
}

/* Parent Area All Creations multi-row horizontal grid fix */
#parentGalleryGrid.gallery-grid.small {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
  flex-direction: initial !important;
  flex-wrap: initial !important;
  gap: 18px !important;
  overflow-x: hidden !important;
  overflow-y: visible !important;
  width: 100%;
  max-width: 100%;
  padding: 8px 6px 18px;
  scroll-snap-type: none !important;
  -webkit-overflow-scrolling: auto;
}
#parentGalleryGrid.gallery-grid.small .gallery-card {
  flex: initial !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  scroll-snap-align: none !important;
}
#parentGalleryGrid.gallery-grid.small .gallery-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
}
@media (min-width: 1100px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: repeat(4, minmax(230px, 1fr)) !important;
  }
}
@media (min-width: 760px) and (max-width: 1099px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: repeat(3, minmax(220px, 1fr)) !important;
  }
}
@media (min-width: 520px) and (max-width: 759px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 519px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: 1fr !important;
  }
}

/* Parent Area All Creations final layout fix
   The earlier layout placed All Creations as a normal item inside the 2-column
   dashboard grid, so cards were squeezed into the left column and looked cut off.
   This section now spans the full dashboard width and cards form clean rows. */
.parent-all-creations-section {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  margin-top: 4px;
}
.parent-all-creations-section h3 {
  margin: 0 0 14px;
  font-size: 1.45rem;
}
#parentGalleryGrid.gallery-grid.small {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
  gap: 22px !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: visible !important;
  padding: 0 !important;
  box-sizing: border-box;
}
#parentGalleryGrid.gallery-grid.small .gallery-card {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  align-self: start;
}
#parentGalleryGrid.gallery-grid.small .gallery-card img {
  width: 100% !important;
  height: 170px !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
}
#parentGalleryGrid .gallery-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
}
#parentGalleryGrid .gallery-actions button,
#parentGalleryGrid .gallery-actions a {
  min-width: 0 !important;
  width: 100% !important;
  padding: 10px 6px !important;
  box-sizing: border-box !important;
}
@media (min-width: 1300px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: repeat(4, minmax(250px, 1fr)) !important;
  }
}
@media (min-width: 900px) and (max-width: 1299px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: repeat(3, minmax(240px, 1fr)) !important;
  }
}
@media (min-width: 600px) and (max-width: 899px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: repeat(2, minmax(230px, 1fr)) !important;
  }
}
@media (max-width: 599px) {
  #parentGalleryGrid.gallery-grid.small {
    grid-template-columns: 1fr !important;
  }
}

/* Admin uploaded coloring pages */
.admin-upload-panel {
  margin: 18px 0 24px;
  padding: 18px;
  border: 2px dashed #c7d2fe;
  border-radius: 22px;
  background: #f8fafc;
}

.admin-upload-panel h4 {
  margin: 0 0 6px;
  color: #312e81;
}

.admin-uploaded-pages-grid {
  margin-top: 14px;
}

.admin-coloring-page-card img {
  object-fit: contain;
  background: #ffffff;
}


.age-select {
  min-height: 44px;
  border: 2px solid #d7e3ff;
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 1rem;
  background: #fff;
}
.inline-field {
  font-weight: 800;
  color: #34405c;
  margin-right: 6px;
}
.gallery-upload-card {
  gap: 12px;
  flex-wrap: wrap;
}

/* Who is coloring screen: database child selector */
.profile-children-section {
  margin: 1rem 0 1.25rem;
  text-align: left;
}
.profile-children-list {
  margin-bottom: 1rem;
}
.profile-children-list .child-profile-row {
  background: #f8fafc;
}
.profile-children-list .select-profile-child-btn {
  background: #22c55e;
  color: #ffffff;
}
.profile-child-form-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px dashed #e5e7eb;
}
.profile-child-form-section h3 {
  font-size: 1.25rem;
  color: #374151;
}

/* Admin Gallery Management filters and pagination */
.small-field-label {
  display: block;
  margin-top: 10px;
  font-size: .9rem;
  color: #475569;
}
.category-select {
  width: 100%;
  margin-top: 6px;
}
.mini-helper {
  font-size: .85rem;
  margin: 6px 0 0;
}
.admin-gallery-filter-panel {
  margin: 12px 0 16px;
  padding: 14px;
  border: 2px solid #dbeafe;
  border-radius: 20px;
  background: #f8fbff;
}
.compact-filter-grid {
  align-items: end;
  margin: 0;
}
.filter-button-cell .button-row {
  margin: 0;
}
.load-more-wrap {
  display: none;
  justify-content: center;
  margin: 18px 0 4px;
}
.admin-saved-gallery-card .mini-helper {
  color: #64748b;
}

/* Keep saved-gallery filters directly below the admin upload area */
.admin-filter-below-upload {
  margin-top: -8px;
  margin-bottom: 20px;
}
.filter-panel-title {
  margin: 0 0 6px;
  color: #1e3a8a;
  font-size: 1.05rem;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  font-weight: 800;
  color: #334155;
}

.checkbox-line input {
  width: 20px;
  height: 20px;
  accent-color: #22c55e;
}

.gallery-tools-row {
  justify-content: center;
  margin: 8px 0 10px;
}

.danger-link {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.35);
  background: #fff5f5;
}
.danger-link:hover { background: #ffe4e6; }

/* Admin Uploaded Gallery Management: saved-gallery action button overlap fix */
#adminGalleryGrid.gallery-grid,
#adminSavedGalleryGrid.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}

#adminGalleryGrid .admin-saved-gallery-card,
#adminSavedGalleryGrid .admin-saved-gallery-card {
  min-width: 0;
  overflow: hidden;
}

#adminGalleryGrid .admin-saved-gallery-card h3,
#adminGalleryGrid .admin-saved-gallery-card p,
#adminSavedGalleryGrid .admin-saved-gallery-card h3,
#adminSavedGalleryGrid .admin-saved-gallery-card p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#adminGalleryGrid .admin-saved-gallery-card .gallery-actions,
#adminSavedGalleryGrid .admin-saved-gallery-card .gallery-actions {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)) !important;
  gap: 10px !important;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  box-sizing: border-box;
}

#adminGalleryGrid .admin-saved-gallery-card .gallery-actions button,
#adminGalleryGrid .admin-saved-gallery-card .gallery-actions a,
#adminSavedGalleryGrid .admin-saved-gallery-card .gallery-actions button,
#adminSavedGalleryGrid .admin-saved-gallery-card .gallery-actions a {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
  line-height: 1.15;
  padding: 10px 8px;
  text-align: center;
  word-break: break-word;
}

@media (max-width: 620px) {
  #adminGalleryGrid.gallery-grid,
  #adminSavedGalleryGrid.gallery-grid {
    grid-template-columns: 1fr;
  }
}

/* FINAL FIX: Admin Uploaded Gallery Management action buttons must never overlap.
   Stack buttons vertically inside each admin gallery/card so View / Compress / Delete
   always stay inside the card on desktop, tablet, and mobile. */
#adminColoringPagesGrid .gallery-card .gallery-actions,
#adminGalleryGrid .gallery-card .gallery-actions,
#adminSavedGalleryGrid .gallery-card .gallery-actions {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  grid-template-columns: none !important;
  gap: 8px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

#adminColoringPagesGrid .gallery-card .gallery-actions > *,
#adminGalleryGrid .gallery-card .gallery-actions > *,
#adminSavedGalleryGrid .gallery-card .gallery-actions > * {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  text-align: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.25 !important;
  padding: 11px 10px !important;
}

#adminColoringPagesGrid .gallery-card,
#adminGalleryGrid .gallery-card,
#adminSavedGalleryGrid .gallery-card {
  min-width: 0 !important;
  overflow: hidden !important;
}
