/* ---------- Fonts (bundled for offline use) ---------- */
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(../fonts/cairo-arabic-wght-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(../fonts/cairo-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Orbitron';
  font-display: swap;
  font-weight: 700;
  src: url(../fonts/orbitron-latin-700-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Orbitron';
  font-display: swap;
  font-weight: 900;
  src: url(../fonts/orbitron-latin-900-normal.woff2) format('woff2');
}

/* ---------- Tokens ---------- */
:root {
  /* Aura colors as "r g b" so they work inside rgb(... / alpha). Set by app.js. */
  --acc: 47 123 255;
  --acc2: 89 168 255;

  --bg: #060a16;
  --bg-2: #0a1020;
  --card: #0b1326;
  --card-2: #0f1a33;
  --line: #1a2747;
  --line-2: #243457;
  --text: #e8eeff;
  --muted: #8794b6;
  --dim: #5a6687;
  --green: #2fd67b;
  --red: #ff4d6d;
  --gold: #ffc83d;
  --flame: #ff7a2f;

  --radius: 16px;
  --radius-sm: 11px;
  --nav-h: 68px;
  --font: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --display: 'Orbitron', var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(120% 60% at 50% -10%, rgb(var(--acc) / .16), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgb(var(--acc) / .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
[hidden] { display: none !important; }

.ic { width: 1.25em; height: 1.25em; flex: none; display: block; }

:focus-visible { outline: 2px solid rgb(var(--acc2)); outline-offset: 2px; border-radius: 8px; }

/* ---------- Shell ---------- */
.app-header,
#app,
.app-nav { max-width: 520px; margin-inline: auto; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { text-align: center; line-height: 1.15; }
.logo {
  font-family: var(--display);
  font-weight: 900;
  font-size: 24px;
  letter-spacing: .5px;
  background: linear-gradient(180deg, #fff 10%, rgb(var(--acc2)) 60%, rgb(var(--acc)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgb(var(--acc) / .55));
  direction: ltr;
  display: inline-block;
}
.logo.big { font-size: 44px; }
.brand small { display: block; font-size: 11.5px; color: var(--muted); }
.page-title { text-align: center; font-size: 19px; font-weight: 800; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  position: relative;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn .ic { width: 22px; height: 22px; }
.icon-btn:active { background: rgb(255 255 255 / .06); }
.bell .dot {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgb(var(--acc2));
  box-shadow: 0 0 8px rgb(var(--acc2));
}
[dir='rtl'] .back .ic { transform: scaleX(-1); }

#app {
  padding: 4px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.app-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 6px env(safe-area-inset-bottom);
  background: rgb(8 13 28 / .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.app-nav a {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--dim);
  transition: color .2s;
}
.app-nav a .ic { width: 23px; height: 23px; }
.app-nav a.on { color: rgb(var(--acc2)); }
.app-nav a.on .ic { filter: drop-shadow(0 0 8px rgb(var(--acc) / .9)); }
.app-nav a.on::before {
  content: '';
  position: absolute;
  top: -6px;
  width: 30px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: rgb(var(--acc2));
  box-shadow: 0 0 12px rgb(var(--acc2));
}
.app-nav .badge {
  position: absolute;
  top: 4px;
  inset-inline-start: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  color: #fff;
  background: var(--red);
}

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 0 0 1px rgb(var(--acc) / .04), 0 10px 30px -18px rgb(var(--acc) / .5), inset 0 1px 0 rgb(255 255 255 / .03);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head h2 { font-size: 16px; font-weight: 800; }
.head-ic { color: var(--muted); }
.card-link {
  display: block;
  margin-top: 10px;
  padding: 9px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / .025);
  border: 1px solid var(--line);
}
.empty { color: var(--muted); text-align: center; padding: 14px 6px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.hint.center { text-align: center; margin-top: 12px; }
.accent { color: rgb(var(--acc2)) !important; }
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 800;
  margin: 4px 2px -4px;
}
.section-title small { font-size: 11.5px; font-weight: 600; color: var(--dim); }

.chip {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  background: rgb(255 255 255 / .06);
  border: 1px solid var(--line-2);
}
.chip.glow {
  color: #fff;
  background: rgb(var(--acc) / .25);
  border-color: rgb(var(--acc) / .7);
  box-shadow: 0 0 12px rgb(var(--acc) / .45);
  animation: pulse 1.8s ease-in-out infinite;
}

/* ---------- Bars ---------- */
.bar {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgb(255 255 255 / .07);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgb(var(--acc)), rgb(var(--acc2)));
  box-shadow: 0 0 10px rgb(var(--acc) / .8);
  transition: width .5s cubic-bezier(.2, .9, .3, 1.2);
}
[dir='rtl'] .bar i { background: linear-gradient(270deg, rgb(var(--acc)), rgb(var(--acc2))); }
.bar.green i { background: var(--green); box-shadow: 0 0 10px rgb(47 214 123 / .7); }
.bar.danger i { background: var(--red); box-shadow: 0 0 10px rgb(255 77 109 / .7); }
.bar.thick { height: 10px; }

/* ---------- Home hero ---------- */
.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}
.avatar {
  border-radius: 50%;
  overflow: hidden;
  background: #040815;
  display: grid;
}
.avatar img, .avatar .avatar-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 92px; height: 92px; }
.avatar.xl { width: 168px; height: 168px; }
.avatar.ring {
  border: 2px solid rgb(var(--acc2) / .9);
  box-shadow: 0 0 0 4px rgb(var(--acc) / .15), 0 0 26px rgb(var(--acc) / .75), 0 0 60px rgb(var(--acc) / .35);
  animation: aura 3.2s ease-in-out infinite;
}
.hero-mid { min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.player-name {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--muted);
  background: rgb(255 255 255 / .04);
  border: 1px solid var(--line-2);
}
[dir='rtl'] .level-pill { padding: 4px 12px 4px 6px; }
.hex { position: relative; width: 26px; height: 28px; display: inline-grid; place-items: center; }
.hex svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: rgb(var(--acc) / .15); stroke: rgb(var(--acc2)); stroke-width: 1.6; filter: drop-shadow(0 0 4px rgb(var(--acc))); }
.hex b { position: relative; font-family: var(--display); font-size: 12px; color: #fff; }
.hero-rank { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.rank-badge { width: 74px; height: 82px; filter: drop-shadow(0 0 14px rgb(var(--acc) / .6)); }
.rank-badge.big { width: 104px; height: 114px; }

.xp-row { display: flex; align-items: center; gap: 10px; margin-top: -4px; }
.xp-tag { font-family: var(--display); font-size: 11px; font-weight: 700; color: rgb(var(--acc2)); }
.xp-num { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; }
.bar.xp { height: 8px; }

/* ---------- Stats ---------- */
.stats { display: flex; flex-direction: column; gap: 11px; }
.stat {
  display: grid;
  grid-template-columns: 26px 92px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}
.stat:has(.plus) { grid-template-columns: 26px 92px 1fr auto 30px; }
.stat-ic { color: #cbd6f5; display: grid; place-items: center; }
.stat.hp .stat-ic { color: var(--red); }
.stat-name { font-size: 14.5px; font-weight: 600; }
.stat-val { min-width: 26px; text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; }
.stat.hp .stat-val { min-width: 62px; }
.plus {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgb(var(--acc) / .7);
  background: rgb(var(--acc) / .2);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 10px rgb(var(--acc) / .5);
}
.plus .ic { width: 16px; height: 16px; }
.plus:active { transform: scale(.9); }

/* ---------- Quests ---------- */
.tasks { display: flex; flex-direction: column; gap: 8px; }
.task {
  display: grid;
  grid-template-columns: 26px 1fr auto 28px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / .025);
  border: 1px solid var(--line);
  transition: border-color .2s, background .2s;
}
.task.done { border-color: rgb(var(--acc) / .35); background: rgb(var(--acc) / .07); }
.task.done .task-title { color: var(--muted); }
.task-ic { color: #cbd6f5; display: grid; place-items: center; }
.task-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  text-align: start;
  cursor: pointer;
}
.task-title { font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.task-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.task-body .bar { flex: none; height: 6px; margin-top: 2px; }
.task-xp { font-size: 13px; font-weight: 700; color: rgb(var(--acc2)); direction: ltr; white-space: nowrap; }
.check {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  border: 2px solid #4a5677;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: all .18s;
}
.check .ic { width: 17px; height: 17px; stroke-width: 3.2; }
.task.done .check {
  border-color: var(--green);
  background: var(--green);
  color: #04120a;
  box-shadow: 0 0 12px rgb(47 214 123 / .6);
}
.task.pop .check { animation: pop .35s ease-out; }
.task.pop { animation: flash .6s ease-out; }
.tasks.boxed {
  padding: 10px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}

.float-xp {
  position: absolute;
  z-index: 50;
  transform: translate(-50%, 0);
  font-family: var(--display);
  font-weight: 900;
  font-size: 15px;
  color: rgb(var(--acc2));
  text-shadow: 0 0 10px rgb(var(--acc)), 0 0 2px #fff;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
}

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
}
.tile b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); font-size: 12px; }
.tile-ic .ic { width: 30px; height: 30px; }
.tile-ic.flame { color: var(--flame); filter: drop-shadow(0 0 8px rgb(255 122 47 / .8)); }
.tile-ic.flame .ic { fill: rgb(255 122 47 / .45); }
.tile-ic.star { color: var(--gold); filter: drop-shadow(0 0 8px rgb(255 200 61 / .7)); }
.tile-ic.star .ic { fill: var(--gold); }

/* ---------- Tabs & segmented controls ---------- */
.tabs, .seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--card);
  border: 1px solid var(--line);
}
.tabs a, .seg > button, .seg label span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs a.on, .seg > button.on, .seg input:checked + span {
  color: #fff;
  background: linear-gradient(180deg, rgb(var(--acc) / .45), rgb(var(--acc) / .22));
  box-shadow: inset 0 0 0 1px rgb(var(--acc) / .6), 0 0 14px rgb(var(--acc) / .3);
}
.seg label { flex: 1; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid rgb(var(--acc2)); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap label { flex: 0 0 auto; }
.seg.wrap label span { padding-inline: 12px; }
.seg.big > button { min-height: 46px; font-size: 15px; }
.seg .ic { width: 16px; height: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: rgb(255 255 255 / .05);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: transform .1s, filter .2s;
  text-align: center;
}
.btn:active { transform: scale(.97); }
.btn .ic { width: 19px; height: 19px; }
.btn.primary {
  border-color: rgb(var(--acc2) / .6);
  background: linear-gradient(180deg, rgb(var(--acc2)), rgb(var(--acc)));
  color: #fff;
  box-shadow: 0 6px 22px -6px rgb(var(--acc) / .9), inset 0 1px 0 rgb(255 255 255 / .25);
}
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgb(255 77 109 / .4); }
.btn.danger:not(.ghost) { background: var(--red); color: #fff; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; border-radius: 10px; }
.btn.round { width: 50px; padding: 0; border-radius: 50%; min-height: 50px; }
.btn.price {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 14px;
  color: #ffe6a6;
  border-color: rgb(255 200 61 / .45);
  background: rgb(255 200 61 / .1);
  direction: ltr;
}
.btn.price .ic { color: var(--gold); }
.btn.price.poor { opacity: .5; }
.file-btn { position: relative; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.row-btns { display: flex; gap: 10px; margin-top: 6px; }
.row-btns .btn { flex: 1; }

/* ---------- Profile ---------- */
.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 0 4px;
  background: radial-gradient(50% 60% at 50% 40%, rgb(var(--acc) / .28), transparent 70%);
}
.avatar-btn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.avatar-edit {
  position: absolute;
  bottom: 8px;
  inset-inline-end: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card-2);
  border: 1px solid rgb(var(--acc) / .7);
  color: rgb(var(--acc2));
}
.avatar-edit .ic { width: 18px; height: 18px; }
.name-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  font-size: 23px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 6px;
}
.name-btn .ic { width: 16px; height: 16px; color: var(--muted); }
.level-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: -6px; }
.level-line span:last-child { direction: ltr; }
.rank-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rank-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 160px; text-align: center; }
.rank-card small { color: var(--muted); font-size: 13px; }
.rank-card.dim .next-letter {
  font-family: var(--display);
  font-weight: 900;
  font-size: 46px;
  line-height: 1.1;
  color: #c9d3ec;
  opacity: .8;
}
.rank-card.dim .next-letter .ic { width: 48px; height: 48px; color: var(--gold); }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 12px 8px; }
.mini small { color: var(--muted); font-size: 12.5px; }
.mini b { font-size: 16px; }

.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 120px; }
.wc-col { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.wc-n { font-size: 11px; color: var(--muted); min-height: 16px; }
.wc-bar { flex: 1; width: 100%; max-width: 26px; display: flex; align-items: flex-end; border-radius: 7px; background: rgb(255 255 255 / .04); overflow: hidden; }
.wc-bar i { display: block; width: 100%; border-radius: 7px; background: linear-gradient(0deg, rgb(var(--acc)), rgb(var(--acc2))); box-shadow: 0 0 10px rgb(var(--acc) / .6); min-height: 0; }
.wc-d { font-size: 11.5px; color: var(--dim); }
.wc-col.today .wc-d { color: rgb(var(--acc2)); font-weight: 800; }

/* ---------- Achievements & store ---------- */
.ach-list { display: flex; flex-direction: column; gap: 10px; }
.ach, .shop-item { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 12px; padding: 12px; }
.shop-item.reward { grid-template-columns: 54px 1fr auto auto; }
.ach-ic {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ach);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--ach) 35%, #0b1326), #070c19 75%);
  border: 2px solid color-mix(in srgb, var(--ach) 55%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--ach) 40%, transparent);
}
.ach-ic .ic { width: 26px; height: 26px; }
.ach:not(.complete) .ach-ic { filter: saturate(.55) brightness(.85); }
.ach-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ach-body b { font-size: 15px; }
.ach-body small { color: var(--muted); font-size: 12.5px; }
.ach-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ach-bar span { font-size: 11.5px; color: var(--muted); direction: ltr; white-space: nowrap; }
.ach-reward { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 52px; }
.ach-reward b { font-size: 16px; }
.ach-reward b .ic { color: var(--green); }
.ach.claimed { opacity: .7; }
.ach.complete:not(.claimed) { border-color: rgb(var(--acc) / .6); box-shadow: 0 0 22px -6px rgb(var(--acc) / .8); }
.gold { color: var(--gold); filter: drop-shadow(0 0 6px rgb(255 200 61 / .7)); }
.gold .ic { width: 24px; height: 24px; fill: rgb(255 200 61 / .2); }
.gold.big .ic { width: 40px; height: 40px; }
.balance b.neg { color: var(--red); }

.balance { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px; }
.balance small { display: block; color: var(--muted); font-size: 13px; }
.balance b { font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }

.aura-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.aura {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card-2), var(--card));
  cursor: pointer;
}
.aura b { font-size: 13.5px; }
.aura small { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); direction: ltr; }
.aura small .ic { width: 14px; height: 14px; }
.aura.locked { cursor: default; }
.aura.locked .aura-orb { filter: grayscale(.7) brightness(.55); box-shadow: none; }
.aura-orb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff, rgb(var(--a2)) 30%, rgb(var(--a)) 65%, #050913);
  box-shadow: 0 0 20px rgb(var(--a) / .9);
}
.aura.on { border-color: rgb(var(--a)); box-shadow: 0 0 18px -4px rgb(var(--a)); }
.aura.on small { color: rgb(var(--a2)); font-weight: 700; }

/* ---------- Sheets ---------- */
dialog.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--line-2);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: #0b1224;
  color: var(--text);
  box-shadow: 0 -10px 40px rgb(var(--acc) / .25);
  animation: sheetUp .28s cubic-bezier(.2, .9, .3, 1);
}
dialog.sheet::backdrop { background: rgb(2 4 10 / .7); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet-inner { padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px); overflow-y: auto; max-height: 92dvh; }
.sheet-inner::before { content: ''; display: block; width: 40px; height: 4px; margin: 2px auto 8px; border-radius: 4px; background: var(--line-2); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { font-size: 18px; font-weight: 800; }
.confirm-text { font-size: 16px; text-align: center; padding: 14px 4px 10px; }

dialog.sheet.full {
  margin: 0;
  max-width: none;
  width: 100vw;
  max-height: none;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  background: radial-gradient(60% 45% at 50% 35%, rgb(var(--acc) / .35), transparent 70%), #040713;
  animation: fadeIn .3s ease-out;
}
dialog.sheet.full .sheet-inner { max-height: none; height: 100%; display: grid; place-items: center; }
dialog.sheet.full .sheet-inner::before { display: none; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 700; color: var(--muted); padding: 0; margin-bottom: 6px; }
.field input:not([type=radio]) {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  font-size: 16px;
  outline: none;
}
.field input:focus { border-color: rgb(var(--acc2)); box-shadow: 0 0 0 3px rgb(var(--acc) / .25); }
.field input.invalid { border-color: var(--red); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .hint { margin-top: -8px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-grid label { display: block; }
.icon-grid input { position: absolute; opacity: 0; pointer-events: none; }
.icon-grid span {
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  cursor: pointer;
}
.icon-grid input:checked + span { color: #fff; border-color: rgb(var(--acc2)); background: rgb(var(--acc) / .25); box-shadow: 0 0 12px rgb(var(--acc) / .4); }
.icon-grid input:focus-visible + span { outline: 2px solid rgb(var(--acc2)); }

.progress-sheet { display: flex; flex-direction: column; gap: 16px; }
.big-progress { text-align: center; font-size: 15px; color: var(--muted); direction: ltr; }
.big-progress b { font-size: 34px; color: var(--text); font-variant-numeric: tabular-nums; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  outline: none;
}

.log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.log li { padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); border-inline-start: 3px solid rgb(var(--acc2)); }
.log p { font-size: 14px; margin: 4px 0 2px; }
.log time { font-size: 11px; color: var(--dim); }
.sys-tag { font-family: var(--display); font-size: 10px; font-weight: 700; letter-spacing: 2px; color: rgb(var(--acc2)); }

/* ---------- Level up ---------- */
.levelup { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 380px; text-align: center; }
.emblem { width: 230px; height: 230px; animation: emblemIn .8s cubic-bezier(.2, 1.4, .4, 1) both, float 3s ease-in-out .8s infinite; filter: drop-shadow(0 0 30px rgb(var(--acc) / .9)); }
.lu-title {
  font-family: var(--display);
  font-weight: 900;
  font-size: 40px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 18px rgb(var(--acc)), 0 0 40px rgb(var(--acc) / .6);
  animation: rise .6s .3s both;
}
.levelup p { font-size: 17px; color: #d6e2ff; animation: rise .6s .45s both; }
.lu-rank { color: var(--gold) !important; font-weight: 800; }
.lu-gain { font-weight: 700; margin-top: 10px; }
.lu-gold { display: inline-flex; align-items: center; gap: 6px; font-size: 20px !important; font-weight: 800; color: rgb(var(--acc2)) !important; direction: ltr; }
.lu-gold .ic { color: var(--gold); }
.levelup .btn { margin-top: 24px; animation: rise .6s .6s both; }
.sparks { position: absolute; inset: -40px 0 auto; height: 300px; pointer-events: none; }
.sparks i {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgb(var(--acc2));
  box-shadow: 0 0 8px 2px rgb(var(--acc2));
  animation: spark 2.4s linear infinite;
}
.sparks i:nth-child(1) { left: 10%; top: 60%; animation-delay: 0s; }
.sparks i:nth-child(2) { left: 22%; top: 30%; animation-delay: .3s; }
.sparks i:nth-child(3) { left: 35%; top: 75%; animation-delay: .9s; }
.sparks i:nth-child(4) { left: 48%; top: 10%; animation-delay: 1.2s; }
.sparks i:nth-child(5) { left: 60%; top: 70%; animation-delay: .5s; }
.sparks i:nth-child(6) { left: 72%; top: 25%; animation-delay: 1.6s; }
.sparks i:nth-child(7) { left: 85%; top: 55%; animation-delay: .2s; }
.sparks i:nth-child(8) { left: 92%; top: 20%; animation-delay: 1.9s; }
.sparks i:nth-child(9) { left: 5%; top: 15%; animation-delay: 1.1s; }
.sparks i:nth-child(10) { left: 30%; top: 50%; animation-delay: 2s; }
.sparks i:nth-child(11) { left: 66%; top: 45%; animation-delay: .7s; }
.sparks i:nth-child(12) { left: 78%; top: 85%; animation-delay: 1.4s; }
.sparks i:nth-child(13) { left: 15%; top: 90%; animation-delay: 1.8s; }
.sparks i:nth-child(14) { left: 52%; top: 92%; animation-delay: .4s; }

/* ---------- Onboarding ---------- */
body.onboarding .app-header, body.onboarding .app-nav { display: none; }
body.onboarding #app { padding-top: calc(env(safe-area-inset-top) + 40px); }
.onboard { display: flex; flex-direction: column; align-items: center; gap: 28px; }
.sys-window {
  width: 100%;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid rgb(var(--acc2) / .7);
  background: linear-gradient(180deg, rgb(10 22 52 / .9), rgb(6 12 30 / .95));
  box-shadow: 0 0 30px rgb(var(--acc) / .45), inset 0 0 30px rgb(var(--acc) / .15);
  animation: rise .6s both;
}
.sys-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 16px 10px;
  margin: 0 auto 12px;
  width: fit-content;
  border-bottom: 1px solid rgb(var(--acc2) / .5);
  font-weight: 800;
  font-size: 17px;
  color: #dbe8ff;
  text-shadow: 0 0 10px rgb(var(--acc));
}
.sys-body { text-align: center; font-size: 16px; margin-bottom: 18px; color: #dbe8ff; }

/* ---------- Install gate ---------- */
body.gated .app-header, body.gated .app-nav { display: none; }
body.gated #app { padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 32px); }
.gate { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.gate-lang { align-self: stretch; }
.gate-icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 0 30px rgb(var(--acc) / .6); margin-top: 8px; }
.gate .logo.big { font-size: 36px; }
.gate .sys-window { display: flex; flex-direction: column; gap: 14px; }
.gate .sys-body { margin-bottom: 0; font-size: 15px; }
.gate-msg { text-align: center; font-size: 15px; color: #dbe8ff; }
.steps { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps li {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgb(255 255 255 / .04);
  border: 1px solid var(--line-2);
}
.step-n {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
  background: rgb(var(--acc) / .3);
  border: 1px solid rgb(var(--acc2) / .7);
}
.step-t { font-size: 14.5px; }
.step-t b { color: #fff; }
.step-ic { color: rgb(var(--acc2)); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  max-width: min(92vw, 440px);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background: #121c36;
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 30px rgb(0 0 0 / .5);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: rgb(var(--acc) / .7); box-shadow: 0 0 20px rgb(var(--acc) / .4); }
.toast.bad { border-color: rgb(255 77 109 / .7); }

/* ---------- Motion ---------- */
@keyframes aura {
  50% { box-shadow: 0 0 0 5px rgb(var(--acc) / .2), 0 0 34px rgb(var(--acc) / .9), 0 0 80px rgb(var(--acc) / .45); }
}
@keyframes pulse { 50% { box-shadow: 0 0 20px rgb(var(--acc) / .8); } }
@keyframes pop { 40% { transform: scale(1.3); } }
@keyframes flash { 0% { background: rgb(var(--acc) / .35); } }
@keyframes floatUp {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -46px); }
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: .4; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes emblemIn { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes spark {
  0% { opacity: 0; transform: translateY(20px) scale(.5); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-80px) scale(1.2); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Small phones ---------- */
@media (max-width: 370px) {
  .stat, .stat:has(.plus) { grid-template-columns: 22px 78px 1fr auto; }
  .stat:has(.plus) { grid-template-columns: 22px 78px 1fr auto 28px; }
  .avatar.lg { width: 76px; height: 76px; }
  .rank-badge { width: 60px; height: 66px; }
  .player-name { font-size: 20px; }
  .task { grid-template-columns: 22px 1fr auto 26px; gap: 8px; padding: 9px 10px; }
}
