*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;overflow:hidden;
  background:linear-gradient(180deg,#7C93A8 0%,#9FAEB8 38%,#D7CDB6 72%,#E9DCC4 100%);
  font-family:'Tajawal',system-ui,-apple-system,'Segoe UI',sans-serif;
  color:#14161A;
  user-select:none;-webkit-user-select:none;
  touch-action:none;overscroll-behavior:none;
}
#scene{position:fixed;inset:0;width:100%;height:100%;display:block;z-index:0}
.hidden{display:none !important}

/* ---------------- panels ---------------- */
.panel{
  background:#F7F5F0;color:#14161A;
  border:2px solid #14161A;
  box-shadow:3px 3px 0 rgba(20,22,26,.42);
  padding:6px 10px;
}
.hud-label{font-size:10px;font-weight:700;letter-spacing:.02em;opacity:.62;line-height:1.1}
.money-value{font-size:20px;font-weight:900;line-height:1.1;font-variant-numeric:tabular-nums}

/* ---------------- HUD ---------------- */
#hud{
  position:fixed;inset:0;z-index:20;
  display:flex;flex-direction:column;gap:6px;
  padding:10px 10px 0;pointer-events:none;
}
.hud-top{display:flex;justify-content:space-between;align-items:flex-start;gap:8px}
.stars-panel{display:flex;flex-direction:column;align-items:flex-start;gap:2px}
.stars{position:relative;font-size:17px;line-height:1;letter-spacing:2px;white-space:nowrap;direction:ltr}
.stars-bg{color:#D9D3C5}
.stars-fill{position:absolute;right:0;top:0;overflow:hidden;white-space:nowrap;color:#E12718}

.hud-mid{display:flex;gap:6px;align-items:stretch}
.obj-panel{
  flex:1;min-width:0;font-size:12.5px;font-weight:800;
  display:flex;align-items:center;gap:6px;
  white-space:nowrap;overflow:hidden;
}
.obj-panel span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.timer-panel{
  color:#E12718;font-weight:900;font-size:16px;
  font-variant-numeric:tabular-nums;display:flex;align-items:center;
}
.timer-panel.danger{animation:tpulse .8s infinite alternate}
@keyframes tpulse{from{background:#F7F5F0}to{background:#E12718;color:#F7F5F0}}

.hud-crew{display:flex;gap:6px}
.chip{
  pointer-events:auto;width:74px;padding:4px 5px 5px;
  background:#F7F5F0;border:2px solid #14161A;
  box-shadow:2px 2px 0 rgba(20,22,26,.4);
  display:flex;flex-direction:column;gap:3px;cursor:pointer;
  transition:transform .1s ease;
}
.chip:active{transform:translateY(1px)}
.chip.active{background:#14161A;color:#F7F5F0;border-color:#E12718}
.chip.down{opacity:.42}
.chip-head{display:flex;align-items:center;gap:4px}
.chip svg{width:20px;height:24px;flex:none}
.chip-name{font-size:10.5px;font-weight:800;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chip-bar{height:4px;background:rgba(20,22,26,.18);overflow:hidden}
.chip.active .chip-bar{background:rgba(247,245,240,.25)}
.chip-bar i{display:block;height:100%;background:#14161A;transition:width .2s}
.chip.active .chip-bar i{background:#E12718}

/* ---------------- prompt + toast ---------------- */
#prompt{
  position:fixed;bottom:158px;left:50%;transform:translateX(-50%);
  z-index:22;display:flex;align-items:center;gap:8px;
  background:#F7F5F0;border:2px solid #14161A;box-shadow:3px 3px 0 rgba(20,22,26,.45);
  padding:7px 12px;font-size:13px;font-weight:800;white-space:nowrap;max-width:92vw;
}
#prompt .key{
  display:inline-grid;place-items:center;width:22px;height:22px;
  background:#14161A;color:#F7F5F0;font-size:12px;font-weight:900;flex:none;
}
.toast{
  position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
  z-index:40;background:#14161A;color:#F7F5F0;border:2px solid #F7F5F0;
  padding:10px 16px;font-size:13.5px;font-weight:800;text-align:center;
  max-width:86vw;box-shadow:4px 4px 0 rgba(0,0,0,.35);
  animation:toastIn .22s ease-out;
}
@keyframes toastIn{from{opacity:0;transform:translate(-50%,-44%)}to{opacity:1;transform:translate(-50%,-50%)}}

/* ---------------- controls ---------------- */
#controls{
  position:fixed;left:0;right:0;bottom:0;z-index:24;
  display:flex;justify-content:space-between;align-items:flex-end;
  padding:0 14px 16px;pointer-events:none;
}
#stick{
  pointer-events:auto;width:126px;height:126px;border-radius:50%;
  background:rgba(247,245,240,.14);
  border:2px solid rgba(247,245,240,.72);
  backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);
  display:grid;place-items:center;touch-action:none;
}
#stickKnob{
  width:54px;height:54px;border-radius:50%;
  background:#F7F5F0;border:2px solid #14161A;
  box-shadow:2px 2px 0 rgba(20,22,26,.45);
  display:grid;place-items:center;color:#14161A;
  will-change:transform;
}
#stickKnob svg{width:20px;height:20px;opacity:.4}
#btnGroup{display:flex;align-items:flex-end;gap:10px}
.rbtn{
  pointer-events:auto;border-radius:50%;border:2px solid #14161A;
  background:#F7F5F0;color:#14161A;display:grid;place-items:center;
  box-shadow:3px 3px 0 rgba(20,22,26,.45);
  transition:transform .07s ease,box-shadow .07s ease,background .1s;
  padding:0;cursor:pointer;
}
.rbtn svg{width:30px;height:30px}
.rbtn:active{transform:translate(2px,2px);box-shadow:1px 1px 0 rgba(20,22,26,.45)}
.rbtn.big{width:78px;height:78px}
.rbtn.mid{width:64px;height:64px}
.rbtn.small{width:54px;height:54px;background:#14161A;color:#F7F5F0}
.rbtn.small svg{width:24px;height:24px}
.rbtn:disabled{opacity:.35}

/* ---------------- overlays ---------------- */
.overlay{
  position:fixed;inset:0;z-index:50;display:grid;place-items:center;
  padding:18px;background:rgba(20,22,26,.76);
  backdrop-filter:blur(7px);-webkit-backdrop-filter:blur(7px);
  overflow-y:auto;
}
.card{
  background:#F7F5F0;color:#14161A;border:2px solid #14161A;
  box-shadow:6px 6px 0 rgba(0,0,0,.4);
  padding:20px;max-width:380px;width:100%;
}
.kicker{
  font-size:10.5px;font-weight:800;letter-spacing:.12em;
  color:#E12718;margin-bottom:6px;text-transform:uppercase;
}
.kicker.light{color:#E12718}
h1{font-size:40px;font-weight:900;line-height:1;margin:0 0 8px;letter-spacing:-.02em}
h2{font-size:26px;font-weight:900;line-height:1.15;margin:0 0 10px}
h3{font-size:20px;font-weight:900;margin:0 0 12px;line-height:1.2}
.lead{font-size:14px;line-height:1.55;margin:0 0 16px;font-weight:500;color:#3A3F45}
.start-grid{display:flex;flex-direction:column;gap:6px;margin-bottom:14px;font-size:13px;font-weight:700}
.start-grid b{
  display:inline-grid;place-items:center;width:20px;height:20px;
  background:#14161A;color:#F7F5F0;font-size:11px;margin-inline-end:8px;
}
.keys{list-style:none;display:flex;flex-wrap:wrap;gap:8px;padding:0;margin:0 0 18px;font-size:11.5px;font-weight:700;color:#3A3F45}
.keys span{
  display:inline-block;background:#14161A;color:#F7F5F0;
  padding:1px 6px;font-size:10.5px;font-weight:800;margin-inline-end:4px;
}
.btn-primary{
  width:100%;padding:14px;border:2px solid #14161A;background:#E12718;color:#F7F5F0;
  font-family:inherit;font-size:16px;font-weight:900;cursor:pointer;
  box-shadow:4px 4px 0 rgba(20,22,26,.55);transition:transform .08s,box-shadow .08s;
}
.btn-primary:active{transform:translate(2px,2px);box-shadow:2px 2px 0 rgba(20,22,26,.55)}
.btn-ghost{
  width:100%;margin-top:10px;padding:11px;border:2px solid #14161A;background:transparent;
  color:#14161A;font-family:inherit;font-size:13px;font-weight:800;cursor:pointer;
}
.btn-ghost:active{background:#14161A;color:#F7F5F0}
.fine{font-size:10.5px;color:#7A7570;text-align:center;margin-top:10px;font-weight:600}

/* ---------------- loader ---------------- */
#loader{background:#23262B;z-index:60}
.loader-inner{width:210px;text-align:center}
.loader-bar{height:6px;background:rgba(247,245,240,.16);overflow:hidden;border:1px solid rgba(247,245,240,.3)}
.loader-bar i{display:block;height:100%;width:40%;background:#E12718;animation:lb 1.1s infinite ease-in-out}
@keyframes lb{0%{transform:translateX(-110%)}100%{transform:translateX(320%)}}
.loader-text{color:#F7F5F0;font-size:12px;font-weight:700;margin-top:12px;letter-spacing:.06em}

/* ---------------- wheel ---------------- */
#wheel{background:rgba(20,22,26,.88)}
.wheel-inner{width:100%;max-width:430px;text-align:center}
.wheel-title{color:#F7F5F0;font-size:22px;font-weight:900;margin:0 0 16px}
.wheel-cards{display:flex;gap:8px;justify-content:center;margin-bottom:16px}
.wcard{
  flex:1;min-width:0;background:#F7F5F0;border:2px solid #14161A;
  padding:8px 6px 10px;cursor:pointer;position:relative;
  transition:transform .12s ease,box-shadow .12s ease;
}
.wcard:active{transform:scale(.97)}
.wcard.active{background:#E12718;color:#F7F5F0;border-color:#F7F5F0}
.wcard.down{opacity:.4}
.wcard svg.portrait{width:100%;height:auto;display:block;margin-bottom:6px}
.wcard .wname{font-size:12px;font-weight:900;line-height:1.2;margin-bottom:2px}
.wcard .wrole{font-size:9.5px;font-weight:700;opacity:.7;line-height:1.2}
.wcard .wkey{
  position:absolute;top:4px;inset-inline-start:4px;
  background:#14161A;color:#F7F5F0;font-size:9px;font-weight:900;
  width:16px;height:16px;display:grid;place-items:center;
}
.wcard.active .wkey{background:#F7F5F0;color:#E12718}
.wcard .whp{height:4px;background:rgba(20,22,26,.2);margin-top:5px}
.wcard .whp i{display:block;height:100%;background:#14161A}
.wcard.active .whp{background:rgba(247,245,240,.35)}
.wcard.active .whp i{background:#F7F5F0}

/* ---------------- minigame ---------------- */
.mg-card{max-width:350px}
.seq-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:14px 0}
.seq-btn{
  aspect-ratio:1/1;border:2px solid #14161A;background:#EDE9E0;
  display:grid;place-items:center;cursor:pointer;padding:0;
  font-family:inherit;transition:background .1s,transform .08s;
}
.seq-btn svg{width:34px;height:34px}
.seq-btn.lit{background:#E12718;transform:scale(.96)}
.seq-btn.lit svg{stroke:#F7F5F0}
.seq-btn.err{animation:shake .3s}
@keyframes shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-5px)}75%{transform:translateX(5px)}}
.mg-status{font-size:12.5px;font-weight:800;text-align:center;min-height:18px;color:#E12718}
.meter{margin-bottom:12px}
.meter-label{display:flex;justify-content:space-between;font-size:11px;font-weight:800;margin-bottom:4px}
.meter-track{height:16px;background:#DDD8CC;border:2px solid #14161A;overflow:hidden}
.meter-track i{display:block;height:100%;background:#14161A;transition:width .08s linear}
.meter-track.heat i{background:#E12718;transition:width .08s linear}
.drill-btn{
  width:100%;padding:18px;border:2px solid #14161A;background:#5A5F4A;color:#F7F5F0;
  font-family:inherit;font-size:16px;font-weight:900;cursor:pointer;margin-top:6px;
  box-shadow:4px 4px 0 rgba(20,22,26,.4);
}
.drill-btn:active,.drill-btn.held{background:#E12718;transform:translate(2px,2px);box-shadow:2px 2px 0 rgba(20,22,26,.4)}
.drill-btn:disabled{background:#B7B3A8;color:#6A665E}

/* ---------------- end card ---------------- */
.end-card{text-align:center}
.end-money{font-size:44px;font-weight:900;line-height:1;margin:6px 0 2px;color:#E12718;font-variant-numeric:tabular-nums}
.end-money em{font-size:15px;font-style:normal;font-weight:800;color:#14161A;margin-inline-start:6px}
.end-rank{
  display:inline-block;margin:10px 0 14px;padding:4px 12px;
  background:#14161A;color:#F7F5F0;font-size:12.5px;font-weight:800;
}
.end-best{font-size:12px;font-weight:700;color:#3A3F45;margin-bottom:16px}
.end-actions{display:flex;flex-direction:column;gap:0}

/* ---------------- leaderboard ---------------- */
.board-card{max-width:360px}
.board-list{margin:12px 0;max-height:46vh;overflow-y:auto}
.board-row{
  display:flex;align-items:center;gap:10px;padding:8px 6px;
  border-bottom:1px solid rgba(20,22,26,.13);font-size:13px;font-weight:700;
}
.board-row .r{width:22px;font-weight:900;color:#E12718;flex:none}
.board-row .h{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.board-row .s{font-variant-numeric:tabular-nums;font-weight:900}
.board-row.me{background:rgba(225,39,24,.09)}
.board-empty{text-align:center;font-size:12.5px;font-weight:700;color:#5A5F4A;padding:18px 8px;line-height:1.6}

/* ---------------- language toggle ---------------- */
.lang-btn{
  pointer-events:auto;font-family:inherit;font-size:12px;font-weight:900;letter-spacing:.06em;
  padding:8px 10px;min-width:44px;min-height:34px;
  border:2px solid #F7F5F0;background:#14161A;color:#F7F5F0;
  box-shadow:3px 3px 0 rgba(20,22,26,.42);cursor:pointer;
  transition:transform .08s ease,box-shadow .08s ease;
}
.lang-btn:active{transform:translate(2px,2px);box-shadow:1px 1px 0 rgba(20,22,26,.42)}
.card{position:relative}
.start-lang{position:absolute;top:12px;inset-inline-end:12px;z-index:2}
html[dir="ltr"] .hud-label{letter-spacing:.06em}
html[dir="ltr"] .obj-panel{font-size:12px}

/* ---------------- responsive ---------------- */
@media (max-width:430px){
  .money-value{font-size:18px}
  .stars{font-size:15px}
  .chip{width:66px}
  .rbtn.big{width:72px;height:72px}
  .rbtn.mid{width:60px;height:60px}
  .rbtn.small{width:50px;height:50px}
  #stick{width:114px;height:114px}
  #stickKnob{width:50px;height:50px}
  h1{font-size:34px}
  #prompt{bottom:150px;font-size:12px}
}
@media (max-height:430px){
  .hud-crew{display:none}
  #stick{width:96px;height:96px}
  #stickKnob{width:44px;height:44px}
  .rbtn.big{width:64px;height:64px}
  .rbtn.mid{width:54px;height:54px}
  .rbtn.small{width:44px;height:44px}
  #prompt{bottom:112px}
  .card{padding:14px}
  h1{font-size:28px}
  .keys{display:none}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001s !important;transition-duration:.001s !important}
}

/* ---------------- missions & unlocks ---------------- */
.mission-tag{
  font-size:9.5px;font-weight:900;color:#E12718;
  letter-spacing:.02em;line-height:1.2;margin-top:3px;white-space:nowrap;
}
.mission-line{
  display:inline-block;background:#14161A;color:#F7F5F0;
  font-size:11.5px;font-weight:900;padding:4px 12px;
  margin-bottom:12px;letter-spacing:.05em;white-space:nowrap;
}
.start-grid .roster-row{
  display:flex;align-items:center;gap:8px;padding:6px 7px;
  border:2px solid #14161A;background:#F1EDE4;
}
.roster-row.active{background:#F7F5F0;border-color:#E12718}
.roster-row.locked{opacity:.62;background:#E7E1D5;border-color:#6A665E}
.roster-row svg{width:22px;height:26px;flex:none}
.roster-row .rr-name{flex:1;min-width:0;font-size:12px;font-weight:900;line-height:1.2}
.roster-row .rr-role{display:block;font-size:9.5px;font-weight:700;opacity:.65;margin-top:1px}
.roster-row .rr-lock{font-size:9.5px;font-weight:900;color:#E12718;white-space:nowrap}
.roster-row.active .rr-lock{color:#3E7A45}
.unlock-line{font-size:11px;font-weight:800;color:#5A5F4A;line-height:1.55;margin:0 0 14px}
.end-unlock{font-size:11.5px;font-weight:800;color:#3E7A45;line-height:1.55;margin-bottom:14px}
.end-unlock.warn{color:#E12718}
.chip{position:relative}
.chip.lock{opacity:.4}
.chip-lock{
  position:absolute;top:3px;inset-inline-end:3px;
  color:#E12718;display:grid;place-items:center;
}
.chip-lock svg{width:11px;height:11px}
.wcard.lock{opacity:.55;filter:grayscale(.72)}
.wcard.lock .wrole{color:#E12718;opacity:1;font-weight:900}