:root{
  --bg:#120d09;
  --panel:#241a12;
  --panel-2:#2c2016;
  --line:#43301f;
  --gold:#f5b642;
  --gold-l:#ffd479;
  --cream:#f7ecd9;
  --muted:#b7a48b;
  --red:#e2563b;
  --font:'Tajawal',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
}
*,*::before,*::after{box-sizing:border-box}
html,body{height:100%;margin:0;padding:0}
body{
  font-family:var(--font);
  background:var(--bg);
  color:var(--cream);
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-user-select:none;user-select:none;
  -webkit-tap-highlight-color:transparent;
  -webkit-text-size-adjust:100%;
  font-size:16px;
  line-height:1.5;
}
button{font-family:inherit;-webkit-user-select:none;user-select:none;touch-action:manipulation;cursor:pointer}
:focus-visible{outline:2px solid var(--gold-l);outline-offset:2px}

#gameRoot{
  position:relative;
  display:flex;flex-direction:column;
  width:100%;height:100vh;height:100dvh;
  background:radial-gradient(120% 80% at 50% 0%,#22180f 0%,#120d09 72%);
}

/* ================= HUD ================= */
.hud{
  position:relative;
  flex:0 0 auto;
  display:flex;align-items:center;justify-content:space-between;gap:6px;
  padding:6px 10px 9px;
  background:linear-gradient(180deg,#261b12 0%,#1a1210 100%);
  border-bottom:1px solid #3a2a1c;
  z-index:5;
}
.hud-side{display:flex;align-items:center;gap:6px;min-width:0}
.hud-end{gap:6px}
.stat{display:flex;flex-direction:column;line-height:1.05;min-width:0}
.stat-l{font-size:10px;color:var(--muted);letter-spacing:.01em;white-space:nowrap}
.stat-v{font-size:19px;font-weight:800;color:var(--gold-l);font-variant-numeric:tabular-nums;white-space:nowrap}

.hud-mid{display:flex;align-items:center;justify-content:center;min-width:0}
.pill{
  display:flex;align-items:center;gap:8px;
  background:#2b2016;border:1px solid #46331f;border-radius:999px;
  padding:3px 12px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.05);
}
.pcol{display:flex;flex-direction:column;align-items:center;line-height:1.05}
.pl{font-size:9px;color:var(--muted);white-space:nowrap}
.pcol b{font-size:14px;font-weight:800;color:var(--cream);font-variant-numeric:tabular-nums}
.psep{width:1px;height:18px;background:#4a3624;display:block}

.hearts{display:flex;gap:2px;align-items:center}
.hearts svg{width:17px;height:17px;color:#e2563b;filter:drop-shadow(0 1px 1px rgba(0,0,0,.5));transition:color .2s,transform .2s}
.hearts svg.off{color:#4a3a2c;transform:scale(.86)}

.icon-btn{
  width:40px;height:40px;border-radius:12px;border:1px solid #4a3624;
  background:linear-gradient(180deg,#3a2c1e,#281e15);
  color:var(--gold-l);display:grid;place-items:center;padding:0;
  transition:transform .1s ease,background .15s ease;
}
.icon-btn svg{width:18px;height:18px}
.icon-btn:active{transform:translateY(2px);background:#4a3623}

.timebar{position:absolute;left:0;right:0;bottom:0;height:3px;background:rgba(255,255,255,.07)}
.timebar i{display:block;height:100%;width:100%;background:linear-gradient(90deg,#f0a92a,#ffd479);transition:width .14s linear}
.timebar.low i{background:linear-gradient(90deg,#c0392b,#e2563b);animation:pulseBar .6s ease-in-out infinite alternate}
@keyframes pulseBar{from{opacity:.55}to{opacity:1}}

/* ================= STAGE ================= */
.stage{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
  background:#20301d;
  isolation:isolate;
}
#cv{display:block;width:100%;height:100%;touch-action:none}

.banner{
  position:absolute;left:50%;top:14%;transform:translate(-50%,-8px);
  z-index:12;pointer-events:none;text-align:center;
  background:rgba(28,19,12,.86);
  border:1px solid #5a4326;
  border-radius:16px;
  padding:8px 18px;
  opacity:0;
  transition:opacity .24s ease,transform .24s ease;
  box-shadow:0 10px 30px rgba(0,0,0,.45);
  max-width:86%;
}
.banner.show{opacity:1;transform:translate(-50%,0)}
.banner[hidden]{display:none}
.banner b{display:block;font-size:17px;font-weight:800;color:var(--gold-l);white-space:nowrap}
.banner span{display:block;font-size:12px;color:#d3c0a5;margin-top:1px;white-space:nowrap}

.combo{
  position:absolute;top:8px;left:50%;transform:translateX(-50%);
  z-index:11;pointer-events:none;
  background:linear-gradient(180deg,#ffd479,#eda42a);
  color:#301f06;font-weight:800;font-size:12px;
  padding:3px 12px;border-radius:999px;
  box-shadow:0 4px 14px rgba(0,0,0,.4);
}
.combo[hidden]{display:none}

/* ================= OVERLAYS ================= */
.overlay{
  position:absolute;inset:0;z-index:60;
  display:flex;align-items:center;justify-content:center;
  padding:10px;
  background:rgba(9,6,4,.72);
  -webkit-backdrop-filter:blur(7px);
  backdrop-filter:blur(7px);
  animation:fadeIn .18s ease;
}
.overlay[hidden]{display:none!important}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}

.panel{
  width:100%;max-width:420px;max-height:100%;
  overflow-y:auto;-webkit-overflow-scrolling:touch;
  background:linear-gradient(180deg,#2b2017,#211810);
  border:1px solid #47331f;
  border-radius:20px;
  padding:16px;
  box-shadow:0 24px 60px rgba(0,0,0,.6),inset 0 1px 0 rgba(255,255,255,.05);
}
.panel-sm{max-width:360px;text-align:center}
.panel h2{margin:0 0 4px;font-size:21px;font-weight:800}
.panel .sub{margin:0 0 12px;color:var(--muted);font-size:13px}

.brand{display:flex;align-items:center;gap:12px;margin-bottom:10px}
.brand-badge{
  flex:0 0 auto;width:52px;height:60px;border-radius:16px;
  background:radial-gradient(120% 100% at 30% 10%,#4a3620,#2a1e13);
  border:1px solid #55401f;
  display:grid;place-items:center;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.06);
}
.brand-badge svg{width:26px;height:33px;filter:drop-shadow(0 3px 5px rgba(0,0,0,.5))}
.brand-txt h1{margin:0;font-size:26px;font-weight:800;letter-spacing:-.01em;line-height:1.15}
.brand-txt p{margin:2px 0 0;font-size:12px;color:var(--gold);font-weight:700;letter-spacing:.06em}

.lede{margin:0 0 10px;font-size:14px;line-height:1.65;color:#ddcdb4}
.how{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}
.how-row{display:flex;align-items:center;gap:8px;font-size:12.5px;color:#cdbb9f;background:#241a12;border:1px solid #3a2b1c;border-radius:10px;padding:6px 9px}
.key{flex:0 0 auto;font-size:11px;font-weight:800;color:#2b1a05;background:linear-gradient(180deg,#ffd479,#eda42a);border-radius:7px;padding:2px 8px}

.mini-stats{display:flex;gap:8px;margin-bottom:12px}
.mini-stats>div{
  flex:1;background:#241a12;border:1px solid #3a2b1c;border-radius:12px;
  padding:7px 10px;display:flex;flex-direction:column;gap:1px;
}
.mini-stats span{font-size:10.5px;color:var(--muted)}
.mini-stats b{font-size:17px;font-weight:800;color:var(--gold-l);font-variant-numeric:tabular-nums}

.btn{
  display:block;width:100%;border:0;border-radius:14px;
  min-height:52px;padding:13px 16px;
  font-size:17px;font-weight:800;letter-spacing:.01em;
  transition:transform .1s ease,box-shadow .1s ease,background .15s ease;
}
.btn-primary{
  background:linear-gradient(180deg,#ffd377,#f0a92a);
  color:#2b1a05;
  box-shadow:0 5px 0 #a86f10,0 12px 22px rgba(0,0,0,.35);
}
.btn-primary:active{transform:translateY(4px);box-shadow:0 1px 0 #a86f10,0 4px 10px rgba(0,0,0,.3)}
.btn-ghost{
  margin-top:8px;min-height:48px;font-size:15px;font-weight:700;
  background:#33271b;color:#f0e2cc;border:1px solid #4b3722;box-shadow:none;
}
.btn-ghost:active{background:#41311f;transform:translateY(1px)}
.btn[hidden]{display:none}

.cracked{width:52px;height:52px;margin:0 auto 6px}
.cracked svg{width:100%;height:100%}

.result-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:2px 0 14px}
.result-grid>div{background:#241a12;border:1px solid #3a2b1c;border-radius:12px;padding:8px}
.result-grid span{display:block;font-size:10.5px;color:var(--muted)}
.result-grid b{display:block;font-size:19px;font-weight:800;color:var(--gold-l);font-variant-numeric:tabular-nums}

.lb-body{margin:4px 0 12px;max-height:46vh;overflow-y:auto;text-align:start}
.lb-empty{color:var(--muted);font-size:13px;text-align:center;padding:12px 4px}
.lb-row{display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:10px;background:#241a12;border:1px solid #3a2b1c;margin-bottom:6px;font-size:13px}
.lb-row .rk{width:22px;font-weight:800;color:var(--gold)}
.lb-row .hd{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.lb-row .sc{font-weight:800;color:var(--gold-l);font-variant-numeric:tabular-nums}
.lb-row.you{border-color:#8a6a24;background:#2f2315}

/* ================= DOCK ================= */
.dock{
  flex:0 0 auto;
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:8px 12px;
  background:linear-gradient(0deg,#261b12 0%,#1a1210 100%);
  border-top:1px solid #3a2a1c;
  z-index:6;
}
.dpad{display:flex;gap:6px;align-items:center}
.pad-btn{
  width:54px;height:48px;padding:0;border-radius:14px;
  background:linear-gradient(180deg,#3b2c1e,#281f15);
  border:1px solid #4f3a26;
  color:var(--gold-l);
  display:grid;place-items:center;
  box-shadow:0 3px 0 #120c07;
  transition:transform .08s ease,background .1s ease;
}
.pad-btn svg{width:20px;height:20px}
.pad-btn:active,.pad-btn.on{transform:translateY(3px);box-shadow:none;background:#4b3723;color:#fff}

.dash-btn{
  position:relative;overflow:hidden;
  width:78px;height:56px;padding:0;
  border-radius:16px;border:1px solid #b7821f;
  background:radial-gradient(circle at 50% 26%,#5d4522,#32230f);
  color:var(--gold-l);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
  box-shadow:0 3px 0 #120c07;
  transition:transform .08s ease;
}
.dash-btn svg{width:20px;height:20px;position:relative;z-index:2}
.dash-btn .dl{font-size:10px;font-weight:800;position:relative;z-index:2;letter-spacing:.02em}
.dash-btn:active{transform:translateY(3px);box-shadow:none}
.dash-btn .cd{
  position:absolute;inset:0;z-index:1;
  background:rgba(8,5,3,.72);
  transform-origin:bottom;
  transform:scaleY(var(--cd,0));
}
.dash-btn.ready{border-color:#ffd479;box-shadow:0 3px 0 #120c07,0 0 16px rgba(255,190,60,.28)}
.dash-btn.ready svg{animation:dashPulse 1.6s ease-in-out infinite}
@keyframes dashPulse{0%,100%{opacity:.85}50%{opacity:1}}

@media (max-width:400px){
  .hud{padding:5px 8px 8px;gap:4px}
  .stat-v{font-size:17px}
  .pill{padding:3px 9px;gap:6px}
  .pcol b{font-size:13px}
  .pl{font-size:8.5px}
  .hearts svg{width:15px;height:15px}
  .icon-btn{width:38px;height:38px}
  .panel{padding:13px}
  .brand-txt h1{font-size:23px}
  .pad-btn{width:50px;height:46px}
  .dpad{gap:5px}
  .dash-btn{width:70px;height:52px}
  .dock{padding:7px 9px;gap:6px}
}
@media (max-height:420px){
  .lede,.how{display:none}
  .brand-badge{width:42px;height:48px}
  .brand-txt h1{font-size:20px}
  .mini-stats{margin-bottom:8px}
  .btn{min-height:46px;padding:10px 14px;font-size:15px}
  .result-grid{margin-bottom:8px}
  .panel{padding:12px}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}
}