:root {
  color-scheme: dark;
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --bg: #090d1b;
  --panel: rgba(18, 25, 48, .88);
  --panel-2: rgba(25, 35, 66, .95);
  --line: rgba(255,255,255,.12);
  --text: #f7f8ff;
  --muted: #aeb9d7;
  --accent: #ffd166;
  --accent-2: #70e1f5;
  --danger: #ff7a8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 50% -10%, #1e315f 0%, var(--bg) 55%); color: var(--text); }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
button { font: inherit; }
.app-shell { width: min(1480px, 100%); margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.14); background: linear-gradient(145deg, rgba(112,225,245,.23), rgba(255,209,102,.14)); border-radius: 14px; color: var(--accent); font-size: 20px; box-shadow: inset 0 1px rgba(255,255,255,.12); }
h1 { font-size: clamp(18px, 2.4vw, 30px); margin: 0; letter-spacing: -.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: clamp(12px, 1.3vw, 15px); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn, .secondary, .primary, .touch-btn { border: 1px solid var(--line); color: var(--text); border-radius: 13px; background: rgba(255,255,255,.075); padding: 10px 13px; cursor: pointer; min-height: 44px; transition: transform .14s ease, border-color .14s ease, background .14s ease; }
.icon-btn:active, .secondary:active, .primary:active, .touch-btn:active { transform: translateY(1px) scale(.98); }
.icon-btn:focus-visible, .secondary:focus-visible, .primary:focus-visible, .touch-btn:focus-visible { outline: 3px solid rgba(112,225,245,.55); outline-offset: 2px; }
.game-card { border: 1px solid var(--line); border-radius: 24px; background: rgba(10,14,29,.86); box-shadow: 0 22px 60px rgba(0,0,0,.3); overflow: hidden; }
.hud { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.hud-item { min-height: 64px; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(11,16,34,.96); padding: 8px; }
.hud-item span { color: var(--muted); font-size: 13px; }
.hud-item strong { font-size: 18px; }
.canvas-wrap { position: relative; background: #0b1122; aspect-ratio: 16 / 9; overflow: hidden; }
#gameCanvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }
.overlay { position: absolute; inset: 0; display: none; place-items: center; padding: 24px; background: linear-gradient(180deg, rgba(6,10,23,.18), rgba(6,10,23,.72)); backdrop-filter: blur(5px); }
.overlay.visible { display: grid; }
.panel { width: min(610px, 100%); background: linear-gradient(180deg, rgba(26,36,66,.96), rgba(13,19,39,.97)); border: 1px solid rgba(255,255,255,.16); border-radius: 24px; padding: clamp(22px, 4vw, 42px); box-shadow: 0 24px 80px rgba(0,0,0,.42); text-align: center; }
.eyebrow { color: var(--accent-2); font-weight: 800; letter-spacing: .04em; margin-bottom: 6px; }
.panel h2 { font-size: clamp(28px, 5vw, 48px); margin: 4px 0 10px; }
.panel p { color: #d9e0f5; line-height: 1.75; margin: 0 auto 18px; max-width: 52ch; }
.control-hints { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 22px; }
.control-hints span { background: rgba(255,255,255,.075); border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; color: #dfe7ff; font-size: 13px; }
.panel-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.primary { background: linear-gradient(180deg, #ffd166, #f3aa43); color: #241a08; border-color: rgba(255,255,255,.3); font-weight: 900; padding-inline: 24px; }
.secondary { background: rgba(255,255,255,.07); }
.copyright-note { font-size: 11px; color: #98a4c8 !important; margin-top: 18px !important; }
.toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; background: rgba(13,18,38,.92); border: 1px solid rgba(255,255,255,.16); padding: 9px 14px; border-radius: 999px; font-weight: 800; transition: .2s ease; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.touch-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; border-top: 1px solid var(--line); background: rgba(9,13,27,.98); }
.move-pad { display: flex; gap: 10px; }
.touch-btn { min-width: 68px; min-height: 58px; font-size: 22px; font-weight: 900; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-btn.jump { min-width: 110px; background: linear-gradient(180deg, rgba(112,225,245,.22), rgba(112,225,245,.08)); }
.help-panel { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; }
.help-panel h2 { margin-top: 0; }
.help-panel p { color: #d6def4; line-height: 1.9; }
footer { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; padding: 12px 4px 0; }
.classroom .topbar .brand p, .classroom .help-panel, .classroom footer { display: none !important; }
.classroom .app-shell { width: 100%; max-width: none; padding: 8px; }
.classroom .game-card { border-radius: 12px; }
.classroom .hud-item { min-height: 58px; }
.classroom .hud-item span { font-size: 15px; }
.classroom .hud-item strong { font-size: 21px; }
.classroom .canvas-wrap { max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); margin: 0 auto; }
@media (pointer:fine) and (min-width: 900px) { .touch-controls { display: none; } }
@media (max-width: 780px) {
  .app-shell { padding: 8px; }
  .topbar { align-items: flex-start; }
  .brand p { display: none; }
  .logo-mark { width: 38px; height: 38px; }
  .top-actions { max-width: 54%; }
  .icon-btn { min-height: 40px; padding: 8px 10px; font-size: 12px; }
  .hud-item { flex-direction: column; gap: 1px; min-height: 56px; }
  .hud-item span { font-size: 11px; }
  .hud-item strong { font-size: 15px; }
  .panel { border-radius: 18px; }
  .overlay { padding: 12px; }
}
@media (max-width: 520px) {
  .topbar { gap: 8px; }
  .logo-mark { display: none; }
  h1 { font-size: 17px; }
  .top-actions { max-width: 58%; gap: 5px; }
  .icon-btn { padding: 7px 8px; font-size: 11px; }
  .touch-controls { padding: 10px 12px; }
  .touch-btn { min-width: 62px; min-height: 54px; }
  .touch-btn.jump { min-width: 98px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}
