/*! (c) 2026 Apex Infra. All rights reserved. Copying, republishing or hosting this work elsewhere is not permitted. */
:root {
  /* Layout: one narrow column. Title and scores share the first row, then the
     controls, a square 4x4 board, and the item chain. One night-desert theme. */
  --night: #0F1F33;
  --dune: #1B3350;
  --cell: #26476B;
  --sand: #F3E6CC;
  --mist: #A9BCD0;
  --saffron: #F2A541;
  --font-display: "Reem Kufi", "Noto Kufi Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: radial-gradient(120% 55% at 85% -10%, #21405F 0%, var(--night) 62%) no-repeat, var(--night);
  color: var(--sand);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 460px;
  min-height: 100%;
  margin: 0 auto;
  padding: 20px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.alt {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--mist);
}

.scores { display: flex; gap: 8px; }

.scorebox {
  min-width: 68px;
  padding: 6px 12px 7px;
  border-radius: 10px;
  background: var(--dune);
  text-align: center;
}

.scorebox .label {
  display: block;
  font-size: 11px;
  color: var(--mist);
}

.scorebox strong {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tagline {
  margin: 0;
  font-size: 14px;
  color: var(--mist);
  max-width: 46ch;
}

.controls { display: flex; gap: 8px; flex-wrap: wrap; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}

.btn-primary { background: var(--saffron); color: #2B1B00; }
.btn-quiet {
  background: transparent;
  color: var(--sand);
  box-shadow: inset 0 0 0 1.5px #3F6088;
}

button:focus-visible,
.board:focus-visible {
  outline: 3px solid var(--sand);
  outline-offset: 3px;
}

.board {
  --g: 2.4%;
  --s: calc((100% - 5 * var(--g)) / 4);
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  background: var(--dune);
  overflow: hidden;
  direction: ltr;
  container-type: inline-size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cell, .tile {
  position: absolute;
  width: var(--s);
  height: var(--s);
  border-radius: 10px;
}

.cell { background: var(--cell); }

.tile {
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2cqw;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
  transition: left 110ms ease, top 110ms ease;
}

.tile .glyph { font-size: 10cqw; line-height: 1; }

.tile .name {
  font-family: var(--font-display);
  font-size: 3.7cqw;
  font-weight: 700;
  line-height: 1.1;
}

.tile.glow {
  box-shadow: 0 0 0 2px var(--sand), 0 0 22px rgba(242, 165, 65, 0.6);
}

.tile.dying { z-index: 1; }
.tile.spawn { animation: appear 160ms ease-out both; }
.tile.pop { z-index: 3; animation: pop 210ms 90ms ease-out both; }

@keyframes appear {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile.spawn, .tile.pop { animation: none; }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  background: rgba(15, 31, 51, 0.9);
}

.overlay h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.2;
  text-wrap: balance;
}

.overlay p { margin: 0 0 6px; color: var(--mist); max-width: 30ch; }

.hint { margin: 0; font-size: 13px; color: var(--mist); }

.chain h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mist);
}

.chain ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chain li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--dune);
  font-size: 12.5px;
  opacity: 0.4;
}

.chain li.reached { opacity: 1; }
.chain li.goal { box-shadow: inset 0 0 0 1.5px var(--saffron); }

.foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 12.5px;
  color: var(--mist);
}

.foot a { color: var(--sand); text-underline-offset: 3px; }
.foot a:focus-visible { outline: 3px solid var(--sand); outline-offset: 3px; border-radius: 4px; }
.foot .rights { flex-basis: 100%; }

.noscript { padding: 12px 16px; background: var(--dune); border-radius: 10px; }

/* Small Arabic labels read better in the text face than in the display face. */
html[lang="ar"] .tile .name { font-family: var(--font-body); font-weight: 600; font-size: 4.2cqw; }
