/* ── Design tokens ── */
:root {
  --bg: #0F172A;
  --bg-deep: #070c17;
  --bg-card: rgba(255,255,255,.05);
  --bg-hover: rgba(255,255,255,.09);
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.18);
  --text: #f2f5fb;
  --text-muted: #93a0bb;
  --primary: #DC2626;
  --secondary: #2563EB;
  --accent: #22C55E;
  --amber: #fbbf24;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 60px rgba(0,0,0,.6);
  --pixel: 'Press Start 2P', monospace;
  font-family: 'Cairo', ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh; background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
.glow {
  position: fixed; inset: -30% -10% auto -10%; height: 65vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(220,38,38,.22), transparent 58%),
              radial-gradient(ellipse at 15% 10%, rgba(37,99,235,.22), transparent 55%);
  filter: blur(10px);
}
main { position: relative; z-index: 1; }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 20; height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  background: rgba(7,12,23,.78); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--primary); box-shadow: 0 0 0 3px rgba(220,38,38,.2), 0 0 18px rgba(220,38,38,.7);
}
.brand-name { font-weight: 900; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-tag { font-family: var(--pixel); font-size: .5rem; color: var(--text-muted); letter-spacing: .06em; padding-top: 4px; }
.nav-links { display: flex; gap: 1.4rem; }
.nav-link { color: var(--text-muted); text-decoration: none; font-size: .92rem; font-weight: 600; transition: color .2s ease; }
.nav-link:hover { color: var(--text); }

/* ── Hero band ── */
.hero-band { max-width: 940px; margin: 0 auto; padding: clamp(2rem, 6vw, 3.5rem) 1.25rem 1.25rem; text-align: center; }
.hero-band h1 {
  font-size: clamp(2rem, 7vw, 3.6rem); font-weight: 900; line-height: 1.08;
  background: linear-gradient(120deg, #fff 20%, var(--primary) 60%, var(--secondary) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -.02em; margin-bottom: .75rem;
}
.hero-band p { color: var(--text-muted); font-size: clamp(.95rem, 2.4vw, 1.1rem); max-width: 620px; margin: 0 auto; }

/* ── Stage ── */
.stage-wrap { max-width: 1000px; margin: 0 auto; padding: 0 1rem 1rem; }
.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius-lg); border: 1px solid var(--border-strong);
  background: #05070f; box-shadow: var(--shadow-lg);
}
#arena { display: block; width: 100%; height: 100%; }

/* ── HUD ── */
.hud {
  position: absolute; inset: 0 0 auto 0; display: flex; align-items: flex-start;
  gap: clamp(.4rem, 1.6vw, 1.2rem); padding: clamp(.5rem, 1.6vw, .9rem);
  pointer-events: none; z-index: 3;
}
.hud .side { flex: 1; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.hud .side.p2 { align-items: flex-end; }
.name-row { display: flex; align-items: center; gap: .5rem; }
.hud .side.p2 .name-row { flex-direction: row; }
.fname { font-weight: 800; font-size: clamp(.7rem, 1.6vw, .95rem); text-shadow: 0 2px 6px rgba(0,0,0,.8); }
.rounds { display: flex; gap: 4px; }
.rounds i {
  width: 9px; height: 9px; border-radius: 50%; display: block;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  transition: all .3s ease;
}
.rounds i.win { background: var(--accent); box-shadow: 0 0 10px rgba(34,197,94,.9); border-color: transparent; }
.bar {
  position: relative; width: 100%; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.22);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
.bar.hp { height: clamp(11px, 2.1vw, 19px); }
.bar.meter { height: clamp(6px, 1.2vw, 10px); width: 62%; border-color: rgba(255,255,255,.15); }
.hud .side.p2 .bar.meter { align-self: flex-end; }
.bar .fill, .bar .lag { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; }
.hud .side.p2 .bar .fill, .hud .side.p2 .bar .lag { left: auto; right: 0; }
.bar .lag { background: rgba(255,255,255,.85); transition: width .45s ease .12s; z-index: 1; }
.bar.hp .fill {
  z-index: 2; background: linear-gradient(180deg, #ff6b6b, var(--primary) 55%, #8c1414);
  box-shadow: 0 0 14px rgba(220,38,38,.6);
}
.hud .side.p2 .bar.hp .fill { background: linear-gradient(180deg, #7db1ff, var(--secondary) 55%, #14337e); box-shadow: 0 0 14px rgba(37,99,235,.6); }
.bar.meter .fill { background: linear-gradient(90deg, var(--accent), #a3e635); }
.bar.meter.full .fill { background: linear-gradient(90deg, var(--amber), #f97316); box-shadow: 0 0 16px rgba(251,191,36,.85); }

.hud .center { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: .1rem; }
.timer {
  font-family: var(--pixel); font-size: clamp(1rem, 3vw, 1.7rem);
  color: #fff; text-shadow: 0 0 14px rgba(255,255,255,.5), 0 3px 0 rgba(0,0,0,.6);
  min-width: 2.4em; text-align: center;
}
.timer.low { color: #ff8f8f; animation: pulse .8s infinite; }
.round-no { font-size: clamp(.55rem, 1.3vw, .72rem); color: var(--text-muted); font-weight: 700; }

.combo {
  position: absolute; top: 24%; opacity: 0; z-index: 4; pointer-events: none;
  font-weight: 900; font-size: clamp(.8rem, 2.2vw, 1.3rem); text-shadow: 0 3px 12px rgba(0,0,0,.9);
}
.combo.c1 { left: 6%; color: #ff8a8a; }
.combo.c2 { right: 6%; color: #8fb8ff; }
.combo.show { animation: comboPop .9s ease forwards; }

.msg {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  pointer-events: none; font-weight: 900; text-align: center; padding: 0 1rem;
  font-size: clamp(1.4rem, 5vw, 3rem); opacity: 0;
  color: #fff; text-shadow: 0 0 24px rgba(220,38,38,.8), 0 6px 0 rgba(0,0,0,.55);
}
.msg.show { animation: msgIn 1.5s ease forwards; }
.msg.fight { color: var(--accent); text-shadow: 0 0 28px rgba(34,197,94,.9), 0 6px 0 rgba(0,0,0,.55); }
.msg.ko { color: #ffd54a; text-shadow: 0 0 32px rgba(251,191,36,.95), 0 6px 0 rgba(0,0,0,.55); }

/* ── Overlays ── */
.overlay {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center;
  padding: clamp(.6rem, 2vw, 1.5rem);
  background: radial-gradient(ellipse at 50% 40%, rgba(15,23,42,.82), rgba(4,6,12,.94));
  backdrop-filter: blur(5px); transition: opacity .25s ease, visibility .25s ease;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.panel {
  width: 100%; max-width: 620px; text-align: center;
  background: rgba(14,21,37,.86); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: clamp(1rem, 3vw, 1.9rem);
  box-shadow: var(--shadow-lg); animation: fadeUp .4s ease both;
  max-height: 100%; overflow: auto;
}
.panel.small { max-width: 460px; }
.panel-kicker { font-size: .72rem; font-weight: 800; letter-spacing: .14em; color: var(--primary); text-transform: uppercase; }
.panel-title { font-size: clamp(1.3rem, 4.4vw, 2.2rem); font-weight: 900; margin: .25rem 0 .35rem; }
.panel-sub { color: var(--text-muted); font-size: clamp(.82rem, 2.2vw, .95rem); margin-bottom: 1rem; }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 1rem .75rem; cursor: pointer; color: var(--text); font-family: inherit;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: var(--radius); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.mode-card:hover { transform: translateY(-3px); background: var(--bg-hover); border-color: var(--border-strong); box-shadow: 0 14px 40px rgba(220,38,38,.18); }
.mode-card .mode-icon { color: var(--primary); display: grid; place-items: center; }
.mode-card .mode-icon svg { width: 26px; height: 26px; stroke-width: 1.75; }
.mode-card + .mode-card .mode-icon { color: var(--secondary); }
.mode-name { font-weight: 800; font-size: .98rem; }
.mode-desc { color: var(--text-muted); font-size: .78rem; }

.diff-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .6rem; margin-bottom: .75rem; }
.diff-label { font-size: .8rem; color: var(--text-muted); font-weight: 700; }
.pills { display: flex; gap: .3rem; background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 999px; padding: .22rem; }
.pill {
  cursor: pointer; border: none; background: transparent; color: var(--text-muted);
  font-family: inherit; font-weight: 700; font-size: .82rem; padding: .32rem .9rem; border-radius: 999px;
  transition: all .2s ease;
}
.pill:hover { color: var(--text); }
.pill.active { background: linear-gradient(135deg, var(--primary), #f87171); color: #fff; box-shadow: 0 6px 20px rgba(220,38,38,.4); }
.hint { font-size: .76rem; color: var(--text-muted); }
.overlay-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 1rem; }

/* ── Buttons ── */
.tbtn {
  display: inline-flex; align-items: center; gap: .45rem; cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: .86rem;
  padding: .55rem 1.1rem; border-radius: 999px; color: var(--text);
  background: rgba(255,255,255,.06); border: 1px solid var(--border-strong);
  transition: transform .16s ease, box-shadow .16s ease, background .2s ease, opacity .2s;
}
.tbtn svg { width: 17px; height: 17px; stroke-width: 1.9; }
.tbtn:hover:not(:disabled) { transform: translateY(-2px); background: var(--bg-hover); }
.tbtn:active:not(:disabled) { transform: translateY(0); }
.tbtn[aria-pressed="false"] { color: var(--text-muted); }
.tbtn.primary {
  background: linear-gradient(135deg, var(--primary), #f0603d); border-color: transparent; color: #fff;
  box-shadow: 0 8px 28px rgba(220,38,38,.35);
}
.tbtn.primary:hover:not(:disabled) { box-shadow: 0 12px 36px rgba(220,38,38,.5); }
.tbtn:disabled { opacity: .4; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Toolbar + touch ── */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .9rem; }
.touch { display: none; justify-content: space-between; gap: .6rem; margin-top: .75rem; touch-action: none; }
.touch.on { display: flex; }
.touch-pad, .touch-acts { display: flex; gap: .45rem; }
.touch-acts { flex-wrap: wrap; justify-content: flex-end; }
.tbtn-key {
  width: 3.6rem; height: 3.6rem; border-radius: 16px; display: grid; place-items: center;
  cursor: pointer; font-family: inherit; font-weight: 800; font-size: .78rem; color: #fff;
  background: rgba(255,255,255,.08); border: 1px solid var(--border-strong);
  backdrop-filter: blur(8px); user-select: none; -webkit-user-select: none;
  transition: transform .1s ease, background .1s ease;
}
.tbtn-key svg { width: 22px; height: 22px; stroke-width: 2.2; }
.tbtn-key.holding { background: rgba(220,38,38,.45); transform: scale(.94); }
.tbtn-key.atk { background: rgba(220,38,38,.28); }
.tbtn-key.atk.holding { background: rgba(220,38,38,.7); }
.tbtn-key.sp { background: rgba(34,197,94,.25); }
.tbtn-key.sp.holding { background: rgba(34,197,94,.65); }

/* ── Sections ── */
.section { max-width: 1080px; margin: 0 auto; padding: clamp(2rem, 6vw, 3.5rem) 1.25rem; }
.sec-title { font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 900; margin-bottom: .3rem; }
.sec-sub { color: var(--text-muted); margin-bottom: 1.5rem; max-width: 680px; font-size: .95rem; }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(12px); padding: 1.25rem; box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.ctl-card h3 { display: flex; align-items: center; gap: .5rem; font-size: 1rem; margin-bottom: .8rem; }
.ctl-card h3 svg { width: 18px; height: 18px; stroke-width: 1.9; color: var(--primary); }
.card-note { color: var(--text-muted); font-size: .9rem; }

.keys { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.keys li { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .9rem; color: var(--text-muted); }
.kbd {
  display: inline-grid; place-items: center; min-width: 1.9rem; padding: .1rem .45rem;
  font-family: var(--pixel); font-size: .55rem; border-radius: 7px; color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.05));
  border: 1px solid var(--border-strong); box-shadow: 0 2px 0 rgba(0,0,0,.5);
}
.table-card {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
table.moves { width: 100%; border-collapse: collapse; min-width: 560px; font-size: .9rem; }
table.moves th, table.moves td { padding: .8rem 1rem; text-align: right; border-bottom: 1px solid var(--border); }
table.moves thead th { font-size: .78rem; letter-spacing: .05em; color: var(--text-muted); text-transform: uppercase; background: rgba(255,255,255,.03); }
table.moves tbody tr { transition: background .18s ease; }
table.moves tbody tr:hover { background: rgba(255,255,255,.045); }
table.moves tbody tr:last-child td { border-bottom: none; }
table.moves td:first-child { font-weight: 700; }

.footer {
  display: flex; flex-direction: column; gap: .35rem; align-items: center; text-align: center;
  padding: 2.5rem 1.25rem 3rem; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: .85rem;
}

/* ── Animations ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes comboPop {
  0% { opacity: 0; transform: scale(.6) translateY(10px); }
  25% { opacity: 1; transform: scale(1.12) translateY(0); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1) translateY(-14px); }
}
@keyframes msgIn {
  0% { opacity: 0; transform: scale(.5); }
  18% { opacity: 1; transform: scale(1.08); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}
@keyframes pulse { 50% { opacity: .45; } }

@media (max-width: 720px) {
  .nav-links { display: none; }
  .hud .center { padding-top: 0; }
  .stage { border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ── أيقونات Lucide مضمّنة ── */
svg.lucide { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.tbtn svg.lucide { width: 17px; height: 17px; }
.mode-card .mode-icon svg.lucide { width: 26px; height: 26px; }
.ctl-card h3 svg.lucide { width: 18px; height: 18px; color: var(--primary); }
.tbtn-key svg.lucide { width: 22px; height: 22px; }
