:root {
  --ink: #1a1210;
  --cream: #fff4dc;
  --paper: #fbe9c4;
  --orange: #ff8a00;
  --orange-d: #d96a00;
  --red: #d8342b;
  --green: #3c9a4a;
  --blue: #2d6fb8;
  --str: #e5532f;
  --pat: #3a9fd6;
  --acc: #f2b01e;
  --line: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #120c09; }
body { font-family: 'Tajawal', system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }

/* ---------- Fixed 1920x1080 stage, scaled to fit ---------- */
#viewport { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#stage {
  position: absolute; width: 1920px; height: 1080px; left: 50%; top: 50%;
  transform-origin: center center; overflow: hidden; background: #2a1d15;
}

/* ---------- World ---------- */
#world { position: absolute; inset: 0; }
#bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#world.shake { animation: shake .45s; }
@keyframes shake {
  0%,100% { transform: translate(0,0); } 20% { transform: translate(-14px,6px); }
  40% { transform: translate(12px,-8px); } 60% { transform: translate(-8px,4px); } 80% { transform: translate(6px,-3px); }
}

.prop { position: absolute; pointer-events: none; filter: drop-shadow(0 18px 10px rgba(0,0,0,.35)); transition: opacity .4s; }
#taxi { width: 1180px; left: 1900px; bottom: 120px; opacity: 0; }
#taxi.parked { left: 720px; opacity: 1; transition: left 2.2s cubic-bezier(.2,.7,.25,1), opacity .3s; }
#taxi.bounce { animation: taxiBounce .5s 2.1s; }
#taxi.leave { left: -1400px; transition: left 1.6s ease-in; }
/* while the wheel is being changed, the others step aside so it stays in view */
#world.car-work #char-lady { left: 1290px; }
#world.car-work #char-driver { left: 1660px; }
@keyframes taxiBounce { 0%,100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(10px) rotate(-1deg); } 70% { transform: translateY(-4px) rotate(.5deg); } }
#crate { width: 330px; left: 1500px; bottom: 70px; opacity: 0; }
#crate.show { opacity: 1; }
#crate.spilled { width: 520px; left: 1180px; bottom: 40px; }

/* ---------- Characters ---------- */
#chars { position: absolute; inset: 0; pointer-events: none; }
.char {
  position: absolute; bottom: -10px; height: 760px; opacity: 0;
  transform: translateX(-50%) translateY(60px); transform-origin: bottom center;
  transition: opacity .35s, transform .45s cubic-bezier(.3,1.4,.5,1), filter .3s, left .6s ease;
}
.char img { height: 100%; width: auto; display: block; filter: drop-shadow(0 14px 12px rgba(0,0,0,.45)); animation: idle 3.2s ease-in-out infinite; transform-origin: bottom center; }
.char.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.char.dim { filter: brightness(.72) saturate(.85); }
.char.talk img { animation: idle 3.2s ease-in-out infinite, talk .5s ease-in-out infinite; }
.char.pop img { animation: pop .38s cubic-bezier(.3,1.6,.5,1); }
@keyframes idle { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.012) translateY(-3px); } }
@keyframes talk { 0%,100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@keyframes pop { 0% { transform: scale(.92,1.06); } 60% { transform: scale(1.04,.97); } 100% { transform: scale(1); } }
#char-mazen { left: 300px; }
#char-lady { left: 1080px; height: 700px; }
#char-driver { left: 1600px; height: 720px; }
#char-mazen.center { left: 960px; }

/* ---------- Hotspots ---------- */
#hotspots { position: absolute; inset: 0; z-index: 5; }
#chars { z-index: 4; }
.hotspot {
  position: absolute; border-radius: 28px; pointer-events: none; opacity: 0;
  transition: opacity .3s;
}
.hotspot.active { pointer-events: auto; opacity: 1; cursor: pointer; }
.hotspot.active::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  border: 5px dashed rgba(255, 216, 120, .95); background: rgba(255, 200, 80, .12);
  animation: glow 1.6s ease-in-out infinite;
}
.hotspot.used { opacity: 0 !important; pointer-events: none !important; }
.hotspot .tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--cream); font: 700 30px 'Tajawal'; padding: 6px 18px; border-radius: 14px;
  white-space: nowrap; opacity: 0; transition: opacity .2s;
}
.hotspot.active:hover .tip, .hotspot.active.peek .tip { opacity: 1; }
@keyframes glow { 0%,100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.04); } }

/* ---------- HUD ---------- */
#hud { position: absolute; z-index: 45; top: 24px; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 0 130px 0 36px; pointer-events: none; }
#clock-wrap {
  background: var(--ink); color: var(--cream); border-radius: 26px; padding: 10px 34px 14px;
  border: var(--line) solid #000; box-shadow: 0 8px 0 rgba(0,0,0,.35); text-align: center; min-width: 300px;
}
#clock-label { font: 700 24px 'Tajawal'; opacity: .75; }
#clock { font: 400 92px/1 'Lalezar'; letter-spacing: 4px; direction: ltr; transition: color .3s; }
#clock.warn { color: #ffb43a; }
#clock.danger { color: #ff4b3e; animation: pulse .8s infinite; }
#clock.bump { animation: bump .5s; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.25); color: #ff4b3e; } 100% { transform: scale(1); } }

#stats {
  background: var(--cream); border: var(--line) solid var(--ink); border-radius: 26px; padding: 16px 26px;
  box-shadow: 0 8px 0 rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 10px;
}
.stat { display: flex; align-items: center; gap: 12px; font: 900 28px 'Tajawal'; position: relative; }
.stat .ico { font-size: 34px; width: 42px; text-align: center; }
.stat .name { width: 70px; }
.stat .bar { width: 300px; height: 26px; background: #e3d2b0; border: 4px solid var(--ink); border-radius: 14px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; width: 0; border-radius: 8px; transition: width .6s cubic-bezier(.3,1.3,.5,1); }
.stat[data-stat=str] .bar i { background: var(--str); }
.stat[data-stat=pat] .bar i { background: var(--pat); }
.stat[data-stat=acc] .bar i { background: var(--acc); }
.stat b { width: 40px; text-align: center; font-size: 32px; }
.stat .delta {
  position: absolute; left: -70px; font: 900 34px 'Tajawal'; animation: rise 1.4s forwards; pointer-events: none;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--red); }
@keyframes rise { 0% { opacity: 0; transform: translateY(10px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px); } }

.icon-btn {
  position: absolute; top: 28px; right: 30px; width: 84px; height: 84px; border-radius: 50%;
  background: var(--cream); border: var(--line) solid var(--ink); font-size: 40px; box-shadow: 0 6px 0 rgba(0,0,0,.35); z-index: 50;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }

/* ---------- Dialogue ---------- */
#dialogue {
  position: absolute; left: 110px; right: 110px; bottom: 34px; min-height: 230px;
  background: var(--cream); border: var(--line) solid var(--ink); border-radius: 34px;
  box-shadow: 0 12px 0 rgba(0,0,0,.4); padding: 48px 56px 34px; cursor: pointer; z-index: 20;
  animation: slideUp .3s ease-out;
}
#dialogue.narr { background: #2b211b; color: var(--cream); }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
#nameplate {
  position: absolute; top: -34px; right: 50px; padding: 4px 34px 8px; border-radius: 18px;
  font: 400 46px 'Lalezar'; color: #fff; background: var(--orange); border: var(--line) solid var(--ink);
  box-shadow: 0 6px 0 rgba(0,0,0,.3);
}
#nameplate:empty { display: none; }
#nameplate.mazen { background: var(--blue); }
#nameplate.lady { background: #2a2a2a; }
#nameplate.driver { background: #d9605a; }
#nameplate.other { background: var(--green); }
#line { font: 700 46px/1.55 'Tajawal'; min-height: 140px; }
/* text rows (text.js): each Arabic or English run sits on its own line */
.seg { display: block; text-align: right; }
.drink-card .quote .seg { text-align: center; }
#next-hint { position: absolute; left: 40px; bottom: 18px; font-size: 34px; opacity: 0; animation: hint 1s infinite; }
#dialogue.done #next-hint { opacity: 1; }
@keyframes hint { 50% { transform: translateY(8px); } }

/* ---------- Choices ---------- */
/* The menu sits at the bottom right. The chair, the tyre pile, the kettle, the radio and the wall phone are
   clickable, so it must not cover them; engine.js shrinks the text (--fit) if a menu gets too tall. */
#choices {
  position: absolute; right: 18px; bottom: 18px; width: 1080px;
  display: flex; flex-direction: column; gap: calc(18px * var(--fit, 1)); z-index: 30;
}
#choices .choice { padding: calc(17px * var(--fit, 1)) 26px; font-size: calc(38px * var(--fit, 1)); line-height: 1.34; gap: 16px; }
#choices .choice .key { width: calc(54px * var(--fit, 1)); height: calc(54px * var(--fit, 1)); font-size: calc(34px * var(--fit, 1)); }
#choices .tag { font-size: calc(26px * var(--fit, 1)); padding: 3px 12px; }
.choice {
  position: relative; text-align: right; background: var(--cream); border: var(--line) solid var(--ink); border-radius: 26px;
  padding: 20px 34px; font: 700 38px/1.4 'Tajawal'; box-shadow: 0 9px 0 var(--ink);
  transition: transform .12s, box-shadow .12s, background .2s; animation: choiceIn .35s backwards;
  display: flex; align-items: center; gap: 18px;
}
.choice:nth-child(2) { animation-delay: .07s; } .choice:nth-child(3) { animation-delay: .14s; } .choice:nth-child(4) { animation-delay: .21s; }
@keyframes choiceIn { from { opacity: 0; transform: translateX(-40px); } }
.choice:hover:not(.locked) { background: #fff; transform: translateY(-3px); box-shadow: 0 12px 0 var(--ink); }
.choice:active:not(.locked) { transform: translateY(6px); box-shadow: 0 3px 0 var(--ink); }
.choice .key {
  flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--orange); color: #fff; border: 4px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font: 400 34px 'Lalezar';
}
.choice .txt { flex: 1; }
.choice .meta { flex: none; display: flex; gap: 10px; }
.tag { font: 900 26px 'Tajawal'; padding: 4px 14px; border-radius: 14px; border: 3px solid var(--ink); background: #fff; white-space: nowrap; }
.tag.time { background: #ffe1d6; }
.tag.req { background: #ffeeb0; }
.tag.game { background: #d9f0c9; }
.choice.special { background: #fff1c2; }
.choice.special .key { background: var(--acc); color: var(--ink); }
.choice.locked { opacity: .55; cursor: not-allowed; filter: grayscale(.6); box-shadow: 0 6px 0 var(--ink); }
.choice.locked .key { background: #888; }
.choice.forced { background: #ffd2cc; border-color: var(--red); box-shadow: 0 9px 0 var(--red); animation: choiceIn .35s backwards, wobble .6s .4s infinite; }
.choice.forced .key { background: var(--red); }
@keyframes wobble { 0%,100% { rotate: 0deg; } 25% { rotate: -.6deg; } 75% { rotate: .6deg; } }

#hint-bar {
  position: absolute; top: 230px; left: 50%; transform: translateX(-50%); background: rgba(26,18,16,.85); color: var(--cream);
  font: 700 28px 'Tajawal'; padding: 10px 28px; border-radius: 20px; z-index: 25; animation: slideUp .4s;
}

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#screen-title { background: radial-gradient(ellipse at 50% 40%, rgba(255,138,0,.35), rgba(18,12,9,.92) 70%), url(../assets/img/workshop_bg.webp) center/cover; }
.title-card { text-align: center; color: var(--cream); animation: slideUp .6s; }
.title-sub { font: 700 34px 'Tajawal'; opacity: .85; margin-bottom: 6px; }
h1 { font: 400 190px/0.95 'Lalezar'; color: var(--orange); text-shadow: 0 10px 0 var(--ink), 0 0 60px rgba(255,138,0,.5); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
h1 span { color: #8fc23a; }
.title-tag { font: 700 38px 'Tajawal'; margin: 30px 0 46px; max-width: 1100px; }
.big-btn {
  font: 400 64px 'Lalezar'; color: #fff; background: var(--orange); border: var(--line) solid var(--ink); border-radius: 34px;
  padding: 10px 80px 18px; box-shadow: 0 12px 0 var(--ink); transition: transform .12s, box-shadow .12s;
}
.big-btn:hover { transform: translateY(-3px); box-shadow: 0 15px 0 var(--ink); }
.big-btn:active { transform: translateY(8px); box-shadow: 0 4px 0 var(--ink); }
#endings-found { margin-top: 36px; font: 700 30px 'Tajawal'; opacity: .85; }

#screen-drink { background: rgba(18,12,9,.86); color: var(--cream); }
#screen-drink h2 { font: 400 76px 'Lalezar'; margin-bottom: 40px; text-shadow: 0 6px 0 var(--ink); }
#drink-cards { display: flex; gap: 46px; }
.drink-card {
  width: 500px; background: var(--cream); color: var(--ink); border: var(--line) solid var(--ink); border-radius: 34px;
  padding: 26px 30px 30px; box-shadow: 0 12px 0 #000; text-align: center; transition: transform .15s, box-shadow .15s;
  animation: slideUp .5s backwards;
}
.drink-card:nth-child(2) { animation-delay: .1s; } .drink-card:nth-child(3) { animation-delay: .2s; }
.drink-card:hover { transform: translateY(-10px) rotate(-1deg); box-shadow: 0 22px 0 #000; }
.drink-card:active { transform: translateY(6px); box-shadow: 0 4px 0 #000; }
.drink-card img { height: 290px; width: auto; max-width: 100%; object-fit: contain; filter: drop-shadow(0 10px 8px rgba(0,0,0,.3)); }
.drink-card h3 { font: 400 52px/1.1 'Lalezar'; margin: 10px 0 4px; }
.drink-card .quote { font: 700 28px 'Tajawal'; opacity: .75; margin-bottom: 16px; min-height: 40px; }
.drink-card .mini { display: flex; align-items: center; gap: 10px; font: 900 26px 'Tajawal'; margin: 8px 0; }
.drink-card .mini .bar { flex: 1; height: 20px; border: 3px solid var(--ink); border-radius: 10px; background: #e3d2b0; overflow: hidden; }
.drink-card .mini .bar i { display: block; height: 100%; }
.drink-note { margin-top: 44px; font: 700 32px 'Tajawal'; opacity: .8; }

#screen-end { background: rgba(18,12,9,.9); }
.end-card {
  display: flex; align-items: center; gap: 50px; background: var(--cream); border: var(--line) solid var(--ink); border-radius: 40px;
  padding: 40px 60px; box-shadow: 0 16px 0 #000; max-width: 1600px; animation: slideUp .5s;
}
#end-img { height: 640px; width: auto; filter: drop-shadow(0 12px 10px rgba(0,0,0,.35)); }
.end-body { flex: 1; }
#end-kicker { font: 900 30px 'Tajawal'; color: var(--orange-d); }
#end-title { font: 400 88px/1.05 'Lalezar'; margin: 6px 0 16px; }
#end-text { font: 700 36px/1.6 'Tajawal'; margin-bottom: 24px; }
#end-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
#end-stats .tag { font-size: 28px; padding: 6px 18px; }
#end-progress { font: 900 30px 'Tajawal'; margin-bottom: 28px; }
.end-btns .big-btn { font-size: 54px; padding: 6px 60px 14px; }

#toast {
  position: absolute; top: 250px; left: 50%; transform: translateX(-50%) translateY(-20px); opacity: 0; z-index: 70;
  background: var(--ink); color: var(--cream); font: 400 54px 'Lalezar'; padding: 10px 46px 16px; border-radius: 26px;
  border: 5px solid var(--orange); transition: opacity .3s, transform .3s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- FX ---------- */
#fx { position: absolute; inset: 0; pointer-events: none; }
.puff { position: absolute; font-size: 70px; animation: puff 1.2s forwards; }
@keyframes puff { 0% { opacity: 0; transform: scale(.4); } 25% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: translateY(-120px) scale(1.3); } }
.flash { position: absolute; inset: 0; background: #fff; animation: flash .5s forwards; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

/* ---------- Phones: larger text inside the scaled stage ---------- */
#stage.small #line { font-size: 58px; line-height: 1.45; }
#stage.small #nameplate { font-size: 56px; }
#stage.small .choice { font-size: 48px; padding: 22px 34px; }
#stage.small .tag { font-size: 32px; }
#stage.small .choice .key { width: 66px; height: 66px; font-size: 40px; }
#stage.small #choices .choice { font-size: calc(48px * var(--fit, 1)); line-height: 1.3; padding: calc(15px * var(--fit, 1)) 24px; }
#stage.small #choices .choice .key { width: calc(62px * var(--fit, 1)); height: calc(62px * var(--fit, 1)); font-size: calc(38px * var(--fit, 1)); }
#stage.small #choices .tag { font-size: calc(31px * var(--fit, 1)); }
#stage.small #dialogue { left: 60px; right: 60px; }
#stage.small .stat { font-size: 34px; }
#stage.small .icon-btn { width: 110px; height: 110px; font-size: 52px; }

/* ---------- Radio playing: floating notes over the radio ---------- */
#world.radio-on::after {
  content: '♪ ♫ ♪'; position: absolute; left: 25%; top: 17%; font: 900 64px 'Tajawal'; color: #ffd36b;
  text-shadow: 0 4px 0 var(--ink); animation: notes 1.4s ease-in-out infinite; pointer-events: none; z-index: 6;
}
@keyframes notes { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-22px) rotate(6deg); } }

/* ---------- Rotate prompt ---------- */
#rotate { display: none; position: fixed; inset: 0; background: #120c09; color: var(--cream); z-index: 999; align-items: center; justify-content: center; text-align: center; font: 700 26px/1.8 'Tajawal'; }
#rotate div { font-size: 26px; }
@media (orientation: portrait) and (max-width: 900px) { #rotate { display: flex; } }
