/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, 'Hiragino Sans', 'Noto Sans JP', 'Segoe UI', sans-serif; background: #f0f4ff; color: #1a1a2e; -webkit-text-size-adjust: 100%; }
/* Prevent iOS tap highlight */
button, a { -webkit-tap-highlight-color: transparent; }
/* Twemoji: インライン絵文字画像のサイズ統一 */
img.emoji { height: 1.2em; width: 1.2em; vertical-align: -0.2em; display: inline-block; }

/* ===== VARIABLES ===== */
:root {
  --primary: #6c63ff;
  --primary-light: #a29bfe;
  --secondary: #fd79a8;
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #e17055;
  --info: #74b9ff;
  --dark: #2d3436;
  --light: #f9f9f9;
  --card-bg: #ffffff;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(108,99,255,0.12);
  --sidebar-w: 260px;
}

/* ===== SCREEN MANAGEMENT ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ===== LOGIN ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.logo-area { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 4rem; animation: bounce 2s infinite; }
.logo-title { font-size: 2.5rem; font-weight: 900; color: white; text-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.logo-sub { color: rgba(255,255,255,0.85); font-size: 1rem; margin-top: 0.25rem; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
}
.card h2 { margin-bottom: 1.25rem; font-size: 1.3rem; color: var(--dark); }

/* ===== INPUTS ===== */
.input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 16px; /* Prevents iOS auto-zoom */
  margin-bottom: 0.75rem;
  transition: border-color 0.2s;
  outline: none;
  -webkit-appearance: none;
}
.input-field:focus { border-color: var(--primary); }
select.input-field { appearance: none; background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%236c63ff'/%3E%3C/svg%3E") no-repeat right 12px center; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px; /* iOS minimum touch target */
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-full { width: 100%; margin-bottom: 0.5rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #5a52d5; box-shadow: 0 4px 12px rgba(108,99,255,0.4); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #e84393; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #009674; }
.btn-warning { background: var(--warning); color: #333; }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-ghost:hover { background: var(--primary); color: white; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; min-height: 38px; }
.btn-icon { padding: 0.5rem; font-size: 1.1rem; border-radius: 8px; min-height: 44px; min-width: 44px; }

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top);
  z-index: 100;
  box-shadow: 0 2px 10px rgba(108,99,255,0.3);
}
.menu-btn { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; padding: 0.5rem; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; touch-action: manipulation; }
.header-title { flex: 1; text-align: center; font-weight: 800; font-size: 1.2rem; }
.header-user { font-size: 1.5rem; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: -300px;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: white;
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  z-index: 200;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar.open { left: 0; }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
  display: none;
}
.sidebar-overlay.show { display: block; }
.sidebar-user { font-size: 2.5rem; text-align: center; padding: 1rem 0 0.5rem; }
.sidebar-balance {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
  margin-bottom: 1rem;
}
.nav-list { list-style: none; flex: 1; }
.nav-list li { margin-bottom: 0.125rem; }
.nav-btn {
  width: 100%;
  background: none;
  border: none;
  padding: 0.875rem 1rem;
  min-height: 48px;
  border-radius: 10px;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background 0.15s;
  color: var(--dark);
  font-weight: 500;
  touch-action: manipulation;
}
.nav-btn:hover { background: #f0f0ff; color: var(--primary); }
.nav-btn.active { background: var(--primary); color: white; }
.nav-icon { font-size: 1.2rem; width: 1.5rem; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-top: 60px;
  padding: 1.25rem;
  padding-top: 80px;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== PAGE SECTIONS ===== */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.25rem; display: flex; align-items: center; gap: 0.5rem; }
.hint { color: #888; font-size: 0.875rem; margin-bottom: 1rem; }

/* ===== DASHBOARD ===== */
.balance-card {
  background: linear-gradient(135deg, var(--primary) 0%, #a29bfe 100%);
  color: white;
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(108,99,255,0.35);
}
.balance-label { font-size: 0.9rem; opacity: 0.9; margin-bottom: 0.5rem; }
.balance-amount { font-size: 3rem; font-weight: 900; }
.balance-unit { font-size: 1.4rem; }
.balance-points { margin-top: 0.75rem; font-size: 0.9rem; opacity: 0.9; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.75rem; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: #888; }

.recent-list { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.recent-header { padding: 1rem 1.25rem; font-weight: 700; border-bottom: 1px solid #f0f0f0; }
.tx-item {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #f8f8f8;
  gap: 1rem;
}
.tx-item:last-child { border-bottom: none; }
.tx-icon { font-size: 1.5rem; width: 2rem; text-align: center; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 0.75rem; color: #aaa; margin-top: 2px; }
.tx-amount { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.tx-amount.positive { color: var(--success); }
.tx-amount.negative { color: var(--danger); }
.tx-amount.pending { color: var(--warning); }
.tx-status-badge { font-size: 0.7rem; padding: 2px 6px; border-radius: 6px; margin-left: 0.5rem; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-rejected { background: #f8d7da; color: #842029; }

/* ===== CHILD CARDS (parent dashboard) ===== */
.children-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.child-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.child-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(108,99,255,0.2); }
.child-avatar { font-size: 3rem; margin-bottom: 0.5rem; }
.child-name { font-weight: 700; margin-bottom: 0.25rem; }
.child-balance { color: var(--primary); font-weight: 600; font-size: 0.9rem; }
.child-points { color: #888; font-size: 0.8rem; }

/* ===== HISTORY / CHART ===== */
.chart-container {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.chart-container canvas { max-height: 280px; }

/* ===== TICKETS ===== */
.tickets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.875rem; }
.ticket-card {
  background: white;
  border-radius: 14px;
  padding: 1.25rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
  position: relative;
  overflow: hidden;
}
.ticket-card:hover { transform: translateY(-3px); }
.ticket-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.ticket-emoji { font-size: 2.5rem; margin-bottom: 0.5rem; }
.ticket-name { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.5rem; line-height: 1.3; }
.ticket-points { color: var(--primary); font-weight: 800; font-size: 1rem; margin-bottom: 0.75rem; }

.my-ticket {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
}
.my-ticket.used { opacity: 0.55; }
.my-ticket-emoji { font-size: 2rem; flex-shrink: 0; }
.my-ticket-info { flex: 1; }
.my-ticket-name { font-weight: 700; font-size: 0.9rem; }
.my-ticket-date { font-size: 0.75rem; color: #aaa; }

/* ===== SLOT MACHINE ===== */
.slot-machine {
  background: linear-gradient(135deg, #2d3436 0%, #1a1a2e 100%);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: white;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  margin-bottom: 1rem;
}
.slot-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 0.5rem; color: var(--warning); }
.slot-subtitle { font-size: 0.8rem; color: #aaa; margin-bottom: 1.5rem; }
.slot-promo {
  background: linear-gradient(135deg, #fdcb6e, #e17055);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  animation: promo-pulse 2s ease-in-out infinite;
  line-height: 1.4;
}
@keyframes promo-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(253,203,110,0); }
  50% { transform: scale(1.03); box-shadow: 0 0 20px rgba(253,203,110,0.5); }
}
.slot-jackpot-banner {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  text-align: center;
  animation: jackpot-glow 1.5s ease-in-out infinite alternate;
}
@keyframes jackpot-glow {
  0% { box-shadow: 0 0 8px rgba(108,92,231,0.3); }
  100% { box-shadow: 0 0 24px rgba(108,92,231,0.8); }
}
.jackpot-text { display: block; font-size: 0.85rem; font-weight: 800; letter-spacing: 2px; }
.jackpot-amount { display: block; font-size: 1.5rem; font-weight: 900; color: #ffeaa7; }
.jackpot-sub { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.7); }
.slot-loss-taunt {
  background: rgba(253,203,110,0.15);
  border: 1px solid rgba(253,203,110,0.3);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fdcb6e;
  text-align: center;
  animation: taunt-bounce 0.5s ease-out;
}
@keyframes taunt-bounce {
  0% { transform: translateY(-10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
.slot-reels {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.slot-reel {
  width: 80px; height: 80px;
  background: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.1s;
}
.slot-reel.spinning { animation: spin-reel 0.1s linear infinite; }
@keyframes spin-reel { 0% { transform: scaleY(0.8); } 100% { transform: scaleY(1); } }
.slot-controls { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.slot-bet-label { color: #ccc; font-size: 0.85rem; }
.slot-bet-input { width: 80px; padding: 0.5rem; border-radius: 8px; border: 2px solid var(--warning); background: rgba(255,255,255,0.1); color: white; font-size: 1rem; text-align: center; }
.slot-spin-btn {
  background: linear-gradient(135deg, var(--warning), var(--danger));
  color: white;
  border: none;
  padding: 0.875rem 2rem;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(253,203,110,0.4);
}
.slot-spin-btn:hover { transform: scale(1.05); }
.slot-spin-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.slot-result { min-height: 2rem; font-size: 1rem; margin-bottom: 1rem; }
.slot-stats-bar {
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 0.875rem;
  font-size: 0.8rem;
  color: #aaa;
  display: flex;
  justify-content: space-around;
}
.slot-stat-item { text-align: center; }
.slot-stat-val { font-size: 1.1rem; font-weight: 800; color: var(--warning); }

.slot-warning {
  background: linear-gradient(135deg, #e17055, #d63031);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
}
.slot-warning strong { font-size: 1rem; display: block; margin-bottom: 0.25rem; }

/* ===== INTEREST ===== */
.interest-card {
  background: linear-gradient(135deg, var(--success) 0%, #55efc4 100%);
  color: white;
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(0,184,148,0.35);
}
.interest-rate { font-size: 3rem; font-weight: 900; }
.interest-label { font-size: 0.9rem; opacity: 0.9; }
.interest-projected { margin-top: 0.75rem; font-size: 1.1rem; font-weight: 600; }

/* ===== ADS GAME ===== */
.ads-intro {
  background: linear-gradient(135deg, #e17055, #d63031);
  color: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  text-align: center;
}
.ads-intro h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.ads-intro p { font-size: 0.875rem; opacity: 0.9; }
.ads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.ad-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 2px solid #ffcc00;
  position: relative;
  overflow: hidden;
  animation: ad-pulse 3s infinite;
}
@keyframes ad-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255,200,0,0.3); }
  50% { box-shadow: 0 4px 30px rgba(255,200,0,0.6), 0 0 0 3px rgba(255,200,0,0.2); }
}
.ad-card::before {
  content: '広告';
  position: absolute;
  top: 0; right: 0;
  background: #ffcc00;
  color: #333;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-bottom-left-radius: 6px;
}
.ad-emoji { font-size: 2rem; margin-bottom: 0.5rem; }
.ad-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.5rem; color: #c0392b; }
.ad-body { font-size: 0.8rem; color: #555; margin-bottom: 1rem; line-height: 1.4; }
.ad-click-btn {
  width: 100%;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  border: none;
  padding: 0.625rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.875rem;
  animation: btn-flash 1.5s infinite;
}
@keyframes btn-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.75; } }
.safe-btn {
  width: 100%;
  background: var(--success);
  color: white;
  border: none;
  padding: 0.625rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* ===== CHORE FORM ===== */
.chore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.chore-btn {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 1rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}
.chore-btn:hover, .chore-btn.selected { border-color: var(--primary); background: #f0f0ff; color: var(--primary); }
.chore-btn-emoji { font-size: 1.75rem; display: block; margin-bottom: 0.25rem; }
.chore-btn-name { font-weight: 600; }
.chore-btn-pts { color: var(--primary); font-size: 0.8rem; font-weight: 700; }

.chore-item {
  background: white;
  border-radius: 12px;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.625rem;
}
.chore-status { font-size: 0.75rem; padding: 3px 8px; border-radius: 8px; }
.status-pending { background: #fff3cd; color: #856404; }
.status-approved { background: #d1f2eb; color: #0e7c5a; }
.status-rejected { background: #f8d7da; color: #842029; }

/* ===== PARENT PANEL ===== */
.approval-item {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.approval-info { flex: 1; min-width: 200px; }
.approval-name { font-weight: 700; font-size: 0.9rem; }
.approval-desc { font-size: 0.8rem; color: #888; }
.approval-amount { font-size: 1.2rem; font-weight: 800; color: var(--primary); }
.approval-btns { display: flex; gap: 0.5rem; }

/* ===== AVATAR PICKER ===== */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.avatar-option {
  font-size: 1.75rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.avatar-option:hover, .avatar-option.selected { border-color: var(--primary); background: #f0f0ff; }

/* ===== LOGIN TABS ===== */

/* ===== EMOJI PICK BUTTON ===== */
.emoji-pick-btn {
  font-size: 1.75rem;
  width: 3rem;
  height: 3rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
  line-height: 1;
}
.emoji-pick-btn:hover { border-color: var(--primary); background: #f0f0ff; }
.emoji-pick-btn img.emoji { width: 1.75rem; height: 1.75rem; }

/* ===== EMOJI PICKER MODAL ===== */
.ep-cats {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
}
.ep-cat-btn {
  padding: .3rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #f5f5ff;
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.ep-cat-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.ep-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .4rem;
  max-height: 260px;
  overflow-y: auto;
}
.ep-emoji-btn {
  font-size: 1.5rem;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: .5rem;
  background: none;
  cursor: pointer;
  transition: background .1s, border-color .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ep-emoji-btn img.emoji { width: 1.5rem; height: 1.5rem; }
.ep-emoji-btn:hover { background: #f0f0ff; border-color: var(--primary); }

/* ===== PAY MANAGE ===== */
.children-selector {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: .5rem;
}
.child-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .6rem .75rem;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: var(--bg-card);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  min-width: 80px;
}
.child-select-btn.active { border-color: var(--primary); background: #f0f0ff; }
.child-select-btn:hover { border-color: var(--primary-light); }
.cs-avatar { font-size: 1.75rem; line-height: 1; }
.cs-avatar img.emoji { width: 1.75rem; height: 1.75rem; }
.cs-name { font-size: .8rem; font-weight: 700; }
.cs-balance { font-size: .7rem; color: var(--text-secondary); }
.pm-direction-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-top: .5rem;
}
.pm-dir-btn {
  padding: .75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  color: var(--text-secondary);
}
.pm-dir-btn.active:first-child { background: #e8fff5; border-color: var(--success); color: var(--success); }
.pm-dir-btn.active:last-child  { background: #fff0ee; border-color: var(--danger);  color: var(--danger);  }

/* ===== ACCOUNT SETTINGS ===== */
.account-member-card {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.account-member-card:last-child { border-bottom: none; }
.acct-avatar-wrap { position: relative; flex-shrink: 0; }
.acct-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: #f0f0ff;
}
.acct-avatar img.emoji { width: 2.5rem; height: 2.5rem; }
.acct-av-edit-btn {
  position: absolute;
  bottom: -4px; right: -4px;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: .6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.acct-info { flex: 1; min-width: 0; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(2rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: #2d3436;
  color: white;
  padding: 0.875rem 1.5rem;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 9999;
  transition: transform 0.3s ease;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #333; }

/* ===== PAY MANAGE BALANCE BANNER ===== */
.pm-balance-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #6c63ff, #a29bfe);
  color: white;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.pm-bal-avatar { font-size: 2.5rem; line-height: 1; }
.pm-bal-avatar img.emoji { width: 2.5rem; height: 2.5rem; }
.pm-bal-name { font-size: .85rem; opacity: .85; }
.pm-bal-amount { font-size: 1.75rem; font-weight: 900; line-height: 1.1; }
.pm-bal-pts { font-size: .8rem; opacity: .8; margin-top: .15rem; }

/* ===== TICKET SHOP EXTRAS ===== */
.ticket-desc { font-size: .75rem; color: var(--text-secondary); margin: .2rem 0; line-height: 1.4; }
.ticket-stock { font-size: .75rem; background: #fff3cd; color: #856404; border-radius: 999px; padding: .1rem .5rem; display: inline-block; margin: .2rem 0; }
.ticket-expire { font-size: .75rem; background: #fde8e8; color: #c62828; border-radius: 999px; padding: .1rem .5rem; display: inline-block; }

/* ===== SUSPICIOUS AD POPUP ===== */
.suspicious-ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.suspicious-ad-overlay.show { pointer-events: auto; }
.suspicious-ad-box {
  position: relative;
  background: linear-gradient(135deg, #fff9c4, #fff176);
  border: 3px solid #f9a825;
  border-radius: 1rem 1rem 0 0;
  padding: 1.25rem 1rem 1.5rem;
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.25);
}
.suspicious-ad-overlay.show .suspicious-ad-box { transform: translateY(0); }
.sad-tag {
  position: absolute;
  top: .5rem;
  left: .75rem;
  font-size: .65rem;
  background: #aaa;
  color: white;
  padding: .1rem .4rem;
  border-radius: 3px;
}
.sad-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 1.5px solid #999;
  background: #f5f5f5;
  font-size: .7rem;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sad-emoji { font-size: 2rem; text-align: center; margin: .75rem 0 .25rem; }
.sad-emoji img.emoji { width: 2rem; height: 2rem; }
.sad-title {
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  color: #b71c1c;
  margin-bottom: .4rem;
  line-height: 1.3;
}
.sad-body {
  font-size: .85rem;
  color: #444;
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1.5;
}
.sad-click-btn {
  display: block;
  width: 100%;
  padding: .875rem;
  background: linear-gradient(135deg, #e53935, #ff5722);
  color: white;
  font-size: 1rem;
  font-weight: 800;
  border: none;
  border-radius: .75rem;
  cursor: pointer;
  font-family: inherit;
  animation: sad-pulse 1.2s infinite;
}
@keyframes sad-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* ===== FULLSCREEN AD ===== */
.sad-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .3s;
}
.sad-fullscreen.show { opacity: 1; }
.sad-fs-close {
  position: fixed;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: rgba(255,255,255,0.2);
  font-size: 7px;
  cursor: pointer;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sad-fs-content {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 420px;
}
.sad-fs-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: .75rem;
  line-height: 1.4;
}
.sad-fs-body {
  font-size: .9rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}
.sad-fs-btn {
  font-size: 1.1rem;
  padding: 1rem 2rem;
  border-radius: 2rem;
  animation: sad-pulse .8s infinite;
}
.sad-fs-urgency {
  margin-top: 1rem;
  font-size: .75rem;
  color: #ff5252;
  animation: sad-blink 1s infinite;
}
@keyframes sad-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ===== FAKE CLOSE AD ===== */
.sad-fakeclose-box { padding-top: 2.5rem !important; }
.sad-fakeclose-big {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: #f5f5f5;
  border: 2px solid #999;
  border-radius: 8px;
  padding: .3rem .75rem;
  font-size: .85rem;
  font-weight: 700;
  color: #333;
  cursor: pointer;
  font-family: inherit;
  z-index: 2;
}
.sad-fakeclose-big:active { background: #e0e0e0; }
.sad-fakeclose-real {
  margin-top: .75rem;
  font-size: .55rem;
  color: #ccc;
  text-align: right;
  cursor: pointer;
  text-decoration: none;
}
.sad-fakeclose-real:hover { color: #999; }

/* ===== SYSTEM ALERT AD ===== */
.sad-sysalert-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity .2s;
}
.sad-sysalert-overlay.show { opacity: 1; }
.sad-sysalert-box {
  background: #fff;
  border-radius: 14px;
  max-width: 340px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.35);
}
.sad-sysalert-header {
  background: #f8f8f8;
  padding: .75rem 1rem;
  font-size: .85rem;
  font-weight: 700;
  color: #333;
  border-bottom: 1px solid #e0e0e0;
  text-align: center;
}
.sad-sysalert-body {
  padding: 1rem 1.25rem;
  font-size: .9rem;
  color: #222;
}
.sad-sysalert-btns {
  display: flex;
  border-top: 1px solid #e0e0e0;
}
.sad-sysalert-btn {
  flex: 1;
  padding: .75rem;
  border: none;
  background: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.sad-sysalert-ok { color: #007aff; border-right: 1px solid #e0e0e0; }
.sad-sysalert-cancel { color: #007aff; }
.sad-sysalert-btn:active { background: #f0f0f0; }
.sad-sysalert-dismiss {
  text-align: center;
  padding: .4rem;
  font-size: .55rem;
  color: #bbb;
  cursor: pointer;
}

/* ===== COUNTDOWN AD ===== */
.sad-countdown-box { border-color: #e53935 !important; background: linear-gradient(135deg, #fff5f5, #ffe0e0) !important; }
.sad-countdown-timer {
  font-size: 3rem;
  font-weight: 900;
  color: #e53935;
  text-align: center;
  margin: .5rem 0 0;
  font-variant-numeric: tabular-nums;
  animation: sad-timer-pulse 1s infinite;
}
.sad-countdown-label {
  text-align: center;
  font-size: .8rem;
  font-weight: 700;
  color: #b71c1c;
  margin-bottom: .75rem;
}
@keyframes sad-timer-pulse {
  0%, 100% { transform: scale(1); color: #e53935; }
  50% { transform: scale(1.15); color: #b71c1c; }
}

/* ===== QUIZ POPUP ===== */
.quiz-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.quiz-popup-overlay.show { pointer-events: auto; }
.quiz-popup-box {
  position: relative;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  border: 3px solid #43a047;
  border-radius: 1rem 1rem 0 0;
  padding: 1.25rem 1rem 1.5rem;
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
}
.quiz-popup-overlay.show .quiz-popup-box { transform: translateY(0); }
.quiz-popup-tag {
  position: absolute;
  top: .5rem;
  left: .75rem;
  font-size: .65rem;
  background: #43a047;
  color: white;
  padding: .1rem .4rem;
  border-radius: 3px;
  font-weight: 700;
}
.quiz-popup-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 1.5px solid #999;
  background: #f5f5f5;
  font-size: .7rem;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
}
.quiz-popup-icon { font-size: 2rem; text-align: center; margin: .75rem 0 .25rem; }
.quiz-popup-question {
  font-size: .95rem;
  font-weight: 700;
  text-align: center;
  color: #1b5e20;
  margin-bottom: .75rem;
  line-height: 1.4;
}
.quiz-popup-options { display: grid; gap: .4rem; margin-bottom: .75rem; }
.quiz-popup-option {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .75rem;
  background: white;
  border: 2px solid #a5d6a7;
  border-radius: .6rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.quiz-popup-option:hover:not(:disabled) { background: #f1f8e9; border-color: #43a047; }
.quiz-opt-label { font-weight: 900; color: #43a047; min-width: 1rem; }
.quiz-opt-correct { background: #e8f5e9 !important; border-color: #43a047 !important; color: #1b5e20; }
.quiz-opt-wrong { background: #ffebee !important; border-color: #e53935 !important; color: #b71c1c; }
.quiz-popup-explanation {
  background: white;
  border-radius: .5rem;
  padding: .625rem .75rem;
  font-size: .8rem;
  color: #444;
  line-height: 1.5;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}
.modal-box h3 { font-size: 1.3rem; margin-bottom: 1rem; }
.modal-emoji { font-size: 4rem; margin-bottom: 1rem; }
.modal-loss { font-size: 2rem; font-weight: 900; color: var(--danger); margin-bottom: 0.5rem; }
.modal-explanation { background: #fff3cd; border-radius: 10px; padding: 1rem; font-size: 0.875rem; line-height: 1.6; text-align: left; margin-bottom: 1rem; border-left: 4px solid var(--warning); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: #888; }
.empty-state .empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.9rem; }

/* ===== SECTION HEADER ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { font-size: 1rem; font-weight: 700; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; overflow-x: auto; padding-bottom: 2px; }
.tab-btn { padding: 0.5rem 1rem; border-radius: 20px; border: none; background: #e0e0e0; color: #555; font-weight: 600; cursor: pointer; white-space: nowrap; font-size: 0.875rem; transition: all 0.2s; }
.tab-btn.active { background: var(--primary); color: white; }

/* ===== REGISTER CHILD ===== */
.add-child-card { background: white; border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.add-child-card h3 { margin-bottom: 1rem; font-size: 1rem; }

/* ===== GRANT FORM ===== */
.grant-form { background: white; border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grant-form h3 { margin-bottom: 1rem; }
.amount-presets { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.preset-btn { padding: 0.4rem 0.75rem; border-radius: 8px; border: 2px solid var(--primary); background: transparent; color: var(--primary); font-weight: 600; font-size: 0.85rem; cursor: pointer; transition: all 0.15s; }
.preset-btn:hover { background: var(--primary); color: white; }

/* ===== INTEREST TIPS ===== */
.tip-list { list-style: none; }
.tip-item { display: flex; gap: 0.75rem; padding: 0.75rem; background: white; border-radius: 10px; margin-bottom: 0.625rem; box-shadow: var(--shadow); align-items: flex-start; }
.tip-icon { font-size: 1.5rem; flex-shrink: 0; }
.tip-text { font-size: 0.875rem; line-height: 1.5; }

/* ===== MANAGE ITEMS ===== */
.manage-item {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.625rem;
}
.manage-item-inactive { opacity: 0.5; }
.manage-info { flex: 1; min-width: 0; }
.manage-inline-input {
  width: 100%;
  padding: 0.35rem 0.6rem;
  border: 1.5px solid #e0e0e0;
  border-radius: 7px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
.manage-inline-input:focus { border-color: var(--primary); }

/* ===== RAINBOW OVERLAY ===== */
@keyframes rainbow-flash {
  0%   { background: rgba(255,0,0,0.25); }
  14%  { background: rgba(255,127,0,0.25); }
  28%  { background: rgba(255,255,0,0.25); }
  42%  { background: rgba(0,255,0,0.25); }
  57%  { background: rgba(0,0,255,0.25); }
  71%  { background: rgba(75,0,130,0.25); }
  85%  { background: rgba(148,0,211,0.25); }
  100% { background: rgba(255,0,0,0.25); }
}
.rainbow-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  animation: rainbow-flash 0.4s linear infinite;
}

/* ===== SLOT REEL EFFECTS ===== */
@keyframes reel-glow-pulse {
  0%, 100% { box-shadow: 0 0 12px 4px gold, inset 0 0 8px rgba(255,215,0,0.4); }
  50%       { box-shadow: 0 0 24px 10px gold, inset 0 0 16px rgba(255,215,0,0.7); }
}
.reel-highlight {
  animation: reel-glow-pulse 0.5s ease-in-out infinite !important;
  border-color: gold !important;
  background: linear-gradient(135deg, #fff9e6, #fff3b0) !important;
  transform: scale(1.08);
  transition: transform 0.15s;
}
@keyframes reel-snap-anim {
  0%   { transform: scale(1.18) rotate(-3deg); }
  50%  { transform: scale(0.92) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.reel-snap {
  animation: reel-snap-anim 0.18s ease-out forwards !important;
}

/* ===== NEAR MISS TEXT ===== */
@keyframes near-miss-bounce {
  0%, 100% { transform: scale(1); }
  30%       { transform: scale(1.25); }
  60%       { transform: scale(0.9); }
}
.near-miss-pulse {
  animation: near-miss-bounce 0.5s ease-in-out 3;
}
.slot-near-miss-text {
  font-size: 1.3rem;
  font-weight: 800;
  color: #e74c3c;
  text-align: center;
  margin-top: 0.5rem;
  text-shadow: 0 2px 6px rgba(231,76,60,0.4);
}

/* ===== RESPONSIVE ===== */

/* iPhone small */
@media (max-width: 390px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .slot-reel { width: 60px; height: 60px; font-size: 1.8rem; }
  .ads-grid { grid-template-columns: 1fr; }
  .balance-amount { font-size: 2.4rem; }
  .chore-grid { grid-template-columns: repeat(2, 1fr); }
  .tickets-grid { grid-template-columns: repeat(2, 1fr); }
}

/* iPhone standard */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .slot-reel { width: 65px; height: 65px; font-size: 2rem; }
  .ads-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 1.3rem; }
  .approval-item { gap: 0.75rem; }
}

/* iPad portrait and above */
@media (min-width: 768px) {
  :root { --sidebar-w: 280px; }
  .main-content { max-width: 860px; padding-left: 1.75rem; padding-right: 1.75rem; }
  .balance-amount { font-size: 3.5rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .children-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .tickets-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .chore-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .ads-grid { grid-template-columns: repeat(2, 1fr); }
  .card { max-width: none; }
  .slot-reel { width: 100px; height: 100px; font-size: 3rem; }
  .slot-machine { padding: 2.5rem; }
  .page-title { font-size: 1.75rem; }
  .nav-btn { font-size: 1.05rem; }
  .btn { font-size: 1rem; }
  .input-field { font-size: 16px; }
  .approval-item { padding: 1.25rem; }
  .manage-item { padding: 1.25rem; }
}

/* iPad landscape / large tablet */
@media (min-width: 1024px) {
  .main-content { max-width: 960px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
