:root {
  --blue-950: #123853;
  --blue-900: #174b6a;
  --blue-800: #236f8f;
  --blue-700: #2f8fab;
  --blue-500: #54abc3;
  --blue-200: #ccebf2;
  --pink-700: #d77da0;
  --pink-500: #eda9c2;
  --pink-200: #f9dbe6;
  --cream: #fff9ee;
  --paper: rgba(255, 255, 255, 0.92);
  --paper-soft: rgba(255, 255, 255, 0.78);
  --gold: #f5bd4e;
  --success: #2ea57b;
  --danger: #c94d6a;
  --ink: #173f62;
  --muted: #698093;
  --line: rgba(47, 143, 171, 0.18);
  --shadow: 0 18px 52px rgba(20, 68, 92, 0.16);
  --shadow-small: 0 9px 24px rgba(20, 68, 92, 0.11);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --grid-size: 11;
}

* { box-sizing: border-box; }

html,
body { width: 100%; min-height: 100%; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Cairo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e8f4f4;
}

button { border: 0; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 4px solid rgba(47, 143, 171, 0.24); outline-offset: 3px; }
[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }

/* =========================================================
   Moving brand-colour background
   ========================================================= */

.world-background {
  position: fixed;
  inset: 0;
  z-index: -10;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 10%, rgba(84, 171, 195, 0.22), transparent 31%),
    radial-gradient(circle at 92% 18%, rgba(237, 169, 194, 0.24), transparent 28%),
    radial-gradient(circle at 76% 86%, rgba(245, 189, 78, 0.13), transparent 25%),
    linear-gradient(125deg, #e2f3f5 0%, #f8fbf5 48%, #fff1f4 100%);
  animation: backgroundShift 18s ease-in-out infinite alternate;
}

.world-background::before {
  content: "";
  position: absolute;
  inset: -18%;
  background-image:
    linear-gradient(rgba(23, 75, 106, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 75, 106, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  transform: rotate(-5deg);
  animation: gridDrift 28s linear infinite;
}

.world-background::after {
  content: "";
  position: absolute;
  width: 880px;
  height: 880px;
  right: -390px;
  top: 8%;
  border: 2px dashed rgba(47, 143, 171, 0.12);
  border-radius: 50%;
  box-shadow:
    0 0 0 105px rgba(47, 143, 171, 0.025),
    0 0 0 230px rgba(215, 125, 160, 0.025);
  animation: slowRotate 40s linear infinite;
}

.bg-orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(1px);
  opacity: 0.5;
  animation: orbFloat 13s ease-in-out infinite alternate;
}

.orb-a { width: 290px; height: 290px; left: -90px; top: 40%; background: rgba(84, 171, 195, 0.18); }
.orb-b { width: 360px; height: 360px; right: -110px; bottom: -80px; background: rgba(237, 169, 194, 0.18); animation-delay: -5s; }
.orb-c { width: 190px; height: 190px; left: 46%; top: -70px; background: rgba(255, 255, 255, 0.65); animation-delay: -8s; }

.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px 5px rgba(245, 189, 78, 0.25);
  animation: sparkle 4.5s ease-in-out infinite;
}
.spark-one { left: 18%; top: 20%; }
.spark-two { right: 22%; top: 12%; animation-delay: -1.5s; }
.spark-three { right: 11%; bottom: 24%; animation-delay: -3s; }
.spark-four { left: 35%; bottom: 9%; animation-delay: -2.2s; }

@keyframes backgroundShift {
  from { filter: saturate(0.94); background-position: 0 0, 0 0, 0 0, 0 0; }
  to { filter: saturate(1.06); background-position: 50px -20px, -40px 30px, 20px -25px, 0 0; }
}
@keyframes gridDrift { to { transform: translate3d(42px, 42px, 0) rotate(-5deg); } }
@keyframes slowRotate { to { transform: rotate(360deg); } }
@keyframes orbFloat { from { transform: translate3d(0, 0, 0) scale(0.92); } to { transform: translate3d(32px, -24px, 0) scale(1.08); } }
@keyframes sparkle { 0%, 100% { opacity: 0.22; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.25) translateY(-8px); } }

/* =========================================================
   Shared
   ========================================================= */

.app-shell {
  width: min(1480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px clamp(10px, 2vw, 26px) 22px;
}

.paper-card {
  border: 1px solid rgba(255, 255, 255, 0.94);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(rgba(47, 143, 171, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 143, 171, 0.028) 1px, transparent 1px),
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(255, 250, 240, 0.84));
  background-size: 22px 22px, 22px 22px, auto;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.section-kicker,
.eyebrow {
  margin: 0 0 4px;
  color: var(--pink-700);
  font-size: 12px;
  font-weight: 900;
}

.action-button,
.round-button,
.nav-button,
.compass-button,
.brand-button,
.word-token {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

.action-button:hover,
.round-button:hover,
.nav-button:hover,
.compass-button:hover,
.brand-button:hover,
.word-token:hover { transform: translateY(-2px); filter: saturate(1.08); }
.action-button:active,
.round-button:active,
.nav-button:active,
.compass-button:active,
.brand-button:active,
.word-token:active { transform: translateY(1px); }

.action-button {
  min-height: 52px;
  padding: 12px 22px;
  border-radius: 16px;
  font-weight: 900;
}
.action-button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500) 55%, var(--pink-700));
  box-shadow: 0 13px 26px rgba(47, 143, 171, 0.25);
}
.action-button-secondary {
  color: var(--blue-900);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-small);
}

/* =========================================================
   Intro — restored light identity
   ========================================================= */

.intro-screen {
  min-height: calc(100dvh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.intro-brandbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 14px 10px;
  border-bottom: 1px solid rgba(47, 143, 171, 0.25);
}

.edition-pill {
  padding: 8px 16px;
  border: 1px solid rgba(215, 125, 160, 0.25);
  border-radius: 999px;
  color: var(--pink-700);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-small);
  font-size: 12px;
  font-weight: 900;
}

.client-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
}
.client-brand div { display: grid; line-height: 1.3; }
.client-brand strong { color: var(--blue-950); font-size: 17px; font-weight: 900; }
.client-brand small { color: var(--pink-700); font-size: 10px; font-weight: 800; }
.client-brand img { width: 58px; height: 58px; object-fit: contain; }

.intro-card {
  min-height: min(810px, calc(100dvh - 128px));
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 38px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 30px 86px rgba(20, 68, 92, 0.17);
  backdrop-filter: blur(22px);
  animation: introIn 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.intro-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(34px, 6vw, 88px);
  text-align: right;
  background:
    radial-gradient(circle at 92% 18%, rgba(249, 219, 230, 0.52), transparent 28%),
    linear-gradient(145deg, rgba(255,255,255,0.85), rgba(255,250,244,0.72));
}

.intro-copy h1 {
  margin: 0;
  color: var(--blue-950);
  font-size: clamp(54px, 7vw, 90px);
  line-height: 1.04;
  font-weight: 900;
}
.intro-copy h1 span { color: var(--pink-700); position: relative; }
.intro-copy h1 span::after {
  content: "";
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 2px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-500), var(--pink-500));
  opacity: 0.5;
}

.intro-text {
  max-width: 660px;
  margin: 18px 0 0;
  color: #567186;
  font-size: clamp(16px, 1.7vw, 22px);
  line-height: 1.9;
  font-weight: 700;
}

.intro-features {
  width: min(540px, 100%);
  margin: 30px 0 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-small);
}
.intro-features div {
  padding: 14px 10px;
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--blue-900);
  background: rgba(255,255,255,0.88);
  border-inline-start: 4px solid var(--blue-500);
}
.intro-features div:nth-child(2) { border-color: var(--pink-500); }
.intro-features div:nth-child(3) { border-color: var(--gold); }
.intro-features strong { font-size: 25px; font-weight: 900; }
.intro-features span { color: var(--muted); font-size: 10px; font-weight: 800; }

.intro-visual {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(105deg, rgba(224, 241, 244, 0.72), rgba(247, 239, 244, 0.62));
  clip-path: polygon(13% 0, 100% 0, 100% 100%, 0 100%);
}

.logo-orbit {
  position: relative;
  width: min(460px, 72%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.logo-stage {
  position: relative;
  z-index: 2;
  width: 68%;
  height: 68%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.82);
  box-shadow: 0 20px 50px rgba(47, 143, 171, 0.18), inset 0 0 0 12px rgba(249,219,230,0.4);
  animation: logoFloat 5s ease-in-out infinite;
}
.logo-stage img { width: 82%; height: 82%; object-fit: contain; }
.orbit {
  position: absolute;
  inset: 7%;
  border: 2px dashed rgba(47, 143, 171, 0.28);
  border-radius: 50%;
  animation: slowRotate 20s linear infinite;
}
.orbit-two { inset: 0; border-color: rgba(215,125,160,0.2); animation-duration: 28s; animation-direction: reverse; }
.orbit-dot {
  position: absolute;
  z-index: 4;
  width: 23px;
  height: 23px;
  border: 5px solid #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-small);
}
.dot-one { top: 10%; left: 26%; background: var(--pink-700); }
.dot-two { right: 8%; bottom: 25%; background: var(--blue-700); }
.dot-three { left: 4%; bottom: 18%; background: var(--gold); }
.visual-caption {
  position: absolute;
  left: 34px;
  bottom: 32px;
  margin: 0;
  padding: 12px 18px;
  border-radius: 5px;
  color: #fff;
  background: var(--blue-900);
  box-shadow: var(--shadow-small);
  font-size: 12px;
  font-weight: 800;
  transform: rotate(-2deg);
}
.visual-caption strong { color: var(--pink-200); }

@keyframes introIn { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes logoFloat { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-9px) rotate(1deg); } }

/* =========================================================
   Game layout — light command rail version
   ========================================================= */

.game-screen {
  min-height: calc(100dvh - 36px);
  display: grid;
  grid-template-columns: 1fr 220px;
  grid-template-areas: "play rail";
  gap: 14px;
  animation: introIn 0.45s ease both;
}

.control-rail {
  grid-area: rail;
  min-height: calc(100dvh - 36px);
  position: sticky;
  top: 14px;
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  color: #fff;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--blue-950), var(--blue-800) 62%, var(--blue-700));
  box-shadow: var(--shadow);
}
.control-rail::before {
  content: "";
  position: absolute;
  width: 300px;
  height: 300px;
  left: -150px;
  top: 18%;
  border-radius: 50%;
  border: 22px solid rgba(255,255,255,0.07);
  box-shadow: 0 0 0 70px rgba(255,255,255,0.025);
}

.brand-button {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  background: transparent;
  text-align: right;
}
.brand-mark {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 9px 20px rgba(0,0,0,0.14);
}
.brand-mark img { width: 92%; height: 92%; object-fit: contain; }
.brand-copy { min-width: 0; display: grid; line-height: 1.3; }
.brand-copy strong { font-size: 17px; font-weight: 900; }
.brand-copy small { color: var(--pink-200); font-size: 10px; font-weight: 800; }
.rail-divider { position: relative; z-index: 1; height: 1px; margin: 18px 0; background: rgba(255,255,255,0.2); }

.progress-ring {
  position: relative;
  z-index: 1;
  width: 142px;
  aspect-ratio: 1;
  margin: 0 auto 18px;
}
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track,
.ring-progress { fill: none; stroke-width: 10; }
.ring-track { stroke: rgba(255,255,255,0.16); }
.ring-progress {
  stroke: var(--pink-500);
  stroke-linecap: round;
  stroke-dasharray: 307.88;
  stroke-dashoffset: 307.88;
  transition: stroke-dashoffset 0.45s ease;
}
.ring-copy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring-copy strong { font-size: 31px; line-height: 1; font-weight: 900; }
.ring-copy span { margin-top: 5px; color: rgba(255,255,255,0.78); font-size: 10px; font-weight: 800; }

.rail-progress { position: relative; z-index: 1; }
.rail-progress > span { color: var(--pink-200); font-size: 12px; font-weight: 900; }
.mission-track {
  height: 7px;
  margin: 8px 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
}
.mission-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-200), var(--pink-500)); transition: width 0.45s ease; }
.rail-progress p { min-height: 38px; margin: 0 0 12px; color: rgba(255,255,255,0.86); font-size: 10px; line-height: 1.7; font-weight: 700; }

.header-stats { position: relative; z-index: 1; display: grid; gap: 8px; }
.stat-box {
  min-height: 46px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
}
.stat-box span { font-size: 9px; font-weight: 800; }
.stat-box strong { font-size: 15px; font-weight: 900; }
.stat-box b { font: inherit; }

.header-actions { position: relative; z-index: 1; margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.round-button {
  min-height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--blue-950);
  background: #fff;
  box-shadow: var(--shadow-small);
  font-size: 18px;
}

.play-zone {
  grid-area: play;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.mission-card {
  min-height: 150px;
  display: grid;
  grid-template-columns: 0.78fr 1.22fr;
  overflow: hidden;
}
.mission-summary {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(145deg, rgba(224,243,246,0.84), rgba(249,219,230,0.34));
  border-inline-end: 1px dashed rgba(47,143,171,0.28);
}
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-title-row h2,
.board-heading h2 { margin: 0; color: var(--blue-950); font-size: 19px; font-weight: 900; }
.mission-number {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, var(--blue-700), var(--pink-700));
  box-shadow: var(--shadow-small);
  font-size: 21px;
  font-weight: 900;
}

.compass-button {
  width: max-content;
  max-width: 100%;
  margin-top: 14px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(245,189,78,0.55);
  border-radius: 13px;
  color: #68470a;
  background: linear-gradient(145deg, #fff9dc, #ffe8a6);
  box-shadow: 0 8px 18px rgba(197,139,25,0.13);
  text-align: right;
}
.compass-button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.compass-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--pink-700);
  font-size: 18px;
}
.compass-button span:last-child { display: grid; line-height: 1.35; }
.compass-button strong { font-size: 11px; font-weight: 900; }
.compass-button small { font-size: 8px; font-weight: 800; }

.clue-card {
  position: relative;
  min-width: 0;
  padding: 22px 28px 14px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  background: rgba(255,255,255,0.78);
}
.quote-mark { position: absolute; top: 6px; left: 18px; color: var(--pink-200); font-size: 74px; font-weight: 900; line-height: 1; }
.clue-card > p { position: relative; z-index: 1; margin: 0; color: #45687f; font-size: clamp(13px, 1.3vw, 17px); line-height: 1.8; font-weight: 800; }
.answer-mask { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; direction: rtl; }
.mask-letter {
  width: 34px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(47,143,171,0.22);
  border-radius: 9px;
  color: transparent;
  background: rgba(232,247,248,0.85);
  font-size: 17px;
  font-weight: 900;
}
.mask-letter.revealed { color: var(--blue-950); background: rgba(220,245,235,0.94); animation: popIn 0.35s ease both; }

.clue-navigation { margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; direction: ltr; }
.nav-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--blue-900);
  background: #fff;
  box-shadow: var(--shadow-small);
  font-size: 16px;
}
.clue-dots { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; }
.clue-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 999px;
  background: #cee6eb;
  cursor: pointer;
  transition: width 0.22s ease, background 0.22s ease, transform 0.22s ease;
}
.clue-dot.active { width: 28px; background: var(--pink-700); }
.clue-dot.found { background: var(--success); }

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-areas: "vault board";
  gap: 14px;
}

.vault-stack { grid-area: vault; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; }
.vault-card { min-height: 0; padding: 18px; }
.compact-title { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.compact-title small { color: var(--muted); font-size: 8px; font-weight: 700; }
.word-vault {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  align-content: start;
}
.word-token {
  position: relative;
  min-height: 40px;
  padding: 8px 20px 8px 8px;
  overflow: hidden;
  border: 1px solid rgba(47,143,171,0.16);
  border-radius: 10px;
  color: var(--blue-900);
  background: rgba(255,255,255,0.9);
  box-shadow: 0 5px 13px rgba(20,68,92,0.07);
  font-size: 11px;
  font-weight: 900;
}
.word-token::before {
  content: "";
  position: absolute;
  right: 9px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pink-500);
  transform: translateY(-50%);
}
.word-token.active { color: var(--pink-700); border-color: rgba(215,125,160,0.45); background: rgba(255,239,246,0.94); }
.word-token.found { color: #287d65; border-color: rgba(46,165,123,0.35); background: rgba(220,245,235,0.92); }
.word-token.found::before { content: "✓"; width: 20px; height: 20px; display: grid; place-items: center; color: #fff; background: var(--success); font-size: 12px; }

.secret-box { padding: 16px; background: linear-gradient(145deg, rgba(255,242,247,0.9), rgba(255,255,255,0.92)); }
.secret-heading { display: flex; align-items: center; gap: 10px; }
.lock-badge { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: #fff; box-shadow: var(--shadow-small); }
.secret-heading div { display: grid; line-height: 1.45; }
.secret-heading span { color: var(--pink-700); font-size: 9px; font-weight: 900; }
.secret-heading strong { color: var(--blue-950); font-size: 10px; font-weight: 900; }
.secret-word { margin-top: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; direction: rtl; }
.secret-letter { width: 31px; height: 37px; display: grid; place-items: center; border: 1px solid rgba(47,143,171,0.18); border-radius: 9px; color: transparent; background: rgba(255,255,255,0.9); font-size: 16px; font-weight: 900; }
.secret-letter.revealed { color: var(--blue-950); border-color: rgba(215,125,160,0.4); background: rgba(255,237,245,0.96); animation: popIn 0.38s ease both; }
.micro-tip { margin: 10px 0 0; color: var(--muted); font-size: 8px; line-height: 1.6; font-weight: 700; text-align: center; }

.board-card { grid-area: board; min-width: 0; min-height: 0; padding: 18px; display: flex; flex-direction: column; }
.board-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 11px; }
.direction-key { display: flex; gap: 6px; direction: ltr; }
.direction-key span { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--blue-700); background: #fff; font-size: 14px; font-weight: 900; }

.grid-frame {
  position: relative;
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: hidden;
  border: 1px solid rgba(47,143,171,0.18);
  border-radius: 19px;
  background:
    radial-gradient(circle at 20% 16%, rgba(255,255,255,0.96), transparent 29%),
    linear-gradient(145deg, rgba(222,242,245,0.74), rgba(249,232,240,0.55));
}
.corner { position: absolute; width: 44px; height: 44px; pointer-events: none; }
.corner-tl { top: 10px; left: 10px; border-top: 4px solid var(--blue-700); border-left: 4px solid var(--blue-700); }
.corner-tr { top: 10px; right: 10px; border-top: 4px solid var(--pink-700); border-right: 4px solid var(--pink-700); }
.corner-bl { bottom: 10px; left: 10px; border-bottom: 4px solid var(--pink-700); border-left: 4px solid var(--pink-700); }
.corner-br { bottom: 10px; right: 10px; border-bottom: 4px solid var(--blue-700); border-right: 4px solid var(--blue-700); }

.letter-grid {
  --available-grid: min(68dvh, 700px);
  width: min(100%, var(--available-grid));
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-size), minmax(0, 1fr));
  gap: 5px;
  direction: ltr;
  user-select: none;
  touch-action: none;
}
.letter-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(47,143,171,0.19);
  border-radius: 9px;
  color: var(--blue-950);
  background: rgba(255,255,255,0.93);
  box-shadow: 0 4px 10px rgba(28,89,112,0.09), inset 0 -3px 0 rgba(47,143,171,0.04);
  font-size: clamp(15px, 1.8vw, 24px);
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.13s ease, color 0.13s ease, background 0.13s ease, box-shadow 0.13s ease;
}
.letter-cell:hover { transform: translateY(-1px); background: #fff; }
.letter-cell.is-selected { z-index: 3; color: #fff; background: linear-gradient(145deg, var(--blue-700), var(--pink-700)); box-shadow: 0 7px 16px rgba(47,143,171,0.25); transform: scale(1.04); }
.letter-cell.is-found { color: #236b57; border-color: rgba(46,165,123,0.4); background: linear-gradient(145deg, rgba(205,243,229,0.98), #fff); animation: cellFound 0.42s ease both; }
.letter-cell.is-hint-start,
.letter-cell.is-hint-next,
.letter-cell.is-hint-end { z-index: 4; color: var(--blue-950); border-color: rgba(245,189,78,0.9); background: #fff0ae; box-shadow: 0 0 0 5px rgba(245,189,78,0.2), 0 8px 20px rgba(174,119,13,0.2); animation: hintPulse 0.9s ease-in-out infinite; }
.letter-cell.is-hint-start::after,
.letter-cell.is-hint-next::after,
.letter-cell.is-hint-end::after {
  position: absolute;
  top: -8px;
  right: -7px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--pink-700);
  font-size: 9px;
  font-weight: 900;
}
.letter-cell.is-hint-start::after { content: "1"; }
.letter-cell.is-hint-next::after { content: "2"; background: var(--blue-700); }
.letter-cell.is-hint-end::after { content: "★"; color: #604408; background: var(--gold); }
.selection-status { min-height: 24px; margin-top: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 10px; font-weight: 900; text-align: center; }
.selection-status.success { color: var(--success); }
.selection-status.error { color: var(--danger); }

@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(0.8); } to { opacity: 1; transform: none; } }
@keyframes cellFound { 0% { transform: scale(0.82) rotate(-4deg); } 70% { transform: scale(1.1) rotate(2deg); } 100% { transform: none; } }
@keyframes hintPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08) translateY(-2px); } }

/* =========================================================
   Toast and modal
   ========================================================= */

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: 18px;
  min-width: min(330px, calc(100vw - 24px));
  max-width: min(560px, calc(100vw - 24px));
  padding: 12px 17px;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 15px;
  color: #fff;
  background: rgba(18,56,83,0.94);
  box-shadow: 0 18px 38px rgba(18,56,83,0.25);
  backdrop-filter: blur(14px);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.success { background: rgba(32,130,97,0.95); }
.toast.error { background: rgba(190,69,95,0.95); }
.toast.hint { background: rgba(126,87,13,0.95); }

.win-modal { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,49,68,0.62); backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.28s ease; }
.win-card {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: 92dvh;
  padding: 25px;
  overflow-y: auto;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.95);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(255,255,255,0.98), rgba(255,245,248,0.96));
  box-shadow: 0 30px 85px rgba(14,48,67,0.3);
  opacity: 0;
  transform: translateY(22px) scale(0.93);
  transition: opacity 0.28s ease, transform 0.34s cubic-bezier(0.2,0.85,0.2,1);
}
.win-modal.open .modal-backdrop { opacity: 1; }
.win-modal.open .win-card { opacity: 1; transform: none; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--blue-950); background: #fff; box-shadow: var(--shadow-small); cursor: pointer; font-size: 25px; }
.win-emblem { width: 92px; height: 92px; margin: 0 auto 8px; display: grid; place-items: center; border-radius: 50%; background: #fff; box-shadow: var(--shadow); }
.win-emblem img { width: 88%; height: 88%; object-fit: contain; }
.win-card h2 { margin: 4px 0 6px; color: var(--blue-950); font-size: 31px; font-weight: 900; }
.win-copy, .closing-message { color: var(--muted); font-size: 13px; line-height: 1.8; font-weight: 700; }
.final-secret { margin: 16px 0; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(204,235,242,0.7), rgba(249,219,230,0.7)); }
.final-secret span { display: block; color: var(--pink-700); font-size: 10px; font-weight: 900; }
.final-secret strong { color: var(--blue-950); font-size: 28px; font-weight: 900; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-grid div { padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,0.86); }
.result-grid span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; }
.result-grid strong { color: var(--blue-950); font-size: 17px; font-weight: 900; }
.win-actions { display: flex; justify-content: center; gap: 9px; }
.confetti-piece { position: fixed; z-index: 130; top: -18px; width: 10px; height: 16px; border-radius: 3px; pointer-events: none; animation: confettiFall var(--duration) linear forwards; }
@keyframes confettiFall { from { opacity: 1; transform: translate3d(0,-20px,0) rotate(0); } to { opacity: 0.85; transform: translate3d(var(--drift),110vh,0) rotate(var(--rotation)); } }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1120px) {
  .game-screen { grid-template-columns: 1fr; grid-template-areas: "rail" "play"; }
  .control-rail { min-height: auto; position: static; display: grid; grid-template-columns: minmax(220px,1fr) 130px minmax(220px,1fr) auto; align-items: center; gap: 14px; }
  .rail-divider { display: none; }
  .progress-ring { width: 112px; margin: 0 auto; }
  .ring-copy strong { font-size: 25px; }
  .header-stats { grid-template-columns: repeat(3, 1fr); }
  .header-actions { margin: 0; align-self: stretch; grid-template-columns: 48px; }
  .round-button { min-height: 42px; }
  .play-zone { grid-template-rows: auto auto; }
}

@media (max-width: 860px) {
  .app-shell { padding: 8px; }
  .intro-card { grid-template-columns: 1fr; }
  .intro-visual { min-height: 370px; clip-path: none; order: -1; }
  .intro-copy { align-items: center; text-align: center; padding: 34px 20px 44px; }
  .intro-features { margin-inline: auto; }
  .intro-brandbar { padding-inline: 4px; }

  .control-rail { grid-template-columns: 1fr 112px; }
  .rail-progress { grid-column: 1 / -1; order: 3; }
  .header-stats { grid-column: 1 / -1; order: 4; }
  .header-actions { position: absolute; top: 15px; left: 15px; display: flex; }
  .control-rail { position: relative; }

  .mission-card { grid-template-columns: 1fr; }
  .mission-summary { border-inline-end: 0; border-bottom: 1px dashed rgba(47,143,171,0.28); }
  .game-layout { grid-template-columns: 1fr; grid-template-areas: "board" "vault"; }
  .board-card { order: -1; }
  .vault-stack { grid-template-rows: auto auto; }
  .word-vault { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .letter-grid { --available-grid: min(78dvh, calc(100vw - 76px), 680px); }
}

@media (max-width: 560px) {
  .intro-brandbar { min-height: 58px; }
  .client-brand strong { font-size: 13px; }
  .client-brand img { width: 45px; height: 45px; }
  .edition-pill { padding: 6px 10px; font-size: 9px; }
  .intro-card { border-radius: 25px; }
  .intro-visual { min-height: 300px; }
  .intro-copy h1 { font-size: 51px; }
  .intro-text { font-size: 14px; }
  .intro-features { grid-template-columns: 1fr; }
  .intro-features div { grid-template-columns: auto 1fr; justify-content: center; gap: 8px; }

  .control-rail { padding: 13px 10px; border-radius: 19px; grid-template-columns: 1fr 86px; }
  .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
  .brand-copy strong { font-size: 14px; }
  .progress-ring { width: 84px; }
  .ring-copy strong { font-size: 19px; }
  .ring-copy span { font-size: 8px; }
  .header-actions { top: 10px; left: 10px; }
  .round-button { width: 38px; min-height: 38px; }
  .header-stats { gap: 5px; }
  .stat-box { min-height: 42px; padding: 7px; display: grid; text-align: center; }

  .mission-card, .board-card, .vault-card, .secret-box { border-radius: 20px; }
  .mission-summary, .clue-card, .board-card, .vault-card, .secret-box { padding: 13px; }
  .mission-number { width: 50px; height: 50px; border-radius: 15px; font-size: 17px; }
  .card-title-row h2, .board-heading h2 { font-size: 15px; }
  .clue-card > p { font-size: 12px; }
  .mask-letter { width: 29px; height: 34px; }
  .word-vault { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
  .word-token { min-height: 38px; font-size: 10px; }
  .grid-frame { padding: 16px 8px; }
  .letter-grid { --available-grid: calc(100vw - 48px); gap: 3px; }
  .letter-cell { border-radius: 6px; font-size: clamp(12px, 4vw, 17px); }
  .corner { width: 30px; height: 30px; }
  .result-grid { grid-template-columns: 1fr; }
  .win-actions { display: grid; }
}

@media (max-height: 760px) and (min-width: 1121px) {
  .app-shell { padding-top: 8px; padding-bottom: 8px; }
  .game-screen { min-height: calc(100dvh - 16px); }
  .control-rail { min-height: calc(100dvh - 16px); top: 8px; }
  .mission-card { min-height: 126px; }
  .mission-summary { padding: 14px 18px; }
  .clue-card { padding-top: 14px; padding-bottom: 9px; }
  .progress-ring { width: 120px; margin-bottom: 9px; }
  .letter-grid { --available-grid: min(62dvh, 590px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* =========================================================
   Arabic / English language controls and LTR support
   ========================================================= */

.intro-tools {
  display: flex;
  align-items: center;
  gap: 9px;
}

.language-toggle {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid rgba(47, 143, 171, 0.22);
  border-radius: 12px;
  color: var(--blue-900);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-small);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.language-toggle:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
}

.language-toggle:active {
  transform: translateY(1px);
}

.header-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rail-language {
  min-width: 0;
  min-height: 46px;
  padding-inline: 6px;
  border: 0;
}

html[dir="ltr"] .client-brand,
html[dir="ltr"] .brand-button,
html[dir="ltr"] .compass-button {
  text-align: left;
}

html[dir="ltr"] .intro-copy {
  align-items: flex-start;
  text-align: left;
}

html[dir="ltr"] .intro-copy h1 {
  font-size: clamp(46px, 6.2vw, 80px);
}

html[dir="ltr"] .answer-mask,
html[dir="ltr"] .secret-word {
  direction: ltr;
}

html[dir="ltr"] .quote-mark {
  left: auto;
  right: 18px;
}

html[dir="ltr"] .modal-close {
  right: auto;
  left: 12px;
}

html[dir="ltr"] .letter-cell {
  font-size: clamp(10px, 1.15vw, 17px);
}

html[dir="ltr"] .word-token {
  white-space: normal;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .header-actions {
    grid-template-columns: repeat(3, 48px);
  }
}

@media (max-width: 860px) {
  html[dir="ltr"] .intro-copy {
    align-items: center;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .intro-tools {
    gap: 5px;
  }

  .language-toggle {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 9px;
  }

  .rail-language {
    min-height: 38px;
  }

  html[dir="ltr"] .intro-copy h1 {
    font-size: 43px;
  }

  html[dir="ltr"] .letter-cell {
    font-size: clamp(9px, 2.75vw, 13px);
  }
}
