:root {
  color-scheme: dark;
  --bg: #050807;
  --panel: rgba(7, 18, 15, 0.72);
  --panel-strong: rgba(8, 28, 22, 0.88);
  --line: rgba(0, 255, 136, 0.18);
  --green: #00ff88;
  --green-soft: rgba(0, 255, 136, 0.14);
  --cyan: #62e8ff;
  --red: #ff3864;
  --text: #effff7;
  --muted: rgba(239, 255, 247, 0.66);
  --dim: rgba(239, 255, 247, 0.42);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 16% 12%, rgba(0, 255, 136, 0.18), transparent 32%),
    radial-gradient(circle at 84% 8%, rgba(98, 232, 255, 0.13), transparent 28%),
    radial-gradient(circle at 70% 78%, rgba(255, 56, 100, 0.08), transparent 30%),
    linear-gradient(180deg, #06100d, var(--bg));
  color: var(--text);
}

body[dir="rtl"] {
  font-family:
    Vazirmatn, "Noto Sans Arabic", Tahoma, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body[dir="rtl"] .hero-copy h1 {
  max-width: 820px;
  font-family: Vazirmatn, "Noto Sans Arabic", Tahoma, sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

button,
a,
textarea,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.matrix,
.scanline {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: -1;
}

.matrix {
  background-image:
    linear-gradient(rgba(0, 255, 136, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 72%);
  animation: drift 22s linear infinite;
}

.scanline {
  background: linear-gradient(180deg, transparent, rgba(0, 255, 136, 0.055), transparent);
  height: 36%;
  animation: scan 8s ease-in-out infinite;
  opacity: 0.55;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(42px, 42px, 0); }
}

@keyframes scan {
  0%, 100% { transform: translateY(-55%); }
  50% { transform: translateY(260%); }
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 2rem, 1180px);
  margin: 0 auto;
  padding: 1.25rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.brand img {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--dim);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.top-actions,
.switcher,
.share-actions,
.game-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.switcher {
  padding: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.chip,
.ghost-btn,
.share-btn {
  min-height: 42px;
  border: 1px solid rgba(0, 255, 136, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  cursor: pointer;
  padding: 0 1rem;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.chip:hover,
.ghost-btn:hover,
.share-btn:hover,
.chip.is-active {
  border-color: rgba(0, 255, 136, 0.55);
  background: var(--green-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.shell {
  width: min(100% - 2rem, 1180px);
  margin: 0 auto;
  padding: 1rem 0 4rem;
}

.hero-panel,
.game-card,
.future-section {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(5, 18, 14, 0.78), rgba(5, 8, 7, 0.52));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: stretch;
  padding: clamp(1.2rem, 4vw, 2.4rem);
  overflow: hidden;
}

.eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin: 0 0 0.9rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.hero-copy h1 {
  max-width: 740px;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.9;
  margin-bottom: 1.3rem;
}

.hero-copy h1 span {
  display: block;
}

.hero-text,
.muted {
  color: var(--muted);
  line-height: 1.75;
}

.terminal-card {
  overflow: hidden;
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.28);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.14);
  padding: 0 1rem;
}

.terminal-bar span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.terminal-bar span:nth-child(2) {
  background: var(--cyan);
  box-shadow: 0 0 16px var(--cyan);
}

.terminal-bar span:nth-child(3) {
  background: var(--red);
  box-shadow: 0 0 16px var(--red);
}

.terminal-bar code {
  margin-inline-start: auto;
  color: var(--dim);
  font-size: 0.8rem;
}

.terminal-body {
  padding: 1.25rem;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.terminal-body p {
  color: var(--muted);
  margin: 0.8rem 0;
}

.terminal-body span:first-child {
  color: var(--green);
}

.code-text,
.snippet,
pre,
code,
textarea,
input,
.terminal-line,
.terminal-bar code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.game-card {
  margin-top: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: screenIn 360ms ease both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.screen-grid,
.result-grid {
  display: grid;
  grid-template-columns: 1fr 0.75fr;
  gap: 1rem;
  align-items: center;
}

.screen h2,
.future-section h2 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.96;
  margin-bottom: 1rem;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 54px;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #02100b;
  cursor: pointer;
  font-weight: 900;
  padding: 0 1.4rem;
  box-shadow: 0 18px 60px rgba(0, 255, 136, 0.26);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 76px rgba(0, 255, 136, 0.34);
}

.difficulty-picker {
  margin: 1.4rem 0;
}

.difficulty-picker p {
  color: var(--dim);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  margin-bottom: 0.65rem;
  text-transform: uppercase;
}

.difficulty-switcher {
  display: inline-flex;
}

.stats-grid,
.hud {
  display: grid;
  gap: 0.75rem;
}

.stats-grid {
  grid-template-columns: 1fr;
}

.stat,
.hud div,
.question-card,
.share-card,
.score-orb {
  border: 1px solid rgba(0, 255, 136, 0.14);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.045);
  padding: 1rem;
}

.stat span,
.hud span,
.score-orb span {
  display: block;
  color: var(--dim);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat strong,
.hud strong,
.score-orb strong {
  display: block;
  color: var(--green);
  font-size: 1.75rem;
  margin-top: 0.35rem;
  text-shadow: 0 0 18px rgba(0, 255, 136, 0.28);
}

.hud {
  grid-template-columns: repeat(5, 1fr);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin: 1rem 0;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width 180ms ease;
}

.typing-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.code-box,
.typing-input {
  min-height: 300px;
  border: 1px solid rgba(0, 255, 136, 0.16);
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  padding: 1rem;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.65;
  overflow: auto;
  white-space: pre-wrap;
}

.typing-input {
  outline: none;
  resize: vertical;
}

.typing-input:focus {
  border-color: rgba(0, 255, 136, 0.65);
  box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.1);
}

.answers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.answer-btn {
  min-height: 70px;
  border: 1px solid rgba(0, 255, 136, 0.16);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  cursor: pointer;
  padding: 1rem;
  text-align: start;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.answer-btn:hover,
.answer-btn:focus-visible {
  border-color: rgba(0, 255, 136, 0.6);
  background: rgba(0, 255, 136, 0.09);
  transform: translateY(-2px);
  outline: none;
}

.answer-btn.is-correct {
  border-color: var(--green);
  background: rgba(0, 255, 136, 0.15);
}

.answer-btn.is-wrong {
  border-color: var(--red);
  background: rgba(255, 56, 100, 0.12);
}

.feedback {
  min-height: 1.6rem;
  color: var(--green);
  margin: 1rem 0 0;
}

.share-card {
  margin: 1rem 0;
}

.reward-card {
  border: 1px solid rgba(0, 255, 136, 0.35);
  border-radius: 24px;
  background:
    radial-gradient(circle at 10% 0%, rgba(0, 255, 136, 0.16), transparent 42%),
    rgba(0, 255, 136, 0.055);
  box-shadow: 0 20px 80px rgba(0, 255, 136, 0.12);
  margin: 1rem 0;
  padding: 1.1rem;
}

.reward-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.7;
}

.claim-box {
  align-items: center;
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 18px;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
}

.claim-box span {
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.claim-box strong {
  color: var(--green);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.storage-consent {
  position: fixed;
  inset-inline: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 2rem, 840px);
  margin-inline: auto;
  padding: 1rem;
  border: 1px solid rgba(0, 255, 136, 0.22);
  border-radius: 22px;
  background: rgba(5, 14, 12, 0.92);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.42), 0 0 34px rgba(0, 255, 136, 0.08);
  backdrop-filter: blur(20px);
}

.storage-consent[hidden] {
  display: none;
}

.storage-consent p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.storage-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.storage-actions a,
.storage-actions button {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 0.95rem;
  font-weight: 800;
}

.storage-actions a {
  display: inline-flex;
  align-items: center;
  color: var(--dim);
}

.storage-actions button {
  border: 0;
  background: var(--green);
  color: #03100b;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 255, 136, 0.18);
}

.share-text {
  color: var(--muted);
  line-height: 1.7;
  word-break: break-word;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.score-orb {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  max-width: 240px;
  margin-inline-start: auto;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(0, 255, 136, 0.18), transparent 58%),
    rgba(255, 255, 255, 0.04);
}

.score-orb strong {
  font-size: clamp(3rem, 10vw, 5rem);
}

.future-section {
  margin-top: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.future-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.future-grid article {
  min-height: 92px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(0, 255, 136, 0.25);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

body[dir="rtl"] .answer-btn:not(.code-text) {
  text-align: right;
}

body[dir="rtl"] .difficulty-picker p,
body[dir="rtl"] .question-card,
body[dir="rtl"] .share-card,
body[dir="rtl"] .reward-card {
  text-align: right;
}

body[dir="rtl"] .terminal-bar code {
  margin-inline-start: 0;
  margin-inline-end: auto;
}

@media (max-width: 820px) {
  .site-header,
  .hero-panel,
  .screen-grid,
  .result-grid,
  .typing-layout {
    grid-template-columns: 1fr;
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .switcher {
    width: 100%;
  }

  .chip {
    flex: 1;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .answers {
    grid-template-columns: 1fr;
  }

  .score-orb {
    margin: 0;
    max-width: none;
    aspect-ratio: auto;
  }

  .future-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .storage-consent {
    align-items: stretch;
    flex-direction: column;
  }

  .storage-actions {
    justify-content: space-between;
  }
}

@media (max-width: 520px) {
  .shell,
  .site-header {
    width: min(100% - 1rem, 1180px);
  }

  .hero-panel,
  .game-card,
  .future-section {
    border-radius: 22px;
  }

  .hero-copy h1 {
    font-size: clamp(3rem, 17vw, 5rem);
  }

  .hud {
    gap: 0.5rem;
  }

  .hud div {
    padding: 0.75rem;
  }

  .code-box,
  .typing-input {
    min-height: 220px;
    font-size: 0.86rem;
  }

  .future-grid {
    grid-template-columns: 1fr;
  }
}
