/* ============ أساسيات ============ */
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%;margin:0;padding:0}
body{
  font-family:'Cairo',ui-sans-serif,system-ui,-apple-system,sans-serif;
  background:#FAF7F2;
  color:#3E3550;
  overflow:hidden;
  -webkit-user-select:none;user-select:none;
  overscroll-behavior:none;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;color:inherit;border:0;background:none;cursor:pointer}
.hidden{display:none!important}

#game{
  position:relative;
  display:flex;
  flex-direction:column;
  width:100%;
  height:100vh;
  height:100dvh;
  overflow:hidden;
  background:#FAF7F2;
}

/* ============ HUD ============ */
#hud{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:6px;
  padding:8px 12px 4px;
}
.hud-row{
  flex:1 1 auto;
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
}
.chip{
  display:flex;
  align-items:center;
  gap:6px;
  min-width:0;
  background:#fff;
  border-radius:16px;
  padding:4px 9px;
  box-shadow:0 6px 18px rgba(90,74,120,.12);
}
.chip-dot{
  width:12px;height:12px;border-radius:50%;
  flex:0 0 auto;
  background:#C9B8F0;
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.75);
}
.chip-body{display:flex;flex-direction:column;align-items:flex-start;line-height:1;min-width:0}
.chip-b .chip-body{align-items:flex-end}
.score{
  font-size:clamp(22px,8vw,42px);
  font-weight:800;
  line-height:.95;
  color:#7C5CE0;
  font-variant-numeric:tabular-nums;
}
.chip-b .score{color:#F0925C}
.pts{
  font-size:9px;
  font-weight:600;
  color:#8B81A6;
  margin-top:2px;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}
.clock-wrap{
  flex:0 0 auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  min-width:64px;
}
.clock{
  font-size:clamp(14px,4.4vw,20px);
  font-weight:800;
  letter-spacing:.4px;
  font-variant-numeric:tabular-nums;
  color:#3E3550;
}
.phase{font-size:9px;font-weight:600;color:#8B81A6;white-space:nowrap;margin-top:1px}
.pause-btn{
  flex:0 0 auto;
  width:34px;height:34px;
  border-radius:12px;
  background:#fff;
  box-shadow:0 6px 18px rgba(90,74,120,.12);
  display:grid;place-items:center;
  transition:transform .1s ease;
}
.pause-btn:active{transform:scale(.92)}
.pause-btn svg{width:15px;height:15px;fill:#3E3550}

/* ============ STAGE ============ */
#stage{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
#pitch{
  display:block;
  width:100%;
  height:100%;
  touch-action:none;
}

/* ============ DOCK ============ */
[data-meeem-game-controls]{flex:0 0 auto;padding:4px 14px 10px}
.dock-inner{
  direction:ltr;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:10px;
}
.stick{
  position:relative;
  width:108px;height:108px;
  border-radius:50%;
  background:radial-gradient(circle at 50% 36%,#FFFFFF 0%,#F3EDFC 68%,#E9E0F9 100%);
  box-shadow:0 6px 18px rgba(90,74,120,.12),inset 0 0 0 2px #EAE1F9;
  touch-action:none;
}
.stick::before{
  content:'';
  position:absolute;inset:15px;
  border-radius:50%;
  border:2px dashed rgba(124,92,224,.18);
}
.stick-knob{
  position:absolute;left:50%;top:50%;
  width:48px;height:48px;border-radius:50%;
  background:linear-gradient(180deg,#B79DF1,#8E6BE8);
  box-shadow:0 6px 14px rgba(124,92,224,.38),inset 0 2px 5px rgba(255,255,255,.5);
  transform:translate(-50%,-50%);
  will-change:transform;
}
.action-group{
  display:grid;
  grid-template-columns:54px 66px;
  grid-template-rows:50px 66px;
  gap:8px;
  align-items:end;
}
.act{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  border-radius:18px;
  background:#fff;
  color:#3E3550;
  box-shadow:0 6px 18px rgba(90,74,120,.12);
  font-weight:800;font-size:10px;line-height:1;
  transition:transform .08s ease,background .12s ease;
  touch-action:none;
  padding:0;
}
.act svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.act:active,.act.is-down{transform:scale(.93);background:#F3EDFB}
.act-shoot{
  border-radius:24px;
  color:#fff;
  font-size:11px;
  background-color:#7C5CE0;
  background-image:
    linear-gradient(to top, rgba(255,255,255,.55) var(--charge,0%), rgba(255,255,255,0) var(--charge,0%)),
    linear-gradient(180deg,#8E6BE8,#6F4BD6);
  box-shadow:0 8px 20px rgba(124,92,224,.34);
}
.act-shoot svg{width:24px;height:24px}
.act-shoot:active,.act-shoot.is-down{background-color:#6F4BD6;transform:scale(.95)}

/* ============ OVERLAYS ============ */
.overlay{
  position:absolute;inset:0;z-index:40;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:14px;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  background:rgba(250,247,242,.9);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  animation:ovIn .22s ease-out;
}
@keyframes ovIn{from{opacity:0}to{opacity:1}}
.overlay-end{padding-top:104px}
.ov-card{
  width:100%;
  max-width:390px;
  margin:auto 0;
  background:#fff;
  border-radius:24px;
  padding:16px;
  box-shadow:0 16px 40px rgba(90,74,120,.16);
  border:1px solid #F1EBFA;
}
.center-card{text-align:center;display:flex;flex-direction:column;gap:10px;align-items:stretch}

.menu-head{display:flex;align-items:center;gap:12px;margin-bottom:14px}
.menu-badge{
  width:52px;height:52px;flex:0 0 auto;
  border-radius:18px;
  display:grid;place-items:center;
  font-size:26px;
  background:linear-gradient(140deg,#EFE9FB,#FFE7D6);
  box-shadow:inset 0 0 0 1px #F3ECFB;
}
.menu-badge.small{width:44px;height:44px;font-size:20px;margin:0 auto}
.menu-head-text{min-width:0}
.menu-title{font-size:21px;font-weight:800;margin:0;letter-spacing:0;line-height:1.2}
.menu-sub{font-size:12px;color:#8B81A6;margin:3px 0 0;font-weight:600}

.field-group{margin-bottom:12px}
.lbl{font-size:11.5px;font-weight:700;color:#7A6E96;display:block;margin-bottom:6px}
.seg{display:flex;gap:4px;background:#F4EFFB;border-radius:14px;padding:4px}
.seg-btn{
  flex:1;
  padding:9px 4px;
  border-radius:11px;
  font-size:12.5px;
  font-weight:700;
  color:#7A6E96;
  transition:background .15s ease,color .15s ease,box-shadow .15s ease;
  white-space:nowrap;
}
.seg-btn.is-on{background:#fff;color:#5B3FC4;box-shadow:0 3px 10px rgba(90,74,120,.12)}
.seg-btn:active{transform:scale(.98)}

.kit-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}
.kit-row .lbl{margin-bottom:0}
.swatches{display:flex;gap:7px}
.swatch{
  width:28px;height:28px;border-radius:50%;
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.9),0 2px 6px rgba(90,74,120,.18);
  transition:transform .12s ease,box-shadow .12s ease;
  padding:0;
}
.swatch.is-on{
  transform:scale(1.08);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.95),0 0 0 3px var(--ring,#7C5CE0),0 6px 12px rgba(90,74,120,.22);
}

.hint-box{
  background:#FBF8FE;
  border:1px solid #F1EBFA;
  border-radius:16px;
  padding:10px 12px;
  margin-bottom:12px;
}
.hint-line{font-size:11.5px;line-height:1.6;color:#4E4468;font-weight:600}
.hint-line b{color:#5B3FC4}
.hint-line.muted{color:#8B81A6;font-weight:600;margin-top:4px}
.hint-line.muted b{color:#8B81A6}

.btn-primary{
  width:100%;
  padding:14px;
  border-radius:18px;
  background:linear-gradient(135deg,#8E6BE8,#6F4BD6);
  color:#fff;
  font-weight:800;
  font-size:16px;
  box-shadow:0 10px 24px rgba(124,92,224,.32);
  transition:transform .1s ease,box-shadow .1s ease;
}
.btn-primary:active{transform:scale(.98);box-shadow:0 6px 16px rgba(124,92,224,.28)}
.btn-ghost{
  width:100%;
  padding:11px;
  margin-top:8px;
  border-radius:16px;
  background:#F4EFFB;
  color:#5B3FC4;
  font-weight:700;
  font-size:13.5px;
  transition:background .12s ease,transform .1s ease;
}
.btn-ghost:active{background:#EBE2FA;transform:scale(.99)}

.menu-foot{margin-top:14px}
.best-line{font-size:12px;font-weight:700;color:#7A6E96;text-align:center}
.best-line b{color:#5B3FC4;font-size:14px}
.best-line.center{margin:2px 0 6px}

.board-box{
  margin-top:10px;
  border-radius:16px;
  background:#FBF8FE;
  border:1px solid #F1EBFA;
  padding:10px 12px;
}
.board-head{
  display:flex;align-items:center;justify-content:space-between;
  font-size:11.5px;font-weight:800;color:#7A6E96;
}
.btn-tiny{
  font-size:10.5px;font-weight:800;
  background:#EDE5FB;color:#5B3FC4;
  padding:5px 9px;border-radius:10px;
}
.btn-tiny:active{transform:scale(.96)}
.board-body{margin-top:6px}
.board-note{font-size:11px;color:#8B81A6;margin:2px 0 0;line-height:1.55;font-weight:600}
.board-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}
.board-list li{
  display:flex;align-items:center;gap:8px;
  font-size:11.5px;font-weight:700;color:#4E4468;
  background:#fff;border-radius:10px;padding:5px 9px;
}
.board-list li.is-you{background:#EFE9FB;color:#5B3FC4}
.board-list .rank{width:16px;color:#A79DC2;font-weight:800}
.board-list .handle{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.board-list .sc{font-variant-numeric:tabular-nums;font-weight:800}

/* ============ END SCREEN ============ */
.end-card{text-align:center}
.end-top{margin-bottom:12px}
.end-title{font-size:20px;font-weight:800;color:#3E3550}
.end-score{
  font-size:44px;font-weight:800;line-height:1.05;
  color:#7C5CE0;margin:2px 0 0;
  font-variant-numeric:tabular-nums;
}
.end-sub{font-size:12px;color:#8B81A6;font-weight:600;margin-top:2px}
.end-stats{
  background:#FBF8FE;
  border:1px solid #F1EBFA;
  border-radius:16px;
  padding:10px 12px;
  margin-bottom:10px;
  display:flex;flex-direction:column;gap:6px;
}
.stat-row{
  display:flex;align-items:center;justify-content:space-between;
  font-size:12px;font-weight:700;color:#5C527A;
}
.stat-row b{font-variant-numeric:tabular-nums;color:#3E3550}
.stat-row.total{
  border-top:1px dashed #E9E1F7;
  padding-top:6px;
  color:#5B3FC4;font-size:13px;
}
.stat-row.total b{color:#5B3FC4;font-size:16px}
.end-board{
  font-size:11px;font-weight:700;color:#8B81A6;
  min-height:14px;margin-bottom:8px;
}
.end-card .btn-ghost{margin-top:8px}

/* ============ شاشات قصيرة / أفقية ============ */
@media (max-height:620px){
  .overlay-end{padding-top:74px}
  .menu-badge{width:44px;height:44px;font-size:22px}
  .menu-title{font-size:19px}
}
@media (orientation:landscape) and (max-height:520px){
  .stick{width:84px;height:84px}
  .stick-knob{width:38px;height:38px}
  .action-group{grid-template-columns:48px 58px;grid-template-rows:44px 58px;gap:6px}
  [data-meeem-game-controls]{padding:2px 12px 6px}
  .act{font-size:9px;border-radius:15px}
  .act svg{width:16px;height:16px}
  .act-shoot svg{width:20px;height:20px}
  .overlay{padding:8px}
  .overlay-end{padding-top:16px}
  .ov-card{padding:12px}
  #hud{padding:4px 10px 2px}
  .score{font-size:24px}
}

@media (prefers-reduced-motion:reduce){
  .overlay{animation:none}
  *{transition-duration:.01ms!important}
}