:root {
  --navy: #000F1A;
  --blue: #007ACC;
  --white: #FFFFFF;
  --lime: #8BBD35;
  --amber: #FFB800;
  --line: rgba(255, 255, 255, 0.16);
  --card: rgba(0, 15, 26, 0.84);
  --font: "Outfit", sans-serif;
  --display: "Rajdhani", sans-serif;
}

* { box-sizing: border-box; }

html {
  overflow-x: clip;
  background: var(--navy);
  color: var(--white);
  color-scheme: dark;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  background: var(--navy);
  color: var(--white);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(0, 15, 26, 0.84), rgba(0, 15, 26, 0.94)),
    url("bg-arena.jpg") center / cover no-repeat;
}

[hidden] { display: none !important; }

h1, h2, h3, h4, p { margin: 0; }

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

img { max-width: 100%; object-fit: contain; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

::selection { background: var(--amber); color: var(--navy); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0;
  color: var(--lime);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(0, 15, 26, 0.42), rgba(0, 15, 26, 0.8)),
    url("bg-mosaic.jpg") center / cover no-repeat;
}

#splash h1 {
  font-family: var(--display);
  font-size: clamp(34px, 9vw, 68px);
  line-height: 0.9;
  max-width: 100%;
}

.splash-mosaic {
  display: grid;
  grid-template-columns: 72px 72px;
  gap: 10px;
}

.splash-mosaic img { width: 72px; height: 72px; }

.splash-bar {
  width: min(240px, 70%);
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.splash-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--lime) 60%, var(--amber));
  animation: load 1.5s linear forwards;
}

@keyframes load { to { width: 100%; } }

#onboarding {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(0, 15, 26, 0.72), rgba(0, 15, 26, 0.88)),
    url("bg-mosaic.jpg") center / cover no-repeat;
}

.ob-card {
  width: min(480px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 18px 16px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
}

#ob-art { width: min(148px, 36vw); height: min(148px, 36vw); }

#ob-title {
  font-family: var(--display);
  font-size: clamp(32px, 8vw, 48px);
  line-height: 0.9;
}

#ob-copy { line-height: 1.45; max-width: 38ch; }

.ob-dots { display: flex; gap: 6px; justify-content: center; }

.ob-dots i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
}

.ob-dots i.on { width: 22px; background: var(--amber); }

.ob-actions { display: flex; gap: 8px; width: 100%; }

.ob-actions .btn { flex: 1; }

#app {
  width: min(1200px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
  background: rgba(0, 15, 26, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue) 0 42%, var(--lime) 42% 70%, var(--amber) 70% 100%);
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }

.mark {
  width: 34px;
  height: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  flex: none;
}

.mark i { display: block; border-radius: 3px; }
.mark i:nth-child(1) { background: var(--blue); }
.mark i:nth-child(2) { background: var(--lime); }
.mark i:nth-child(3) { background: var(--amber); }
.mark i:nth-child(4) { background: var(--white); }

.brand h1 {
  font-family: var(--display);
  font-size: clamp(16px, 4vw, 24px);
  line-height: 1;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy { min-width: 0; }

main {
  width: 100%;
  min-width: 0;
  padding: 14px 14px calc(96px + env(safe-area-inset-bottom));
  overflow-x: clip;
}

.dock {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  width: min(1200px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(0, 15, 26, 0.96);
  border-top: 1px solid var(--line);
}

.dock button {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--white);
  border-radius: 12px;
  padding: 6px 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.72;
}

.dock button svg { width: 20px; height: 20px; }

.dock button[aria-current="page"] {
  opacity: 1;
  background: var(--navy);
  box-shadow: inset 0 0 0 1px var(--blue), inset 0 -3px 0 var(--amber);
}

.view { display: grid; gap: 12px; min-width: 0; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.page-head > img { width: 64px; height: 64px; flex: none; }

.page-head h2, #onboarding h2, .win h3, .panel h3, .streak-num, .points, .stat b {
  font-family: var(--display);
  font-weight: 700;
}

h2 { font-size: clamp(32px, 7vw, 46px); line-height: 0.9; }

.lede, .meta { overflow-wrap: anywhere; }

.lede { font-size: 14px; opacity: 0.84; }

.meta { color: var(--white); opacity: 0.74; font-size: 13px; }

.sprite-row { display: flex; gap: 6px; flex: none; }

.sprite-row img { width: 36px; height: 36px; }

.btn {
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.btn.solid { background: var(--blue); color: var(--white); border: 1px solid var(--blue); }
.btn.ghost { background: transparent; color: var(--white); border: 1px solid rgba(255, 255, 255, 0.28); }
.btn.amber { background: var(--amber); color: var(--navy); border: 1px solid var(--amber); }
.btn.lime { background: var(--lime); color: var(--navy); border: 1px solid var(--lime); }

.util-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  flex: none;
}

.util-btn svg { width: 18px; height: 18px; display: block; }

.util-btn[aria-pressed="true"] {
  background: var(--amber);
  color: var(--navy);
  border-color: var(--amber);
}

.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }

input, textarea, select {
  width: 100%;
  min-width: 0;
  background: var(--navy);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  appearance: none;
  -webkit-appearance: none;
}

textarea { resize: vertical; min-height: 84px; max-height: 160px; }

.toolbar {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr);
}

.toolbar > * { min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  color: var(--white);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
}

.chip[aria-pressed="true"], .chip.on {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--navy);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  text-align: center;
  padding: 8px 4px;
  border-radius: 14px;
  background: rgba(0, 15, 26, 0.72);
  border: 1px solid var(--line);
}

.stat span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.stat b { display: block; font-size: clamp(28px, 7vw, 40px); line-height: 0.9; }

.stat small {
  display: block;
  min-height: 1em;
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
}

[data-stat="combo"].hot { color: var(--lime); }
[data-stat="combo"].hotter { color: var(--amber); }

.game { position: relative; display: grid; gap: 12px; min-width: 0; }

.board {
  width: min(100%, 520px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.5vw, 12px);
}

.tile {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 12px;
  perspective: 700px;
  touch-action: manipulation;
  user-select: none;
}

.tile .inner {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}

.tile.up .inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.face.back {
  background-color: var(--blue);
  background-image:
    linear-gradient(45deg, rgba(0, 15, 26, 0.45) 25%, transparent 25%, transparent 75%, rgba(0, 15, 26, 0.45) 75%),
    linear-gradient(45deg, rgba(0, 15, 26, 0.45) 25%, transparent 25%, transparent 75%, rgba(0, 15, 26, 0.45) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
}

.face.back::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  right: 7px;
  bottom: 7px;
  background: var(--amber);
}

.face.front {
  display: grid;
  place-items: center;
  background: var(--navy);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transform: rotateY(180deg);
}

.face.front svg { width: 58%; height: 58%; }

.tile.matched .face.front { box-shadow: inset 0 0 0 3px var(--lime); }

.hint { text-align: center; font-size: 13px; opacity: 0.78; }

.combo-pop {
  position: absolute;
  left: 50%;
  top: 64px;
  z-index: 2;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 99px;
  background: var(--lime);
  color: var(--navy);
  font-weight: 700;
  pointer-events: none;
  animation: rise 0.8s ease forwards;
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 6px); }
  30% { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -16px); }
}

.cards { display: grid; gap: 12px; }

.card, .panel {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}

.card.pinned { box-shadow: inset 4px 0 0 var(--amber); }

.card-top, .actions, .row-actions, .side { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.actions .btn { flex: 1 1 7.5rem; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill.final { background: var(--lime); color: var(--navy); border-color: var(--lime); }
.pill.pin { background: var(--amber); color: var(--navy); border-color: var(--amber); }
.pill.open { border-color: var(--blue); }

.match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
}

.side { min-width: 0; flex-wrap: nowrap; }

.team-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }

.star {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--white);
  padding: 0;
}

.star svg { width: 18px; height: 18px; }

.star path { fill: none; stroke: var(--white); stroke-width: 1.7; }

.star[aria-pressed="true"] path { fill: var(--amber); stroke: var(--amber); }

.points {
  font-size: clamp(32px, 8vw, 46px);
  line-height: 0.85;
  text-align: right;
}

.points.dim { opacity: 0.35; }

.note {
  overflow-wrap: anywhere;
  border-left: 3px solid var(--amber);
  padding-left: 8px;
}

.empty { text-align: center; padding: 12px 8px 4px; }

.empty img { width: 84px; height: 84px; }

.progress {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
}

.progress i {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
}

.progress i.on { background: var(--blue); }
.progress i.done { background: var(--lime); }

.question {
  font-size: clamp(18px, 4.2vw, 24px);
  line-height: 1.3;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.answers { display: grid; gap: 8px; }

.answer {
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 15, 26, 0.72);
  color: var(--white);
  overflow-wrap: anywhere;
}

.answer:disabled { cursor: default; }
.answer.good { border-color: var(--lime); background: rgba(139, 189, 53, 0.16); }
.answer.bad { border-color: var(--amber); }

.streak-box { grid-template-columns: 72px minmax(0, 1fr); align-items: center; }
.streak-box > div:last-child { display: grid; gap: 8px; min-width: 0; }

.streak-num { display: block; color: var(--amber); font-size: 52px; line-height: 0.8; }

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cell {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 15, 26, 0.55);
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
}

.cell.hit { background: var(--lime); color: var(--navy); border-color: var(--lime); }
.cell.today { box-shadow: inset 0 0 0 2px var(--amber); }

.chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.bar-col {
  min-width: 0;
  height: 150px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 4px;
}

.bar-track {
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.16);
}

.bar {
  display: block;
  width: min(100%, 22px);
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: var(--blue);
}

.bar.today { background: var(--amber); }

.bar-val, .bar-day { font-size: 11px; font-weight: 700; }

.rowline { display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.1); }

.rowline h4 { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }

.kind {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; background: var(--white); }
.dot.mosaic { background: var(--blue); }
.dot.quiz { background: var(--lime); }
.dot.daily { background: var(--amber); }
.dot.score { background: var(--white); }

.win {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: rgba(0, 15, 26, 0.82);
  border: 1px solid var(--lime);
}

.win img { width: 54px; height: 54px; flex: none; }

.win h3 { font-size: 30px; line-height: 0.9; }

dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 16px;
  overflow: auto;
  color: var(--white);
  background: var(--navy);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
}

dialog[open] { display: grid; gap: 12px; }

dialog::backdrop { background: rgba(0, 15, 26, 0.72); }

#score-form { display: grid; gap: 12px; min-width: 0; }

#score-form h3, #confirm-dialog h3 {
  font-family: var(--display);
  font-size: 32px;
  line-height: 0.95;
}

.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.row-actions .btn { flex: 1; }

#toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100% - 24px);
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--navy);
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.noscript { padding: 24px; }

@media (min-width: 720px) {
  .toolbar { grid-template-columns: minmax(0, 1fr) 200px; }
  .answers { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 900px) {
  #util-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
  #util-body .panel:first-child,
  #util-body .panel:only-child { grid-column: 1 / -1; }
}

@media (max-width: 379px) {
  .util-btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .page-head > img { width: 52px; height: 52px; }
  main { padding-left: 12px; padding-right: 12px; }
}

@media (max-height: 700px) {
  #ob-art { width: 84px; height: 84px; }
  .splash-mosaic { grid-template-columns: 56px 56px; }
  .splash-mosaic img { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .splash-bar span { animation: none; width: 100%; }
  .tile .inner, .combo-pop, #toast { transition: none; animation: none; }
  .combo-pop { opacity: 1; }
}
