:root {
  --bg: #0c0a09;
  --surface: #161210;
  --surface-2: #1f1a17;
  --line: #2e2723;
  --text: #ece6e1;
  --muted: #a39a93;
  --accent: #c0322b;
  --danger: #ff6b5e;
  --radius: 14px;
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Noto Kufi Arabic", var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
}

/* A faint light behind the page, tinted by the game's colour. */
.glow {
  position: fixed;
  inset: -20vh -10vw auto;
  height: 70vh;
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; }

.top, main { position: relative; z-index: 1; }

.top {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .02em;
  text-decoration: none;
  color: var(--muted);
}

.lang {
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
}
.lang:hover { color: var(--text); border-color: var(--muted); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1 {
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.3;
  margin: 0 0 8px;
}

.hero { padding: 40px 0 28px; }
.hero h1 { font-size: clamp(34px, 8vw, 52px); }

.lead { color: var(--muted); margin: 0; font-size: 18px; }

/* ---------- home: the list of games ---------- */

.games { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }

.game {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .2s, transform .2s, background .2s;
}
.game:hover, .game:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  transform: translateY(-2px);
}
.game img { border-radius: 18px; flex: none; background: #000; }
.game-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.game-name { font-family: var(--display); font-weight: 600; font-size: 20px; }
.game-tag { color: var(--muted); font-size: 15px; }
.arrow { color: var(--accent); font-size: 22px; }

/* ---------- a game's form ---------- */

.game-head { display: flex; align-items: center; gap: 18px; padding: 24px 0 24px; }
.game-head img { border-radius: 20px; flex: none; background: #000; box-shadow: 0 10px 40px color-mix(in srgb, var(--accent) 30%, transparent); }
.game-head h1 { font-size: clamp(26px, 6vw, 36px); margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 24px;
}

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend, .label { font-weight: 600; margin-bottom: 10px; padding: 0; display: block; }
small { color: var(--muted); font-weight: 400; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip span:hover { border-color: var(--muted); }
.chip input:checked + span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
}
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Stars: the inputs run 5 to 1, and row-reverse puts 1 at the start in
   either direction, so "this one and the ones before it" light up. */
.stars { display: inline-flex; flex-direction: row-reverse; gap: 4px; }
.stars input { position: absolute; opacity: 0; pointer-events: none; }
.stars label {
  width: 42px;
  height: 42px;
  cursor: pointer;
  background: var(--line);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: background .12s;
}
.stars input:checked ~ label,
.stars label:hover,
.stars label:hover ~ label { background: #e8b04a; }
.stars:hover input:checked ~ label:not(:hover):not(:hover ~ label) { background: var(--line); }
.stars input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.field { display: block; }
textarea, input[type="email"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .15s;
}
textarea { resize: vertical; min-height: 140px; }
textarea::placeholder { color: #6f6660; }
textarea:focus, input[type="email"]:focus { outline: none; border-color: var(--accent); }
input[type="email"] { text-align: start; }
[dir="rtl"] input[type="email"] { text-align: right; }

button, .button {
  font: inherit;
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  padding: 14px 24px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: filter .15s, transform .1s;
}
button:hover, .button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }

.error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: #ffd2cd;
}

/* Hidden from people; bots fill it in. */
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.back { margin-top: 20px; }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--text); }

.done { text-align: center; justify-items: center; padding: 40px 24px; margin-top: 32px; gap: 14px; }
.done img { border-radius: 20px; }
.done h1 { font-size: 30px; margin: 6px 0 0; }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .card { padding: 18px; }
  .game img { width: 72px; height: 72px; border-radius: 14px; }
  .game-head img { width: 72px; height: 72px; }
  button[type="submit"] { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
