/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: #0f0f1a;
  color: #e0e0f5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  padding-bottom: 32px;
}

/* ── Nav ─────────────────────────────────────────────────────────────── */
.nav {
  background: #161628;
  border-bottom: 1px solid #2a2a4a;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  color: #9090c0;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover, .nav-links a.active { background: #2a2a4a; color: #fff; }

/* ── Main layout ─────────────────────────────────────────────────────── */
main { max-width: 720px; margin: 0 auto; padding: 16px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.page-header h2 { font-size: 1.3rem; font-weight: 700; }

.points-badge {
  background: linear-gradient(135deg, #f0c040, #e07000);
  color: #1a1000;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.alert-badge {
  background: #cc2244;
  color: white;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.7; } }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: #161628;
  border: 1px solid #2a2a4a;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; color: #b0b0e0; }
.card-urgent { border-color: #cc4400; }
.card-scoreboard { background: linear-gradient(135deg, #1a1a2e, #1e1430); }

/* ── Two-column ──────────────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 500px) { .two-col { grid-template-columns: 1fr; } }

/* ── Mission cards ───────────────────────────────────────────────────── */
.mission-card {
  background: #1e1e38;
  border: 1px solid #3a3a5a;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  transition: border-color .2s;
}
.mission-card:hover { border-color: #6060b0; }
.mission-card.task-submitted { opacity: .6; }
.mission-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.mission-title { font-weight: 700; font-size: 1rem; flex: 1; }
.mission-pts { background: #f0c040; color: #1a1000; font-weight: 700; border-radius: 8px; padding: 2px 8px; font-size: 0.8rem; white-space: nowrap; }
.mission-brief { color: #a0a0cc; font-size: 0.88rem; margin-bottom: 10px; line-height: 1.4; }
.mission-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* ── Difficulty badges ───────────────────────────────────────────────── */
.difficulty-badge { border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; font-weight: 700; }
.diff-1 { background: #1a4a1a; color: #80ff80; }
.diff-2 { background: #1a3a4a; color: #80d0ff; }
.diff-3 { background: #3a3a1a; color: #ffd080; }
.diff-4 { background: #4a1a1a; color: #ff9080; }
.diff-5 { background: #4a1040; color: #ff80ff; }

.due-date { color: #8080b0; font-size: 0.78rem; }
.recur-badge { color: #6080a0; font-size: 0.78rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: 9px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: linear-gradient(135deg, #5050cc, #7030aa); color: white; }
.btn-success { background: #1a8a3a; color: white; }
.btn-danger  { background: #8a1a2a; color: white; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; border-radius: 7px; }
.btn-complete { width: 100%; margin-top: 4px; }
.btn-link { background: none; border: none; color: #7070cc; font-size: 0.85rem; cursor: pointer; padding: 4px 0; text-decoration: underline; }

/* ── Approval items ──────────────────────────────────────────────────── */
.approval-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #2a2a4a;
  gap: 8px;
  flex-wrap: wrap;
}
.approval-item:last-child { border-bottom: none; }
.approval-info { display: flex; align-items: center; gap: 10px; }
.approval-emoji { font-size: 1.5rem; }
.approval-task { font-size: 0.85rem; color: #a0a0cc; }
.approval-pts { font-weight: 700; color: #f0c040; font-size: 0.8rem; }
.approval-btns { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Scoreboard ──────────────────────────────────────────────────────── */
.score-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #1e1e3a; }
.score-row:last-child { border-bottom: none; }
.score-me { background: #1a1a3a; border-radius: 8px; padding: 8px 10px; margin: 0 -10px; }
.score-rank { width: 24px; color: #6060a0; font-size: 0.85rem; }
.score-emoji { font-size: 1.3rem; }
.score-name { flex: 1; font-weight: 600; }
.score-pts { color: #f0c040; font-weight: 700; }

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: #1a1a30;
}
.leaderboard-first { background: linear-gradient(135deg, #2a2010, #3a3020); border: 1px solid #604000; }
.lb-rank { font-size: 1.3rem; width: 32px; }
.lb-emoji { font-size: 1.5rem; }
.lb-name { flex: 1; font-weight: 700; font-size: 1rem; }
.lb-right { text-align: right; }
.lb-week-pts { color: #f0c040; font-weight: 700; }
.lb-total-pts { color: #6060a0; font-size: 0.8rem; }

/* ── Commentator box ─────────────────────────────────────────────────── */
.commentator-box {
  background: #1a1428;
  border: 1px solid #3a2850;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.commentator-icon { font-size: 2rem; margin-bottom: 8px; }
.commentator-text { color: #c0b0e0; font-style: italic; line-height: 1.5; margin-bottom: 10px; }

/* ── Rewards ─────────────────────────────────────────────────────────── */
.rewards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.reward-card {
  background: #1e1e38;
  border: 1px solid #3a3a5a;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reward-card.reward-locked { opacity: .5; }
.reward-title { font-weight: 700; font-size: 0.95rem; }
.reward-desc { color: #8080a0; font-size: 0.82rem; }
.reward-cost { color: #f0c040; font-weight: 700; }
.reward-need { color: #606080; font-size: 0.8rem; }

/* ── History ─────────────────────────────────────────────────────────── */
.history-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid #1e1e38; font-size: 0.87rem; }
.history-item:last-child { border-bottom: none; }
.history-title { color: #c0c0e0; flex: 1; padding-right: 8px; }
.history-meta { flex-shrink: 0; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge { border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; font-weight: 700; }
.badge-success { background: #1a4a1a; color: #80ff80; }
.badge-pending { background: #3a3010; color: #ffd080; }
.badge-danger  { background: #4a1010; color: #ff8080; }

/* ── Admin ───────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tab-btn { background: #1a1a30; border: 1px solid #2a2a4a; color: #8080b0; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; transition: .15s; }
.tab-btn.active, .tab-btn:hover { background: #2a2a50; color: white; border-color: #5050a0; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; color: #8080b0; font-size: 0.82rem; margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 400px) { .form-row { grid-template-columns: 1fr; } }
.input {
  width: 100%;
  background: #0f0f1a;
  border: 1px solid #2a2a4a;
  color: #e0e0f5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.input:focus { outline: none; border-color: #5050a0; }

.admin-task-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #1e1e38; gap: 8px; }
.admin-task-row:last-child { border-bottom: none; }
.admin-task-row.archived { opacity: .45; }
.admin-task-info { flex: 1; min-width: 0; }
.admin-task-title { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-task-sub { color: #7070a0; font-size: 0.78rem; margin-top: 2px; }
.admin-task-brief { color: #6060a0; font-size: 0.78rem; font-style: italic; margin-top: 2px; }

.creating-msg { color: #f0c040; font-size: 0.85rem; margin-top: 8px; animation: pulse 1s infinite; }
.empty-msg { color: #4a4a6a; font-size: 0.9rem; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 30px 16px; color: #5050a0; }
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a5a;
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 0.9rem;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  max-width: 90vw;
  text-align: center;
}
.toast-error { background: #5a1a2a; }

/* ── Login ───────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 400px; padding: 24px; }
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-header h1 { font-size: 1.8rem; font-weight: 800; }
.login-header p { color: #6060a0; }
.login-prompt { text-align: center; color: #8080b0; margin-bottom: 16px; }

.user-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.user-card {
  background: #161628;
  border: 2px solid #2a2a4a;
  border-radius: 14px;
  padding: 20px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, background .15s;
}
.user-card:hover { border-color: #5050b0; background: #1e1e38; }
.user-emoji { font-size: 2.2rem; }
.user-name { font-weight: 700; font-size: 1rem; }

.pin-display { display: flex; justify-content: center; gap: 16px; margin: 20px 0; font-size: 1.8rem; letter-spacing: 4px; }
.pin-dot { color: #6060a0; transition: color .1s; }

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 260px;
  margin: 0 auto 16px;
}
.numpad-btn {
  background: #1e1e38;
  border: 1px solid #2a2a4a;
  color: white;
  border-radius: 12px;
  padding: 14px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .1s;
}
.numpad-btn:active { background: #3a3a60; }
.numpad-confirm { background: #1a4a1a; border-color: #2a6a2a; }
.numpad-back { background: #1e1e38; color: #8080b0; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.88rem; }
.alert-error { background: #3a1020; border: 1px solid #6a2030; color: #ff9090; }

/* ── Theme accents ───────────────────────────────────────────────────── */
.theme-sci-fi   .btn-primary { background: linear-gradient(135deg, #0050cc, #00aabb); }
.theme-fantasy  .btn-primary { background: linear-gradient(135deg, #6a2090, #c04080); }
.theme-spy      .btn-primary { background: linear-gradient(135deg, #202020, #505050); }
.theme-sports   .btn-primary { background: linear-gradient(135deg, #cc4400, #ffaa00); }
.theme-adventure .btn-primary { background: linear-gradient(135deg, #3a7020, #80b030); }
