/* =========================================================================
 * kiddo-scoreboard — child UI styles (Warm Playful design system)
 * Extracted from docs/demo.html, but cleaned up, scoped to child-only UI,
 * and using real design tokens. No frameworks. Mobile-first.
 * ========================================================================= */

:root {
  /* Surfaces */
  --bg-warm: #FFF9F0;
  --bg-card: #FFFFFF;
  --bg-soft: #FFFCF5;

  /* Brand colors */
  --game-green: #10B981;
  --game-green-soft: #D1FAE5;
  --money-gold: #F59E0B;
  --money-gold-soft: #FEF3C7;
  --accent-orange: #FF8A4C;
  --accent-orange-dark: #FF6B35;

  /* Text */
  --text-strong: #1F2937;
  --text-soft: #6B7280;
  --text-muted: #9CA3AF;

  /* Borders + shadows */
  --border-soft: #F3F4F6;
  --border-med: #E5E7EB;
  --shadow-xs: 0 1px 3px rgba(31, 41, 55, 0.06);
  --shadow-sm: 0 2px 8px rgba(31, 41, 55, 0.08);
  --shadow-md: 0 6px 16px rgba(31, 41, 55, 0.1);
  --shadow-lg: 0 20px 60px rgba(31, 41, 55, 0.3);
  --shadow-game: 0 8px 24px rgba(16, 185, 129, 0.18);
  --shadow-money: 0 8px 24px rgba(245, 158, 11, 0.18);

  /* Radii */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;

  /* Motion */
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Type */
  --font-stack: -apple-system, "SF Pro Rounded", "PingFang SC",
                "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-stack);
  font-size: 18px;
  line-height: 1.5;
  color: var(--text-strong);
  background: var(--bg-warm);
  letter-spacing: -0.01em;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- Layout ---------- */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 60px;
}

.section { margin-top: 24px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-strong);
}
.section-hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--game-green) 0%, #059669 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 24px 24px 20px;
  margin: 8px 0 0;
  box-shadow: var(--shadow-game);
  text-align: center;
}
.hero-greeting {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 6px 0 0;
  font-size: 15px;
  opacity: 0.92;
}

/* ---------- Balance cards ---------- */
.balance-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0 0;
}
.balance-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px 18px 18px;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s var(--bounce);
}
.balance-card.game-time { box-shadow: var(--shadow-md), var(--shadow-game); }
.balance-card.pocket-money { box-shadow: var(--shadow-md), var(--shadow-money); }
.balance-card.game-time::before,
.balance-card.pocket-money::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  pointer-events: none;
}
.balance-card.game-time::before {
  background: radial-gradient(circle, var(--game-green-soft) 0%, transparent 70%);
}
.balance-card.pocket-money::before {
  background: radial-gradient(circle, var(--money-gold-soft) 0%, transparent 70%);
}
.balance-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 4px;
  line-height: 1;
}
.balance-label {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 6px;
}
.balance-value {
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  margin: 4px 0 0;
  letter-spacing: -0.03em;
  color: var(--text-strong);
  transition: transform 0.3s var(--bounce);
}
.balance-card.game-time .balance-value { color: var(--game-green); }
.balance-card.pocket-money .balance-value { color: var(--money-gold); }
.balance-unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-soft);
  margin-left: 4px;
}
.balance-card.pulse .balance-value {
  animation: balance-pulse 0.6s var(--bounce);
}
@keyframes balance-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ---------- Task shortcuts ---------- */
.task-shortcuts-section { margin-top: 24px; }
.task-shortcuts {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 4px 8px;
  margin: 0 -4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.task-shortcuts::-webkit-scrollbar { height: 4px; }
.task-shortcuts::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 2px; }

.task-shortcut {
  flex: 0 0 auto;
  min-width: 150px;
  scroll-snap-align: start;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--bg-soft), var(--bg-card));
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-strong);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  min-height: 76px;
  transition: transform 0.2s var(--bounce),
              box-shadow 0.2s var(--ease),
              background 0.2s var(--ease),
              border-color 0.2s var(--ease);
}
.task-shortcut:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent-orange);
  box-shadow: 0 6px 16px rgba(255, 138, 76, 0.2);
}
.task-shortcut:active:not(:disabled) {
  transform: scale(0.94);
}
.task-shortcut.completed {
  background: var(--game-green-soft);
  border-color: var(--game-green);
  color: #047857;
  cursor: not-allowed;
  opacity: 0.9;
}
.task-shortcut-emoji { font-size: 22px; line-height: 1; }
.task-shortcut-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

/* ---------- Task buttons (rendered by app.js renderTasks) ---------- */
/* JS uses .task-btn + .task-btn-done class names (not the legacy .task-shortcut above). */
.task-btn {
  flex: 0 0 auto;
  min-width: 140px;
  min-height: 100px;
  scroll-snap-align: start;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 2px solid var(--border-med);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-strong);
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.2s var(--bounce),
              box-shadow 0.2s var(--ease),
              background 0.2s var(--ease),
              border-color 0.2s var(--ease);
}
.task-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent-orange);
  box-shadow: 0 6px 16px rgba(255, 138, 76, 0.2);
}
.task-btn:active:not(:disabled) { transform: scale(0.94); }
.task-btn:disabled { cursor: not-allowed; }

.task-btn.task-btn-done {
  background: linear-gradient(135deg, var(--game-green), #059669);
  border-color: var(--game-green);
  color: #fff;
  box-shadow: var(--shadow-game);
  opacity: 0.95;
}
/* §3.12 sleep task self-lockout (Item #002) — pre-cutoff: dimmed but clickable. */
.task-btn.task-btn-locked {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
  color: #4A4A4A;
  opacity: 0.85;
}
.task-btn.task-btn-locked:hover:not(:disabled) {
  background: rgba(0,0,0,0.08);
}
/* Past cutoff: fully grayed + disabled. Server still rejects POST /complete as authoritative. */
.task-btn.task-btn-locked-out,
.task-btn.task-btn-locked:disabled {
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.08);
  color: #888;
  cursor: not-allowed;
  opacity: 0.55;
}
.task-btn .task-cutoff-label { font-size: 12px; opacity: 0.7; margin-left: 6px; }
.task-btn .task-countdown-text { font-variant-numeric: tabular-nums; font-weight: 600; margin-left: 4px; }
.task-btn-icon { font-size: 26px; line-height: 1; }
.task-btn .task-name,
.task-btn .task-icon,
.task-btn .task-reward {
  color: inherit;
}
.task-btn .task-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.task-btn .task-reward {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}
.task-done-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
}
.task-shortcut-reward {
  color: var(--money-gold);
  font-weight: 800;
  font-size: 14px;
}
.task-shortcut.completed .task-shortcut-reward { color: var(--game-green); }

/* ---------- Action buttons ---------- */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.action-btn {
  min-height: 64px;
  padding: 16px 20px;
  font-size: 17px;
}

.btn {
  padding: 14px 22px;
  border-radius: var(--radius-md);
  border: 0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  min-height: 60px;
  transition: transform 0.2s var(--bounce), box-shadow 0.2s var(--ease),
              background 0.2s var(--ease);
}
.btn:active { transform: scale(0.94); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 138, 76, 0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(255, 138, 76, 0.45);
}
.btn-secondary {
  background: #fff;
  color: var(--text-strong);
  border: 2px solid var(--border-med);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--text-soft);
}

/* ---------- Event list ---------- */
.events-section { margin-top: 28px; }
.event-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.event-item {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-soft);
}
.event-item .event-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.event-item .event-icon.game { background: var(--game-green-soft); }
.event-item .event-icon.money { background: var(--money-gold-soft); }
.event-item.event-status-pending  { border-left: 4px solid #F59E0B; }
.event-item.event-status-approved { border-left: 4px solid #10B981; }
.event-item.event-status-rejected { border-left: 4px solid #EF4444; opacity: 0.7; }
.event-item.event-status-revoked  { border-left: 4px solid #9CA3AF; opacity: 0.6; }
.event-item.event-status-revoked .event-amount { text-decoration: line-through; color: var(--text-muted); }
.event-body { flex: 1; min-width: 0; }
.event-reason {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
  word-break: break-word;
}
.event-meta {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.event-value {
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}
.event-value.pos { color: var(--game-green); }
.event-value.neg { color: #EF4444; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
}
.badge.approved { background: var(--game-green-soft); color: #065F46; }
.badge.pending  { background: #FEF3C7; color: #B45309; }
.badge.rejected { background: #FEE2E2; color: #991B1B; }
.badge.revoked  { background: #FED7AA; color: #9A3412; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}
.empty-icon { font-size: 44px; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 0.2s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-back[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.3s var(--bounce);
}
@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.modal-title { margin: 0 0 4px; font-size: 20px; }
.modal-hint  { margin: 0 0 16px; color: var(--text-soft); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---------- Welcome modal (special) ---------- */
.welcome-modal {
  background: rgba(31, 41, 55, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
}
.welcome-content {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  text-align: center;
  border: 1px solid var(--border-soft);
}
.welcome-emoji {
  font-size: 64px;
  display: block;
  margin-bottom: 12px;
  animation: bounce 2s var(--bounce) infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.welcome-title { margin: 0 0 6px; font-size: 22px; }
.welcome-hint  { margin: 0 0 20px; color: var(--text-soft); font-size: 14px; }
.welcome-input {
  width: 100%;
  padding: 16px 18px;
  font-size: 18px;
  border: 2px solid var(--border-med);
  border-radius: var(--radius-md);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.welcome-input:focus {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 4px rgba(255, 138, 76, 0.15);
}
.welcome-btn { width: 100%; margin-top: 14px; }
.welcome-error {
  margin: 12px 0 0;
  color: #B91C1C;
  font-size: 14px;
}

/* ---------- Form ---------- */
.form { margin: 0; }
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border-med);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent-orange);
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seg-btn {
  padding: 14px;
  background: #fff;
  border: 2px solid var(--border-med);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 60px;
  color: var(--text-strong);
  transition: all 0.15s var(--ease);
}
.seg-btn.active,
.seg-btn.seg-btn-active {
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-dark));
  border-color: var(--accent-orange);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.seg-btn:active { transform: scale(0.96); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-strong);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--bounce);
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.toast-error { background: #B91C1C; }
.toast.toast-success { background: var(--game-green); }

/* ---------- Error banner ---------- */
.error-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #FEE2E2;
  color: #991B1B;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid #FECACA;
  font-size: 14px;
  font-weight: 600;
}
.error-banner[hidden] { display: none; }
.error-banner-retry {
  margin-left: auto;
  background: #fff;
  color: #991B1B;
  border: 1px solid #FECACA;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Confetti canvas ---------- */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  .app { padding: 24px 24px 80px; }
  .hero { padding: 32px 32px 24px; }
  .hero-greeting { font-size: 32px; }
  .balance-value { font-size: 56px; }
  .action-btn { font-size: 18px; }
}
@media (min-width: 1024px) {
  .app { max-width: 760px; padding: 32px 32px 80px; }
  .balance-row { gap: 20px; }
  .balance-value { font-size: 64px; }
  .balance-card { padding: 24px 22px 22px; }
}

/* ===== Progress bars (Item #005) ===== */
.progress-bars { margin: 18px 0 6px; display: flex; flex-direction: column; gap: 12px; }
.progress-bar { display: flex; flex-direction: column; gap: 4px; }
.progress-bar-track { background: rgba(0,0,0,0.06); border-radius: 999px; overflow: hidden; height: 14px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #FF8A4C, #F59E0B); border-radius: 999px 0 0 999px; transition: width 0.4s ease; }  /* §5.2 fix: left-rounded, right-flat so track's overflow:hidden clips the right edge to match track's pill shape — prevents "fill bulges out at 100%" illusion */
.progress-bar-text { font-size: 13px; color: #6B5E50; font-weight: 500; }
.progress-bar.daily .progress-bar-track { height: 22px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.08); }
.progress-bar.daily .progress-bar-text { font-size: 16px; font-weight: 700; color: #2C2416; }
.progress-bar.monthly .progress-bar-track { height: 14px; }
.progress-bar.yearly .progress-bar-track { height: 8px; opacity: 0.85; }
.progress-bar.yearly .progress-bar-text { font-size: 11px; opacity: 0.7; }

/* ===== Emoji picker (Item #001, admin tasks form) ===== */
.emoji-picker { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; padding: 8px 10px; background: rgba(0,0,0,0.03); border-radius: var(--radius-sm, 6px); }
.emoji-pick-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.emoji-pick-cat { font-size: 11px; color: #6B5E50; font-weight: 600; min-width: 32px; opacity: 0.7; }
.emoji-pick { background: white; border: 1.5px solid transparent; border-radius: 8px; padding: 4px 8px; font-size: 20px; cursor: pointer; transition: transform 0.1s, border-color 0.15s, background 0.15s; line-height: 1; }
.emoji-pick:hover { background: #FFF5E8; transform: scale(1.15); }
.emoji-pick.selected { border-color: #FF8A4C; background: #FFF5E8; }

@media (max-width: 380px) {
  .balance-value { font-size: 36px; }
  .balance-icon { font-size: 30px; }
  .task-shortcut { min-width: 130px; }
}
