/* =========================================================================
   IQI AG WARRIORS — "Warriors Sunrise" theme
   Brand tokens pulled from the IQI logo (orange→gold→green) + JIQI red jersey.
   Mobile-first, large tap targets, weak-connection friendly.
   ========================================================================= */

:root {
  /* Brand core */
  --orange:   #F5821F;
  --orange-d: #E06A12;
  --gold:     #F9A826;
  --green:    #8DC63F;
  --green-d:  #6FA82E;
  --red:      #E11B22;
  --red-d:    #B71419;
  --ink:      #2B2B2B;
  --ink-soft: #5A5650;
  --cream:    #FFF9F0;
  --surface:  #FFFFFF;
  --line:     #EFE3D2;

  /* Signature gradient (the logo, alive) */
  --grad-sun: linear-gradient(135deg, var(--orange) 0%, var(--gold) 48%, var(--green) 100%);
  --grad-fire: linear-gradient(135deg, var(--red) 0%, var(--orange) 100%);
  --grad-soft: linear-gradient(135deg, #FFF1DE 0%, #FFF9F0 60%, #F4FBE8 100%);

  /* Semantic */
  --p1: var(--red);        /* priority 1 / urgent      */
  --p2: var(--orange);     /* priority 2               */
  --ok: var(--green-d);    /* done / on time           */

  /* Elevation */
  --sh-sm: 0 1px 3px rgba(43,43,43,.08), 0 1px 2px rgba(43,43,43,.06);
  --sh-md: 0 6px 18px rgba(224,106,18,.12), 0 2px 6px rgba(43,43,43,.06);
  --sh-lg: 0 18px 40px rgba(224,106,18,.18);

  /* Geometry */
  --r-sm: 12px;
  --r:    18px;
  --r-lg: 26px;
  --tap:  52px;            /* min tap target */

  --z-nav: 40;
  --z-sheet: 50;
  --z-toast: 60;
  --z-modal: 70;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, .display {
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 0;
}

button, input, textarea, select { font-family: inherit; font-size: 16px; }
a { color: var(--orange-d); }

/* ---------- App frame ---------- */
#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--cream);
  box-shadow: 0 0 60px rgba(0,0,0,.06);
}

.view { padding: 16px 16px calc(96px + var(--safe-b)); animation: fadeUp .28s ease both; }
.view[hidden] { display: none; }

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

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: rgba(255,249,240,.86);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar img.logo { height: 30px; }
.topbar .spacer { flex: 1; }
.topbar .pts {
  display: flex; align-items: center; gap: 6px;
  background: var(--grad-sun); color: #fff;
  font-weight: 800; font-size: 14px;
  padding: 7px 12px; border-radius: 999px;
  box-shadow: var(--sh-sm);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--sh-sm);
}
.card + .card { margin-top: 12px; }

.hero {
  position: relative; overflow: hidden;
  background: var(--grad-sun);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--sh-md);
}
.hero h1 { font-size: clamp(22px, 6.5vw, 30px); }
.hero p { margin: 6px 0 0; opacity: .95; font-weight: 500; }
.hero .mascot {
  position: absolute; right: -8px; bottom: -10px;
  width: 116px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.18));
  pointer-events: none;
}
.hero .ring-row { display: flex; gap: 14px; margin-top: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: none; border-radius: 999px;
  font-weight: 700; font-size: 16px;
  cursor: pointer; user-select: none;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--grad-fire); color: #fff; box-shadow: var(--sh-md); }
.btn-sun { background: var(--grad-sun); color: #fff; box-shadow: var(--sh-md); }
.btn-green { background: var(--green-d); color: #fff; box-shadow: var(--sh-sm); }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.ico { display: inline-flex; align-items: center; justify-content: center; vertical-align: -0.16em; }
.ico svg { width: 1.15em; height: 1.15em; }
.btn .ico { width: 20px; height: 20px; flex: none; }
.btn .ico svg { width: 20px; height: 20px; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: var(--ink); }
.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap);
  padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, textarea.input:focus, select.input:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(245,130,31,.16);
}
.input::placeholder { color: #B6AC9C; }

/* ---------- Section headers ---------- */
.sec-head { display: flex; align-items: center; gap: 10px; margin: 22px 2px 12px; }
.sec-head h2 { font-size: 19px; }
.sec-head .sub { color: var(--ink-soft); font-size: 13px; margin: 2px 0 0; font-weight: 500; }
.sec-head .badge-ico { width: 38px; height: 38px; border-radius: 12px; background: var(--grad-sun);
  display: grid; place-items: center; color: #fff; flex: none; box-shadow: var(--sh-sm); }
.sec-head .badge-ico svg { width: 22px; height: 22px; }

/* ---------- Bottom nav ---------- */
.botnav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b));
  width: min(496px, calc(100% - 20px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(43,43,43,.94); color: #fff;
  border-radius: 22px; padding: 8px 6px;
  box-shadow: var(--sh-lg); z-index: var(--z-nav);
  backdrop-filter: blur(8px);
}
.botnav button {
  background: none; border: none; color: #C9C4BC;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 14px; cursor: pointer;
  font-size: 10.5px; font-weight: 700; transition: color .2s;
}
.botnav button svg { width: 24px; height: 24px; }
.botnav button.active { color: #fff; }
.botnav button.active svg { stroke: var(--gold); }
.botnav button.active::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold); margin-top: 1px;
}

/* ---------- Progress ring ---------- */
.ring { position: relative; width: 72px; height: 72px; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #fff; }
.ring.dark .val { color: var(--ink); }
.ring-label { font-size: 11px; opacity: .9; text-align: center; margin-top: 4px; font-weight: 600; }

/* ---------- Pills / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: #FFF1DE; color: var(--orange-d);
  font-size: 13px; font-weight: 700; cursor: pointer;
  border: 1.5px solid transparent; transition: .15s;
}
.chip.sel { background: var(--grad-sun); color: #fff; }
.chip.green { background: #EEF7DD; color: var(--green-d); }

/* ---------- Task rows ---------- */
.task {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 10px;
  transition: transform .15s, opacity .3s, background .3s;
}
.task.p1 { border-left-color: var(--red); }
.task.p2 { border-left-color: var(--orange); }
.task.tier2 { border-left-style: dashed; }
.task.done { opacity: .55; background: #F6F9EF; }
.task.done .t-title { text-decoration: line-through; }
.task .t-time { font-weight: 800; font-size: 13px; color: var(--orange-d); min-width: 52px; }
.task .t-body { flex: 1; min-width: 0; }
.task .t-title { font-weight: 600; }
.task .t-meta { font-size: 12px; color: var(--ink-soft); }
.task .t-check {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; transition: .2s;
}
.task .t-check.on { background: var(--green-d); border-color: var(--green-d); }
.task .t-check svg { width: 18px; height: 18px; color: #fff; opacity: 0; transition: .2s; }
.task .t-check.on svg { opacity: 1; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 14px; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(var(--orange), var(--green)); border-radius: 2px; }
.timeline .task { margin-left: 6px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; background: #F3EADB; padding: 5px; border-radius: 14px; margin-bottom: 14px; }
.tabs button { flex: 1; min-height: 42px; border: none; background: none; border-radius: 10px;
  font-weight: 700; color: var(--ink-soft); cursor: pointer; transition: .2s; }
.tabs button.active { background: #fff; color: var(--orange-d); box-shadow: var(--sh-sm); }

/* ---------- Leaderboard ---------- */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 8px; }
.lb-row.me { background: linear-gradient(135deg,#FFF4E2,#F4FBE8); border-color: var(--gold); }
.lb-rank { font-weight: 800; width: 30px; text-align: center; font-size: 18px; }
.lb-row.top1 .lb-rank { color: var(--gold); }
.lb-row.top2 .lb-rank { color: #9AA0A6; }
.lb-row.top3 .lb-rank { color: #CD7F32; }
.lb-av { width: 40px; height: 40px; border-radius: 50%; background: var(--grad-sun); color: #fff;
  display: grid; place-items: center; font-weight: 800; flex: none; }
.lb-name { flex: 1; font-weight: 700; }
.lb-pts { font-weight: 800; color: var(--orange-d); }

/* ---------- Catalog ---------- */
.prop { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; box-shadow: var(--sh-sm); }
.prop .ph { aspect-ratio: 16/10; background: var(--grad-soft) center/cover no-repeat; position: relative; }
.prop .ph .type { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff;
  font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.prop .pb { padding: 14px; }
.prop .price { font-family: 'Plus Jakarta Sans'; font-weight: 800; font-size: 20px; color: var(--ink); }
.prop .loc { color: var(--ink-soft); font-size: 13px; margin: 2px 0 8px; }
.prop .specs { display: flex; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }

/* ---------- Quote / leader mode ---------- */
.leader { background: var(--grad-fire); color: #fff; border-radius: var(--r-lg); padding: 18px;
  position: relative; overflow: hidden; box-shadow: var(--sh-md); }
.leader .q { font-family: 'Plus Jakarta Sans'; font-weight: 800; font-size: 18px; line-height: 1.3; }
.leader .who { margin-top: 8px; font-weight: 600; opacity: .92; font-size: 13px; }
.leader .mascot { position: absolute; right: -6px; bottom: -8px; width: 92px; opacity: .96; }

/* ---------- Sheet / modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(43,43,43,.5); z-index: var(--z-sheet);
  opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(100%);
  bottom: 0; width: min(520px, 100%);
  background: var(--cream); border-radius: 24px 24px 0 0;
  padding: 8px 18px calc(24px + var(--safe-b));
  z-index: var(--z-sheet); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  max-height: 88dvh; overflow-y: auto; box-shadow: var(--sh-lg);
}
.sheet.show { transform: translateX(-50%) translateY(0); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #DCD2C2; margin: 8px auto 14px; }
.sheet h3 { font-size: 20px; margin-bottom: 4px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-weight: 600;
  z-index: var(--z-toast); opacity: 0; pointer-events: none; transition: .3s; box-shadow: var(--sh-lg); max-width: 90%; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: var(--green-d); }
#toast.err { background: var(--red-d); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 24px calc(32px + var(--safe-b)); background: var(--grad-soft); }
.login .logo-wrap { text-align: center; margin-bottom: 8px; }
.login .logo-wrap img { width: 120px; }
.login h1 { text-align: center; font-size: 26px; background: var(--grad-fire); -webkit-background-clip: text;
  background-clip: text; color: transparent; }
.login .tag { text-align: center; color: var(--ink-soft); margin: 6px 0 26px; font-weight: 600; }
.login .jiqi { width: 150px; display: block; margin: 0 auto 10px; filter: drop-shadow(0 8px 14px rgba(0,0,0,.15)); }

/* ---------- Rank-up celebration ---------- */
.celebrate { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center;
  background: rgba(43,43,43,.55); opacity: 0; pointer-events: none; transition: opacity .3s; }
.celebrate.show { opacity: 1; pointer-events: auto; }
.celebrate .box { background: #fff; border-radius: var(--r-lg); padding: 26px 24px; text-align: center;
  width: min(340px, 86%); transform: scale(.8); transition: transform .35s cubic-bezier(.2,1.3,.4,1); box-shadow: var(--sh-lg); }
.celebrate.show .box { transform: scale(1); }
.celebrate .box img { width: 130px; margin: -70px auto 6px; display: block; animation: pop .5s ease both; }
.celebrate .box h2 { font-size: 24px; color: var(--orange-d); }
.celebrate .box p { color: var(--ink-soft); font-weight: 600; }
@keyframes pop { 0% { transform: scale(0) rotate(-12deg); } 70% { transform: scale(1.1) rotate(4deg); } 100% { transform: scale(1); } }

/* Confetti */
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: calc(var(--z-modal) + 1);
  pointer-events: none; opacity: .95; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0; } }

/* Task complete burst */
@keyframes burst { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
.t-check.burst { animation: burst .4s ease; }

/* streak flame pulse */
@keyframes flame { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.streak-flame { display: inline-block; animation: flame 1.4s ease-in-out infinite; }

/* skeleton */
.skel { background: linear-gradient(90deg,#F0E7D8,#F8F1E6,#F0E7D8); background-size: 200% 100%;
  animation: shine 1.2s infinite; border-radius: 8px; }
@keyframes shine { to { background-position: -200% 0; } }

.muted { color: var(--ink-soft); }
.center { text-align: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.hidden { display: none !important; }

.empty { text-align: center; color: var(--ink-soft); padding: 28px 16px; }
.empty img { width: 110px; opacity: .9; margin-bottom: 8px; }

/* Accessibility */
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
