* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #041a2b; color: #e8f7ff;
  font-family: "Segoe UI", Tahoma, "Geeza Pro", "Noto Kufi Arabic", "Noto Sans Arabic", Arial, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none; overscroll-behavior: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- مؤثرات الشاشة ---------- */
#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200,0,0,.25) 75%, rgba(170,0,0,.75) 100%); }
#vignette.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { filter: brightness(.7); } 50% { filter: brightness(1.5); } }
#hitFlash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255,60,30,.05), rgba(255,40,20,.55)); }
#cracks { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .5s; filter: drop-shadow(0 0 2px rgba(0,0,0,.6)); }

/* ---------- واجهة اللعب ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.panel { background: rgba(4, 30, 48, .55); border: 1px solid rgba(120, 220, 255, .25); border-radius: 14px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#hudStats { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); padding: 8px 12px; min-width: 230px; }
#hudStats .row { display: flex; align-items: center; gap: 8px; }
#hudStats .row.small { justify-content: space-between; font-size: 14px; margin-top: 6px; color: #bfe9ff; }
#hudStats b { color: #fff; }
.lbl { font-size: 13px; color: #9fd9f5; }
.bar { flex: 1; height: 12px; background: rgba(0,0,0,.45); border-radius: 8px; overflow: hidden; border: 1px solid rgba(255,255,255,.15); }
#hpFill { height: 100%; width: 100%; background: linear-gradient(90deg, #2cf58a, #8dffb8); border-radius: 8px; transition: width .2s; float: right; }
#hpFill.mid { background: linear-gradient(90deg, #ffc531, #ffe08a); }
#hpFill.low { background: linear-gradient(90deg, #ff3b30, #ff8a80); }
#hpTxt { min-width: 30px; text-align: center; }

#radarWrap { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#radar { width: 150px; height: 150px; border-radius: 50%; box-shadow: 0 0 18px rgba(60,255,160,.25); }
#hudBtns { display: flex; gap: 6px; pointer-events: auto; }
.ib { width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(120,220,255,.35); background: rgba(4,30,48,.65); padding: 9px; }
.ib svg { width: 100%; height: 100%; fill: #cfefff; stroke: #cfefff; }
.ib:active { transform: scale(.92); }
#bMute .x { display: none; }
#bMute.muted .x { display: inline; } #bMute.muted .w { display: none; }

#depth { position: absolute; right: calc(10px + env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 62px; }
#depthGauge { position: relative; width: 12px; height: 150px; border-radius: 8px; background: linear-gradient(#5fd3ff, #0a5a8a 50%, #021220); border: 1px solid rgba(255,255,255,.2); }
#depthMark { position: absolute; left: -7px; right: -7px; height: 4px; background: #ffc531; border-radius: 2px; box-shadow: 0 0 6px #ffc531; top: 0; }
#depthTxt { font-size: 14px; }

#weapons { position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.w { width: 96px; padding: 6px 8px 8px; border-radius: 12px; background: rgba(4,30,48,.6); border: 1px solid rgba(120,220,255,.25); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 6px; position: relative; }
.w .ic { font-size: 16px; } .w .nm { font-size: 12px; color: #bfe9ff; } .w .cnt { font-size: 17px; }
.w .cd { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: rgba(0,0,0,.5); overflow: hidden; }
.w .cd i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #3ee3ff, #9ff3ff); }
.w.cooling .cd i { background: linear-gradient(90deg, #ff9a3c, #ffcf6e); }
.w.empty { opacity: .45; }
.w .key { position: absolute; top: -9px; left: 6px; font-size: 10px; background: #0d3c58; border-radius: 6px; padding: 0 5px; color: #9fd9f5; }
body.touch .w .key { display: none; }

#bossBar { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(420px, 40vw); text-align: center; font-weight: bold; color: #ff9aa8; text-shadow: 0 0 8px #000; }
#bossBar .bar { height: 14px; margin-top: 4px; border-color: rgba(255,80,100,.5); }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, #b5179e, #ff3b6b); float: right; transition: width .2s; }

#banner { position: fixed; top: 22%; left: 50%; transform: translate(-50%, -20px); text-align: center; pointer-events: none; opacity: 0; transition: opacity .5s, transform .5s; width: 92%; }
#banner.show { opacity: 1; transform: translate(-50%, 0); }
#banner h2 { margin: 0; font-size: clamp(28px, 6vw, 52px); color: #ffd85a; text-shadow: 0 3px 18px rgba(0,0,0,.8), 0 0 30px rgba(255,200,60,.4); }
#banner p { margin: 8px 0 0; font-size: clamp(14px, 2.6vw, 20px); color: #e2f6ff; text-shadow: 0 2px 8px #000; }
#toast { position: fixed; bottom: calc(110px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: rgba(4,30,48,.85); border: 1px solid rgba(120,220,255,.4); padding: 8px 16px; border-radius: 20px; font-size: 15px; opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }
#scorePop { position: fixed; top: 36%; left: 50%; transform: translateX(-50%); font-size: 26px; font-weight: bold; color: #7dffb0; text-shadow: 0 2px 10px #000; pointer-events: none; opacity: 0; }
#scorePop.go { animation: pop 1s ease-out; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -40px) scale(1); } }

/* ---------- اللمس ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; }
#joyZone { position: absolute; left: 0; bottom: 0; width: 45%; height: 60%; pointer-events: auto; touch-action: none; }
#joyZone .hint { position: absolute; left: calc(40px + env(safe-area-inset-left)); bottom: calc(180px + env(safe-area-inset-bottom)); font-size: 12px; color: rgba(200,240,255,.5); }
#joyBase { position: absolute; left: calc(30px + env(safe-area-inset-left)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(120,220,255,.12), rgba(120,220,255,.25)); border: 2px solid rgba(160,230,255,.45); }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #bff2ff, #2f9fd0); box-shadow: 0 4px 14px rgba(0,0,0,.5); }
#tBtns { position: absolute; right: calc(14px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); width: 230px; height: 230px; pointer-events: none; }
.tb { position: absolute; pointer-events: auto; touch-action: none; border-radius: 50%; border: 2px solid rgba(160,230,255,.5); background: rgba(10,60,90,.55); color: #e8f7ff; font-weight: bold; font-size: 13px; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; padding: 0; }
.tb.on { background: rgba(60,200,255,.55); transform: scale(.94); }
.tb.big { width: 96px; height: 96px; right: 0; bottom: 0; background: rgba(200,60,40,.55); border-color: rgba(255,170,150,.7); font-size: 16px; }
#tMissile { right: 104px; bottom: 6px; background: rgba(200,120,30,.5); }
#tMine { right: 14px; bottom: 104px; background: rgba(190,170,30,.45); }
.tb.sm { width: 64px; height: 50px; border-radius: 14px; font-size: 12px; }
#tUp { right: 160px; bottom: 150px; } #tDown { right: 160px; bottom: 92px; }
.tb.cd-on { opacity: .55; }
body.touch #weapons { bottom: auto; top: calc(10px + env(safe-area-inset-top)); }
body.touch #weapons .w { width: 84px; padding: 4px 6px 6px; }
body.touch #bossBar { top: calc(78px + env(safe-area-inset-top)); }
@media (max-width: 600px) {
  body.touch #weapons { top: calc(150px + env(safe-area-inset-top)); transform: translateX(-50%) scale(.85); }
  body.touch #bossBar { top: calc(205px + env(safe-area-inset-top)); width: 70vw; }
}
body.touch #toast { bottom: auto; top: calc(120px + env(safe-area-inset-top)); }

/* ---------- الشاشات ---------- */
.screen, .modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 16px; background: radial-gradient(ellipse at center, rgba(2,20,36,.35), rgba(2,14,26,.85)); z-index: 10; }
.modal { z-index: 20; background: rgba(2,14,26,.85); }
.card { background: linear-gradient(180deg, rgba(10,50,78,.88), rgba(4,26,44,.92)); border: 1px solid rgba(120,220,255,.35); border-radius: 22px; padding: 22px 26px; width: min(460px, 94vw); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); max-height: 86vh; }
.card.scroll { overflow-y: auto; text-align: right; width: min(620px, 94vw); touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.card h1 { margin: 4px 0; font-size: clamp(34px, 8vw, 52px); color: #ffd85a; text-shadow: 0 4px 20px rgba(255,200,60,.35); letter-spacing: 1px; }
.card h2 { margin: 0 0 14px; color: #ffd85a; }
.card h2.red { color: #ff6b6b; }
.card h3 { margin: 16px 0 6px; color: #8fe3ff; font-size: 17px; }
.card p, .card li { line-height: 1.8; color: #d8f1ff; font-size: 15px; }
.card ul, .card ol { padding-right: 20px; margin: 4px 0; }
kbd { background: #0d3c58; border: 1px solid #2e6c90; border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; font-family: inherit; font-size: 13px; }
.logo svg { width: 120px; height: 60px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-2deg); } }
.sub { margin: 0 0 6px; } .best { color: #9fd9f5 !important; } .best b { color: #ffd85a; }
.btns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.btn { font-size: 18px; padding: 12px 18px; border-radius: 14px; border: 1px solid rgba(120,220,255,.4); background: rgba(20,80,115,.6); color: #e8f7ff; transition: transform .1s, background .2s; }
.btn:hover { background: rgba(30,110,150,.75); } .btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffd85a, #f0a818); color: #2a1a00; border-color: #ffe9a0; font-weight: bold; }
.btn.install { background: linear-gradient(180deg, #34d399, #0f9f6e); color: #032016; font-weight: bold; border-color: #8ff0c8; }
.card .back, .card .close { margin-top: 16px; width: 100%; }
.sig { position: absolute; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 14px; color: #9fd9f5; text-shadow: 0 1px 4px #000; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0; font-size: 16px; }
.set.chk { justify-content: flex-start; cursor: pointer; } .set input[type=checkbox] { width: 22px; height: 22px; accent-color: #ffc531; }
.set input[type=range] { width: 50%; accent-color: #ffc531; }
.seg { display: flex; border-radius: 12px; overflow: hidden; border: 1px solid rgba(120,220,255,.4); }
.seg button { background: rgba(20,80,115,.5); border: 0; color: #e8f7ff; padding: 9px 14px; font-size: 15px; }
.seg button.on { background: #ffc531; color: #2a1a00; font-weight: bold; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.stats div { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.stats span { font-size: 13px; color: #9fd9f5; } .stats b { font-size: 26px; color: #fff; }
#newRec { color: #ffd85a; font-size: 20px; font-weight: bold; animation: pulse 1s infinite; }
.share { display: inline-block; background: #1f6fd0; color: #fff; border-radius: 6px; padding: 0 6px; }

#loading { position: fixed; inset: 0; background: #041a2b; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; color: #9fd9f5; }
.spin { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(120,220,255,.2); border-top-color: #ffc531; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
#err { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #7a1a1a; padding: 10px 16px; border-radius: 12px; z-index: 60; }
#rotateHint { position: fixed; top: 45%; left: 50%; transform: translateX(-50%); background: rgba(4,30,48,.9); padding: 10px 18px; border-radius: 14px; z-index: 5; pointer-events: none; }

@media (max-width: 700px), (max-height: 500px) {
  #radar { width: 110px; height: 110px; }
  #hudStats { min-width: 180px; padding: 6px 10px; }
  #depth { display: none; }
  #depthMini { display: inline; }
  #bossBar { top: calc(84px + env(safe-area-inset-top)); width: 56vw; }
  .ib { width: 38px; height: 38px; padding: 7px; }
  .card { padding: 16px 18px; }
  .btn { font-size: 16px; padding: 10px 14px; }
  .btns { gap: 8px; }
}
@media (max-height: 500px) {
  .logo { display: none; }
  .card h1 { font-size: 28px; margin: 0; }
  .card { padding: 12px 16px; max-height: 92vh; overflow-y: auto; }
  .card.main .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
  .card.main .sub { display: none; }
  .screen { padding: 8px 8px 26px; }
  .stats { gap: 6px; margin: 6px 0; } .stats div { padding: 6px; } .stats b { font-size: 20px; }
  .card h2 { margin-bottom: 8px; }
  #tBtns { transform: scale(.85); transform-origin: bottom right; }
  #joyBase { transform: scale(.85); transform-origin: bottom left; }
  .sig { font-size: 12px; bottom: 4px; }
}
