:root { --brand: #04955F; --deep: #063B28; --bg: #021A11; --glow: #3EE0A0; --text: #FFFFFF; --panel: rgba(255,255,255,.07); --amber: #FFC93C; --red: #FF5D4D; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none; }
body { position: fixed; inset: 0; background: radial-gradient(120% 90% at 50% 38%, var(--deep) 0%, var(--bg) 72%); }
#app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* ------------------------------------------------------------ header: status | Egypt Post emblem + names | full screen */
header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 14px 18px 0; }
header > :first-child { justify-self: start; } header > :last-child { justify-self: end; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { width: clamp(46px, 8vmin, 78px); height: clamp(46px, 8vmin, 78px); border-radius: 22%; box-shadow: 0 6px 22px rgba(0,0,0,.45), 0 0 0 2px rgba(255,255,255,.18); }
.names { line-height: 1.15; }
.names b { display: block; letter-spacing: .2em; font-size: clamp(14px, 2.4vmin, 24px); font-weight: 800; }
.names small { letter-spacing: .32em; font-size: clamp(9px, 1.4vmin, 13px); color: var(--glow); font-weight: 700; }
.chip, .icon-btn { font: inherit; color: var(--text); background: var(--panel); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; }
.chip { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: clamp(10px, 1.7vmin, 15px); letter-spacing: .14em; font-weight: 700; min-width: 168px; }
.icon-btn { width: 48px; height: 48px; font-size: 24px; line-height: 1; padding: 0; }
#dot { width: 12px; height: 12px; border-radius: 50%; background: #8a9a92; flex: none; }
.chip.ok #dot { background: var(--glow); box-shadow: 0 0 12px var(--glow); }
.chip.wait #dot { background: var(--amber); animation: blink 1s infinite; }
.chip.bad #dot { background: var(--red); animation: blink .6s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ------------------------------------------------------------ the joystick */
#stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.pad { position: relative; width: min(86vw, calc(100vh - 250px), 760px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 36%, rgba(255,255,255,.16), rgba(4,149,95,.30) 55%, rgba(0,0,0,.30));
  border: 4px solid rgba(255,255,255,.30); box-shadow: inset 0 0 70px rgba(0,0,0,.50), 0 22px 60px rgba(0,0,0,.5); transition: border-color .15s, box-shadow .15s; }
.pad.active { border-color: #fff; box-shadow: inset 0 0 70px rgba(0,0,0,.40), 0 0 56px rgba(62,224,160,.45); }
.mark { position: absolute; left: 50%; top: 50%; width: 58%; transform: translate(-50%, -50%); opacity: .16; pointer-events: none; }
.ring { position: absolute; border-radius: 50%; border: 2px dashed rgba(255,255,255,.18); }
.ring.r1 { inset: 12%; } .ring.r2 { inset: 30%; border-style: solid; border-color: rgba(255,255,255,.10); }
.cross { position: absolute; background: rgba(255,255,255,.12); }
.cross.h { left: 8%; right: 8%; top: 50%; height: 2px; } .cross.v { top: 8%; bottom: 8%; left: 50%; width: 2px; }
.hint { position: absolute; font-size: clamp(11px, 2.2vmin, 20px); letter-spacing: .22em; color: rgba(255,255,255,.78); font-weight: 800; pointer-events: none; }
.hint.up { top: 3.2%; left: 50%; transform: translateX(-50%); } .hint.down { bottom: 3.2%; left: 50%; transform: translateX(-50%); }
.hint.left { left: 3.5%; top: 50%; transform: translateY(-50%) rotate(-90deg); transform-origin: left center; margin-left: 1.2em; margin-top: 3em; }
.hint.right { right: 3.5%; top: 50%; transform: translateY(-50%) rotate(90deg); transform-origin: right center; margin-right: 1.2em; margin-top: 3em; }
.knob { position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; margin: -17% 0 0 -17%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 36% 30%, #ffffff 0%, #e9fff6 22%, #bff0d9 46%, var(--brand) 100%);
  box-shadow: 0 16px 32px rgba(0,0,0,.55), inset 0 -10px 22px rgba(4,60,38,.35); will-change: transform; }
.knob i { position: absolute; inset: 22%; border-radius: 50%; border: 3px solid rgba(4,149,95,.55); }
.pad.active .knob { box-shadow: 0 0 42px rgba(62,224,160,.8), 0 16px 32px rgba(0,0,0,.55); }

.buttons { position: absolute; right: 3vmin; bottom: 3vmin; display: flex; gap: 14px; }
.buttons button { width: 22vmin; height: 22vmin; max-width: 160px; max-height: 160px; border-radius: 50%; border: 3px solid rgba(255,255,255,.4);
  background: radial-gradient(circle at 35% 30%, #fff, #d8f5e8); color: var(--brand); font: 800 clamp(12px, 2.4vmin, 20px) system-ui; letter-spacing: .12em; }
.buttons button:active, .buttons button.down { filter: brightness(.9); transform: scale(.95); }

/* ------------------------------------------------------------ footer */
footer { padding: 6px 18px 18px; text-align: center; }
.msg { display: inline-block; font-size: clamp(14px, 2.6vmin, 24px); letter-spacing: .22em; font-weight: 800; color: #fff; min-height: 1.4em;
  padding: .45em 1.2em; border-radius: 999px; background: rgba(4,149,95,.45); border: 1px solid rgba(255,255,255,.22); }
.msg.live { background: var(--brand); box-shadow: 0 0 22px rgba(62,224,160,.4); }
.stats { margin-top: 8px; font-size: 11px; letter-spacing: .12em; color: rgba(255,255,255,.4); min-height: 1.2em; }

.setup { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: grid; place-items: center; z-index: 10; }
.setup[hidden] { display: none; }
.setup form { width: min(92vw, 520px); background: var(--deep); border: 1px solid rgba(255,255,255,.22); border-radius: 18px; padding: 22px; display: grid; gap: 14px; user-select: text; }
.setup h2 { margin: 0 0 4px; letter-spacing: .12em; font-size: 18px; }
.setup label { display: grid; gap: 6px; font-size: 12px; letter-spacing: .12em; color: rgba(255,255,255,.75); }
.setup input { font: 16px ui-monospace, Consolas, monospace; padding: 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: var(--bg); color: var(--text); user-select: text; }
.setup .row { display: flex; gap: 12px; }
.setup button { flex: 1; font: 700 15px system-ui; padding: 14px; border-radius: 12px; border: 0; background: var(--brand); color: #fff; }
.setup button[type=button] { background: rgba(255,255,255,.14); }

@media (orientation: landscape) and (max-height: 700px) { .pad { width: min(60vh, 86vw); } header { padding-top: 8px; } footer { padding-bottom: 8px; } }
@media (max-width: 640px) { .names small { display: none; } .chip { min-width: 0; } }
