/* ============================================================
   Army Command — design tokens (from ui-ux-pro-max design system:
   "Felt green + gold on dark", tactical HUD)
   ============================================================ */
:root {
  --bg:            #0f172a;
  --bg-deep:       #080d18;
  --bg-muted:      #0f1f2b;
  --panel:         rgba(15, 23, 42, .72);
  --panel-solid:   #111c30;
  --card:          rgba(255,255,255,.045);
  --card-hover:    rgba(255,255,255,.085);
  --border:        rgba(255,255,255,.10);
  --border-strong: rgba(255,255,255,.20);

  --primary:       #15803d;
  --primary-2:     #166534;
  --accent:        #d97706;
  --accent-2:      #fbbf24;
  --danger:        #dc2626;
  --info:          #38bdf8;

  --ally:          #3b82f6;
  --ally-dark:     #1d4ed8;
  --ally-trim:     #bfdbfe;
  --enemy:         #ef4444;
  --enemy-dark:    #b91c1c;
  --enemy-trim:    #fecaca;

  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --text-dim:      #64748b;

  --r-sm: 8px;  --r: 14px;  --r-lg: 20px;
  --sh:    0 4px 24px rgba(0,0,0,.45);
  --sh-lg: 0 18px 60px rgba(0,0,0,.6);
  --icon-sm: 16px; --icon-md: 20px; --icon-lg: 24px;
  --font: 'Cairo', 'Tajawal', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Orbitron', ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
h1, h2, h3 { line-height: 1.2; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- stage ---------- */
.app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#game.grabbing { cursor: grabbing; }
#game.no-drop { cursor: not-allowed; }

.hud { position: absolute; z-index: 5; pointer-events: none; }
.hud > *, .hud button { pointer-events: auto; }
.glass {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh);
}

/* ---------- top bar ---------- */
.hud-top {
  top: 0; right: 0; left: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  background: linear-gradient(180deg, rgba(8,13,24,.92), rgba(8,13,24,.45) 70%, transparent);
}
.team-strip { width: min(30vw, 290px); display: flex; flex-direction: column; gap: 5px; }
.team-strip.enemy { align-items: flex-start; }
.team-meta { display: flex; align-items: baseline; gap: 8px; }
.team-name { font-weight: 900; font-size: .95rem; letter-spacing: .01em; }
.ally .team-name { color: var(--ally-trim); }
.enemy .team-name { color: var(--enemy-trim); }
.team-count { font-size: .72rem; color: var(--text-muted); }
.team-count b { font-family: var(--mono); color: var(--text); font-size: .82rem; }
.bar { height: 9px; border-radius: 99px; background: rgba(255,255,255,.09); overflow: hidden; border: 1px solid var(--border); }
.bar i { display: block; height: 100%; width: 100%; border-radius: 99px; transition: width .35s ease; }
.ally .bar i { background: linear-gradient(90deg, var(--ally-dark), var(--ally)); }
.enemy .bar i { background: linear-gradient(90deg, var(--enemy), var(--enemy-dark)); }
.bar.sm { height: 5px; }
.morale { display: flex; align-items: center; gap: 8px; font-size: .64rem; color: var(--text-dim); }
.morale .bar { flex: 1; }
.morale .bar i { background: linear-gradient(90deg, #475569, #94a3b8); }
.morale.warn .bar i { background: linear-gradient(90deg, #b45309, var(--accent-2)); }
.morale.crit .bar i { background: linear-gradient(90deg, #7f1d1d, var(--danger)); }

.center-hud { display: flex; align-items: center; gap: 10px; }
.clock {
  font-family: var(--mono); font-weight: 800; font-size: 1.05rem;
  letter-spacing: .08em; color: var(--accent-2);
  background: rgba(0,0,0,.4); border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 99px; min-width: 84px; text-align: center;
}
.speed-group, .tools { display: flex; gap: 2px; background: rgba(0,0,0,.35); border: 1px solid var(--border); border-radius: 99px; padding: 3px; }
.ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; border-radius: 99px; color: var(--text-muted);
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.ico svg { width: var(--icon-sm); height: var(--icon-sm); stroke-width: 1.9; }
.ico:hover { background: var(--card-hover); color: var(--text); transform: translateY(-1px); }
.ico.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.ico.off { color: var(--text-dim); }
.ico:focus-visible, .ord:focus-visible, .btn:focus-visible, .segmented button:focus-visible, .link-btn:focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}

/* ---------- orders panel ---------- */
.orders {
  bottom: 14px; inset-inline-start: 14px;
  width: min(340px, 34vw); padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.orders-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.orders-head h2 { display: flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 900; }
.orders-head h2 svg { width: var(--icon-sm); height: var(--icon-sm); color: var(--accent); stroke-width: 2; }
.sel-total { font-size: .7rem; color: var(--text-muted); font-family: var(--mono); }
.sel-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--border); color: var(--text-muted);
}
.chip svg { width: 13px; height: 13px; stroke-width: 2; }
.chip.a { color: var(--ally-trim); border-color: rgba(59,130,246,.35); background: rgba(59,130,246,.12); }
.chip.e { color: var(--enemy-trim); border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.12); }
.order-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ord {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 2px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--border);
  font-size: .62rem; font-weight: 700; color: var(--text-muted);
  transition: transform .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}
.ord svg { width: 17px; height: 17px; stroke-width: 1.9; }
.ord:hover { background: var(--card-hover); color: var(--text); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.ord:active { transform: translateY(0) scale(.97); }
.ord.hot { border-color: rgba(217,119,6,.5); color: var(--accent-2); }
.tip { font-size: .68rem; color: var(--text-dim); line-height: 1.6; }

/* ---------- minimap ---------- */
.minimap-wrap { bottom: 14px; inset-inline-end: 14px; padding: 8px; }
#minimap { display: block; width: 252px; height: 158px; border-radius: 10px; cursor: pointer; background: #0b1a12; }
.mm-foot { display: flex; justify-content: center; margin-top: 5px; font-size: .6rem; color: var(--text-dim); }
@media (max-width: 900px) { #minimap { width: 170px; height: 107px; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 92px; inset-inline-end: 16px; z-index: 40; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 9px 15px; border-radius: var(--r-sm); font-size: .82rem; font-weight: 700;
  background: rgba(8,13,24,.9); border: 1px solid var(--border-strong);
  box-shadow: var(--sh-lg); animation: slideIn .3s ease both;
}
.toast.ally { border-color: rgba(59,130,246,.5); color: var(--ally-trim); }
.toast.enemy { border-color: rgba(239,68,68,.5); color: var(--enemy-trim); }
.toast.gold { border-color: rgba(217,119,6,.55); color: var(--accent-2); }
@keyframes slideIn { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

/* ---------- full screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(21,128,61,.30), transparent 60%),
    radial-gradient(ellipse at 50% 110%, rgba(217,119,6,.18), transparent 55%),
    rgba(8,13,24,.94);
  animation: fadeIn .35s ease both; overflow-y: auto;
}
.screen.dark { background: rgba(8,13,24,.96); }
.screen[hidden] { display: none; }
.screen-inner { width: min(880px, 100%); text-align: center; padding: 18px 0; }
.screen-inner.narrow { width: min(620px, 100%); }
.brand-row {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .32em; color: var(--accent);
}
.brand-row svg { width: 18px; height: 18px; stroke-width: 2; }
.screen h1 { font-size: clamp(2.1rem, 5.2vw, 3.3rem); font-weight: 900; letter-spacing: -.01em; }
.lede { color: var(--text-muted); font-size: .95rem; max-width: 620px; margin: 12px auto 22px; }
.sm-h { font-size: 1.3rem; font-weight: 900; margin: 6px 0 14px; color: var(--accent-2); }

/* roster */
.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 24px; text-align: right; }
.unit-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; backdrop-filter: blur(10px);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.unit-card:hover { transform: translateY(-3px); background: var(--card-hover); border-color: var(--border-strong); }
.unit-card .uc-head { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: .88rem; margin-bottom: 4px; }
.unit-card .uc-head svg { width: 18px; height: 18px; stroke-width: 2; }
.unit-card p { font-size: .7rem; color: var(--text-muted); line-height: 1.65; }
.unit-card .swatch { width: 10px; height: 10px; border-radius: 3px; margin-inline-start: auto; }
.swatch.ally-c { background: var(--ally); box-shadow: 0 0 10px rgba(59,130,246,.7); }
.swatch.enemy-c { background: var(--enemy); box-shadow: 0 0 10px rgba(239,68,68,.7); }

/* segmented + buttons */
.setup { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-bottom: 26px; }
.field { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.lbl { font-size: .68rem; font-weight: 700; letter-spacing: .1em; color: var(--text-dim); }
.segmented { display: flex; gap: 3px; background: rgba(0,0,0,.4); border: 1px solid var(--border); border-radius: 99px; padding: 3px; }
.segmented button {
  padding: 7px 15px; border-radius: 99px; font-size: .78rem; font-weight: 700;
  color: var(--text-muted); transition: background .2s ease, color .2s ease, transform .2s ease;
}
.segmented button:hover { color: var(--text); transform: translateY(-1px); }
.segmented button.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 30px; border-radius: 99px; font-size: .95rem; font-weight: 900;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn svg { width: 18px; height: 18px; stroke-width: 2.1; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #b45309); color: #1a1206; box-shadow: 0 10px 34px rgba(217,119,6,.34); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 44px rgba(217,119,6,.5); }
.btn-ghost { border: 1.5px solid var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--card-hover); transform: translateY(-2px); }
.link-btn { margin-top: 14px; font-size: .8rem; color: var(--text-muted); text-decoration: underline; text-underline-offset: 4px; }
.link-btn:hover { color: var(--accent-2); }

/* ---------- help keys ---------- */
.keys { list-style: none; display: grid; gap: 6px; margin-bottom: 20px; }
.keys li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 13px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--border); font-size: .8rem;
}
.keys li b { font-family: var(--mono); font-size: .72rem; color: var(--accent-2); text-align: start; }
.keys li span { color: var(--text-muted); text-align: end; flex: 1; }
.keys.rules li b { color: var(--info); font-family: var(--font); font-size: .8rem; }

/* ---------- result ---------- */
.result-icon { display: flex; justify-content: center; margin-bottom: 10px; }
.result-icon svg { width: 54px; height: 54px; stroke-width: 1.6; color: var(--accent-2); }
.result.lose .result-icon svg { color: var(--enemy); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 18px 0 24px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; }
.stat b { display: block; font-family: var(--mono); font-size: 1.5rem; color: var(--text); }
.stat span { font-size: .68rem; color: var(--text-muted); }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- misc ---------- */
.banner {
  position: absolute; top: 34%; inset-inline: 0; z-index: 8;
  text-align: center; font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 900;
  color: var(--accent-2); text-shadow: 0 6px 40px rgba(0,0,0,.9);
  pointer-events: none; animation: bannerIn 2.6s ease forwards;
}
.banner.enemy { color: var(--enemy-trim); }
@keyframes bannerIn {
  0% { opacity: 0; transform: scale(.86); }
  15% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- entrance animation ---------- */
.fade-up { animation: fadeUp .55s cubic-bezier(.16,1,.3,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: none } }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .orders { width: min(300px, 44vw); }
  .order-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 820px) {
  .team-strip { width: 34vw; }
  .morale span { display: none; }
  .clock { font-size: .9rem; min-width: 66px; padding: 4px 8px; }
  .orders { inset-inline-start: 8px; bottom: 8px; width: 52vw; padding: 10px; }
  .minimap-wrap { bottom: 8px; inset-inline-end: 8px; padding: 6px; }
  .order-grid { grid-template-columns: repeat(5, 1fr); }
  .ord span { display: none; }
  .ord { padding: 8px 0; }
  #minimap { width: 132px; height: 83px; }
  .mm-foot { display: none; }
  .hud-top { padding: 8px; }
  .tools .ico:nth-child(3) { display: none; }
}
@media (max-width: 560px) {
  .orders { width: 58vw; }
  .team-strip.ally .morale, .team-strip.enemy .morale { display: none; }
  .speed-group .ico { width: 28px; }
}
