/* ─── TASK MASTER — STYLE ───────────────────────────────────── */

:root {
  --bg: #050304;
  --bg-glow-red: #FF3B30;
  --bg-glow-orange: #FF8C42;
  --text-primary: #FAFAFA;
  --text-secondary: #C7C2BE;
  --text-tertiary: #79746F;

  --power: #FF3B30;
  --brain: #3DB4FF;
  --story: #B36BFF;
  --skill: #3DDC84;
  --discipline: #FF8C42;

  --card-bg: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  overscroll-behavior-y: none;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  padding: max(20px, env(safe-area-inset-top)) 18px max(60px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(255,59,48,0.16) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 95%, rgba(255,140,66,0.10) 0%, transparent 60%),
    var(--bg);
}

.numeric { font-family: 'SF Mono', ui-monospace, Menlo, monospace; }

/* ─── SCREENS ────────────────────────────────────────────────── */
.screen { display: none; max-width: 520px; margin: 0 auto; }
.screen.active { display: block; }

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card-glow {
  border-color: rgba(255,59,48,0.4);
  box-shadow: 0 0 24px rgba(255,59,48,0.18), inset 0 0 24px rgba(255,59,48,0.06);
}

/* ─── TITLES ─────────────────────────────────────────────────── */
.tm-title {
  font-size: 26px; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(180deg, #FFFFFF 0%, #FFB199 140%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  margin: 0 0 4px;
}
.tm-subtitle { font-size: 13px; color: var(--text-tertiary); margin: 0 0 16px; }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.05); color: var(--text-primary);
  cursor: pointer; transition: transform 0.1s, opacity 0.1s, background 0.2s;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }
.btn-primary {
  background: linear-gradient(135deg, var(--power), var(--discipline));
  border: none; color: #0a0a0a; font-weight: 800;
}
.btn-block { display: flex; width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--card-border); color: var(--text-secondary); }
.btn-danger { border-color: rgba(255,59,48,0.4); color: var(--power); background: rgba(255,59,48,0.08); }

/* ─── TOP BAR ────────────────────────────────────────────────── */
.tm-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 8px;
}
.tm-topbar .tm-back { font-size: 20px; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 4px 8px; }
.tm-topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }

/* ─── PLAYER SELECT ──────────────────────────────────────────── */
.player-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.player-card {
  cursor: pointer; text-align: center; padding: 22px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform 0.1s, border-color 0.2s;
}
.player-card:active { transform: scale(0.97); }
.player-card .avatar { font-size: 44px; }
.player-card .pname { font-size: 16px; font-weight: 700; }
.player-card .ptitle { font-size: 11px; color: var(--text-tertiary); }
.player-card .plevel {
  font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: rgba(255,140,66,0.15); color: var(--discipline);
}
.player-card.add-player {
  border-style: dashed; color: var(--text-tertiary); justify-content: center;
}
.player-card.add-player .avatar { font-size: 32px; opacity: 0.6; }

/* ─── DASHBOARD ──────────────────────────────────────────────── */
.dash-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.dash-header .avatar { font-size: 40px; }
.dash-header .meta { flex: 1; }
.dash-header .pname { font-size: 20px; font-weight: 800; }
.dash-header .ptitle { font-size: 12px; color: var(--discipline); font-weight: 700; }
.dash-header .switch-btn { font-size: 12px; }

.streak-row { display: flex; align-items: center; gap: 10px; }
.streak-flame { font-size: 22px; }
.streak-num { font-size: 22px; font-weight: 800; }
.streak-label { font-size: 11px; color: var(--text-tertiary); }
.shield-row { margin-left: auto; font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; }

/* category bars */
.cat-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.cat-icon { font-size: 20px; width: 28px; text-align: center; }
.cat-info { flex: 1; }
.cat-name-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.cat-name { font-weight: 700; }
.cat-level { color: var(--text-tertiary); }
.cat-bar-track { height: 6px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }

/* quest progress today */
.quest-progress { display: flex; align-items: center; gap: 10px; }
.quest-progress .ring {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  border: 3px solid var(--discipline);
  background: rgba(255,140,66,0.08);
}
.latest-badge { display: flex; align-items: center; gap: 10px; }
.latest-badge .glyph { font-size: 28px; }
.latest-badge .label { font-weight: 700; font-size: 13px; }
.latest-badge .desc { font-size: 11px; color: var(--text-tertiary); }

.nav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.nav-grid .btn { padding: 14px; font-size: 13px; flex-direction: column; }
.nav-grid .btn .icon { font-size: 20px; }

/* ─── QUEST BOARD ────────────────────────────────────────────── */
.quest-card {
  display: flex; align-items: flex-start; gap: 12px;
  transition: transform 0.1s;
}
.quest-card.done { opacity: 0.5; }
.quest-card .q-icon {
  font-size: 26px; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); flex-shrink: 0;
}
.quest-card .q-body { flex: 1; }
.quest-card .q-title { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.quest-card .q-desc { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.4; }
.quest-card .q-footer { display: flex; align-items: center; justify-content: space-between; }
.quest-card .q-xp { font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.quest-card .q-complete-btn { font-size: 13px; padding: 8px 16px; }
.quest-card.boss { border-color: rgba(255,59,48,0.5); box-shadow: 0 0 28px rgba(255,59,48,0.22), inset 0 0 24px rgba(255,59,48,0.08); }
.quest-card.boss .q-title::before { content: "👑 "; }

/* ─── REWARD OVERLAY ─────────────────────────────────────────── */
.reward-overlay {
  position: fixed; inset: 0; z-index: 900;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(6px);
  padding: 20px;
}
.reward-overlay.show { display: flex; }
.reward-card {
  background: #0c0a0b; border: 1px solid rgba(255,140,66,0.4);
  border-radius: 20px; padding: 28px; text-align: center; max-width: 320px; width: 100%;
  box-shadow: 0 0 50px rgba(255,140,66,0.25);
  animation: reward-pop 0.35s cubic-bezier(.2,1.4,.4,1);
}
@keyframes reward-pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.reward-card h2 { font-size: 22px; margin: 0 0 8px; }
.reward-xp {
  font-size: 32px; font-weight: 900; margin: 12px 0;
  background: linear-gradient(135deg, var(--discipline), var(--power));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.reward-line { font-size: 13px; color: var(--text-secondary); margin: 4px 0; }
.reward-line.level-up { color: var(--brain); font-weight: 800; }
.reward-line.badge-unlock { color: var(--discipline); font-weight: 800; }
.reward-line.streak-event { color: var(--power); font-weight: 800; }

/* ─── BADGES ─────────────────────────────────────────────────── */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-tile {
  text-align: center; padding: 14px 6px; border-radius: 14px;
  background: var(--card-bg); border: 1px solid var(--card-border);
}
.badge-tile.locked { opacity: 0.35; }
.badge-tile .glyph { font-size: 28px; margin-bottom: 6px; }
.badge-tile .label { font-size: 10px; font-weight: 700; line-height: 1.3; }
.cat-section-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-tertiary); margin: 18px 0 8px;
}

/* ─── SETTINGS ───────────────────────────────────────────────── */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; font-weight: 600; }
.setting-sub { font-size: 11px; color: var(--text-tertiary); }
.pill-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 12px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--card-border); background: rgba(255,255,255,0.03);
  color: var(--text-secondary); cursor: pointer;
}
.pill.active { background: rgba(255,140,66,0.18); border-color: var(--discipline); color: var(--discipline); font-weight: 700; }

/* ─── TASK EDITOR ────────────────────────────────────────────── */
.task-row { display: flex; align-items: center; gap: 10px; }
.task-row .t-icon { font-size: 18px; width: 26px; text-align: center; }
.task-row .t-info { flex: 1; }
.task-row .t-title { font-weight: 700; font-size: 13px; }
.task-row .t-meta { font-size: 11px; color: var(--text-tertiary); }
.task-row .t-actions { display: flex; gap: 6px; }
.task-row .t-actions button { font-size: 16px; background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 4px; }

input, select, textarea {
  width: 100%; background: rgba(255,255,255,0.04); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 10px 12px; color: var(--text-primary); font-size: 14px;
  font-family: inherit; margin-bottom: 10px;
}
label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-tertiary); display: block; margin-bottom: 4px; }

/* ─── INTRO ──────────────────────────────────────────────────── */
#introScreen {
  position: fixed; inset: 0; z-index: 1000;
  background: #000; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; overflow: hidden; padding: 20px;
}
#introScreen.hidden { display: none; }
.intro-flash {
  position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, rgba(255,140,66,0.5), transparent 60%);
  opacity: 0; pointer-events: none;
}
.intro-flash.flash { animation: lightning-flash 0.6s ease-out; }
@keyframes lightning-flash {
  0% { opacity: 0; }
  10% { opacity: 1; }
  20% { opacity: 0.2; }
  30% { opacity: 0.9; }
  45% { opacity: 0; }
  100% { opacity: 0; }
}
.intro-title {
  font-size: 48px; font-weight: 900; letter-spacing: 0.06em;
  background: linear-gradient(135deg, #FFD700, var(--power));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(255,59,48,0.5);
  opacity: 0; transform: scale(0.6);
  animation: intro-title-in 0.8s ease-out 0.2s forwards;
}
@keyframes intro-title-in {
  to { opacity: 1; transform: scale(1); }
}
.intro-tagline {
  margin-top: 14px; font-size: 14px; letter-spacing: 0.08em; color: #FFB199;
  opacity: 0; animation: fade-in 0.6s ease-out 1.1s forwards;
}
.intro-choose {
  margin-top: 36px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.2em; color: #888;
  opacity: 0; animation: fade-in 0.6s ease-out 1.7s forwards;
}
.intro-players {
  display: flex; gap: 14px; margin-top: 16px;
  opacity: 0; animation: fade-in 0.6s ease-out 2.0s forwards;
}
.intro-players .ip-card {
  width: 64px; height: 64px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,140,66,0.3);
}
.intro-loading {
  margin-top: 28px; font-size: 12px; color: #666; letter-spacing: 0.1em;
  opacity: 0; animation: fade-in 0.6s ease-out 2.6s forwards;
}
@keyframes fade-in { to { opacity: 1; } }
.intro-skip {
  position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); right: 20px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; border-radius: 999px; padding: 8px 16px; font-size: 12px;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.intro-skip.visible { opacity: 1; pointer-events: auto; }

/* ─── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1c; border: 1px solid var(--card-border); border-radius: 12px;
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 950;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
