@font-face {
  font-family: Vazir;
  src: url('../vazirmatn.woff2') format('woff2');
  font-display: swap;
  font-weight: 100 900;
}
:root {
  --screen-h: 100vh;
  color-scheme: dark;
  --bg: #060c0e;
  --panel: #0c1719d9;
  --panel-solid: #0d1a1c;
  --ink: #eef3ea;
  --muted: #9fb3ad;
  --faint: #6f8580;
  --line: #ffffff17;
  --line-strong: #ffffff2b;
  --accent: #b7f5d7;
  --accent-deep: #447d71;
  --gold: #f2cb80;
  --hot: #ff8a5c;
  --radius: 18px;
  --mono: Consolas, 'SFMono-Regular', Vazir, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: Vazir, 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@supports (height: 100dvh) {
  :root {
    --screen-h: 100dvh;
  }
}
body[data-chapter='1'] {
  --accent: #ffcd80;
  --accent-deep: #907246;
  --gold: #a9e5c2;
  --hot: #ff6b4a;
}
body[data-chapter='2'] {
  --accent: #c3b0ff;
  --accent-deep: #7863a3;
  --gold: #73e9e1;
  --hot: #ff7ab8;
}
body[data-chapter='3'] {
  --accent: #ffab92;
  --accent-deep: #a76767;
  --gold: #f3d17d;
  --hot: #ff5f6d;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  min-height: var(--screen-h);
}
body {
  isolation: isolate;
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}
button,
a {
  touch-action: manipulation;
}
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
  border: 0;
  background: none;
  transition:
    background 0.18s,
    border-color 0.18s,
    color 0.18s,
    box-shadow 0.25s,
    transform 0.18s var(--ease-out),
    opacity 0.18s;
}
a {
  color: inherit;
  text-decoration: none;
}
button:disabled {
  cursor: default;
  opacity: 0.38;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1,
h2,
p {
  margin: 0;
}
kbd {
  font: 10px var(--mono);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--muted);
}

/* ---------- city backdrop ---------- */
.city-backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  contain: layout paint style;
  background: radial-gradient(ellipse at 50% 35%, #1d3a3a66, #050b0d 70%);
}
#city-scene {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.85;
}
.city-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 35%, #03070899 85%),
    linear-gradient(
      180deg,
      #03070880,
      transparent 18%,
      transparent 80%,
      #030708cc
    );
}

/* ---------- app frame ---------- */
.app {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: auto;
  padding: 0 28px;
  min-height: var(--screen-h);
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 17px/1 var(--mono);
  letter-spacing: 0.32em;
  direction: ltr;
}
.wordmark-text {
  display: grid;
  gap: 5px;
}
.wordmark small {
  font-size: 8.5px;
  letter-spacing: 0.3em;
  color: var(--faint);
  font-weight: 500;
}
.brand-symbol {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(145deg, #ffffff14, #ffffff03);
  border: 1px solid var(--line-strong);
  box-shadow:
    inset 0 1px 0 #ffffff1a,
    0 0 24px color-mix(in srgb, var(--accent) 22%, transparent);
}
.edition {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
    box-shadow: 0 0 2px var(--accent);
  }
}
.tools {
  display: flex;
  gap: 8px;
}
.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(160deg, #ffffff12, #ffffff04);
  border: 1px solid var(--line-strong);
  color: #dfe9e4;
  box-shadow: inset 0 1px 0 #ffffff12;
}
.icon-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--accent);
}
.icon-button[aria-pressed='true'] {
  color: var(--hot);
}

/* ---------- workspace ---------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 34px;
  padding: 18px 0 10px;
  align-items: start;
}
.intro {
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.city-sign {
  display: grid;
  gap: 2px;
  margin-bottom: 4px;
}
.city-sign-coordinate {
  font: 10px var(--mono);
  letter-spacing: 0.22em;
  color: var(--faint);
}
.city-sign-name {
  font:
    800 44px/1 Bahnschrift,
    'Segoe UI',
    sans-serif;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #f6f3e6, #9fb7ad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 30px #0008;
}
.city-sign-caption {
  font: 600 13px var(--mono);
  letter-spacing: 0.5em;
  color: var(--muted);
}
.city-sign-line {
  height: 1px;
  margin-top: 10px;
  background: linear-gradient(90deg, var(--gold), transparent);
  position: relative;
}
.city-sign-line i {
  position: absolute;
  left: 0;
  top: -3px;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}
.eyebrow {
  font: 600 10px var(--mono);
  letter-spacing: 0.22em;
  color: var(--faint);
  text-transform: uppercase;
}
h1 {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(100deg, var(--ink), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chapter-badge {
  align-self: flex-start;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 99px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.route-art {
  position: relative;
  max-width: 230px;
  opacity: 0.9;
}
.route-art svg {
  width: 100%;
  height: auto;
}
.route-grid {
  stroke: #ffffff10;
  stroke-width: 1;
}
.route-ghost {
  stroke: #ffffff1c;
  stroke-width: 6;
}
.route-beam {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 8 10;
  animation: beam 2.8s linear infinite;
  filter: drop-shadow(0 0 4px var(--accent));
}
@keyframes beam {
  to {
    stroke-dashoffset: -72;
  }
}
.route-node circle:first-child {
  fill: #0c1719;
  stroke: #ffffff30;
}
.route-node circle + circle,
.route-node path {
  stroke: var(--muted);
}
body[data-chapter='0'] .node-0 circle:first-child,
body[data-chapter='1'] .node-1 circle:first-child,
body[data-chapter='2'] .node-2 circle:first-child,
body[data-chapter='3'] .node-3 circle:first-child {
  stroke: var(--gold);
  filter: drop-shadow(0 0 6px var(--gold));
}
.route-coordinate {
  position: absolute;
  bottom: 0;
  right: 0;
  font: 9px var(--mono);
  letter-spacing: 0.18em;
  color: var(--faint);
}
.chapter {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.chapter strong {
  font: 700 30px var(--mono);
  color: var(--ink);
  direction: ltr;
}
.chapter em {
  font-style: normal;
  color: var(--faint);
  font-size: 18px;
}
#chapter-title {
  font-size: 20px;
  font-weight: 700;
}
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}
.level-dots {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  direction: ltr;
}
.level-dots span {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: #ffffff14;
  transition: background 0.3s;
}
.level-dots .done {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}
.level-dots .current {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}
.chapter-progress,
.save-note {
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.7;
}
.text-button {
  align-self: flex-start;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 2px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.text-button:hover {
  color: var(--gold);
}

/* ---------- game column ---------- */
.game-column {
  --board-width: min(500px, calc((var(--screen-h) - 214px) * 2 / 3));
  display: grid;
  grid-template-columns: var(--board-width) minmax(230px, 280px);
  grid-template-rows: auto auto auto 1fr;
  column-gap: 26px;
  row-gap: 8px;
  justify-content: center;
  align-items: start;
  direction: ltr;
  min-width: 0;
}
.game-column > * {
  direction: rtl;
  min-width: 0;
}
html[dir='ltr'] .game-column > * {
  direction: ltr;
}
.board-header {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
}
.board-title {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}
.board-title strong {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font: 600 12px var(--mono);
  direction: ltr;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, #0b1517);
}
.chapter-chip:hover {
  border-color: var(--accent);
}
.board-context {
  grid-column: 1;
  position: relative;
  min-height: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
#board-caption {
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#event-banner {
  position: absolute;
  inset: 0;
  z-index: 3;
  line-height: 24px;
  border-radius: 99px;
  font-weight: 700;
  color: #1a1308;
  background:
    linear-gradient(90deg, #0000, var(--gold) 14%, var(--gold) 86%, #0000),
    var(--bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: banner 0.45s var(--spring);
}
#event-banner:empty {
  display: none;
}
@keyframes banner {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
}

/* ---------- arena ---------- */
.arena-wrap {
  grid-column: 1;
  grid-row: 3 / 5;
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #04080a;
  box-shadow:
    0 0 0 1px #ffffff1f,
    0 0 0 6px #0a1214,
    0 0 0 7px color-mix(in srgb, var(--accent) 22%, transparent),
    0 30px 80px #000a,
    0 0 90px color-mix(in srgb, var(--accent) 10%, transparent);
}
.arena-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#arena {
  background: transparent;
  z-index: 1;
}
#arena-gl {
  z-index: 0;
}
canvas[data-aiming='true'] {
  cursor: crosshair;
}
.board-hud {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6.5%;
  pointer-events: none;
  font: 700 clamp(10px, 2.6cqw, 14px) var(--mono);
  color: #f3f1e6;
  direction: ltr;
  text-shadow: 0 1px 6px #000;
}
.arena-wrap {
  container-type: inline-size;
}
.board-hud {
  font-size: clamp(10px, 3.1cqw, 15px);
}
.hud-keys,
.hud-score,
.hud-lives {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-gem {
  width: 0.8em;
  height: 0.8em;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #fff6d8, var(--gold));
  box-shadow: 0 0 10px var(--gold);
}
.hud-keys[data-done='true'] b {
  color: var(--gold);
}
.hud-score b {
  letter-spacing: 0.06em;
  transition: transform 0.2s var(--spring);
}
.hud-score b[data-bump='true'] {
  transform: scale(1.18);
}
.hud-score em {
  font-style: normal;
  color: var(--gold);
  font-size: 0.85em;
  opacity: 0;
  transition: opacity 0.2s;
}
.hud-score em[data-active='true'] {
  opacity: 1;
}
.hud-lives i {
  width: 0.72em;
  height: 0.72em;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    #fff,
    var(--accent) 60%,
    var(--accent-deep)
  );
  box-shadow: 0 0 9px var(--accent);
  transition:
    transform 0.4s var(--spring),
    opacity 0.4s,
    background 0.4s;
}
.hud-lives i[data-lost='true'] {
  transform: scale(0.6);
  opacity: 0.25;
  background: #ffffff40;
  box-shadow: none;
}
.mirror-controls {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.mirror-hit {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  touch-action: none;
  background: transparent;
}
.mirror-hit:hover:not(:disabled) {
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--accent) 22%, transparent),
    transparent 70%
  );
}
.mirror-hit:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.92);
}
.mirror-hit:disabled {
  pointer-events: none;
}
#load-status {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  background: radial-gradient(circle, #0f2023, #05090b);
}

/* ---------- control deck ---------- */
.control-deck {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(170deg, #ffffff0d, #ffffff03 60%), var(--panel);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 #ffffff12,
    0 20px 60px #0007;
  backdrop-filter: blur(14px);
}
.console-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.console-code {
  margin-inline-start: auto;
  font: 600 9px var(--mono);
  letter-spacing: 0.2em;
  color: var(--accent);
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.score-readout {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
}
.score-readout > div {
  display: grid;
  gap: 2px;
}
.score-readout span {
  font-size: 11px;
  color: var(--faint);
}
#score-count {
  font: 700 34px/1.1 var(--mono);
  letter-spacing: 0.02em;
}
.combo-readout {
  text-align: end;
}
#combo-count {
  font: 700 22px var(--mono);
  color: var(--faint);
  transition:
    color 0.2s,
    transform 0.3s var(--spring);
}
#combo-count[data-active='true'] {
  color: var(--gold);
  transform: scale(1.12);
  text-shadow: 0 0 14px var(--gold);
}
.telemetry {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0;
  border-block: 1px solid var(--line);
}
.telemetry span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.telemetry b {
  color: var(--ink);
  font-family: var(--mono);
}
.energy i {
  font-style: normal;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold);
}
.attempts b {
  color: var(--accent);
  letter-spacing: 0.1em;
}
.aim-control {
  display: grid;
  grid-template-columns: auto 1fr 3.2em;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.aim-control output {
  font: 700 13px var(--mono);
  color: var(--accent);
  text-align: center;
  direction: ltr;
}
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  direction: ltr;
  margin: 0;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    #ffffff12,
    color-mix(in srgb, var(--accent) 50%, transparent),
    #ffffff12
  );
  border: 1px solid var(--line);
}
input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    #ffffff12,
    color-mix(in srgb, var(--accent) 50%, transparent),
    #ffffff12
  );
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    #fff,
    var(--accent) 55%,
    var(--accent-deep)
  );
  box-shadow:
    0 0 0 4px #0008,
    0 0 16px var(--accent);
}
input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 30%,
    #fff,
    var(--accent) 55%,
    var(--accent-deep)
  );
  box-shadow:
    0 0 0 4px #0008,
    0 0 16px var(--accent);
}
input[type='range']:disabled {
  opacity: 0.35;
}
.actions {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr) auto;
  gap: 8px;
  align-items: stretch;
}
.primary {
  position: relative;
  overflow: hidden;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  font-size: 15px;
  color: #071311;
  background-color: var(--accent);
  background: linear-gradient(
    160deg,
    #ffffff,
    var(--accent) 45%,
    color-mix(in srgb, var(--accent) 70%, #000)
  );
  box-shadow:
    inset 0 1px 0 #ffffffb0,
    inset 0 -3px 0 #0003,
    0 10px 30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    #ffffff80 48%,
    transparent 66%
  );
  transform: translateX(-120%);
  animation: shine 3.6s ease-in-out infinite;
}
@keyframes shine {
  55%,
  100% {
    transform: translateX(120%);
  }
}
.primary:hover:not(:disabled) {
  box-shadow:
    inset 0 1px 0 #ffffffb0,
    inset 0 -3px 0 #0003,
    0 12px 40px color-mix(in srgb, var(--accent) 55%, transparent);
}
.primary svg {
  stroke-width: 2.2;
}
.actions .icon-button {
  width: 52px;
  height: 52px;
  border-radius: 15px;
}
.focus-button {
  position: relative;
  min-height: 52px;
  padding: 0 10px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: #ddd2ff;
  background: linear-gradient(160deg, #a58cff26, #ffffff05);
  border: 1px solid #b9a5ff40;
}
.focus-button[aria-pressed='true'] {
  background: linear-gradient(160deg, #a58cff66, #a58cff20);
  box-shadow: 0 0 24px #a58cff55;
}
.focus-track {
  position: absolute;
  inset: auto 12px 7px;
  height: 3px;
  border-radius: 99px;
  background: #ffffff14;
  overflow: hidden;
}
#focus-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: #cdbfff;
  box-shadow: 0 0 8px #cdbfff;
  transition: width 0.1s linear;
}
.focus-button kbd {
  display: none;
}
.status {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
  line-height: 1.6;
}
.account-panel {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.account-summary {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--faint);
}
.account-summary > span {
  display: grid;
  gap: 2px;
}
.account-summary b {
  font: 700 15px var(--mono);
  color: var(--ink);
}
.account-summary b[data-large='true'] {
  font-size: 12px;
}
.reward-multiplier {
  font: 800 13px var(--mono);
  color: var(--gold);
  padding: 6px 9px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}
.account-state {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}
.account-status {
  flex: 1;
  text-align: start;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 0;
}
.account-status[data-state='ranked'] {
  color: var(--accent);
}
.account-status[data-state='failed'] {
  color: var(--hot);
}
#account-login,
#account-resume {
  color: var(--accent);
  font-weight: 700;
}
.leaderboard-button {
  min-height: 44px;
  border-radius: 13px;
  font-weight: 700;
  font-size: 13px;
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--gold) 14%, transparent),
    transparent
  );
}
.leaderboard-button:hover {
  border-color: var(--gold);
}

/* ---------- goals, hints, replay ---------- */
.goals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.goal-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 99px;
  font: 600 11.5px var(--mono);
  color: var(--muted);
  background: #ffffff0a;
  border: 1px solid var(--line);
  white-space: nowrap;
}
#goal-par[data-state='ok'] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
#goal-par[data-state='tight'] {
  color: var(--gold);
}
#goal-par[data-state='missed'] {
  color: var(--hot);
}
#goal-chain[data-state='done'] {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
}
.hint-button {
  margin-inline-start: auto;
  cursor: pointer;
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 40%, transparent);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  font-family: Vazir, var(--mono);
}
.hint-button b {
  font-family: var(--mono);
}
.replay-badge {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 4%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 12px;
  color: var(--ink);
  background: #000b;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  white-space: nowrap;
}
.replay-badge b {
  color: var(--accent);
}
.goal-list {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 12.5px;
  color: var(--faint);
}
.goal-list li::before {
  content: '○ ';
}
.goal-list li[data-met='true'] {
  color: var(--accent);
}
.goal-list li[data-met='true']::before {
  content: '● ';
}
.replay-button {
  justify-self: center;
  align-self: center;
}

/* ---------- field notes ---------- */
.field-notes {
  grid-column: 2;
  grid-row: 4;
  display: grid;
  gap: 12px;
  padding: 16px 4px;
}
.note {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}
.note-icon {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--accent);
}
.diamond {
  color: var(--gold);
}
.best-record {
  display: grid;
  gap: 6px;
  font-size: 11px;
  color: var(--faint);
}
.best-record strong {
  font: 700 26px var(--mono);
  color: var(--ink);
  direction: ltr;
  text-align: start;
}
.best-record small {
  font-size: 14px;
  color: var(--faint);
}
.progress-track {
  height: 4px;
  border-radius: 99px;
  background: #ffffff10;
  overflow: hidden;
}
#progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.6s var(--ease-out);
}
.signature {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 9px var(--mono);
  letter-spacing: 0.24em;
  color: var(--faint);
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 16px;
  font: 9px var(--mono);
  letter-spacing: 0.2em;
  color: #ffffff38;
  border-top: 1px solid var(--line);
}

/* ---------- modal ---------- */
dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  max-width: min(520px, calc(100vw - 28px));
  width: 100%;
  max-height: calc(var(--screen-h) - 28px);
}
dialog::backdrop {
  background: radial-gradient(circle at 50% 40%, #0b1a1ccc, #020506ee);
  backdrop-filter: blur(6px);
}
dialog[open] .modal-inner {
  animation: rise 0.42s var(--spring);
}
@keyframes rise {
  from {
    transform: translateY(26px) scale(0.96);
    opacity: 0;
  }
}
.modal-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 26px 24px 20px;
  border-radius: 24px;
  overflow: auto;
  max-height: calc(var(--screen-h) - 28px);
  background:
    radial-gradient(
      ellipse at 50% -10%,
      color-mix(in srgb, var(--accent) 22%, transparent),
      transparent 60%
    ),
    linear-gradient(170deg, #142426f2, #0a1315f7);
  border: 1px solid #ffffff22;
  box-shadow:
    inset 0 1px 0 #ffffff1c,
    0 40px 120px #000c,
    0 0 0 1px #0006;
}
.modal-inner h2 {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.3;
}
#modal-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}
.result-stars {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 46px;
  line-height: 1;
  direction: ltr;
}
.result-stars:empty {
  display: none;
}
.result-stars span {
  display: inline-block;
  color: #ffffff1f;
  transform: scale(0.4);
  opacity: 0;
  animation: star 0.55s var(--spring) forwards;
}
.result-stars span[data-on='true'] {
  color: var(--gold);
  text-shadow:
    0 0 18px var(--gold),
    0 0 44px color-mix(in srgb, var(--gold) 60%, transparent);
}
.result-stars span:nth-child(2) {
  animation-delay: 0.16s;
  font-size: 1.22em;
  margin-top: -10px;
}
.result-stars span:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes star {
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.one-shot {
  width: fit-content;
  margin: 0 auto 10px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #1a1308;
  padding: 5px 14px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #fff3cf, var(--gold));
  box-shadow: 0 0 24px color-mix(in srgb, var(--gold) 60%, transparent);
  animation: banner 0.5s 0.5s var(--spring) both;
}
#modal-content:empty {
  display: none;
}
.result-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.result-summary > div {
  display: grid;
  gap: 4px;
  padding: 12px 10px;
  border-radius: 14px;
  text-align: center;
  background: #ffffff08;
  border: 1px solid var(--line);
}
.result-summary span {
  font-size: 11px;
  color: var(--faint);
}
.result-summary strong {
  font: 800 clamp(16px, 5vw, 22px) var(--mono);
  color: var(--accent);
  white-space: nowrap;
}
.stars-rule {
  font-size: 12px;
  line-height: 1.8;
  color: var(--faint);
  margin-top: 4px;
}
.modal-actions {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}
.modal-actions .primary {
  width: 100%;
}
.modal-actions .text-button {
  align-self: center;
  justify-self: center;
}
.help-list {
  margin: 0;
  padding-inline-start: 22px;
  display: grid;
  gap: 8px;
  font-size: 13px;
  line-height: 1.8;
  color: #d5e0db;
}
.help-list li::marker {
  color: var(--accent);
  font-weight: 800;
}
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.chapter-card {
  padding: 12px;
  border-radius: 16px;
  background: #ffffff07;
  border: 1px solid var(--line);
}
.chapter-card[data-chapter='1'] {
  --card: #ffcd80;
}
.chapter-card[data-chapter='2'] {
  --card: #c3b0ff;
}
.chapter-card[data-chapter='3'] {
  --card: #ffab92;
}
.chapter-card {
  --card: #b7f5d7;
  border-top: 2px solid color-mix(in srgb, var(--card) 70%, transparent);
}
.chapter-heading {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--card);
}
.chapter-card p {
  font-size: 11px;
  line-height: 1.7;
  color: var(--faint);
  margin-bottom: 8px;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  direction: ltr;
}
.level-grid button {
  aspect-ratio: 1;
  border-radius: 11px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  font: 700 13px var(--mono);
  background: #ffffff0a;
  border: 1px solid var(--line);
}
.level-grid button small {
  font-size: 9px;
  color: var(--gold);
}
.level-grid button.current {
  border-color: var(--gold);
  box-shadow: 0 0 16px color-mix(in srgb, var(--gold) 35%, transparent);
}
.level-grid button:hover:not(:disabled) {
  border-color: var(--card);
}
.level-paging {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font: 12px var(--mono);
  color: var(--faint);
}
.level-paging button {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 12px;
}
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.rank-table th {
  font-weight: 600;
  font-size: 11px;
  color: var(--faint);
  text-align: start;
  padding: 6px;
  border-bottom: 1px solid var(--line);
}
.rank-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #ffffff0a;
}
.rank-table td:first-child {
  font-family: var(--mono);
  color: var(--muted);
  width: 2.6em;
}
.rank-table tr[data-top='1'] td:first-child {
  color: #ffd76a;
}
.rank-table tr[data-top='2'] td:first-child {
  color: #dfe7ee;
}
.rank-table tr[data-top='3'] td:first-child {
  color: #e7a36d;
}
.rank-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.rank-player img,
.rank-player i {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #ffffff12;
  border: 1px solid var(--line);
}
.rank-player span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 11em;
}
.reward-detail {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted);
  background: #00000030;
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--gold);
}
.reward-detail strong {
  color: var(--gold);
  font-size: 14px;
}
.reward-detail[data-state='confirmed'] {
  border-inline-start-color: var(--accent);
}
.reward-detail[data-state='confirmed'] strong {
  color: var(--accent);
}
.reward-detail[data-state='failed'] {
  border-inline-start-color: var(--hot);
}
.reward-detail .text-button {
  justify-self: center;
}

/* ---------- desktop: the intro panel carries the title, the board gets the height ---------- */
@media (min-width: 1121px) {
  .board-header {
    display: none;
  }
  .game-column {
    --board-width: min(540px, calc((var(--screen-h) - 150px) * 2 / 3));
  }
}
@media (min-width: 701px) {
  .actions {
    grid-template-columns: minmax(0, 1fr) 52px;
    grid-template-areas:
      'launch launch'
      'focus retry';
  }
  #launch {
    grid-area: launch;
  }
  #focus {
    grid-area: focus;
  }
  #retry {
    grid-area: retry;
  }
  .focus-button kbd {
    display: inline;
  }
}
@media (min-width: 701px) and (max-height: 860px) {
  footer {
    display: none;
  }
}

/* ---------- tablet / narrow desktop ---------- */
@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .intro {
    display: none;
  }
}

/* ---------- phone portrait ---------- */
@media (max-width: 700px) {
  .app {
    padding: 0 max(10px, env(safe-area-inset-left)) env(safe-area-inset-bottom);
  }
  .topbar {
    height: 54px;
    gap: 8px;
  }
  .wordmark {
    font-size: 14px;
    letter-spacing: 0.26em;
    gap: 9px;
  }
  .wordmark small {
    font-size: 7px;
  }
  .brand-symbol {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }
  .edition {
    display: none;
  }
  .tools {
    gap: 6px;
  }
  .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  .workspace {
    padding: 8px 0 6px;
    gap: 0;
  }
  .game-column {
    --board-width: min(100%, calc((var(--screen-h) - 292px) * 2 / 3));
    grid-template-columns: minmax(0, 1fr);
    row-gap: 6px;
    justify-items: center;
  }
  .game-column > * {
    width: 100%;
  }
  .board-header,
  .board-context {
    grid-column: 1;
    max-width: var(--board-width);
  }
  .board-header {
    min-height: 34px;
  }
  .board-title strong {
    font-size: 14px;
  }
  .chapter-chip {
    min-height: 32px;
    padding: 0 11px;
    border-radius: 10px;
  }
  .board-context {
    font-size: 11px;
    min-height: 20px;
  }
  #board-caption,
  #event-banner {
    line-height: 20px;
  }
  .arena-wrap {
    grid-row: auto;
    width: var(--board-width);
    border-radius: 16px;
    box-shadow:
      0 0 0 1px #ffffff1f,
      0 0 0 4px #0a1214,
      0 0 0 5px color-mix(in srgb, var(--accent) 24%, transparent),
      0 18px 50px #000a;
  }
  .control-deck {
    grid-column: 1;
    grid-row: auto;
    max-width: max(var(--board-width), min(100%, 420px));
    padding: 10px 2px 4px;
    gap: 8px;
    background: none;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  .console-heading,
  .score-readout,
  .telemetry {
    display: none;
  }
  .aim-control {
    grid-template-columns: auto 1fr 3em;
    gap: 8px;
    font-size: 11px;
  }
  .actions {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.7fr) auto;
  }
  .primary,
  .focus-button,
  .actions .icon-button {
    min-height: 50px;
    height: 50px;
  }
  .actions .icon-button {
    width: 50px;
  }
  .status {
    font-size: 11px;
    min-height: 18px;
  }
  .account-panel {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel);
  }
  .account-summary {
    grid-column: 1 / -1;
  }
  .account-state {
    grid-column: 1;
  }
  .leaderboard-button {
    grid-column: 2;
    grid-row: 2;
    min-height: 38px;
    padding: 0 14px;
    font-size: 12px;
  }
  .field-notes,
  footer {
    display: none;
  }
  .modal-inner {
    padding: 22px 16px 16px;
    border-radius: 22px;
  }
  .modal-inner h2 {
    font-size: 22px;
  }
  .result-stars {
    font-size: 40px;
  }
}
@media (max-width: 370px) {
  .wordmark small {
    display: none;
  }
  .chapter-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- short landscape (phones on their side, small laptops) ---------- */
@media (max-height: 600px) and (min-width: 600px) {
  .topbar {
    height: 46px;
  }
  .icon-button {
    width: 34px;
    height: 34px;
  }
  .workspace {
    padding: 6px 0 4px;
  }
  .intro,
  .field-notes,
  footer,
  .board-context {
    display: none;
  }
  .game-column {
    --board-width: calc((var(--screen-h) - 108px) * 2 / 3);
    grid-template-columns: var(--board-width) minmax(240px, 320px);
  }
  .control-deck {
    grid-row: 3;
    gap: 8px;
    padding: 12px;
  }
  .score-readout #score-count {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
