/* =========================================================
   زحمة المقهى — seventies café visual system
   ========================================================= */
:root{
  --cream:#F2E3C6;
  --cream-2:#E9D6B3;
  --cream-3:#FBF1DC;
  --choc:#4A2C1A;
  --choc-2:#6B472E;
  --ink:#2B1810;
  --mustard:#D9A441;
  --burnt:#C1502E;
  --burnt-d:#8E3320;
  --avocado:#7A8B4A;
  --brass:#B08D57;
  --shadow:0 18px 46px rgba(0,0,0,.55);
}

*{ box-sizing:border-box; }
html,body{
  margin:0; padding:0; height:100%; width:100%;
  background:#1a0f08;
  font-family:'Tajawal', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color:var(--choc);
  overscroll-behavior:none;
  -webkit-tap-highlight-color:transparent;
}
body{ overflow:hidden; }
button{ font-family:inherit; }
.hidden{ display:none !important; }

#game{
  position:relative;
  width:100%;
  height:100%;
  height:100dvh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:
    radial-gradient(circle at 50% 0%, #4a2c1a 0%, #1a0f08 70%);
  user-select:none;
  -webkit-user-select:none;
}

/* ================= HUD ================= */
[data-meeem-game-hud]{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  background:linear-gradient(180deg,#3A2313 0%,#2A1810 100%);
  border-bottom:2px solid rgba(176,141,87,.45);
  box-shadow:0 6px 18px rgba(0,0,0,.45);
  z-index:20;
}
.hud-stats{
  display:flex;
  gap:8px;
  flex:1 1 auto;
  min-width:0;
}
.stat{
  flex:1 1 0;
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:1px;
  padding:5px 6px;
  border-radius:12px;
  background:linear-gradient(180deg, rgba(242,227,198,.14), rgba(242,227,198,.06));
  border:1px solid rgba(176,141,87,.4);
}
.stat-label{
  font-size:10.5px;
  font-weight:700;
  letter-spacing:.02em;
  color:#E9D6B3;
  opacity:.85;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:100%;
}
.stat-value{
  font-size:18px;
  font-weight:900;
  line-height:1.1;
  color:#FBF1DC;
  font-variant-numeric:tabular-nums;
  font-feature-settings:"tnum";
}
.stat.warn{ background:linear-gradient(180deg, rgba(217,164,65,.35), rgba(217,164,65,.15)); }
.stat.crit{ background:linear-gradient(180deg, rgba(193,80,46,.5), rgba(193,80,46,.25)); }
.stat.crit .stat-value{ color:#FFD3A8; }

.icon-btn{
  flex:0 0 auto;
  width:40px; height:40px;
  display:grid; place-items:center;
  border-radius:12px;
  border:1px solid rgba(176,141,87,.45);
  background:rgba(242,227,198,.1);
  color:#F2E3C6;
  cursor:pointer;
  transition:transform .12s ease, background .15s ease;
}
.icon-btn svg{ width:19px; height:19px; fill:currentColor; }
.icon-btn:active{ transform:scale(.93); background:rgba(242,227,198,.22); }
.icon-btn.small{ width:34px; height:34px; background:rgba(74,44,26,.1); color:var(--choc); border-color:rgba(74,44,26,.2); }
.icon-btn.small svg{ stroke:currentColor; }

/* ================= STAGE ================= */
[data-meeem-game-stage]{
  position:relative;
  flex:1 1 auto;
  min-height:0;
  overflow:hidden;
  background:#2a1a10;
}
#cv{
  display:block;
  width:100%;
  height:100%;
  touch-action:none;
}
.bubble-layer{
  position:absolute;
  inset:0;
  pointer-events:none;
  overflow:hidden;
  z-index:5;
}
.bubble{
  position:absolute;
  transform:translate(-50%,-100%);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
  min-width:66px;
  padding:5px 9px 6px;
  border-radius:13px;
  background:#FFF6E4;
  border:2px solid var(--brass);
  box-shadow:0 7px 16px rgba(0,0,0,.42);
  font-size:12px;
  font-weight:800;
  color:var(--choc);
  white-space:nowrap;
  will-change:left,top;
}
.bubble::after{
  content:'';
  position:absolute;
  bottom:-8px; left:50%;
  transform:translateX(-50%);
  border:7px solid transparent;
  border-top-color:var(--brass);
}
.bubble-name{ line-height:1.1; }
.bubble-bar{
  width:58px; height:5px;
  border-radius:99px;
  background:#E0CDA8;
  overflow:hidden;
}
.bubble-bar i{
  display:block;
  height:100%;
  width:100%;
  border-radius:99px;
  background:var(--avocado);
  transition:width .12s linear, background .3s;
}
.bubble.warn .bubble-bar i{ background:var(--mustard); }
.bubble.crit .bubble-bar i{ background:var(--burnt); }
.bubble.taken{
  border-color:var(--avocado);
  box-shadow:0 0 0 3px rgba(122,139,74,.4), 0 7px 16px rgba(0,0,0,.4);
}
.bubble.crit{ animation:pulseB .7s ease-in-out infinite; }
@keyframes pulseB{ 0%,100%{ transform:translate(-50%,-100%) scale(1);} 50%{ transform:translate(-50%,-100%) scale(1.07);} }

.objective{
  position:absolute;
  top:8px;
  left:50%;
  transform:translateX(-50%);
  max-width:calc(100% - 24px);
  width:max-content;
  padding:6px 14px;
  border-radius:13px;
  background:rgba(251,241,220,.95);
  border:2px solid var(--brass);
  box-shadow:0 8px 18px rgba(0,0,0,.35);
  font-size:13px;
  font-weight:800;
  color:var(--choc);
  text-align:center;
  pointer-events:none;
  z-index:6;
  line-height:1.3;
}
.hint{
  position:absolute;
  bottom:12px;
  left:50%;
  transform:translateX(-50%);
  padding:8px 16px;
  border-radius:99px;
  background:rgba(43,24,16,.86);
  color:#FBF1DC;
  font-size:13px;
  font-weight:700;
  pointer-events:none;
  z-index:6;
  transition:opacity .25s;
  max-width:calc(100% - 24px);
  text-align:center;
}

/* ================= CONTROLS ================= */
[data-meeem-game-controls]{
  flex:0 0 auto;
  display:flex !important;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:8px 14px 10px;
  background:linear-gradient(180deg,#2A1810 0%,#1c110a 100%);
  border-top:2px solid rgba(176,141,87,.35);
  z-index:20;
}
.ctrl-group{ display:flex; align-items:center; }
.ctrl-right{ justify-content:flex-end; }

.joystick{
  position:relative;
  width:104px; height:104px;
  border-radius:50%;
  background:radial-gradient(circle at 50% 35%, rgba(242,227,198,.16), rgba(242,227,198,.05) 70%);
  border:2px solid rgba(176,141,87,.5);
  touch-action:none;
  cursor:grab;
}
.joy-ring{
  position:absolute; inset:14px;
  border-radius:50%;
  border:1px dashed rgba(176,141,87,.35);
}
.joy-knob{
  position:absolute;
  left:50%; top:50%;
  width:46px; height:46px;
  margin:0;
  border-radius:50%;
  background:radial-gradient(circle at 40% 32%, #E9D6B3, #C1502E 78%);
  box-shadow:0 5px 14px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.5);
  transform:translate(-50%,-50%);
  will-change:transform;
  pointer-events:none;
}
.act-btn{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:118px;
  min-height:64px;
  padding:0 18px;
  border:0;
  border-radius:20px;
  background:linear-gradient(180deg,#D2603A,#B8452A);
  color:#FFF4E2;
  font-size:16px;
  font-weight:900;
  box-shadow:0 5px 0 var(--burnt-d), 0 10px 22px rgba(140,50,25,.4);
  cursor:pointer;
  transition:transform .1s ease, box-shadow .1s ease, opacity .2s;
  touch-action:manipulation;
}
.act-btn .act-icon{ width:24px; height:24px; flex:0 0 auto; }
.act-btn:active{ transform:translateY(4px); box-shadow:0 1px 0 var(--burnt-d); }
.act-btn:disabled{ opacity:.42; box-shadow:0 5px 0 #6a4030; }

/* ================= SHEET (brew) ================= */
.sheet{
  position:absolute;
  left:0; right:0; bottom:0;
  z-index:60;
  max-height:66%;
  display:flex;
  flex-direction:column;
  gap:9px;
  padding:12px 14px 14px;
  border-radius:22px 22px 0 0;
  background:linear-gradient(180deg,#FBF1DC 0%,#F0E0C2 100%);
  color:var(--choc);
  border-top:3px solid var(--brass);
  box-shadow:0 -14px 44px rgba(0,0,0,.6);
  overflow-y:auto;
  animation:sheetUp .22s ease-out;
}
@keyframes sheetUp{ from{ transform:translateY(30px); opacity:.4;} to{ transform:none; opacity:1;} }
.sheet-head{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
}
.sheet-titles{ display:flex; flex-direction:column; }
.sheet-kicker{ font-size:10.5px; font-weight:800; color:var(--burnt); letter-spacing:.04em; }
.sheet-title{ font-size:19px; font-weight:900; color:var(--choc); }
.step-dots{ display:flex; gap:6px; }
.step-dots span{
  flex:1 1 0;
  height:6px;
  border-radius:99px;
  background:#DFCBAA;
  transition:background .25s;
}
.step-dots span.done{ background:var(--avocado); }
.step-dots span.now{ background:var(--mustard); box-shadow:0 0 0 2px rgba(217,164,65,.3); }

.brew-stage{ display:flex; flex-direction:column; gap:10px; }
.brew-label{ font-size:14px; font-weight:800; color:var(--choc-2); }
.gauge{
  position:relative;
  height:38px;
  border-radius:14px;
  background:#E4D2B0;
  box-shadow:inset 0 2px 6px rgba(90,60,30,.35);
  overflow:hidden;
  border:1px solid rgba(120,80,40,.22);
}
.gauge .zone{
  position:absolute; top:0; bottom:0;
  background:rgba(122,139,74,.35);
  border-left:2px solid var(--avocado);
  border-right:2px solid var(--avocado);
}
.gauge .fill{
  position:absolute; top:0; bottom:0; left:0; width:0%;
  background:linear-gradient(90deg,#8E5A2E,#C1502E);
  border-radius:0 8px 8px 0;
}
.gauge .fill.gold{ background:linear-gradient(90deg,#D9A441,#F0C97A); }
.gauge .fill.milk{ background:linear-gradient(90deg,#E9D6B3,#FFF8EA); }
.gauge .needle{
  position:absolute; top:-3px; bottom:-3px; left:0;
  width:5px;
  margin-left:-2.5px;
  border-radius:3px;
  background:#2B1810;
  box-shadow:0 0 10px rgba(43,24,16,.6);
}
.gauge-hint{ font-size:12px; font-weight:700; color:#8a6a45; text-align:center; }

.ing-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(102px,1fr));
  gap:8px;
}
.ing{
  display:flex;
  align-items:center;
  gap:7px;
  min-height:46px;
  padding:0 10px;
  border-radius:13px;
  border:2px solid rgba(120,80,40,.25);
  background:#FFF6E4;
  color:var(--choc);
  font-size:13.5px;
  font-weight:800;
  cursor:pointer;
  transition:transform .1s, background .15s, border-color .15s;
  touch-action:manipulation;
}
.ing .dot{
  width:16px; height:16px;
  border-radius:50%;
  flex:0 0 auto;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.18);
}
.ing b{ margin-inline-start:auto; font-variant-numeric:tabular-nums; color:var(--burnt); }
.ing:active{ transform:scale(.96); }
.ing.done{ background:#E8EEDA; border-color:var(--avocado); color:#4d5a2f; }
.ing.done b{ color:var(--avocado); }
.ing.shake{ animation:shk .3s; }
@keyframes shk{ 0%,100%{transform:translateX(0);} 25%{transform:translateX(-5px);} 75%{transform:translateX(5px);} }

.brew-action{ min-height:56px; font-size:17px; }

/* ================= OVERLAYS ================= */
#game .overlay{
  position:absolute;
  inset:0;
  z-index:80;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  overflow-y:auto;
  background:radial-gradient(circle at 50% 25%, rgba(30,18,10,.72), rgba(10,6,3,.94));
  backdrop-filter:blur(7px);
  -webkit-backdrop-filter:blur(7px);
  animation:fadeIn .22s ease-out;
}
@keyframes fadeIn{ from{opacity:0;} to{opacity:1;} }

.card{
  width:min(470px,100%);
  margin:auto;
  padding:22px 20px;
  border-radius:22px;
  background:linear-gradient(180deg,#FBF1DC 0%,#EFDFC0 100%);
  border:1px solid rgba(120,80,40,.28);
  box-shadow:var(--shadow), inset 0 1px 0 rgba(255,255,255,.75);
  color:var(--choc);
  display:flex;
  flex-direction:column;
  gap:12px;
}
.start-card{ gap:14px; }
.brand{ display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; }
.brand-badge{
  width:60px; height:60px;
  display:grid; place-items:center;
  font-size:30px;
  border-radius:20px;
  background:linear-gradient(180deg,#D2603A,#A63F26);
  box-shadow:0 8px 20px rgba(160,60,35,.4), inset 0 1px 0 rgba(255,255,255,.35);
  margin-bottom:2px;
}
.title{
  margin:0;
  font-size:32px;
  font-weight:900;
  letter-spacing:-.01em;
  color:var(--choc);
  line-height:1.15;
}
.subtitle{
  margin:0;
  font-size:14px;
  line-height:1.6;
  color:#6B472E;
  max-width:330px;
}
.card-title{ margin:0; font-size:24px; font-weight:900; color:var(--choc); }
.card-sub{ margin:0; font-size:13.5px; line-height:1.6; color:#6B472E; }

.quick-stats{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:8px;
}
.quick-stats > div{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:2px;
  padding:9px 4px;
  border-radius:14px;
  background:rgba(217,164,65,.16);
  border:1px solid rgba(176,141,87,.4);
}
.quick-stats b{ font-size:19px; font-weight:900; font-variant-numeric:tabular-nums; color:var(--choc); line-height:1; }
.quick-stats span{ font-size:10.5px; font-weight:700; color:#6B472E; }

.howto{
  margin:0;
  padding:0;
  list-style:none;
  display:flex;
  flex-direction:column;
  gap:7px;
}
.howto li{
  position:relative;
  padding-inline-start:22px;
  font-size:13.5px;
  line-height:1.55;
  color:#5a3a24;
}
.howto li::before{
  content:'';
  position:absolute;
  inset-inline-start:4px;
  top:8px;
  width:8px; height:8px;
  border-radius:3px;
  background:var(--burnt);
}

.btn-primary{
  width:100%;
  min-height:54px;
  border:0;
  border-radius:16px;
  background:linear-gradient(180deg,#D2603A,#B8452A);
  color:#FFF4E2;
  font-size:19px;
  font-weight:900;
  cursor:pointer;
  box-shadow:0 6px 0 var(--burnt-d), 0 12px 24px rgba(140,50,25,.35);
  transition:transform .1s ease, box-shadow .1s ease;
  touch-action:manipulation;
}
.btn-primary:active{ transform:translateY(4px); box-shadow:0 2px 0 var(--burnt-d); }
.btn-primary:disabled{ opacity:.45; box-shadow:0 6px 0 #7a5a48; }

.btn-ghost{
  width:100%;
  min-height:48px;
  border-radius:15px;
  border:2px solid rgba(120,80,40,.3);
  background:rgba(255,246,228,.7);
  color:var(--choc);
  font-size:15.5px;
  font-weight:800;
  cursor:pointer;
  transition:transform .1s, background .15s;
  touch-action:manipulation;
}
.btn-ghost:active{ transform:scale(.98); background:rgba(217,164,65,.28); }
.btn-ghost.danger{ color:var(--burnt); border-color:rgba(193,80,46,.4); }
.btn-ghost:disabled{ opacity:.45; }

/* Game over */
.over-badge{
  align-self:center;
  width:56px; height:56px;
  display:grid; place-items:center;
  font-size:28px;
  border-radius:18px;
  background:linear-gradient(180deg,#D9A441,#B7822A);
  box-shadow:0 8px 18px rgba(150,110,40,.4);
}
.score-hero{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:0;
  padding:10px 0 4px;
  border-radius:18px;
  background:rgba(217,164,65,.16);
  border:1px solid rgba(176,141,87,.4);
}
.score-hero b{
  font-size:44px;
  font-weight:900;
  line-height:1;
  color:var(--choc);
  font-variant-numeric:tabular-nums;
}
.score-hero span{ font-size:12px; font-weight:800; color:#8a6a45; }
.over-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:8px;
}
.over-grid > div{
  display:flex; flex-direction:column; align-items:center; gap:2px;
  padding:8px 4px;
  border-radius:13px;
  background:rgba(255,246,228,.75);
  border:1px solid rgba(176,141,87,.35);
}
.over-grid b{ font-size:18px; font-weight:900; font-variant-numeric:tabular-nums; }
.over-grid span{ font-size:10.5px; font-weight:700; color:#6B472E; }
.best-line{ margin:0; text-align:center; font-size:13px; font-weight:800; color:#8a6a45; }

/* Shop */
.shop-card{ max-height:100%; }
.shop-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.coins-pill{
  display:flex; align-items:center; gap:5px;
  padding:6px 12px;
  border-radius:99px;
  background:rgba(217,164,65,.28);
  border:1px solid rgba(176,141,87,.55);
  font-size:15px;
  font-weight:900;
  font-variant-numeric:tabular-nums;
}
.shop-list{ display:flex; flex-direction:column; gap:8px; }
.shop-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:15px;
  background:rgba(255,246,228,.85);
  border:1px solid rgba(176,141,87,.4);
}
.shop-item .si-body{ flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:2px; }
.shop-item .si-title{ font-size:14.5px; font-weight:900; color:var(--choc); }
.shop-item .si-desc{ font-size:11.5px; font-weight:600; color:#7a5a3c; line-height:1.4; }
.buy-btn{
  flex:0 0 auto;
  min-height:44px;
  padding:0 14px;
  border-radius:13px;
  border:0;
  background:linear-gradient(180deg,#7A8B4A,#5F7038);
  color:#F7F4E8;
  font-size:14px;
  font-weight:900;
  cursor:pointer;
  box-shadow:0 4px 0 #4a5a2a;
  display:flex; align-items:center; gap:5px;
  font-variant-numeric:tabular-nums;
  touch-action:manipulation;
}
.buy-btn:active{ transform:translateY(3px); box-shadow:0 1px 0 #4a5a2a; }
.buy-btn:disabled{ background:#c3b49a; box-shadow:0 4px 0 #ab9c83; color:#f0e8d8; opacity:.75; cursor:not-allowed; }
.buy-btn.owned{ background:#c3b49a; box-shadow:0 4px 0 #ab9c83; }

/* Toast + floaters */
.toast{
  position:absolute;
  left:50%;
  bottom:24%;
  transform:translateX(-50%);
  padding:11px 20px;
  border-radius:15px;
  background:rgba(43,24,16,.94);
  color:#FBF1DC;
  font-size:14.5px;
  font-weight:800;
  box-shadow:0 12px 30px rgba(0,0,0,.5);
  border:1px solid rgba(176,141,87,.5);
  z-index:95;
  pointer-events:none;
  max-width:calc(100% - 30px);
  text-align:center;
  animation:toastIn .22s ease-out;
}
@keyframes toastIn{ from{ transform:translate(-50%,12px); opacity:0; } to{ transform:translate(-50%,0); opacity:1; } }

.floaters{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:70;
  overflow:hidden;
}
.floater{
  position:absolute;
  transform:translate(-50%,-50%);
  font-size:21px;
  font-weight:900;
  color:#7A8B4A;
  text-shadow:0 2px 10px rgba(0,0,0,.6), 0 0 2px rgba(0,0,0,.8);
  animation:floatUp 1.25s ease-out forwards;
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}
.floater.bad{ color:#E0714C; }
.floater.gold{ color:#F0C97A; }
@keyframes floatUp{
  0%{ opacity:0; transform:translate(-50%,-30%) scale(.7); }
  18%{ opacity:1; transform:translate(-50%,-60%) scale(1.06); }
  100%{ opacity:0; transform:translate(-50%,-180%) scale(1); }
}

/* Small screens */
@media (max-height:620px){
  .title{ font-size:26px; }
  .howto{ display:none; }
  .brand-badge{ width:48px; height:48px; font-size:24px; }
  .joystick{ width:88px; height:88px; }
  .act-btn{ min-height:56px; min-width:104px; font-size:15px; }
  .card{ padding:16px; gap:10px; }
}
@media (min-width:900px){
  .card{ padding:28px 26px; }
  .title{ font-size:38px; }
  .joystick{ width:112px; height:112px; }
}

@media (prefers-reduced-motion:reduce){
  *{ animation-duration:.001ms !important; transition-duration:.001ms !important; }
  .floater{ animation:none; opacity:0; }
}