/* ── Tokens ── */
:root {
  --bg: #05080f;
  --bg-2: #0a1220;
  --panel: rgba(12,20,34,.86);
  --card: rgba(255,255,255,.05);
  --card-hi: rgba(255,255,255,.09);
  --border: rgba(255,255,255,.10);
  --border-hi: rgba(255,255,255,.20);
  --text: #eaf2ff;
  --muted: #8fa3bf;
  --slime: #38bdf8;
  --slime-2: #0ea5e9;
  --slime-deep: #0369a1;
  --sage: #fbbf24;
  --sage-2: #f59e0b;
  --hp: #f87171;
  --xp: #4ade80;
  --mp: #60a5fa;
  --danger: #ef4444;
  --grad-slime: linear-gradient(135deg,#38bdf8,#0ea5e9 60%,#0369a1);
  --grad-sage: linear-gradient(135deg,#fde68a,#fbbf24 55%,#d97706);
  --r-sm: 8px; --r: 14px; --r-lg: 20px;
  --sh: 0 6px 28px rgba(0,0,0,.45);
  --sh-lg: 0 18px 60px rgba(0,0,0,.6);
  --glow-slime: 0 0 28px rgba(56,189,248,.45);
  --glow-sage: 0 0 28px rgba(251,191,36,.45);
  --ff: 'Cairo', 'Segoe UI', system-ui, sans-serif;
  --ff-pix: 'Press Start 2P', monospace;
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--ff); overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.app { position: fixed; inset: 0; display: flex; }
.arena-wrap { position: relative; flex: 1; overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(0,0,0,.65) 100%);
}

/* ── HUD ── */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 16px; gap: 10px; pointer-events: none;
}
.hud-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 14px;
  backdrop-filter: blur(14px); box-shadow: var(--sh);
  display: flex; gap: 14px; align-items: center;
}
.hud-left { flex-direction: column; gap: 2px; align-items: flex-start; }
.stat { display: flex; align-items: baseline; gap: 8px; font-size: .82rem; }
.stat-k { color: var(--muted); font-weight: 600; }
.stat b { font-family: var(--ff-pix); font-size: .78rem; color: var(--slime); letter-spacing: .5px; }
.hud-right { flex-direction: column; gap: 8px; min-width: 230px; }
.avatar { display: flex; align-items: center; gap: 10px; }
.slime-mini {
  position: relative; width: 34px; height: 30px; border-radius: 50% 50% 45% 45%;
  background: var(--grad-slime); box-shadow: var(--glow-slime);
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.slime-mini i { width: 5px; height: 7px; border-radius: 50%; background: #04121f; }
.who { display: flex; flex-direction: column; line-height: 1.15; }
.who b { font-size: .95rem; font-weight: 900; }
.lvl, .lvl-n { font-size: .72rem; color: var(--muted); font-weight: 700; }
.lvl-n { color: var(--sage); font-family: var(--ff-pix); font-size: .68rem; }
.bars { display: flex; flex-direction: column; gap: 5px; width: 100%; }
.bar {
  position: relative; height: 14px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.5); border: 1px solid var(--border);
}
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 999px; transition: width .18s ease; }
html[dir="rtl"] .bar i { inset: 0 0 0 auto; }
.bar.hp i { background: linear-gradient(90deg,#ef4444,#f87171); }
.bar.mp i { background: linear-gradient(90deg,#2563eb,#60a5fa); }
.bar.xp i { background: linear-gradient(90deg,#16a34a,#4ade80); }
.bar.xp { height: 8px; }
.bar span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .62rem; font-weight: 800; font-family: var(--ff-pix);
  text-shadow: 0 1px 3px #000; letter-spacing: .3px;
}
.bar.xp span { font-size: .5rem; }

/* ── Sage ticker (الحكيم العظيم) ── */
.sage-ticker {
  position: absolute; top: 92px; left: 50%; transform: translateX(-50%);
  z-index: 5; display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none; width: min(92%, 560px);
}
.sage-msg {
  display: flex; align-items: center; gap: 8px;
  background: rgba(10,14,24,.9); border: 1px solid rgba(251,191,36,.35);
  border-left: 3px solid var(--sage);
  border-radius: 10px; padding: 7px 14px;
  font-size: .82rem; font-weight: 700; color: #fde68a;
  box-shadow: 0 6px 24px rgba(0,0,0,.5), inset 0 0 30px rgba(251,191,36,.05);
  animation: sageIn .28s ease forwards; max-width: 100%;
}
.sage-msg.out { animation: sageOut .3s ease forwards; }
.sage-msg .sage-ico { color: var(--sage); flex: none; }
.sage-msg b { color: #fff; }
@keyframes sageIn { from { opacity:0; transform: translateY(-10px) scale(.96) } to { opacity:1; transform:none } }
@keyframes sageOut { to { opacity:0; transform: translateY(-8px) } }

/* ── Skill bar ── */
.skillbar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 4; display: flex; gap: 10px; align-items: flex-end;
}
.skill {
  position: relative; width: 60px; height: 60px; border-radius: 14px;
  background: rgba(10,16,28,.85); border: 1px solid var(--border-hi);
  backdrop-filter: blur(10px); display: grid; place-items: center;
  box-shadow: var(--sh); transition: transform .16s ease, box-shadow .16s ease;
}
.skill.ready { box-shadow: 0 0 0 1px rgba(56,189,248,.35), 0 6px 24px rgba(56,189,248,.22); }
.skill.sage { border-color: rgba(251,191,36,.4); }
.skill.locked { opacity: .38; filter: grayscale(.7); }
.skill .ico { color: var(--slime); }
.skill.sage .ico { color: var(--sage); }
.skill .key {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  font-family: var(--ff-pix); font-size: .5rem; background: #0b1220;
  border: 1px solid var(--border-hi); border-radius: 5px; padding: 1px 5px; color: var(--muted);
}
.skill .cd {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  background: rgba(2,6,14,.72); display: grid; place-items: center;
  font-family: var(--ff-pix); font-size: .72rem; color: #fff;
}
.skill .lvlbadge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px;
  border-radius: 999px; background: var(--grad-sage); color: #221600;
  font-size: .6rem; font-weight: 900; display: grid; place-items: center; padding: 0 4px;
}

/* ── Overlays & panels ── */
.overlay {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  padding: 18px; background: radial-gradient(ellipse at 50% 40%, rgba(8,14,26,.86), rgba(2,4,9,.96));
  backdrop-filter: blur(6px); animation: fadeIn .25s ease;
}
.panel {
  width: min(100%, 520px); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(16,26,44,.95), rgba(9,14,26,.97));
  border: 1px solid var(--border-hi); border-radius: var(--r-lg);
  padding: 26px 24px; box-shadow: var(--sh-lg); text-align: center;
  animation: popIn .3s cubic-bezier(.2,.9,.3,1.2);
}
.panel.wide { width: min(100%, 780px); }
.logo-pix {
  font-family: var(--ff-pix); font-size: .62rem; letter-spacing: 2px;
  color: var(--slime); margin-bottom: 14px; line-height: 1.6;
  text-shadow: 0 0 18px rgba(56,189,248,.6);
}
.logo-pix.danger { color: var(--danger); text-shadow: 0 0 18px rgba(239,68,68,.6); }
.title {
  font-size: clamp(2rem, 6vw, 3rem); font-weight: 900; line-height: 1.1;
  letter-spacing: -.02em; margin-bottom: 10px;
  background: linear-gradient(135deg,#dff3ff,#38bdf8 55%,#0369a1);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { font-size: clamp(1.25rem, 3.4vw, 1.7rem); font-weight: 900; margin-bottom: 8px; }
.sub { color: var(--muted); font-size: .95rem; line-height: 1.75; margin: 0 auto 18px; max-width: 46ch; }
.sub.small { font-size: .85rem; }
.sub b { color: var(--sage); }
.row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.4rem; border-radius: 999px; font-size: .92rem; font-weight: 800;
  cursor: pointer; border: 1px solid transparent; color: var(--text);
  background: transparent; transition: transform .15s ease, box-shadow .15s ease, background .2s, opacity .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--grad-slime); color: #04141f; box-shadow: 0 8px 30px rgba(56,189,248,.35); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(56,189,248,.5); }
.btn-ghost { border-color: var(--border-hi); color: var(--text); background: rgba(255,255,255,.03); }
.btn-ghost:hover { background: var(--card-hi); transform: translateY(-2px); }
.btn-ghost[aria-pressed="false"] { color: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity:0; transform: translateY(14px) scale(.97) } to { opacity:1; transform:none } }

/* ── Draft (level-up choices) ── */
.draft-head { margin-bottom: 18px; }
.badge-sage {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--grad-sage); color: #241700;
  font-size: .68rem; font-weight: 900; letter-spacing: .08em;
  padding: 4px 12px; border-radius: 999px; margin-bottom: 10px;
  box-shadow: var(--glow-sage);
}
.draft-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.draft-card {
  text-align: right; padding: 16px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--border); cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s, background .16s;
  display: flex; flex-direction: column; gap: 8px; color: var(--text);
}
html[dir="rtl"] .draft-card { text-align: right; }
.draft-card:hover, .draft-card:focus-visible {
  transform: translateY(-4px); border-color: rgba(56,189,248,.5);
  background: var(--card-hi); box-shadow: 0 16px 44px rgba(56,189,248,.22); outline: none;
}
.draft-card.new { border-color: rgba(251,191,36,.5); }
.draft-card.new:hover { box-shadow: 0 16px 44px rgba(251,191,36,.28); }
.draft-top { display: flex; align-items: center; gap: 10px; }
.draft-ico {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; background: rgba(56,189,248,.14); color: var(--slime);
}
.draft-card.new .draft-ico { background: rgba(251,191,36,.16); color: var(--sage); }
.draft-name { font-weight: 900; font-size: .95rem; }
.draft-desc { color: var(--muted); font-size: .8rem; line-height: 1.65; }
.draft-tag {
  align-self: flex-start; font-size: .62rem; font-weight: 900; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted);
}
.draft-card.new .draft-tag { background: rgba(251,191,36,.16); color: var(--sage); }
.draft-lvl { margin-inline-start: auto; font-family: var(--ff-pix); font-size: .58rem; color: var(--sage); }

/* ── Difficulty / keys / how-to ── */
.difficulty { display: flex; gap: 8px; justify-content: center; margin: 18px 0 4px; flex-wrap: wrap; }
.diff {
  padding: 7px 16px; border-radius: 999px; cursor: pointer; font-size: .82rem; font-weight: 800;
  border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--muted);
  transition: all .18s ease;
}
.diff:hover { background: var(--card-hi); color: var(--text); }
.diff.on { background: var(--grad-slime); color: #04141f; border-color: transparent; box-shadow: 0 6px 22px rgba(56,189,248,.35); }
.keys { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.kbd {
  display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted);
  background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px;
}
.kbd kbd {
  font-family: var(--ff-pix); font-size: .56rem; color: var(--text);
  background: #0b1220; border: 1px solid var(--border-hi); border-radius: 5px; padding: 2px 6px;
}
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; text-align: right; }
.how-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.how-item h4 { font-size: .9rem; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; color: var(--slime); }
.how-item p { font-size: .82rem; color: var(--muted); line-height: 1.7; }
.scoreboard { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0 4px; }
.scoreboard .sb {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.scoreboard .sb span { font-size: .72rem; color: var(--muted); font-weight: 700; }
.scoreboard .sb b { font-family: var(--ff-pix); font-size: .8rem; color: var(--slime); }

/* ── Mobile controls ── */
.mobile { position: absolute; inset: auto 0 0 0; z-index: 6; display: none; pointer-events: none; }
.stick {
  position: absolute; bottom: 26px; inset-inline-start: 22px; width: 118px; height: 118px;
  border-radius: 50%; background: rgba(10,16,28,.5); border: 1px solid var(--border-hi);
  backdrop-filter: blur(8px); pointer-events: auto; touch-action: none;
}
.knob {
  position: absolute; top: 50%; left: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: var(--grad-slime); box-shadow: var(--glow-slime);
  transition: transform .06s linear;
}
.mbtns {
  position: absolute; bottom: 26px; inset-inline-end: 20px;
  display: grid; grid-template-columns: repeat(2, 62px); gap: 12px; pointer-events: auto;
}
.mbtn {
  width: 62px; height: 62px; border-radius: 16px; display: grid; place-items: center;
  background: rgba(10,16,28,.72); border: 1px solid var(--border-hi); color: var(--slime);
  backdrop-filter: blur(8px); position: relative; overflow: hidden;
}
.mbtn:active { transform: scale(.94); }
.mbtn.sage { color: var(--sage); }
.mbtn .cd { position: absolute; inset: 0; background: rgba(2,6,14,.7); display: grid; place-items: center; font-family: var(--ff-pix); font-size: .7rem; color: #fff; }
.mbtn .lvlbadge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--grad-sage); color: #221600; font-size: .55rem; font-weight: 900; display: grid; place-items: center; }
.mbtn.locked { opacity: .35; }

/* ── Utility / anim ── */
.pop { animation: pop .35s cubic-bezier(.2,.9,.3,1.4); }
@keyframes pop { 0% { transform: scale(.6) } 60% { transform: scale(1.12) } 100% { transform: scale(1) } }
.shake { animation: shake .3s ease; }
@keyframes shake { 25% { transform: translate(-4px,2px) } 50% { transform: translate(4px,-2px) } 75% { transform: translate(-2px,-2px) } }

/* ── Responsive ── */
@media (max-width: 860px) {
  .hud { padding: 10px; }
  .hud-right { min-width: 0; }
  .stat b { font-size: .68rem; }
  .skill { width: 52px; height: 52px; border-radius: 12px; }
  .skillbar { bottom: 12px; gap: 7px; }
  .panel { padding: 20px 16px; }
}
@media (hover: none) and (pointer: coarse) {
  .mobile { display: block; }
  .skillbar { display: none; }
  .hud { padding: 8px 10px; }
  .hud-left { flex-direction: row; gap: 12px; flex-wrap: wrap; }
  .sage-ticker { top: 118px; }
}
@media (max-height: 560px) {
  .hud-right { transform: scale(.9); transform-origin: top right; }
  html[dir="rtl"] .hud-right { transform-origin: top left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
