:root {
  --navy: #07122B;
  --royal: #0B1E4A;
  --card: #102652;
  --gold: #E2B657;
  --gold-deep: #A6843A;
  --lime: #C6F135;
  --dim: #B7C3E0;
  --loss: #E15B4C;
  --white: #ffffff;
  --idle: rgba(255, 255, 255, 0.7);
  --gold-wash: rgba(226, 182, 87, 0.2);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy);
  color: var(--white);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

body { overflow: hidden; }

button, input { font: inherit; color: inherit; }

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible, input:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.stage {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--royal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.mast, .tabs { display: none; }

.stage:has([data-screen="arena"]:not([hidden])) .mast,
.stage:has([data-screen="sports"]:not([hidden])) .mast,
.stage:has([data-screen="ranks"]:not([hidden])) .mast,
.stage:has([data-screen="history"]:not([hidden])) .mast,
.stage:has([data-screen="arena"]:not([hidden])) .tabs,
.stage:has([data-screen="sports"]:not([hidden])) .tabs,
.stage:has([data-screen="ranks"]:not([hidden])) .tabs,
.stage:has([data-screen="history"]:not([hidden])) .tabs {
  display: flex;
}

.stage:has([data-screen="arena"]:not([hidden])) .tabs,
.stage:has([data-screen="sports"]:not([hidden])) .tabs,
.stage:has([data-screen="ranks"]:not([hidden])) .tabs,
.stage:has([data-screen="history"]:not([hidden])) .tabs {
  display: grid;
}

.mast {
  align-items: center;
  gap: 8px;
  background: var(--navy);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  min-height: calc(52px + env(safe-area-inset-top));
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  flex: 1;
  text-align: left;
  color: var(--gold);
}

.brand span {
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-shield { width: 28px; height: 28px; flex: 0 0 auto; display: block; }

.points-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-right: 2px;
  text-align: right;
}

.points-btn strong {
  color: var(--gold);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
}

.points-btn small {
  color: var(--dim);
  font-size: 10px;
  font-weight: 400;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at center, var(--gold) 0 18px, var(--gold-deep) 18px 19px, transparent 19.5px);
  color: var(--navy);
  font-weight: 900;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.tabs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: 48px;
  background: var(--navy);
  flex: 0 0 auto;
}

.tabs button {
  min-height: 48px;
  height: 48px;
  color: var(--idle);
  display: flex;
  flex-direction: column;
}

.tabs button span {
  flex: 1;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tabs button i {
  display: block;
  height: 3px;
  background: transparent;
}

.tabs button.on { color: var(--gold); }
.tabs button.on i { background: var(--gold); }

[data-screen][hidden] { display: none !important; }

[data-screen]:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.splash:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  text-align: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
}

.splash-inner { max-width: 320px; }

.splash h1 {
  margin: 18px 0 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.splash p {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: calc(48px + env(safe-area-inset-top));
  padding: calc(4px + env(safe-area-inset-top)) 12px 4px 4px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--royal);
}

.back {
  width: 48px;
  height: 48px;
  min-width: 48px;
  display: grid;
  place-items: center;
}

.back svg { width: 24px; height: 24px; display: block; }

.topbar h1 {
  margin: 0;
  flex: 1;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pad {
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
}

.profile-pad { padding-top: 16px; padding-left: 16px; padding-right: 16px; }

.hint, .fine, .dim { color: var(--dim); }
.hint { margin: 0 0 8px; font-size: 13px; }
.hint.tight { margin: 6px 0 0; }
.fine { margin: 0 0 10px; font-size: 12px; }
.gold { color: var(--gold); }
.lime { color: var(--lime); }
.loss { color: var(--loss); }
.white { color: var(--white); }

.section {
  margin: 16px 0 0;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.section.flat { margin-top: 0; }

.chamfer {
  position: relative;
  background: var(--card);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 14px);
  padding: 14px 12px 12px;
}

.chamfer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 14px;
  pointer-events: none;
  background:
    linear-gradient(var(--gold), var(--gold)) 14px 0 / calc(100% - 28px) 1px no-repeat,
    linear-gradient(135deg, transparent 46%, var(--gold) 47% 53%, transparent 54%) 0 0 / 14px 14px no-repeat,
    linear-gradient(45deg, transparent 46%, var(--gold) 47% 53%, transparent 54%) 100% 0 / 14px 14px no-repeat;
}

.royal-match {
  margin-top: 12px;
  padding: 14px;
  background:
    linear-gradient(115deg, transparent 30%, rgba(226, 182, 87, 0.16) 48%, transparent 66%),
    linear-gradient(180deg, #17356f 0%, var(--card) 55%);
}

body.motion .royal-match { overflow: hidden; }

body.motion .royal-match::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 32%, rgba(226, 182, 87, 0.28) 50%, transparent 68%);
  transform: translateX(-130%);
  animation: gold-sweep 1.1s linear infinite;
  pointer-events: none;
}

@keyframes gold-sweep { to { transform: translateX(130%); } }

@media (prefers-reduced-motion: reduce) {
  body.motion .royal-match::after { animation: none; opacity: 0; }
}

.royal-kicker {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.teams { font-weight: 900; color: var(--white); }
.teams.lg { display: block; margin-top: 6px; font-size: 16px; }
.meta { margin-top: 4px; color: var(--dim); font-size: 14px; }

.chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.chip {
  min-height: 44px;
  padding: 6px 4px;
  background: var(--navy);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.15;
}

.daily-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.daily {
  min-height: 148px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
  color: var(--white);
  padding: 14px 10px 10px;
}

.daily .sport {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
}

.daily .match {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.daily .grow { flex: 1; }

.daily .cat { font-size: 11px; color: var(--dim); }

.daily .when {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--lime);
}

.solid, .outline, .ghost {
  min-height: 48px;
  border-radius: 4px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 8px 12px;
}

.solid { background: var(--gold); color: var(--navy); }
.outline, .ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold); }

.wide { width: 100%; display: block; margin-top: 12px; }

.outline.on, .ghost.on, .pick.on, .qp.on, .qs.on, .stake.on {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
}

.rankhead-top { display: flex; align-items: center; gap: 10px; }
.rankhead-name { font-size: 20px; font-weight: 900; text-transform: uppercase; line-height: 1.1; }
.xp { font-size: 14px; font-weight: 700; color: var(--gold); }
.note { margin: 8px 0 0; color: var(--dim); font-size: 12px; }
.note.next { margin-top: 6px; font-size: 13px; }

.bar { height: 8px; background: var(--navy); margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--gold); }

.path { margin-top: 8px; padding: 14px 12px 12px; }
.track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.track i { display: block; height: 8px; background: var(--navy); }
.track i.done { background: var(--gold-deep); }
.track i.now { background: var(--gold); }
.track-names {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 6px;
}
.track-names span {
  text-align: center;
  font-size: 8px;
  font-weight: 900;
  color: var(--dim);
  line-height: 1.2;
}
.track-names span.done { color: var(--white); }
.track-names span.now { color: var(--gold); }

.sim-label { margin: 2px 0 0; color: var(--dim); font-size: 12px; }

.rival {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  text-align: left;
  padding: 0 2px;
}

.rival .pos, .board-row .pos { color: var(--gold); font-weight: 700; }
.rival .pos { width: 28px; font-size: 14px; flex: 0 0 auto; }
.rival .name { flex: 1; font-size: 14px; }
.rival .pts { font-weight: 700; font-size: 14px; }

.quick-entry { width: 100%; text-align: left; color: var(--white); margin-bottom: 8px; display: block; }
.quick-entry b {
  display: block;
  color: var(--gold);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
}
.quick-entry span { display: block; margin-top: 4px; font-size: 14px; }

.sport-row {
  width: 100%;
  height: 56px;
  min-height: 56px;
  margin-bottom: 8px;
  background: var(--card);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 10px;
  text-align: left;
  border: 1px solid transparent;
}

.sport-row.on { background: var(--gold-wash); border-color: var(--gold); }
.sport-row svg { width: 36px; height: 36px; flex: 0 0 auto; }
.sport-row .label {
  flex: 1;
  font-weight: 900;
  font-size: 14px;
  text-transform: uppercase;
  text-align: left;
}
.sport-row.on .label { color: var(--gold); }
.sport-row .count { color: var(--dim); font-size: 12px; }

.challenge, .history, .ach {
  width: 100%;
  display: block;
  text-align: left;
  color: var(--white);
  margin-bottom: 8px;
}

.challenge .teams, .history .teams { display: block; font-size: 15px; }
.challenge .cat, .history .meta { display: block; margin-top: 4px; color: var(--dim); font-size: 13px; }
.challenge .status { display: block; margin-top: 4px; font-size: 12px; font-weight: 700; }

.hist-row { display: flex; align-items: center; margin-top: 6px; gap: 8px; }
.hist-row .outcome { flex: 1; font-size: 13px; font-weight: 700; text-align: left; }
.hist-row .delta { font-size: 16px; font-weight: 700; }

.rank-card { margin-bottom: 8px; }
.rank-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
}
.rank-card .perk { margin-top: 4px; color: var(--dim); font-size: 13px; }
.divs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }
.div { text-align: center; padding: 8px 4px; font-size: 12px; font-weight: 700; }
.div b, .div span { display: block; }

.empty {
  min-height: 68dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 12px;
}

.empty h2 {
  margin: 12px 0 0;
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

.empty p { margin: 6px 0 0; color: var(--dim); font-size: 14px; }
.empty .solid { margin-top: 16px; }

.balance { margin: 6px 0 0; color: var(--gold); font-size: 20px; font-weight: 700; }
.fixture { margin-top: 6px; font-size: 20px; font-weight: 900; }
.award { margin: 10px 0 0; font-size: 14px; }
.scale { margin: 12px 0 0; font-size: 13px; color: var(--dim); }
.timer { margin: 8px 0 0; color: var(--gold); font-size: 32px; font-weight: 700; line-height: 1.1; }
.qprog { margin: 0; font-size: 14px; }
.qpage { margin-top: 8px; }
.qpage .section { font-size: 12px; }
.qpage .outline { width: 100%; display: block; margin-top: 8px; }

.stake-block { margin-top: 16px; }
.stake-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.choice-col { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.choice-col .pick { width: 100%; }

.settled { margin-top: 12px; font-size: 14px; white-space: pre-line; }
.retry { margin-top: 8px; color: var(--dim); font-size: 13px; }

.hero { text-align: center; }
.hero .shield { margin: 0 auto; display: block; }
.division { margin-top: 8px; font-size: 22px; font-weight: 900; text-transform: uppercase; }
.points-xl { color: var(--gold); font-size: 36px; font-weight: 700; line-height: 1.1; }
.xp-line { color: var(--dim); font-size: 14px; }
.center { text-align: center; }
.settled-line { margin-top: 10px; font-size: 14px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 8px;
  text-align: center;
}

.stats span { display: block; color: var(--dim); font-size: 11px; }
.stats b { display: block; font-size: 18px; font-weight: 700; }

.name-field {
  width: 100%;
  height: 48px;
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--white);
  padding: 0 12px;
  font-size: 14px;
}

.name-field::placeholder { color: var(--dim); }
.save-status { min-height: 18px; margin: 6px 0 0; color: var(--lime); font-size: 13px; text-align: left; }

.board-row {
  min-height: 52px;
  margin-bottom: 6px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.board-row .pos { width: 32px; font-size: 16px; flex: 0 0 auto; }
.board-row .who { flex: 1; display: flex; flex-direction: column; text-align: left; }
.board-row .who b { font-weight: 400; font-size: 14px; }
.board-row .who small { color: var(--gold); font-size: 11px; }
.board-row .pts { font-size: 16px; font-weight: 700; }
.board-row.you { background: var(--gold-wash); border: 1px solid var(--gold); border-radius: 4px; }

.ach-row { display: flex; align-items: center; gap: 8px; }
.ach-row b { flex: 1; font-size: 14px; font-weight: 900; text-transform: uppercase; text-align: left; }
.ach-row span { font-size: 12px; font-weight: 700; }
.ach .detail { margin-top: 4px; color: var(--dim); font-size: 14px; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 10px;
  font-size: 14px;
}

.switch:first-child { margin-top: 0; }

.switch input {
  appearance: none;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: #6d7380;
  position: relative;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  top: 4px;
  left: 4px;
}

.switch input:checked { background: var(--gold); }
.switch input:checked::after { left: 24px; }

.block { margin-top: 16px; }
.block p { margin: 6px 0 0; font-size: 14px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] { display: none; }

.sheet {
  width: min(400px, 100%);
  max-height: min(80dvh, 640px);
  overflow: auto;
  background: var(--navy);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet h2 {
  margin: 4px 0 0;
  text-align: center;
  color: var(--gold);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sheet p { margin: 8px 0 0; font-size: 14px; line-height: 1.4; }
.sheet .solid, .sheet .ghost, .sheet .outline { width: 100%; margin-top: 8px; }

.shield { display: block; }

@media (max-width: 360px) {
  .tabs button span { font-size: 11px; letter-spacing: 0.02em; }
  .daily { padding: 12px 8px 8px; }
  .daily .match { font-size: 12px; }
  .chip { font-size: 9px; }
  .track-names span { font-size: 7px; }
}
