:root {
  --surface: #0e1515;
  --surface-high: #2f3636;
  --surface-mid: #1a2121;
  --outline: #859493;
  --text: #dde4e3;
  --muted: #bac9c9;
  --cyan: #47eaed;
  --cyan-strong: #00ced1;
  --cyan-dark: #005354;
  --lime: #b8e600;
  --lime-strong: #c3f400;
  --lime-dark: #283500;
  --orange: #ff5625;
  --orange-dark: #541100;
  --salmon: #ffb5a0;
  --salmon-soft: #ffdbd1;
  --brown: #601400;
  --shadow: #111a00;
  --radius: 14px;
  --gap: 16px;
}

* {
  box-sizing: border-box;
}

html {
  direction: rtl;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Spline Sans", system-ui, sans-serif;
  background:
    radial-gradient(circle at 1px 1px, rgba(221, 228, 227, 0.22) 1px, transparent 0),
    #202628;
  background-size: 18px 18px;
}

a {
  color: inherit;
  text-decoration: none;
}

.phone-shell {
  width: min(414px, calc(100vw - 24px));
  min-height: 884px;
  margin: 28px auto;
  overflow: hidden;
  border: 1px solid var(--outline);
  border-radius: 16px;
  background: var(--cyan-strong);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.phone-shell.lime {
  background: var(--lime);
}

.phone-shell.salmon {
  background: var(--salmon);
}

.topbar,
.bottom-nav {
  background: var(--surface);
  border-color: var(--cyan);
}

.topbar {
  min-height: 86px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--cyan);
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  direction: ltr;
}

.brand {
  margin: 0;
  color: var(--cyan);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: clamp(26px, 8vw, 42px);
  line-height: 1;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.brand.small {
  font-size: 26px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 0;
  color: var(--muted);
  background: transparent;
  display: grid;
  place-items: center;
}

.icon-btn.accent {
  color: var(--cyan);
}

.screen {
  min-height: 718px;
  padding: 32px 20px 116px;
}

.screen.tight {
  padding-top: 22px;
}

.hero-title {
  margin: 10px 0 8px;
  color: var(--orange-dark);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 38px;
  line-height: 1.1;
  font-weight: 800;
  text-align: center;
}

.hero-subtitle {
  margin: 0 0 28px;
  color: var(--cyan-dark);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.home-auth-panel {
  margin: -10px 0 24px;
  padding: 14px;
  border: 3px solid var(--cyan-dark);
  border-radius: var(--radius);
  color: var(--cyan-dark);
  background: var(--cyan);
  box-shadow: 6px 7px 0 var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.home-auth-panel div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 0 10px;
  align-items: center;
}

.home-auth-panel strong {
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 22px;
}

.home-auth-panel small {
  grid-column: 2;
  font-weight: 900;
  opacity: 0.75;
}

.auth-mini-btn {
  min-width: 92px;
  min-height: 48px;
  padding: 0 14px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  color: var(--salmon-soft);
  background: var(--brown);
  display: grid;
  place-items: center;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.category-card,
.answer-btn,
.stat-card,
.challenge-card,
.question-card,
.primary-action,
.leader-row,
.auth-card {
  border: 3px solid currentColor;
  border-radius: var(--radius);
  box-shadow: 6px 7px 0 var(--shadow);
}

.category-card {
  min-height: 174px;
  padding: 22px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 25px;
  font-weight: 800;
  text-align: right;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.category-card small {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  opacity: 0.65;
}

.category-card:hover,
.primary-action:hover,
.answer-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 3px 4px 0 var(--shadow);
}

.bg-orange {
  color: var(--orange-dark);
  background: var(--orange);
}

.bg-lime {
  color: var(--lime-dark);
  background: var(--lime-strong);
}

.bg-green {
  color: var(--lime-dark);
  background: #9ad000;
}

.bg-cyan {
  color: var(--cyan-dark);
  background: #49d9dc;
}

.challenge-card {
  position: relative;
  margin-top: 32px;
  padding: 24px;
  color: var(--brown);
  background: var(--salmon);
  overflow: hidden;
}

.challenge-card::after {
  content: "✦";
  position: absolute;
  top: -20px;
  left: 22px;
  color: rgba(96, 20, 0, 0.18);
  font-size: 108px;
  transform: rotate(-18deg);
}

.challenge-card h2,
.auth-card h2 {
  margin: 0 0 8px;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 30px;
  line-height: 1;
}

.challenge-card p,
.auth-card p {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 700;
}

.primary-action {
  min-height: 58px;
  padding: 0 26px;
  border-color: var(--brown);
  color: var(--salmon-soft);
  background: var(--brown);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action.full {
  width: 100%;
  margin-top: 16px;
}

.stats-strip {
  margin-top: 34px;
  padding: 12px 8px;
  border: 4px solid #5af8fb;
  border-radius: var(--radius);
  color: #5af8fb;
  background: #087779;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
}

.stats-strip span {
  display: block;
  color: #8efcff;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.stats-strip strong {
  display: block;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 32px;
}

.stats-strip div + div {
  border-right: 2px solid rgba(90, 248, 251, 0.28);
}

.top-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: 36px;
  direction: ltr;
}

.stat-card {
  min-height: 120px;
  padding: 18px;
  background: var(--surface-high);
}

.stat-card.bg-green,
.stat-card.bg-lime {
  color: var(--lime-dark);
  background: #9ad000;
}

.stat-card.bg-orange {
  color: var(--orange-dark);
  background: var(--orange);
}

.stat-card.bg-cyan {
  color: var(--cyan-dark);
  background: #49d9dc;
}

.stat-card.orange {
  color: var(--orange);
}

.stat-card.cyan {
  color: var(--cyan);
}

.label {
  display: block;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 12px;
  display: block;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 32px;
  font-weight: 800;
  text-align: center;
}

.meter {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  background: currentColor;
}

.question-card {
  position: relative;
  min-height: 246px;
  padding: 34px 30px;
  color: var(--lime-dark);
  background: var(--lime-strong);
  overflow: hidden;
}

.question-card::after {
  content: "⚡";
  position: absolute;
  top: 2px;
  left: 18px;
  opacity: 0.08;
  font-size: 120px;
}

.question-meta {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 800;
}

.pill {
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--lime-strong);
  background: var(--lime-dark);
}

.question-card h2 {
  margin: 0;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 29px;
  line-height: 1.35;
  font-weight: 800;
}

.answers {
  margin-top: 38px;
  display: grid;
  gap: var(--gap);
}

.answer-btn {
  min-height: 76px;
  padding: 0 22px;
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  text-align: right;
  font-family: "Spline Sans", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn.correct {
  outline: 5px solid var(--lime-strong);
  filter: saturate(1.25);
}

.answer-btn.wrong {
  outline: 5px solid var(--orange-dark);
  filter: grayscale(0.25) brightness(0.9);
}

.answer-btn strong {
  opacity: 0.22;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 32px;
}

.powerups {
  margin-top: 34px;
  text-align: center;
}

.powerups h3 {
  color: var(--muted);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 13px;
  text-transform: uppercase;
}

.powerup-row {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.powerup {
  width: 58px;
  height: 58px;
  border: 3px solid currentColor;
  border-radius: 999px;
  color: var(--cyan);
  background: var(--surface-high);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
}

.powerup.orange {
  color: var(--orange);
}

.powerup.lime {
  color: var(--lime-strong);
}

.result-ring {
  width: 172px;
  height: 172px;
  margin: 10px auto 28px;
  border: 14px solid var(--lime-dark);
  border-left-color: var(--cyan-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.result-ring strong {
  color: var(--cyan-strong);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 44px;
  line-height: 1;
}

.result-ring span {
  display: block;
  color: var(--lime-dark);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 2px;
  text-align: center;
}

.result-title {
  margin: 0 0 26px;
  color: var(--lime-dark);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 27px;
  text-align: center;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: 26px;
}

.result-grid .stat-card {
  min-height: 136px;
  display: grid;
  place-items: center;
  text-align: center;
}

.wide {
  grid-column: 1 / -1;
}

.progress-card {
  margin: 28px 0;
  padding: 22px;
  border: 3px solid var(--lime-dark);
  border-radius: var(--radius);
  box-shadow: 6px 7px 0 var(--shadow);
  color: var(--brown);
  background: var(--salmon);
}

.progress-row {
  margin: 12px 0;
  display: grid;
  grid-template-columns: 52px 1fr 116px;
  gap: 10px;
  align-items: center;
  font-weight: 800;
}

.progress-line {
  height: 13px;
  border-radius: 999px;
  background: rgba(96, 20, 0, 0.2);
  overflow: hidden;
}

.progress-line i {
  display: block;
  height: 100%;
  background: var(--cyan-strong);
}

.leader-list {
  display: grid;
  gap: 14px;
}

.leader-row {
  min-height: 68px;
  padding: 0 18px;
  color: var(--cyan-dark);
  background: var(--cyan);
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  font-weight: 900;
}

.leader-row small {
  grid-column: 2 / -1;
  margin-top: -10px;
  opacity: 0.68;
  font-size: 12px;
}

.leader-row:nth-child(2n) {
  color: var(--lime-dark);
  background: var(--lime);
}

.leader-row:nth-child(3n) {
  color: var(--orange-dark);
  background: var(--orange);
}

.leader-row .rank {
  opacity: 0.32;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 30px;
}

.leader-row .score {
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 24px;
}

.auth-card {
  padding: 24px;
  color: var(--brown);
  background: var(--salmon);
}

.auth-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--orange-dark);
  font-weight: 900;
}

.form-grid {
  margin: 22px 0;
  display: grid;
  gap: 14px;
}

.input {
  width: 100%;
  height: 58px;
  padding: 0 16px;
  border: 3px solid var(--brown);
  border-radius: 12px;
  color: var(--brown);
  background: var(--salmon-soft);
  font: 800 18px "Spline Sans", system-ui, sans-serif;
}

.ghost-action {
  width: 100%;
  min-height: 58px;
  margin-top: 14px;
  border: 3px solid var(--cyan-dark);
  border-radius: var(--radius);
  color: var(--cyan-dark);
  background: var(--cyan);
  font: 800 22px "Anybody", system-ui, sans-serif;
}

.screen-note {
  margin-top: 12px;
  color: var(--cyan-dark);
  font-weight: 900;
  text-align: center;
}

.game-kicker {
  margin: -18px 0 18px;
  color: var(--brown);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.achievement-panel {
  margin: 24px 0;
  padding: 18px;
  border: 3px solid var(--lime-dark);
  border-radius: var(--radius);
  color: var(--lime-dark);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 6px 7px 0 var(--shadow);
}

.achievement-panel h3 {
  margin: 0 0 12px;
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 24px;
}

.achievement-badge {
  margin-top: 10px;
  padding: 12px;
  border: 2px solid var(--lime-dark);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 4px 10px;
  align-items: center;
  background: var(--lime-strong);
}

.achievement-badge small {
  grid-column: 2;
  opacity: 0.78;
}

.user-chip {
  position: absolute;
  top: 74px;
  right: 20px;
  z-index: 2;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--cyan-dark);
  background: var(--cyan);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 900;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 200;
  height: 82px;
  padding: 10px 20px;
  border-top: 2px solid var(--cyan);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  direction: ltr;
  background: var(--surface);
}

.nav-item {
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.nav-item .material-symbols-outlined {
  pointer-events: none;
}

.nav-item.active {
  border-color: var(--lime-strong);
  color: var(--cyan-dark);
  background: var(--cyan-strong);
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 600, "GRAD" 0, "opsz" 32;
}

@media (max-width: 430px) {
  .phone-shell:not(.game) {
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    border-radius: 0;
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }

  .phone-shell:not(.game) .screen {
    min-height: calc(100vh - 168px);
    padding-bottom: calc(116px + env(safe-area-inset-bottom, 0px));
  }

  #nav-root {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
  }

  .bottom-nav {
    position: relative;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .install-banner {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
}

/* Game screen: fit everything in viewport without scrolling */
@media (max-width: 430px) {
  body.game-page {
    overflow: hidden;
    height: 100dvh;
    min-height: 100dvh;
  }

  body.game-page .phone-shell.game {
    width: 100vw;
    height: 100dvh;
    min-height: unset;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
  }

  body.game-page .topbar {
    flex-shrink: 0;
    min-height: unset;
    padding: 10px 16px;
  }

  body.game-page .brand.small {
    font-size: clamp(18px, 5vw, 24px);
  }

  body.game-page .user-chip {
    display: none;
  }

  body.game-page .screen.game-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px 14px 14px;
  }

  body.game-page .game-kicker {
    flex-shrink: 0;
    margin: 0 0 8px;
    font-size: clamp(11px, 2.8vw, 13px);
  }

  body.game-page .top-stats {
    flex-shrink: 0;
    margin-bottom: 10px;
    gap: 10px;
  }

  body.game-page .top-stats .stat-card {
    min-height: unset;
    padding: 10px 12px;
  }

  body.game-page .top-stats .label {
    font-size: clamp(9px, 2.4vw, 11px);
  }

  body.game-page .top-stats .stat-value {
    margin-top: 6px;
    font-size: clamp(20px, 5.5vw, 28px);
  }

  body.game-page .top-stats .meter {
    margin-top: 6px;
    height: 6px;
  }

  body.game-page .question-card {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 42%;
    padding: clamp(14px, 3.5vw, 22px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.game-page .question-card::after {
    font-size: 72px;
  }

  body.game-page .question-meta {
    flex-shrink: 0;
    margin-bottom: 10px;
    font-size: clamp(10px, 2.6vw, 12px);
  }

  body.game-page .pill {
    padding: 4px 10px;
    font-size: clamp(9px, 2.4vw, 11px);
  }

  body.game-page .question-card h2 {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    font-size: clamp(17px, 4.5vw, 24px);
    line-height: 1.25;
  }

  body.game-page .answers {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: clamp(8px, 2vw, 12px);
  }

  body.game-page .answer-btn {
    min-height: 0;
    height: 100%;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    font-size: clamp(14px, 3.2vw, 17px);
    line-height: 1.2;
  }

  body.game-page .answer-btn strong {
    font-size: clamp(20px, 4.5vw, 26px);
    opacity: 0.35;
    line-height: 1;
  }

  body.game-page .answer-btn span {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
  }

  body.game-page #nav-root {
    display: none;
  }
}

@media (max-width: 430px) and (max-height: 740px) {
  body.game-page .game-kicker {
    display: none;
  }

  body.game-page .question-card {
    max-height: 38%;
  }

  body.game-page .question-card h2 {
    -webkit-line-clamp: 4;
    font-size: clamp(15px, 4vw, 20px);
  }
}

@media (max-width: 430px) and (max-height: 640px) {
  body.game-page .topbar {
    padding: 8px 14px;
  }

  body.game-page .screen.game-layout {
    padding: 8px 12px 10px;
  }

  body.game-page .top-stats {
    margin-bottom: 8px;
    gap: 8px;
  }

  body.game-page .top-stats .stat-card {
    padding: 8px 10px;
  }

  body.game-page .top-stats .stat-value {
    font-size: clamp(18px, 5vw, 24px);
  }

  body.game-page .question-card {
    max-height: 34%;
    padding: 12px;
  }

  body.game-page .question-card h2 {
    -webkit-line-clamp: 3;
    font-size: clamp(14px, 3.8vw, 18px);
  }

  body.game-page .answers {
    gap: 8px;
  }

  body.game-page .answer-btn {
    font-size: clamp(13px, 3vw, 15px);
  }
}

.install-banner {
  position: fixed;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  z-index: 1000;
  padding: 14px 14px 12px;
  border: 2px solid rgba(71, 234, 237, 0.45);
  border-radius: 16px;
  color: var(--text);
  background: rgba(14, 21, 21, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 12px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 240ms ease, transform 240ms ease;
  pointer-events: none;
}

.install-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.install-banner.is-hidden {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
}

.install-banner-body {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
}

.install-banner-icon {
  color: var(--cyan);
  font-size: 24px;
}

.install-banner-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 600;
}

.install-banner-text strong {
  color: var(--cyan);
  font-weight: 800;
}

.install-banner-btn {
  width: 100%;
  min-height: 44px;
  border: 2px solid var(--cyan-dark);
  border-radius: 12px;
  color: var(--cyan-dark);
  background: var(--cyan);
  font-family: "Anybody", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

@media (min-width: 431px) {
  .install-banner {
    display: none;
  }
}
