:root {
  --bg-dark: #0f0c1d;
  --bg-darker: #0a0814;
  --primary: #a855f7;
  --primary-2: #6366f1;
  --accent: #f59e0b;
  --text: #f1eefc;
  --text-dim: #a79fc4;
  --card-bg: rgba(255,255,255,0.06);
  --card-border: rgba(255,255,255,0.1);
  --radius: 18px;
  --success: #22c55e;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: radial-gradient(circle at 20% 0%, #241a3d 0%, var(--bg-dark) 45%, var(--bg-darker) 100%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 78px;
}

a { text-decoration: none; color: inherit; }

.container { max-width: 480px; margin: 0 auto; padding: 16px; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: rgba(15,12,29,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.topbar .brand .logo-emoji { font-size: 1.4rem; animation: floaty 3s ease-in-out infinite; }
.topbar .wallet-pill {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(168,85,247,0.35);
}

@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }

/* ---- Search ---- */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 999px; padding: 10px 16px; margin: 14px 0;
}
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text);
  width: 100%; font-size: 0.95rem;
}
.search-box i { color: var(--text-dim); }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.chip {
  white-space: nowrap; padding: 7px 14px; border-radius: 999px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  font-size: 0.82rem; color: var(--text-dim); transition: all .2s;
}
.chip.active, .chip:hover { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }

/* ---- Story grid ---- */
.story-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.story-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius);
  overflow: hidden; transition: transform .25s, box-shadow .25s;
  animation: fadeUp .5s ease both;
}
.story-card:hover { transform: translateY(-4px); box-shadow: 0 10px 30px rgba(168,85,247,0.25); }
.story-card img { width: 100%; height: 130px; object-fit: cover; display: block; background: #2a2140; }
.story-card .info { padding: 10px 12px 14px; }
.story-card .title { font-size: 0.92rem; font-weight: 600; margin: 0 0 4px; line-height: 1.3; }
.story-card .meta { font-size: 0.72rem; color: var(--text-dim); display: flex; justify-content: space-between; }
.badge {
  display: inline-block; font-size: 0.65rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(168,85,247,0.25); color: #d5b4ff; margin-bottom: 6px;
}

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

/* ---- Story detail ---- */
.story-hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; position: relative; }
.story-hero img { width: 100%; height: 220px; object-fit: cover; display: block; }
.story-hero .overlay {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,8,20,0.95), transparent 60%);
  display: flex; align-items: flex-end; padding: 16px;
}
.story-hero h1 { margin: 0; font-size: 1.3rem; }

.episode-list { display: flex; flex-direction: column; gap: 10px; }
.episode-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; transition: background .2s;
}
.episode-item:hover { background: rgba(255,255,255,0.1); }
.episode-item .ep-icon {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); flex-shrink: 0;
}
.episode-item .ep-info { flex: 1; min-width: 0; }
.episode-item .ep-title { font-weight: 600; font-size: 0.9rem; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.episode-item .ep-meta { font-size: 0.75rem; color: var(--text-dim); }
.coin-tag {
  display: flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 700;
  background: rgba(245,158,11,0.18); color: var(--accent); padding: 4px 10px; border-radius: 999px;
}
.coin-tag.unlocked { background: rgba(34,197,94,0.18); color: var(--success); }

/* ---- Player modal ---- */
.player-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.player-overlay.open { display: flex; animation: fadeIn .2s ease; }
.player-box {
  background: linear-gradient(160deg, #1c1533, #100b1e); border: 1px solid var(--card-border);
  border-radius: 20px; padding: 22px; max-width: 420px; width: 100%; text-align: center;
  animation: popIn .3s ease;
}
.player-box iframe { width: 100%; height: 200px; border-radius: 12px; border: none; margin: 14px 0; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes popIn { from{opacity:0; transform: scale(.9);} to{opacity:1; transform: scale(1);} }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: none; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; transition: transform .15s, box-shadow .15s; width: 100%;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 6px 20px rgba(168,85,247,0.35); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-outline { background: transparent; border: 1px solid var(--card-border); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-success { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.btn-sm { padding: 8px 14px; font-size: 0.8rem; width: auto; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; text-align: left; }
.form-group label { display: block; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.05); color: var(--text); font-size: 0.92rem; outline: none;
  transition: border .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 24px;
  padding: 32px 26px; max-width: 380px; width: 100%; animation: fadeUp .5s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-card .emoji-hero { font-size: 2.6rem; text-align: center; margin-bottom: 6px; }
.auth-card h1 { text-align: center; font-size: 1.4rem; margin: 0 0 4px; }
.auth-card p.sub { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 0.85rem; color: var(--text-dim); }
.auth-switch a { color: var(--primary); font-weight: 600; }
.error-box {
  background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #ffb4b4;
  padding: 10px 14px; border-radius: 10px; font-size: 0.82rem; margin-bottom: 16px;
}
.success-box {
  background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #b7f5c8;
  padding: 10px 14px; border-radius: 10px; font-size: 0.82rem; margin-bottom: 16px;
}

/* ---- Bottom nav (app-like) ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(15,12,29,0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--card-border);
  display: flex; justify-content: space-around; padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.68rem; color: var(--text-dim); }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a i { font-size: 1.15rem; }

/* ---- Wallet ---- */
.wallet-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-radius: 22px; padding: 24px; text-align: center; margin-bottom: 20px;
  box-shadow: 0 15px 40px rgba(168,85,247,0.3);
}
.wallet-card .big-num { font-size: 2.4rem; font-weight: 800; margin: 6px 0; }
.qr-box { background: #fff; border-radius: 16px; padding: 16px; text-align: center; margin: 16px 0; }
.qr-box img { width: 220px; height: 220px; }

.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; font-size: 0.85rem;
}
.status-pill { font-size: 0.7rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.status-pending { background: rgba(245,158,11,0.2); color: var(--accent); }
.status-approved { background: rgba(34,197,94,0.2); color: var(--success); }
.status-rejected { background: rgba(239,68,68,0.2); color: var(--danger); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }

.whatsapp-fab {
  position: fixed; right: 16px; bottom: 90px; z-index: 25;
  width: 52px; height: 52px; border-radius: 50%;
  background: #25D366; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(37,211,102,0.4); font-size: 1.4rem; color: #fff;
  animation: floaty 3s ease-in-out infinite;
}

/* ---- Admin ---- */
.admin-body { background: #0d0b18; min-height: 100vh; padding-bottom: 40px; }
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.admin-nav {
  display: flex; gap: 6px; overflow-x: auto; padding: 12px 20px; background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--card-border); position: sticky; top: 0; z-index: 10;
}
.admin-nav a {
  padding: 8px 14px; border-radius: 10px; font-size: 0.85rem; color: var(--text-dim); white-space: nowrap;
}
.admin-nav a.active, .admin-nav a:hover { background: var(--primary); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; margin: 20px 0; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 18px;
}
.stat-card .num { font-size: 1.6rem; font-weight: 800; }
.stat-card .lbl { font-size: 0.78rem; color: var(--text-dim); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--card-border); }
table th { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.table-wrap { overflow-x: auto; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 4px; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.flex-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-title { font-size: 1.4rem; font-weight: 700; margin: 4px 0 18px; }
.card-panel { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px; padding: 22px; margin-bottom: 20px; }

@media (min-width: 640px) {
  .container { max-width: 720px; }
  .story-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .container { max-width: 960px; }
  .story-grid { grid-template-columns: repeat(4, 1fr); }
}
