/* ============================================================
   Snail Runner 3D - Cloudflare Pages PWA Stylesheet
   STANDARDIZED: Strict Mobile Design | Vanilla JS/HTML5/CSS3
   AdSense: side blocks on main page only
   Affiliate popups: closable on all pages
   Footer: modal links, narrow padding, copyright + trademark
   ============================================================ */

/* ====== RESET & STRICT MOBILE LOCKS ====== */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  touch-action: pan-x pan-y;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

img, svg, video, canvas {
  -webkit-user-drag: none;
  user-drag: none;
}

html, body {
  width: 100%; height: 100dvh;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #dcfce7;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Safe area insets for notch/Dynamic Island/cutout */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --green-primary: #4ade80;
  --green-dark: #16a34a;
  --green-darker: #15803d;
  --green-light: #bbf7d0;
  --green-bg: #dcfce7;
  --accent-gold: #fbbf24;
  --accent-red: #ef4444;
  --white: #ffffff;
  --shadow: 0 4px 24px rgba(0,0,0,0.15);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --ad-width: 160px;
}

/* ====== APP SHELL LAYOUT ====== */
#app-shell {
  display: flex;
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
}

#game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* ====== AD SIDE BLOCKS (LEFT & RIGHT ONLY - MAIN PAGE) ====== */
.ad-side {
  width: var(--ad-width);
  min-width: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.03);
  overflow: hidden;
  transition: width var(--transition), opacity var(--transition);
}

.ad-left {
  border-right: 1px solid rgba(74,222,128,0.2);
  padding-right: 2px;
}

.ad-right {
  border-left: 1px solid rgba(74,222,128,0.2);
  padding-left: 2px;
}

/* STANDARDIZED: Hide AdSense side blocks when user has paid */
body.no-ads .ad-side {
  width: 0 !important;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* STANDARDIZED: Hide AdSense side blocks during gameplay (added via JS) */
.ad-side.ads-hidden {
  width: 0 !important;
  min-width: 0 !important;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ====== TOP BAR ====== */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  padding-top: calc(4px + var(--sat));
  padding-left: calc(12px + var(--sal));
  padding-right: calc(12px + var(--sar));
  background: linear-gradient(135deg, var(--green-dark), var(--green-darker));
  color: var(--white);
  height: 44px;
  min-height: 44px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 28px; height: 28px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.app-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--green-primary);
  object-fit: cover;
}

.user-name {
  font-size: 12px;
  font-weight: 500;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
  color: var(--white);
  box-shadow: 0 2px 12px rgba(74,222,128,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(74,222,128,0.5); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
}
.btn-secondary:hover { background: rgba(255,255,255,0.25); }

.btn-accent {
  background: linear-gradient(135deg, var(--accent-gold), #f59e0b);
  color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(251,191,36,0.4);
  font-size: 12px;
  padding: 6px 12px;
}
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(251,191,36,0.5); }

/* STANDARDIZED: Success state for "Tanpa Iklan" */
.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(34,197,94,0.4);
  font-size: 12px;
  padding: 6px 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ====== GAME CANVAS ====== */
#game-canvas {
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: var(--green-bg);
  position: relative;
  aspect-ratio: auto;
}

/* ====== STANDARDIZED FOOTER (Adventure Kids pattern) ====== */
#app-footer {
  position: relative;
  background: rgba(255,255,255,0.95);
  border-top: 3px solid var(--green-darker);
  padding: 8px;
  padding-bottom: calc(8px + var(--sab));
  text-align: center;
  z-index: 100;
}

.footer-links {
  margin: 2px 0;
}

.footer-link {
  font-size: 10px;
  color: var(--green-darker);
  opacity: 0.7;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s, opacity 0.2s;
  -webkit-user-select: auto;
  user-select: auto;
}

.footer-link:hover {
  color: var(--accent-gold);
  opacity: 1;
}

.footer-brand {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-darker);
  margin: 4px 0;
}

.footer-copyright {
  font-size: 9px;
  color: var(--green-darker);
  opacity: 0.5;
  margin-bottom: 4px;
}

/* ====== MODAL SYSTEM ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  animation: slideUp 0.3s ease;
  position: relative;
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-sm { width: 100%; max-width: 360px; }
.modal-md { width: 100%; max-width: 420px; }
.modal-lg { width: 100%; max-width: 520px; }

.modal-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--green-darker);
  margin-bottom: 8px;
  text-align: center;
}

.modal-text {
  font-size: 14px;
  color: #4b5563;
  line-height: 1.6;
  text-align: center;
  margin-bottom: 16px;
}

.modal-text a {
  color: var(--green-dark);
  text-decoration: underline;
  -webkit-user-select: auto;
  user-select: auto;
}

.modal-scroll {
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: #374151;
  -webkit-user-select: auto;
  user-select: auto;
}

.modal-scroll h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-darker);
  margin-top: 12px;
  margin-bottom: 4px;
}

.modal-scroll p {
  margin-bottom: 8px;
}

.modal-scroll ul {
  margin-bottom: 8px;
  padding-left: 16px;
}

.modal-scroll li {
  margin-bottom: 4px;
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border: none;
  background: rgba(0,0,0,0.08);
  border-radius: 50%;
  font-size: 18px;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 1;
}
.modal-close:hover { background: rgba(0,0,0,0.15); color: #1a1a1a; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-note {
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}

/* Payment price display */
.payment-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--green-light);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.price-label {
  font-size: 13px;
  color: var(--green-darker);
}

.price-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--green-darker);
  letter-spacing: -0.5px;
}

/* ====== PAYMENT TERMS SCROLL ====== */
.pay-terms-scroll {
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: #374151;
  -webkit-user-select: auto;
  user-select: auto;
}

/* ====== TERMS CHECKBOX LABEL ====== */
.terms-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  cursor: pointer;
  -webkit-user-select: auto;
  user-select: auto;
}

.terms-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green-primary);
  cursor: pointer;
}

/* ====== FORM FIELDS (shared by payment, todo, pet) ====== */
.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin: 8px 0 4px;
}

.auth-optional {
  font-weight: 400;
  color: #9ca3af;
  font-size: 11px;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s;
  -webkit-user-select: text;
  user-select: text;
}

.auth-input:focus {
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

/* ====== TODO / Checklist Card ====== */
.todo-card {
  max-height: 85dvh;
}

.todo-add-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: flex-end;
}

.todo-add-row .auth-input {
  /* Reuse auth-input base; override width for inline context */
  flex: 1;
  min-width: 0;
}

.todo-date-input {
  width: auto;
  min-width: 120px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s;
  -webkit-user-select: text;
  user-select: text;
}

.todo-time-input {
  width: auto;
  min-width: 100px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s;
  -webkit-user-select: text;
  user-select: text;
}

.todo-list {
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 12px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}

.todo-item.done {
  text-decoration: line-through;
  opacity: 0.5;
}

.todo-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green-primary);
  flex-shrink: 0;
}

.todo-item-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.todo-item-meta {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}

.todo-delete {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  flex-shrink: 0;
}

/* ====== Scratch Pad (inside todo modal) ====== */
.scratch-section {
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}

.scratch-pad {
  width: 100%;
  min-height: 80px;
  max-height: 150px;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
  color: #1a1a1a;
  line-height: 1.5;
  -webkit-user-select: text;
  user-select: text;
}

.scratch-pad:focus {
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.2);
  outline: none;
}

/* ====== Pet Dashboard Card ====== */
.pet-card {
  max-height: 85dvh;
}

.pet-tabs {
  display: flex;
  gap: 0;
  margin: 12px 0 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.pet-tab {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.pet-tab.active {
  background: var(--green-primary);
  color: #fff;
}

.pet-tab-content {
  margin-top: 4px;
}

.pet-photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.pet-photo-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 2px solid var(--green-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  overflow: hidden;
  object-fit: cover;
  flex-shrink: 0;
}

.pet-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.pet-upload-btn {
  white-space: nowrap;
}

.pet-age-display {
  font-size: 13px;
  color: #6b7280;
  margin: 8px 0;
}

/* ====== Food & Health Items (same row style as todo) ====== */
.food-item,
.health-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}

/* ====== Toast Notification ====== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  background: #1a1a1a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  animation: toast-in 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ====== HIDDEN UTILITY ====== */
.hidden { display: none !important; }

/* ====== LOADING SPINNER ====== */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ====== COOKIE BANNER (Adventure Kids pattern) ====== */
.cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 55;
  padding: 8px;
  padding-bottom: calc(8px + var(--sab));
  background: rgba(0,0,0,0.3);
}
.cookie-banner.hidden { display: none !important; }
.cookie-content {
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  border: 3px solid var(--green-darker);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.cookie-icon { font-size: 24px; flex-shrink: 0; }
.cookie-text { font-size: 11px; line-height: 1.4; color: #374151; flex: 1; }
.cookie-text a { color: var(--accent-gold); font-weight: 700; }
.cookie-btns { display: flex; gap: 6px; flex-shrink: 0; }

/* ====== AFFILIATE BANNER STYLES (STANDARDIZED: closable popups on all pages) ====== */

/* --- Leaderboard Banner (Arleta/Interactive Link) --- */
.leaderboard-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  background: rgba(15,23,42,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(245,158,11,0.3);
  animation: cssfx-slide-down 0.3s ease-out;
}
.leaderboard-banner.hidden { display: none !important; }
body.no-ads .leaderboard-banner { display: none !important; }

.leaderboard-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
  padding: 6px 12px;
}

.leaderboard-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #fbbf24;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.leaderboard-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  animation: pulse 2s infinite;
}

.chevron-up { font-size: 10px; }
.chevron-down { font-size: 10px; transform: rotate(180deg); display: inline-block; }

.leaderboard-close {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 12px;
}
.leaderboard-close:hover { background: rgba(255,255,255,0.2); color: #fff; }

.leaderboard-content {
  border-top: 1px solid rgba(245,158,11,0.15);
  padding: 8px 12px;
  max-width: 900px;
  margin: 0 auto;
}

.leaderboard-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  pointer-events: auto;
}

.leaderboard-img {
  width: 80px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.leaderboard-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.leaderboard-text strong { color: #fbbf24; font-size: 13px; }
.leaderboard-text span { color: #c4b5fd; font-size: 11px; }
.leaderboard-text em { color: #5eead4; font-size: 11px; font-style: normal; font-weight: 700; }

/* --- Wasza Floating Banner --- */
.wasza-banner {
  position: fixed;
  bottom: 60px;
  right: 12px;
  z-index: 45;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(74,222,128,0.3);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-width: 280px;
  animation: cssfx-slide-in-right 0.3s ease-out;
}
.wasza-banner.hidden { display: none !important; }
body.no-ads .wasza-banner { display: none !important; }

.wasza-close {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 10px;
}

.wasza-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  pointer-events: auto;
}

.wasza-img {
  width: 56px; height: 56px%;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.wasza-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wasza-text strong { color: #4ade80; font-size: 12px; }
.wasza-text span { color: #94a3b8; font-size: 10px; }
.wasza-text em { color: #fbbf24; font-size: 10px; font-style: normal; font-weight: 700; }

/* --- Exabytes Bottom Banner --- */
.exabytes-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 42;
  background: linear-gradient(to right, #1e3a5f, #0f2440);
  border-top: 1px solid rgba(96,165,250,0.3);
  padding: 8px 16px;
  padding-bottom: calc(8px + var(--sab));
  animation: cssfx-slide-up 0.3s ease-out;
}
.exabytes-banner.hidden { display: none !important; }
body.no-ads .exabytes-banner { display: none !important; }

.exabytes-close {
  position: absolute;
  top: 4px; right: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 10px;
}

.exabytes-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  pointer-events: auto;
  flex-wrap: wrap;
}
.exabytes-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #60a5fa;
  background: rgba(96,165,250,0.15);
  padding: 2px 6px;
  border-radius: 4px;
}
.exabytes-link strong { color: #93c5fd; font-size: 12px; }
.exabytes-link span { color: #64748b; font-size: 11px; }
.exabytes-link em { color: #fbbf24; font-size: 11px; font-style: normal; font-weight: 700; }

/* --- Shopee Rotating Banner --- */
.shopee-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: linear-gradient(135deg, #fffbeb, #fff7ed);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  max-width: 380px;
  width: calc(100% - 2rem);
  animation: cssfx-slide-up 0.3s ease-out;
  overflow: hidden;
}
.shopee-banner.hidden { display: none !important; }
body.no-ads .shopee-banner { display: none !important; }

.shopee-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.3;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(251,191,36,0.15), transparent);
  background-size: 200% 100%;
  animation: cssfx-shimmer 3s linear infinite;
}

.shopee-close {
  position: absolute;
  top: 6px; right: 6px;
  z-index: 2;
  background: none;
  border: none;
  border-radius: 4px;
  padding: 4px;
  color: rgba(180,83,9,0.5);
  cursor: pointer;
  font-size: 10px;
}

.shopee-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  pointer-events: auto;
  padding-right: 16px;
}

.shopee-icon {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(245,158,11,0.4);
}

.shopee-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.shopee-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #d97706; }
#shopee-name { font-size: 12px; font-weight: 500; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shopee-cta { font-size: 10px; color: #d97706; }

/* ====== ANIMATIONS ====== */
@keyframes cssfx-slide-down {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
@keyframes cssfx-slide-up {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes cssfx-slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes cssfx-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ====== PRINT: HIDE EVERYTHING EXCEPT GAME ====== */
@media print {
  .ad-side, #top-bar, #app-footer, .modal-overlay,
  .leaderboard-banner, .wasza-banner, .exabytes-banner, .shopee-banner,
  .cookie-banner, .toast { display: none !important; }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   1024px — tablets landscape
   768px  — tablets portrait / small tablets
   480px  — phones
   360px  — small phones
   ============================================================ */

/* --- Tablets landscape --- */
@media (max-width: 1024px) {
  :root {
    --ad-width: 140px;
  }
  .modal-lg { max-width: 480px; }
  .todo-list { max-height: 35vh; }
  .pet-photo-preview { width: 72px; height: 72px; }
}

/* --- Tablets portrait / small tablets --- */
@media (max-width: 768px) {
  :root {
    --ad-width: 48px;
  }

  .ad-side {
    width: 48px;
    min-width: 48px;
  }
  .ad-side ins {
    transform: scale(0.6);
    transform-origin: center center;
  }
  body.no-ads .ad-side,
  .ad-side.ads-hidden {
    width: 0 !important;
    min-width: 0 !important;
  }

  #top-bar { padding: 2px 8px; height: 38px; min-height: 38px; }
  .app-name { font-size: 12px; }
  .logo-icon { width: 24px; height: 24px; }
  #app-footer { padding: 6px; }
  .footer-brand { font-size: 11px; }
  .footer-link { font-size: 9px; }
  .modal-card { padding: 16px; }
  .modal-title { font-size: 18px; }
  .modal-icon { font-size: 40px; }
  .price-value { font-size: 24px; }

  .todo-card, .pet-card { max-height: 80dvh; }
  .todo-add-row { gap: 4px; }
  .todo-date-input { min-width: 100px; }
  .todo-time-input { min-width: 80px; }
  .pet-tabs { margin: 8px 0 12px; }
  .pet-tab { padding: 6px 8px; font-size: 12px; }
  .pet-photo-preview { width: 64px; height: 64px; font-size: 32px; }

  .modal-sm, .modal-md { max-width: 90vw; }
  .modal-lg { max-width: 95vw; }
}

/* --- Phones --- */
@media (max-width: 480px) {
  :root {
    --ad-width: 32px;
  }

  .ad-side {
    width: 32px;
    min-width: 32px;
  }
  body.no-ads .ad-side,
  .ad-side.ads-hidden {
    width: 0 !important;
    min-width: 0 !important;
  }

  .app-name { display: none; }
  .user-name { display: none; }
  .modal-card { padding: 12px; border-radius: 12px; }
  .modal-sm, .modal-md, .modal-lg { max-width: 100%; }
  #app-footer { padding: 4px; }
  .footer-brand { font-size: 10px; }
  .footer-link { font-size: 8px; }
  .footer-copyright { font-size: 8px; }
  .modal-title { font-size: 16px; }
  .modal-text { font-size: 13px; }
  .price-value { font-size: 22px; }

  /* Todo responsive */
  .todo-card { max-height: 90dvh; }
  .todo-add-row { flex-direction: column; gap: 6px; }
  .todo-add-row .auth-input { width: 100%; }
  .todo-date-input, .todo-time-input { width: 100%; min-width: 0; }
  .todo-item { font-size: 12px; gap: 6px; }
  .todo-item-meta { font-size: 10px; }
  .scratch-pad { min-height: 60px; max-height: 120px; font-size: 12px; }

  /* Pet responsive */
  .pet-card { max-height: 90dvh; }
  .pet-tabs { flex-wrap: wrap; }
  .pet-tab { font-size: 12px; padding: 6px 8px; }
  .pet-photo-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .pet-photo-preview { width: 56px; height: 56px; font-size: 28px; }

  /* Payment / terms */
  .pay-terms-scroll { font-size: 12px; line-height: 1.6; }
  .terms-checkbox-label { font-size: 12px; }

  /* Toast */
  .toast { font-size: 12px; padding: 8px 16px; bottom: 60px; }
}

/* --- Small phones --- */
@media (max-width: 360px) {
  #top-bar { padding: 1px 6px; height: 34px; min-height: 34px; }
  .logo-icon { width: 20px; height: 20px; }
  .btn { padding: 8px 14px; font-size: 12px; }
  .btn-sm { padding: 5px 10px; font-size: 11px; }
  .btn-accent, .btn-success { font-size: 11px; padding: 5px 10px; }
  .modal-card { padding: 10px; border-radius: 10px; max-height: 95dvh; }
  .modal-title { font-size: 15px; }
  .modal-icon { font-size: 32px; }
  .modal-scroll, .pay-terms-scroll { max-height: 40vh; font-size: 12px; }
  .modal-close { top: 8px; right: 8px; width: 28px; height: 28px; font-size: 16px; }

  #app-footer { padding: 3px; }
  .footer-brand { font-size: 9px; }
  .footer-link { font-size: 7px; }
  .footer-copyright { font-size: 7px; }

  .price-value { font-size: 20px; }
  .payment-price { padding: 8px 12px; }

  .todo-add-row .auth-input,
  .todo-date-input,
  .todo-time-input { font-size: 13px; padding: 8px 10px; }
  .todo-item { font-size: 11px; padding: 4px 0; }
  .todo-item input[type="checkbox"] { width: 14px; height: 14px; }
  .todo-delete { font-size: 12px; }
  .todo-list { max-height: 35vh; }

  .scratch-pad { min-height: 50px; font-size: 4vw; padding: 8px; }

  .pet-tab { font-size: 11px; padding: 5px 6px; }
  .pet-photo-preview { width: 48px; height: 48px; font-size: 24px; }
  .pet-age-display { font-size: 12px; }

  .terms-checkbox-label { font-size: 11px; gap: 6px; }
  .terms-checkbox-label input[type="checkbox"] { width: 16px; height: 16px; }

  .toast { font-size: 11px; padding: 6px 12px; max-width: 95vw; }

  .cookie-content { padding: 8px; }
  .cookie-text { font-size: 10px; }

  /* Hide ad side blocks completely on very small phones */
  .ad-side { width: 0 !important; min-width: 0 !important; opacity: 0; pointer-events: none; }

  /* Affiliate banners tighter */
  .wasza-banner { max-width: 220px; padding: 8px; right: 6px; }
  .shopee-banner { max-width: 280px; padding: 8px; }
  .leaderboard-bar { padding: 4px 8px; }
}

/* ============================================================
   GAME VIEWPORT, HUD, OVERLAYS (Three.js CDN game)
   ============================================================ */

.game-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.game-viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* HUD */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: #fff;
  border: 3px solid var(--green-dark, #16a34a);
  box-shadow: var(--shadow-sm);
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.08s;
}
.hud-btn:active { transform: scale(0.92); }
.hud-stat {
  background: rgba(255,255,255,0.92);
  border: 2px solid var(--green-dark, #16a34a);
  box-shadow: var(--shadow-sm);
  border-radius: 16px;
  padding: 4px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 20px;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-label { display: block; font-size: 9px; font-weight: 700; opacity: 0.6; }

/* Game overlays (ready / paused / game over) */
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.game-overlay.hidden { display: none; }

/* Controls hint box */
.controls-hint {
  background: #fff8e7;
  border: 2px solid var(--green-dark, #16a34a);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 16px;
  font-size: 12px;
  text-align: left;
}
.controls-hint > div { padding: 2px 0; }

/* Stats grid (game over) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.stat-box {
  background: #dcfce7;
  border: 2px solid var(--green-dark, #16a34a);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}
.stat-emoji { font-size: 24px; display: block; }
.stat-val { font-size: 20px; font-weight: 700; display: block; }
.stat-label { font-size: 9px; font-weight: 700; opacity: 0.6; }

/* New best / prev best */
.best-score { font-weight: 700; margin-bottom: 12px; opacity: 0.6; }
.new-best { background: #d1fae5; border: 3px solid var(--green-dark, #16a34a); border-radius: 12px; padding: 6px; font-weight: 700; margin-bottom: 12px; }
.prev-best { font-size: 12px; opacity: 0.5; margin-bottom: 12px; }

/* Confetti animation */
@keyframes confetti-fall { 0% { transform: translateY(-100vh) rotate(0); } 100% { transform: translateY(100vh) rotate(720deg); } }
.confetti-piece {
  position: absolute;
  top: 0;
  width: 10px; height: 14px;
  animation: confetti-fall 2s linear infinite;
}

/* Modal emoji (for game overlays) */
.modal-emoji { font-size: 56px; line-height: 1; margin-bottom: 8px; }

/* ============================================================
   FOOTER HIDE DURING GAMEPLAY
   ============================================================ */
#app-footer.footer-game-hidden {
  display: none !important;
}

/* Button size variants for game */
.btn-lg { font-size: 20px; padding: 16px 24px; }
.btn-danger { background: #ef4444; color: #fff; }

/* ===== PWA INSTALL BANNER ===== */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--sab));
  background: linear-gradient(to right, var(--green-dark), var(--green-darker));
  color: white;
  box-shadow: 0 -4px 20px rgba(21,128,61,0.4);
  animation: slideUp 0.3s ease-out;
}

.pwa-install-banner.hidden { display: none; }

.pwa-banner-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.pwa-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pwa-banner-text strong {
  font-size: 13px;
  font-weight: 900;
}

.pwa-banner-text span {
  font-size: 10px;
  opacity: 0.85;
}

.pwa-banner-install {
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: white;
  color: var(--green-darker);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  flex-shrink: 0;
  transition: transform 0.1s;
}

.pwa-banner-install:hover { transform: scale(1.05); }
.pwa-banner-install:active { transform: scale(0.95); }

.pwa-banner-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-banner-close:hover { background: rgba(255,255,255,0.35); }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (max-width: 380px) {
  .pwa-banner-text strong { font-size: 12px; }
  .pwa-banner-text span { font-size: 9px; }
}
