/* سنيك أورايوس — Snake Uraeus · visual language per spec §11 */
:root {
  --ink: #0A0A0C;
  --grid: #1A1A22;
  --obs-fill: #12121A;
  --gold-hi: #F2D48A;
  --gold-lo: #8A6A22;
  --gold: #FFD166;
  --text: #EDEAE3;
  --green: #35C4A0;
  --blue: #3D7BFF;
  --silver: #E6EAF2;
  --purple: #A855F7;
  --num-font: "Space Grotesk", monospace;
  --ar-font: "Cairo", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--ar-font);
  direction: rtl;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
#stage { position: fixed; inset: 0; }
#game { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }

/* film grain + vignette (broadcast look) */
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.38) 100%);
}
#grain {
  position: absolute; inset: -50%; pointer-events: none; z-index: 4; opacity: .03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='128' height='128'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='128' height='128' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 700ms steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); } 25% { transform: translate(-2%,1%); }
  50% { transform: translate(1%,-2%); } 75% { transform: translate(-1%,2%); } 100% { transform: translate(0,0); }
}

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; right: 0; left: 0; z-index: 10;
  display: none; flex-direction: column; gap: 6px;
  padding: calc(6px + env(safe-area-inset-top)) 54px 0;
  pointer-events: none;
}
#hud.on { display: flex; }
#hud-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#hud-score {
  font-family: var(--num-font); font-weight: 700; font-size: 30px;
  color: var(--gold-hi); font-variant-numeric: tabular-nums; line-height: 1;
}
#hud-combo {
  font-family: var(--num-font); font-size: 17px; font-weight: 700;
  color: var(--text); font-variant-numeric: tabular-nums; min-width: 44px;
}
.hud-stat { font-size: 11px; color: rgba(237,234,227,.62); display: flex; gap: 4px; align-items: baseline; }
.hud-stat b { font-family: var(--num-font); font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
#hud-code {
  flex-basis: 100%; margin-inline-start: 0; font-family: var(--num-font); font-size: 11px;
  letter-spacing: .08em; color: rgba(237,234,227,.55); font-variant-numeric: tabular-nums;
}
#combo-track { height: 3px; background: rgba(237,234,227,.1); border-radius: 2px; overflow: hidden; }
#combo-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); }

/* skill bar (acquired item levels) */
#skills { display: flex; gap: 8px; min-height: 22px; }
.skill {
  display: none; align-items: center; gap: 4px; font-size: 11px;
  background: rgba(18,18,26,.72); border: 1px solid rgba(242,212,138,.14);
  border-radius: 6px; padding: 2px 7px;
}
.skill.on { display: flex; }
.skill .dot { width: 8px; height: 8px; border-radius: 50%; }
.skill .pips { display: flex; gap: 2px; }
.skill .pip { width: 5px; height: 5px; border-radius: 1px; background: rgba(237,234,227,.18); }
.skill .pip.full { background: var(--text); }

/* the rail: a strip beside the field that holds the minimap, so nothing is
   ever drawn on top of the play area */
#rail {
  position: absolute; z-index: 9; top: 0; bottom: 0; right: 0;
  width: var(--rail, 86px); display: none;
  background: linear-gradient(90deg, rgba(18,18,26,.45), rgba(10,10,12,.96));
  border-left: 1px solid rgba(242,212,138,.12);
}
body.in-game #rail { display: block; }
#minimap {
  position: absolute; z-index: 10; right: 9px; top: 50%; transform: translateY(-50%);
  width: calc(var(--rail, 86px) - 18px); height: calc(var(--rail, 86px) - 18px);
  border-radius: 6px; border: 1px solid rgba(242,212,138,.16);
  background: rgba(10,10,12,.85); display: none;
}
#minimap.on { display: block; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 110%, rgba(138,106,34,.14), transparent 60%), rgba(10,10,12,.88);
}
.screen.on { display: flex; }
/* the logo drop-in slot: replace this div's contents with the real mark */
#logo-slot { min-height: 8px; }
.wordmark-latin {
  font-family: var(--num-font); font-weight: 700; font-size: 15px;
  letter-spacing: .42em; color: rgba(242,212,138,.75); text-indent: .42em;
}
.wordmark-ar {
  font-family: var(--ar-font); font-weight: 800; font-size: 46px; line-height: 1.15;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.board-chip {
  font-family: var(--num-font); font-size: 13px; letter-spacing: .1em;
  color: rgba(237,234,227,.6); font-variant-numeric: tabular-nums;
}
.board-chip b { color: var(--gold-hi); font-weight: 700; }
#countdown { font-family: var(--num-font); font-size: 12px; color: rgba(237,234,227,.45); font-variant-numeric: tabular-nums; }
.btn {
  pointer-events: auto; cursor: pointer; border: 0; border-radius: 10px;
  font-family: var(--ar-font); font-weight: 800; color: #0A0A0C;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  padding: 16px 54px; font-size: 21px; box-shadow: 0 6px 24px rgba(138,106,34,.35);
}
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent; color: var(--text); box-shadow: none;
  border: 1px solid rgba(242,212,138,.28); font-size: 15px; padding: 11px 26px; font-weight: 700;
}
.link-like { color: rgba(237,234,227,.55); font-size: 13px; text-decoration: underline; background: none; border: 0; cursor: pointer; }
.hint { font-size: 12.5px; color: rgba(237,234,227,.5); line-height: 1.8; max-width: 320px; }
#code-row { display: flex; gap: 8px; direction: ltr; }
#code-input {
  font-family: var(--num-font); font-size: 15px; letter-spacing: .12em; text-transform: uppercase;
  background: rgba(18,18,26,.9); border: 1px solid rgba(242,212,138,.22); color: var(--text);
  border-radius: 8px; padding: 10px 14px; width: 172px; text-align: center; outline: none;
}
#code-msg { font-size: 12px; color: var(--gold); min-height: 16px; }

/* death screen numbers */
#death .big {
  font-family: var(--num-font); font-weight: 700; font-size: 76px; line-height: 1;
  color: var(--gold-hi); font-variant-numeric: tabular-nums;
}
#death .sub { font-size: 14px; color: rgba(237,234,227,.65); }
#death .sub b { color: var(--text); font-family: var(--num-font); font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(3, auto); gap: 10px 26px; margin: 4px 0 8px; }
.stat-grid .cell { display: flex; flex-direction: column; gap: 2px; }
.stat-grid .k { font-size: 11px; color: rgba(237,234,227,.5); }
.stat-grid .v { font-family: var(--num-font); font-weight: 700; font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.training-tag {
  display: none; font-size: 11px; color: var(--purple); border: 1px solid rgba(168,85,247,.4);
  border-radius: 6px; padding: 2px 10px;
}
.training-tag.on { display: block; }

/* settings */
#settings .panel { display: flex; flex-direction: column; gap: 20px; width: min(340px, 92vw); }
.set-group { text-align: start; }
.set-label { font-size: 13px; color: rgba(237,234,227,.6); margin-bottom: 8px; }
.set-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opt {
  border: 1px solid rgba(242,212,138,.22); background: rgba(18,18,26,.8); color: var(--text);
  border-radius: 8px; padding: 9px 16px; font-family: var(--ar-font); font-size: 14px; font-weight: 700; cursor: pointer;
}
.opt.sel { background: linear-gradient(180deg, rgba(242,212,138,.22), rgba(138,106,34,.22)); border-color: var(--gold-hi); }
.skin-prev { width: 64px; height: 40px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.skin-prev.sel { border-color: var(--gold-hi); }

/* corner buttons */
.corner-btn {
  position: absolute; z-index: 30; top: calc(10px + env(safe-area-inset-top));
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(242,212,138,.22);
  background: rgba(18,18,26,.72); color: var(--text); font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#btn-mute { inset-inline-end: 12px; }
#btn-settings { inset-inline-start: 12px; }
/* the size toggle: same control everywhere, label always says what pressing it does */
#btn-size {
  inset-inline-end: 12px; top: calc(58px + env(safe-area-inset-top));
  width: auto; min-width: 0; padding: 0 12px; border-radius: 20px;
  font-size: 12px; gap: 5px; white-space: nowrap;
}
body.in-game #btn-size { top: calc(154px + env(safe-area-inset-top)); }
body.vw-compact #btn-size { font-size: 11px; padding: 0 9px; }

/* share card preview */
#card-overlay { z-index: 40; background: rgba(10,10,12,.94); }
#card-img { max-height: 62vh; max-width: 86vw; border-radius: 10px; border: 1px solid rgba(242,212,138,.2); }
.card-fmt { display: flex; gap: 8px; }
.toast {
  position: absolute; z-index: 50; bottom: 18vh; right: 50%; transform: translateX(50%);
  background: rgba(18,18,26,.95); border: 1px solid rgba(242,212,138,.3); color: var(--text);
  border-radius: 8px; padding: 10px 20px; font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.on { opacity: 1; }

/* ---------- steering wheel + boost (default control) ---------- */
#wheel {
  position: absolute; z-index: 11; width: 132px; height: 132px; border-radius: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom)); display: none;
  border: 2px solid rgba(242,212,138,.30);
  background: radial-gradient(circle at 50% 50%, rgba(18,18,26,.62) 38%, rgba(18,18,26,.24) 100%);
  touch-action: none;
}
#wheel.on { display: block; }
#wheel-rot { position: absolute; inset: 0; border-radius: 50%; }
#wheel-spoke {
  position: absolute; left: 50%; top: 7px; width: 6px; height: 36px; margin-left: -3px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  border-radius: 3px;
}
#wheel-cap {
  position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--gold-hi), var(--gold-lo));
  opacity: .9;
}
#boost-btn {
  position: absolute; z-index: 11; width: 88px; height: 88px; border-radius: 50%; display: none;
  bottom: calc(16px + env(safe-area-inset-bottom));
  border: 2px solid rgba(255,209,102,.45); color: var(--gold-hi);
  font-family: var(--ar-font); font-weight: 800; font-size: 12px;
  align-items: center; justify-content: center; flex-direction: column; gap: 0;
  background: radial-gradient(circle at 50% 38%, rgba(255,209,102,.26), rgba(18,18,26,.88));
  touch-action: none;
}
#boost-btn.on { display: flex; }
#boost-btn.firing { background: radial-gradient(circle at 50% 38%, rgba(255,209,102,.6), rgba(120,80,10,.92)); }
#boost-btn.empty { border-color: rgba(237,234,227,.16); color: rgba(237,234,227,.35); }
#boost-ico { font-size: 20px; line-height: 1; }
#boost-count { font-family: var(--num-font); font-size: 15px; font-weight: 700; }
#hud-spd.boost { color: var(--gold); }

/* wide view (real landscape or the turned field): tighter HUD */
body.vw-compact #hud { padding: calc(4px + env(safe-area-inset-top)) 128px 0; }
body.in-game #hud { padding-right: calc(var(--rail, 86px) + 16px); }
body.vw-compact #hud-score { font-size: 26px; }
body.vw-compact #minimap { border-radius: 5px; }

/* the turned field: stage swaps its box and turns 90 degrees clockwise */
body.rot #stage {
  inset: auto; top: 0; left: 0; width: var(--sh); height: var(--sw);
  transform-origin: 0 0; transform: translateX(var(--sw)) rotate(90deg);
}

/* view buttons: only while playing, stacked under mute, clear of wheel and boost */
#btn-rot, #btn-zoom { display: none; inset-inline-end: 12px; }
#btn-rot { top: calc(58px + env(safe-area-inset-top)); }
#btn-zoom { top: calc(106px + env(safe-area-inset-top)); }
body.in-game #btn-rot, body.in-game #btn-zoom { display: flex; }

/* screens scroll with touch when the content is taller than the screen */
.screen { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; justify-content: center; justify-content: safe center; }
.screen::-webkit-scrollbar { display: none; }
#settings { justify-content: flex-start; padding: calc(60px + env(safe-area-inset-top)) 18px 48px; }

/* ---------- landscape phone: menus must fit 390px of height ---------- */
.screen > * { flex-shrink: 0; }
@media (orientation: landscape) and (max-height: 520px) {
  .screen { gap: 8px; padding: 10px 18px; }
  #logo-slot { min-height: 0; }
  .wordmark-latin { font-size: 11px; letter-spacing: .34em; }
  .wordmark-ar { font-size: 30px; line-height: 1.1; }
  .board-chip { font-size: 11px; }
  #countdown { font-size: 11px; }
  .btn { padding: 10px 44px; font-size: 17px; }
  .btn-ghost { padding: 8px 20px; font-size: 13px; }
  .hint { font-size: 11px; line-height: 1.55; max-width: 620px; }
  #code-input { padding: 7px 12px; font-size: 13px; width: 150px; }
  #code-msg { min-height: 12px; font-size: 11px; }
  #death .big { font-size: 52px; }
  #death .sub { font-size: 12px; }
  .stat-grid { gap: 4px 20px; margin: 2px 0 4px; }
  .stat-grid .k { font-size: 10px; }
  .stat-grid .v { font-size: 16px; }
  #card-img { max-height: 50vh; }
  .link-like { font-size: 12px; }
}

/* free wheel: ticks and a cross so the turning is easy to see */
#wheel-rot::before { content: ''; position: absolute; left: 16px; right: 16px; top: 50%; height: 3px; margin-top: -1.5px; background: rgba(242,212,138,.22); border-radius: 2px; }
#wheel-rot .tick { position: absolute; left: 50%; top: 3px; width: 2px; height: 7px; margin-left: -1px; background: rgba(242,212,138,.4); transform-origin: 1px 61px; }
#wheel-rot .tick.big { height: 11px; width: 3px; margin-left: -1.5px; transform-origin: 1.5px 61px; background: rgba(242,212,138,.6); }
/* tall view: minimap sits centred between wheel and boost */
/* the minimap never leaves the rail, in any orientation */

/* touch ring: faint, on brand, never covers the snake */
#touch-ring, #touch-dot { position: absolute; left: 0; top: 0; z-index: 9; pointer-events: none; opacity: 0; transition: opacity .12s; border-radius: 50%; }
#touch-ring { width: 100px; height: 100px; border: 1.5px solid rgba(242,212,138,.16); background: radial-gradient(circle, rgba(242,212,138,.05), rgba(242,212,138,0) 70%); }
#touch-dot { width: 16px; height: 16px; background: rgba(242,212,138,.22); border: 1px solid rgba(242,212,138,.4); }
#touch-ring.on, #touch-dot.on { opacity: 1; }

/* the turned field (portrait phone) uses the same compact menus */
body.vw-compact .screen { gap: 8px; padding: 10px 18px; }
body.vw-compact #logo-slot { min-height: 0; }
body.vw-compact .wordmark-latin { font-size: 11px; letter-spacing: .34em; }
body.vw-compact .wordmark-ar { font-size: 30px; line-height: 1.1; }
body.vw-compact .board-chip { font-size: 11px; }
body.vw-compact #countdown { font-size: 11px; }
body.vw-compact .btn { padding: 10px 44px; font-size: 17px; }
body.vw-compact .btn-ghost { padding: 8px 20px; font-size: 13px; }
body.vw-compact .hint { font-size: 11px; line-height: 1.55; max-width: 620px; }
body.vw-compact #code-input { padding: 7px 12px; font-size: 13px; width: 150px; }
body.vw-compact #code-msg { min-height: 12px; font-size: 11px; }
body.vw-compact #death .big { font-size: 52px; }
body.vw-compact #death .sub { font-size: 12px; }
body.vw-compact .stat-grid { gap: 4px 20px; margin: 2px 0 4px; }
body.vw-compact .stat-grid .k { font-size: 10px; }
body.vw-compact .stat-grid .v { font-size: 16px; }
body.vw-compact #card-img { max-height: 190px; }
body.vw-compact .link-like { font-size: 12px; }

#play-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
#btn-full { font-size: 13px; }
#full-help { position: absolute; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; background: rgba(10,10,12,.72); }
#full-help.on { display: flex; }
#full-help-box { width: min(560px, 86%); box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 20px; text-align: center; font-size: 14px; line-height: 1.7; background: rgba(18,18,26,.98); border: 1px solid rgba(242,212,138,.35); border-radius: 12px; }

/* ---------- modes, respawn, players panel ---------- */
#mode-chip {
  align-self: flex-start; font-size: 11px; letter-spacing: .02em;
  color: rgba(242,212,138,.85); background: rgba(18,18,26,.72);
  border: 1px solid rgba(242,212,138,.22); border-radius: 20px;
  padding: 2px 10px; margin-top: 6px;
}
.mode-title { font-family: var(--ar-font); font-weight: 800; font-size: 26px; color: var(--gold-hi); }
#mode-pick { display: flex; flex-direction: column; gap: 10px; width: min(420px, 90%); }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(242,212,138,.35);
  background: linear-gradient(180deg, rgba(242,212,138,.14), rgba(18,18,26,.9));
  color: var(--text); font-family: var(--ar-font);
}
.mode-card b { font-size: 18px; color: var(--gold-hi); }
.mode-card span { font-size: 12px; opacity: .75; }
.mode-card.soon { border-color: rgba(237,234,227,.14); background: rgba(18,18,26,.7); cursor: default; }
.mode-card.soon b { color: rgba(237,234,227,.55); }
#mode-sub { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(460px, 92%); }
.mode-sub-title { font-size: 13px; opacity: .8; }
.mode-sub-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

#died {
  position: absolute; inset: 0; z-index: 45; display: none;
  align-items: center; justify-content: center; background: rgba(10,10,12,.72);
}
#died.on { display: flex; }
#died-box {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 26px; border-radius: 14px; text-align: center;
  background: rgba(18,18,26,.97); border: 1px solid rgba(242,212,138,.32);
}
.died-k { font-size: 12px; opacity: .7; }
#died-score { font-family: var(--num-font); font-weight: 700; font-size: 40px; color: var(--gold-hi); }
#died-sub { font-size: 13px; opacity: .85; }

#players { justify-content: flex-start; padding: calc(56px + env(safe-area-inset-top)) 16px 24px; }
#players-head, .prow {
  display: grid; grid-template-columns: 34px 1fr 72px 56px; gap: 6px;
  width: min(520px, 96%); align-items: center;
}
#players-head { font-size: 11px; opacity: .55; padding: 0 8px 6px; }
#players-head span:nth-child(n+3), .prow span:nth-child(n+3) { text-align: center; }
#players-list { width: min(520px, 96%); display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; }
.prow { font-size: 14px; padding: 7px 8px; border-radius: 8px; background: rgba(18,18,26,.72); }
.prow.me { border: 1px solid rgba(242,212,138,.45); background: rgba(242,212,138,.10); color: var(--gold-hi); }
#players-foot { font-size: 12px; opacity: .85; margin-top: 10px; text-align: center; }

#d-save { font-size: 12px; padding: 4px 12px; border-radius: 20px; }
#d-save.unsaved { color: rgba(237,234,227,.8); border: 1px solid rgba(237,234,227,.18); }
#d-save.saved { color: var(--gold-hi); border: 1px solid rgba(242,212,138,.4); }
body.vw-compact .mode-title { font-size: 20px; }
body.vw-compact .mode-card { padding: 8px 14px; }
body.vw-compact .mode-card b { font-size: 16px; }

/* ---------- leagues (day / week / month) ---------- */
#leagues { justify-content: flex-start; padding: calc(56px + env(safe-area-inset-top)) 16px 24px; overflow-y: auto; }
#lg-tabs { display: flex; gap: 8px; margin: 4px 0 10px; }
.lg-tab { font: inherit; font-size: 13px; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  color: rgba(242,212,138,.75); background: rgba(18,18,26,.72); border: 1px solid rgba(242,212,138,.22); }
.lg-tab.on { color: #0A0A0C; background: linear-gradient(180deg,#F2D48A,#C9A85C); border-color: transparent; font-weight: 700; }
#lg-prize { font-size: 12.5px; line-height: 1.6; opacity: .9; color: rgba(242,212,138,.9);
  max-width: min(560px, 96%); text-align: center; margin-bottom: 10px; }
#lg-head, #lg-list .prow { display: grid; grid-template-columns: 34px 1fr 76px; align-items: center; }
#lg-head { width: min(520px, 96%); font-size: 11px; opacity: .55; padding: 0 8px 6px; }
#lg-head span:nth-child(3), #lg-list .prow span:nth-child(3) { text-align: center; }
#lg-list { width: min(520px, 96%); display: flex; flex-direction: column; gap: 4px; max-height: 44vh; overflow-y: auto; }
#lg-list .prow.empty { opacity: .7; display: block; text-align: center; font-size: 13px; line-height: 1.7; padding: 14px 10px; }
#lg-foot { font-size: 12px; opacity: .85; margin-top: 10px; text-align: center; max-width: min(520px, 96%); line-height: 1.6; }
