/* ============================================
   MACK-A-BEE DREIDEL — Styles
   A night-time Chanukah card room: green felt table, deep navy rail
   and panels, warm gold for coins, trim and the big buttons. Mack's
   honey yellow is kept for Mack alone so he stands out in his corner.
   One deliberate dark look (no light theme): the game is a candlelit room.
   Layout: one full-height screen at a time; the game screen is
   top bar / table stage / control panel, built for a phone held upright.
   ============================================ */
:root {
  --ink: #070d22;          /* the room */
  --navy: #0f1b45;         /* panels, rail */
  --navy-2: #182a63;
  --navy-3: #253c86;
  --gold: #e9b949;
  --gold-hi: #ffe08a;
  --gold-lo: #a87414;
  --felt: #1d6b45;
  --felt-hi: #33a06a;
  --cream: #fff4d9;        /* text */
  --muted: #a9b4d6;
  --honey: #f7b81c;
  --ok: #5fd68f;
  --bad: #ff7a6b;
  --steal: #c99bff;
  --line: rgba(233, 185, 73, 0.35);

  --f-display: 'Suez One', 'Frank Ruhl Libre', Georgia, serif;
  --f-body: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;

  --r: 16px;
  --gut-l: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 190, 90, 0.18), transparent 60%),
    radial-gradient(90% 70% at 50% 110%, rgba(29, 107, 69, 0.25), transparent 70%),
    var(--ink);
  color: var(--cream);
  font: 16px/1.4 var(--f-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;   /* no double-tap zoom, no tap delay */
  overflow: hidden;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

#app { position: relative; height: 100%; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding-left: var(--gut-l); padding-right: var(--gut-r);
}
.screen-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 48px; padding: 10px 18px;
  border-radius: 14px; border: 0;
  font-weight: 700; letter-spacing: 0.01em;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn small { font-weight: 400; font-size: 0.8rem; opacity: 0.85; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #c9952b);
  color: #2a1a00;
  box-shadow: 0 2px 0 var(--gold-lo), 0 8px 24px rgba(233, 185, 73, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn-gold small { color: #3b2700; }
.btn-navy {
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  color: var(--cream);
  box-shadow: inset 0 0 0 1.5px var(--line), 0 4px 14px rgba(0, 0, 0, 0.35);
}
.btn-red { background: linear-gradient(180deg, #e0564a, #b23a30); color: #fff; }
.btn-big { width: 100%; min-height: 64px; font-size: 1.15rem; }
.btn-small { min-height: 38px; padding: 6px 12px; font-size: 0.9rem; border-radius: 11px; flex-direction: row; gap: 6px; }
.btn:disabled { filter: grayscale(0.7) brightness(0.7); cursor: default; }

.icon-btn {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%; border: 0;
  background: var(--navy-2); box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 1.25rem; line-height: 1; display: grid; place-items: center;
}
.icon-btn.back { font-size: 1.8rem; padding-bottom: 4px; }
[dir="rtl"] .icon-btn.back { transform: scaleX(-1); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 4px 14px 4px 6px; border: 0; border-radius: 999px;
  background: var(--navy-2); box-shadow: inset 0 0 0 1.5px var(--line);
}
.lang-btn { padding: 4px 14px; font-weight: 700; }
.link-btn { background: none; border: 0; color: var(--gold-hi); text-decoration: underline; text-underline-offset: 3px; padding: 8px; }
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); font-size: 1.2rem; }
.honey { font-size: 0.85rem; color: var(--gold-hi); white-space: nowrap; }
.honey::before { content: '🍯 '; }
.honey.big { font-size: 1rem; }

/* ---------- Home ---------- */
#scr-home { justify-content: space-between; padding-top: 12px; padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
.home-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.top-tools { display: flex; gap: 8px; }
.home-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-block: 8px; }
.logo { margin: 0; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.logo-main {
  font: 2.6rem/1 var(--f-display);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 60%, var(--gold-lo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.5));
  text-wrap: balance;
}
.logo-sub { font-size: 1rem; font-weight: 500; color: var(--muted); }
.home-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 440px; margin: 0 auto; }
.join-row { display: flex; gap: 10px; }
.code-input {
  flex: 1; min-width: 0; height: 52px; border-radius: 14px; border: 0;
  background: var(--navy); box-shadow: inset 0 0 0 1.5px var(--line);
  text-align: center; font: 1.6rem var(--f-display); letter-spacing: 0.4em; text-transform: uppercase;
  padding-inline-start: 0.4em;
}
.code-input::placeholder { color: rgba(169, 180, 214, 0.4); letter-spacing: 0.2em; font-size: 1.1rem; }
.home-links { display: flex; justify-content: center; gap: 16px; }

/* ---------- Bars & sheets ---------- */
.bar { display: flex; align-items: center; gap: 12px; padding-block: 12px; position: sticky; top: 0; z-index: 2; background: linear-gradient(var(--ink) 70%, transparent); }
.bar h2 { flex: 1; margin: 0; font: 1.45rem var(--f-display); color: var(--gold-hi); }
.sheet { width: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }
.field { display: flex; flex-direction: column; gap: 8px; font-weight: 500; color: var(--muted); }
.field input, .add-person input {
  height: 48px; border-radius: 12px; border: 0; padding: 0 14px;
  background: var(--navy); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--cream); font-size: 1.05rem;
}
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.avatar-grid button { aspect-ratio: 1; border-radius: 12px; border: 0; background: var(--navy); font-size: 1.5rem; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.06); }
.avatar-grid button[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--gold); background: var(--navy-2); }
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.skin {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 6px 10px; border-radius: 14px; border: 0;
  background: radial-gradient(80% 70% at 50% 35%, #2a8a58, var(--felt) 60%, #124a30);
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.08);
  color: var(--cream); font-size: 0.82rem; font-weight: 500; text-align: center;
}
.skin img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.skin[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--gold), 0 0 18px rgba(233,185,73,0.35); }
.skin.locked img { filter: grayscale(1) brightness(0.45); }
.skin .lock { font-size: 0.72rem; color: var(--gold-hi); line-height: 1.2; }
.skin .prog { width: 80%; height: 5px; border-radius: 3px; background: rgba(0,0,0,0.35); overflow: hidden; }
.skin .prog i { display: block; height: 100%; background: var(--gold); }
.stats { color: var(--muted); font-size: 0.9rem; margin: 0; text-align: center; }

/* ---------- Setup / lobby ---------- */
.block { display: flex; flex-direction: column; gap: 10px; }
.block h3 { margin: 0; font: 1.15rem var(--f-display); color: var(--gold-hi); }
.block h3 small { font: 500 0.85rem var(--f-body); color: var(--muted); }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 14px; background: var(--navy); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.player-list .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--navy-3); color: var(--muted); white-space: nowrap; }
.badge.gold { background: var(--gold); color: #2a1a00; font-weight: 700; }
.badge.off { background: #3a2230; color: var(--bad); }
.player-list .x { width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.add-person { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.add-person input { flex: 1; min-width: 0; height: 38px; }
.settings { display: flex; flex-direction: column; gap: 14px; }
.set-row { display: flex; flex-direction: column; gap: 6px; }
.set-row > .lbl { font-weight: 500; color: var(--muted); font-size: 0.92rem; }
.set-row > .lbl small { display: block; font-weight: 400; font-size: 0.8rem; opacity: 0.8; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--navy); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }
.seg button {
  min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted);
  font-weight: 500; font-size: 0.92rem; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.seg button small { font-size: 0.72rem; font-weight: 400; opacity: 0.85; }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1a00; font-weight: 700; }
.seg.tall button { min-height: 58px; }
.custom-row { display: flex; align-items: center; gap: 8px; }
.custom-row input { width: 96px; height: 40px; border-radius: 10px; border: 0; padding: 0 10px; background: var(--navy); box-shadow: inset 0 0 0 1.5px var(--gold); color: var(--cream); font-size: 1.05rem; font-weight: 700; }
.settings.readonly .seg button { pointer-events: none; }
.settings.readonly .seg button:not([aria-pressed="true"]) { opacity: 0.5; }
.room-box { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 14px; border-radius: var(--r); background: linear-gradient(160deg, var(--navy-2), var(--navy)); box-shadow: inset 0 0 0 1.5px var(--line); }
.room-code-wrap { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.room-code { font: 3rem/1 var(--f-display); letter-spacing: 0.18em; color: var(--gold-hi); }
.lbl { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.qr { width: 108px; height: 108px; flex: none; background: #fff; border-radius: 10px; padding: 6px; }
.qr:empty { display: none; }
.qr img, .qr svg { width: 100%; height: 100%; display: block; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.center { text-align: center; }
.warn { color: var(--bad); margin: 0; text-align: center; }

/* ---------- Game ---------- */
.game { padding: 0; }
.game-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 8px var(--gut-r) 2px var(--gut-l);
  position: relative; z-index: 3;
}
.under-menorah { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.round { font: 0.95rem var(--f-display); color: var(--gold-hi); white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.round small { font: 500 0.75rem var(--f-body); color: var(--muted); margin-inline-start: 6px; }
.game-top .icon-btn { justify-self: end; }
.menorah-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
#menorah { width: 150px; height: 58px; overflow: visible; }
#menorah .flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker 0.9s ease-in-out infinite alternate; }
#menorah .flame:nth-child(odd) { animation-duration: 1.2s; }
@keyframes flicker { from { transform: scale(1, 1) rotate(-3deg); } to { transform: scale(0.85, 1.12) rotate(3deg); } }
.pot {
  padding: 2px 10px; border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1a00; font-weight: 800; font-size: 0.9rem;
  box-shadow: 0 2px 0 var(--gold-lo);
}

.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.three, .three canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.no3d { position: absolute; inset: 0; display: grid; place-items: center; }
.no3d span {
  width: 150px; height: 150px; border-radius: 28px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #d9a066, #a8703c); box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  font: 6rem/1 var(--f-display); color: #3b2210;
}
.no3d.spin span { animation: spin2d 0.25s linear infinite; }
@keyframes spin2d { to { transform: rotateY(360deg); } }

.seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 86px; padding: 5px 6px 6px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(37, 60, 134, 0.95), rgba(15, 27, 69, 0.95));
  box-shadow: inset 0 0 0 1.5px var(--line), 0 6px 16px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: box-shadow 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}
.seat .s-av { font-size: 1.35rem; line-height: 1.1; }
.seat .s-name { font-size: 0.74rem; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .s-coins { font-size: 0.82rem; font-weight: 800; color: var(--gold-hi); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 3px; }
.seat .s-coins::before { content: ''; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold-hi), var(--gold) 55%, var(--gold-lo)); box-shadow: 0 0 0 1px var(--gold-lo); }
.seat .s-tag { font-size: 0.62rem; color: var(--muted); }
/* 7–8 players on a phone: smaller plates, no "Computer" line (the bee avatar says it) */
.seats.crowded .seat { width: 70px; padding: 3px 4px 4px; border-radius: 12px; }
.seats.crowded .seat .s-av { font-size: 1.1rem; }
.seats.crowded .seat .s-name { font-size: 0.68rem; }
.seats.crowded .seat .s-coins { font-size: 0.76rem; }
.seats.crowded .seat .s-tag:not(:empty) { font-size: 0.56rem; }
.seats.crowded .seat:not(.out) .s-tag { display: none; }
.seat.active { box-shadow: inset 0 0 0 2.5px var(--gold-hi), 0 0 22px rgba(255, 224, 138, 0.55); transform: translate(-50%, -50%) scale(1.08); z-index: 2; }
.seat.me .s-name { color: var(--gold-hi); }
.seat.out { opacity: 0.5; }
.seat.off { opacity: 0.6; }
.seat .s-bet {
  position: absolute; top: -10px; inset-inline-end: -8px;
  padding: 1px 7px; border-radius: 999px; font-size: 0.72rem; font-weight: 800;
  background: var(--gold); color: #2a1a00; box-shadow: 0 2px 0 var(--gold-lo);
}
.seat .s-delta {
  position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
  font-weight: 800; font-size: 0.95rem; white-space: nowrap;
  animation: rise 1.8s ease-out forwards;
}
.s-delta.plus { color: var(--ok); text-shadow: 0 1px 0 #000; }
.s-delta.minus { color: var(--bad); text-shadow: 0 1px 0 #000; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -14px); } }

.coins-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.coin {
  position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c8, var(--gold) 50%, var(--gold-lo));
  box-shadow: 0 0 0 1.5px #8a5d0c, 0 2px 4px rgba(0,0,0,0.5);
}

.banner {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: 6px 16px; border-radius: 999px; white-space: nowrap;
  background: rgba(7, 13, 34, 0.75); box-shadow: inset 0 0 0 1.5px var(--line);
  font-weight: 700; font-size: 0.92rem; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.result-pop {
  position: absolute; left: 50%; top: 50%; z-index: 5; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
  animation: pop 0.4s cubic-bezier(.2, 1.6, .4, 1) both;
}
.result-pop .rp-letter {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  font: 3.6rem/1 var(--f-display); color: #2a1a00; padding-top: 6px;
  background: radial-gradient(circle at 35% 30%, #fff3c4, var(--gold) 55%, var(--gold-lo));
  box-shadow: 0 0 0 4px rgba(7,13,34,0.6), 0 0 40px rgba(255, 224, 138, 0.55);
}
.result-pop.bad .rp-letter { background: radial-gradient(circle at 35% 30%, #ffd2c9, #e0675a 55%, #8f2c22); color: #fff; box-shadow: 0 0 0 4px rgba(7,13,34,0.6), 0 0 30px rgba(255, 110, 90, 0.4); }
.result-pop.meh .rp-letter { background: radial-gradient(circle at 35% 30%, #e8edff, #9aa8d6 55%, #4d5a8a); color: #10183a; }
.result-pop .rp-name { font: 1.5rem var(--f-display); text-shadow: 0 2px 6px rgba(0,0,0,0.7); }
.result-pop .rp-text { font-weight: 800; font-size: 1.05rem; padding: 4px 12px; border-radius: 999px; background: rgba(7,13,34,0.75); text-align: center; max-width: 280px; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.grade-flash {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  font: 1.6rem var(--f-display); white-space: nowrap; pointer-events: none;
  animation: gradeIn 1.1s ease-out forwards;
}
.grade-flash.perfect { color: var(--gold-hi); text-shadow: 0 0 18px rgba(255, 224, 138, 0.8), 0 2px 0 #000; }
.grade-flash.good { color: var(--ok); text-shadow: 0 2px 0 #000; }
.grade-flash.miss { color: var(--muted); text-shadow: 0 2px 0 #000; font-size: 1.2rem; }
@keyframes gradeIn { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; } }

.stage.fx-speed::after {
  content: ''; position: absolute; inset: -20%; pointer-events: none; z-index: 1;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255,255,255,0.13) 0deg 2deg, transparent 2deg 12deg);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 22%, #000 60%); mask: radial-gradient(circle at 50% 50%, transparent 22%, #000 60%);
  animation: speedspin 0.6s linear infinite;
}
@keyframes speedspin { to { transform: rotate(30deg); } }

/* Mack lives in the top bar, beside the round counter, so he never covers the table.
   His speech bubble drops down over the stage for a moment. */
.top-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
#mack-corner { flex: none; position: relative; z-index: 6; }

/* ---------- Panel ---------- */
.panel {
  position: relative; z-index: 3;
  padding: 12px var(--gut-r) max(12px, env(safe-area-inset-bottom, 0px)) var(--gut-l);
  background: linear-gradient(180deg, var(--navy-2), var(--navy) 40%, #0b1436);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -1.5px 0 var(--line), 0 -10px 30px rgba(0, 0, 0, 0.45);
  /* Fixed height so the table doesn't zoom in and out between turns */
  height: 304px; flex: none; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
}
.panel.compact { height: 172px; }
@media (max-height: 720px) {
  .panel { height: 268px; gap: 8px; }
  .panel.compact { height: 150px; }
  .harder { display: none; }
  .btn-big { min-height: 54px; }
}
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.p-title { font: 1.2rem var(--f-display); color: var(--gold-hi); margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-timer { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 3ch; text-align: end; }
.p-timer.low { color: var(--bad); }
.p-wait { display: flex; align-items: center; gap: 12px; justify-content: center; font-weight: 500; color: var(--muted); }
.p-wait .av { width: 40px; height: 40px; font-size: 1.5rem; }
.bet-row { display: flex; align-items: center; gap: 10px; }
.bet-val { display: flex; flex-direction: column; align-items: center; min-width: 72px; }
.bet-val b { font: 2rem/1 var(--f-display); color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.bet-val small { color: var(--muted); font-size: 0.75rem; }
.bet-step { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--navy-3); font-size: 1.4rem; font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--line); }
input[type="range"].bet-slider { flex: 1; min-width: 0; accent-color: var(--gold); height: 32px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick button { min-height: 36px; border: 0; border-radius: 10px; background: var(--navy-3); font-weight: 700; font-size: 0.9rem; box-shadow: inset 0 0 0 1px var(--line); }
.quick button.allin { background: linear-gradient(180deg, #d8564a, #a8352c); }
.harder { font-size: 0.75rem; color: var(--muted); text-align: center; margin: -4px 0 0; }

/* Meter */
.meter { position: relative; height: 40px; touch-action: manipulation; }
.meter-track {
  position: absolute; inset: 6px 0; border-radius: 12px; overflow: hidden;
  background: linear-gradient(180deg, #2b0f16, #4a1d26 60%, #2b0f16);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08), inset 0 3px 8px rgba(0,0,0,0.6);
}
.meter-zone {
  position: absolute; top: 0; bottom: 0;
  background: linear-gradient(180deg, #7ff0a6, #2fb866 60%, #1d8a4a);
  box-shadow: 0 0 12px rgba(95, 214, 143, 0.6);
  transition: left 0.25s ease, width 0.25s ease;
}
.meter.live .meter-zone { transition: none; }
.meter-gold { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); background: linear-gradient(180deg, #fff6c8, var(--gold) 50%, var(--gold-lo)); box-shadow: 0 0 8px var(--gold-hi); }
.meter-marker {
  position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; border-radius: 3px;
  background: #fff; box-shadow: 0 0 0 2px #10183a, 0 0 12px rgba(255,255,255,0.8);
}
.meter.hit-perfect .meter-marker { background: var(--gold-hi); box-shadow: 0 0 0 2px #10183a, 0 0 22px var(--gold-hi); }
.meter.hit-miss .meter-marker { background: var(--bad); }
.meter.big { height: 64px; }
.meter.big .meter-track { inset: 8px 0; border-radius: 16px; }
.tap-zone { display: flex; flex-direction: column; gap: 10px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.tap-zone .p-title { text-align: center; animation: pulse 0.8s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ---------- Mack ---------- */
.mack { position: relative; display: inline-flex; align-items: flex-start; }
.mack-body { cursor: pointer; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45)); animation: bob 2.6s ease-in-out infinite; }
.mack-big .mack-body { width: 170px; height: 178px; }
.mack-corner .mack-body { width: 50px; height: 53px; }
.mack-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mack .wing { transform-box: fill-box; transform-origin: 50% 90%; animation: flap 0.16s ease-in-out infinite alternate; }
.mack .wing-r { animation-delay: 0.08s; }
/* 3D Mack: the canvas does its own animation */
.mack-3d .mack-body, .mack-3d .mack-body[class*="a-"] { animation: none; filter: drop-shadow(0 8px 12px rgba(0,0,0,0.35)); }
.mack-canvas { display: block; width: 100%; height: 100%; }
.mack-3d.mack-big .mack-body { width: 210px; height: 220px; }
.mack-3d.mack-corner .mack-body { width: 64px; height: 66px; margin: -6px -4px -4px; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(0.55); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.mack .eye { transform-box: fill-box; transform-origin: center; transition: transform 0.06s; }
.mack.blink .eye { transform: scaleY(0.1); }
.mack-body.a-cheer { animation: cheer 0.9s ease-out; }
.mack-body.a-gasp { animation: gasp 0.5s ease-in-out 2; }
.mack-body.a-loop { animation: loop 1.1s ease-in-out; }
.mack-body.a-sad { animation: sad 1.2s ease-in-out; }
@keyframes cheer { 0% { transform: translateY(0); } 30% { transform: translateY(-18px) rotate(-8deg); } 60% { transform: translateY(0) rotate(6deg); } 100% { transform: none; } }
@keyframes gasp { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes loop { 0% { transform: none; } 50% { transform: translateY(-30px) rotate(180deg) scale(1.1); } 100% { transform: rotate(360deg); } }
@keyframes sad { 0%, 100% { transform: none; } 50% { transform: translateY(6px) rotate(-4deg); } }
.mack-bubble {
  position: relative; background: var(--cream); color: #1b1230; font-weight: 600;
  border-radius: 14px; padding: 8px 12px; line-height: 1.3;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  opacity: 0; transform: scale(0.85); transform-origin: 0 50%; transition: opacity 0.25s, transform 0.25s;
}
.mack-bubble.show { opacity: 1; transform: scale(1); }
.mack-corner .mack-bubble { position: absolute; top: calc(100% + 6px); inset-inline-start: 4px; width: max-content; max-width: min(240px, 64vw); font-size: 0.85rem; transform-origin: 20px 0; }
.mack-corner .mack-bubble::before { content: ''; position: absolute; top: -7px; inset-inline-start: 16px; border: 7px solid transparent; border-bottom-color: var(--cream); border-top: 0; }
[dir="rtl"] .mack-corner .mack-bubble { transform-origin: calc(100% - 20px) 0; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  /* flex-start + margin:auto on the card centres it but keeps the top reachable when it's taller than the screen */
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) var(--gut-r) max(16px, env(safe-area-inset-bottom, 0px)) var(--gut-l);
  overflow-y: auto;
}
.overlay.dim { background: rgba(4, 8, 22, 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#ov-intro { background: radial-gradient(100% 70% at 50% 20%, rgba(255, 190, 90, 0.16), transparent 60%), #040816; }
.intro { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 4px; margin: auto; }
.overlay > * { margin: auto; flex: none; }
.intro-card, .menu-card, .pass-card, .quiz, .over {
  width: 100%; border-radius: 22px; padding: 18px;
  background: linear-gradient(170deg, var(--navy-2), var(--navy) 55%, #0b1436);
  box-shadow: inset 0 0 0 1.5px var(--line), 0 20px 50px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; gap: 12px;
}
.intro-card h2, .menu-card h2, .over h2 { margin: 0; font: 1.5rem var(--f-display); color: var(--gold-hi); text-align: center; text-wrap: balance; }
.intro-card p { margin: 0; line-height: 1.5; }
.intro-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.intro-dots { display: flex; justify-content: center; gap: 6px; }
.intro-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--navy-3); }
.intro-dots i.on { background: var(--gold); }
.pay-table { display: grid; gap: 6px; }
.pay-row { display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 12px; background: rgba(7,13,34,0.5); }
.pay-row .g {
  width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center;
  font: 1.6rem/1 var(--f-display); padding-top: 3px;
  background: radial-gradient(circle at 35% 30%, #d9a066, #a8703c); color: #3b2210;
}
.pay-row b { display: block; }
.pay-row span { color: var(--muted); font-size: 0.9rem; }
.pay-row.win b { color: var(--ok); } .pay-row.lose b { color: var(--bad); }
.menu-card { max-width: 360px; }
.pass-card { max-width: 380px; text-align: center; align-items: center; }
.pass-card p { margin: 0; color: var(--muted); }
.pass-who { font: 2rem var(--f-display); color: var(--gold-hi); display: flex; align-items: center; gap: 10px; }

/* Quiz */
.quiz { max-width: 520px; }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-title { font: 1.6rem var(--f-display); color: var(--honey); margin: 0; }
.q-level { font-size: 0.75rem; padding: 3px 10px; border-radius: 999px; background: var(--navy-3); color: var(--muted); }
.q-clock { position: relative; width: 48px; height: 48px; flex: none; }
.q-clock svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.q-clock b { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.q-stake { margin: 0; font-size: 0.88rem; color: var(--muted); }
.q-text { margin: 0; font-size: 1.15rem; font-weight: 600; line-height: 1.45; }
.q-opts { display: grid; gap: 8px; }
.q-opt {
  display: flex; align-items: center; gap: 10px; text-align: start;
  min-height: 52px; padding: 10px 12px; border-radius: 14px; border: 0;
  background: var(--navy); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.08); font-weight: 500;
}
.q-opt i { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; font-style: normal; font-weight: 800; background: var(--navy-3); }
.q-opt[aria-pressed="true"] { box-shadow: inset 0 0 0 2.5px var(--gold); }
.q-opt.right { background: #164a33; box-shadow: inset 0 0 0 2.5px var(--ok); }
.q-opt.wrong { background: #4a1d26; box-shadow: inset 0 0 0 2px var(--bad); }
.q-opt:disabled { cursor: default; }
.q-who { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; justify-content: flex-end; }
.q-who span { font-size: 1rem; }
.q-status { text-align: center; font-weight: 700; color: var(--gold-hi); margin: 0; }
.q-outcome { margin: 0; text-align: center; font: 1.15rem var(--f-display); }
.q-outcome.steal { color: var(--steal); } .q-outcome.kept { color: var(--ok); } .q-outcome.nun { color: var(--muted); }
.q-source { border-radius: 14px; padding: 10px 12px; background: rgba(7,13,34,0.55); display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.q-source .he { font-family: 'Frank Ruhl Libre', var(--f-display); font-size: 1rem; direction: rtl; text-align: right; }
.q-source .en { color: var(--muted); direction: ltr; text-align: left; }
.q-source a { color: var(--gold-hi); font-weight: 700; }
.q-source .ref { font-weight: 700; color: var(--cream); }

/* Game over */
.over { max-width: 460px; align-items: stretch; }
.podium { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.podium .crown { font-size: 2.6rem; animation: cheer 1.2s ease-out infinite; }
.podium .who { font: 1.8rem var(--f-display); color: var(--gold-hi); text-align: center; }
.final { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.final li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(7,13,34,0.5); }
.final li.win { box-shadow: inset 0 0 0 2px var(--gold); }
.final .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.final .c { font-weight: 800; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.earned { text-align: center; color: var(--gold-hi); font-weight: 700; margin: 0; }
.unlock { text-align: center; padding: 10px; border-radius: 14px; background: rgba(233,185,73,0.12); box-shadow: inset 0 0 0 1.5px var(--line); display: flex; align-items: center; gap: 10px; justify-content: center; }
.unlock img { width: 56px; height: 56px; }
.over .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40;
  padding: 10px 18px; border-radius: 14px; background: var(--cream); color: #1b1230; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: calc(100% - 32px); text-align: center;
}

/* ---------- Wider screens ---------- */
@media (min-width: 720px) {
  .seat { width: 104px; padding: 6px 8px 8px; }
  .seat .s-name { font-size: 0.85rem; }
  .seat .s-coins { font-size: 0.95rem; }
  .panel { max-width: 640px; width: 100%; margin: 0 auto; border-radius: 22px 22px 0 0; }
  #menorah { width: 190px; height: 72px; }
  .logo-main { font-size: 3.4rem; }
  .mack-corner .mack-body { width: 64px; height: 67px; }
}
@media (max-width: 360px) {
  #menorah { width: 118px; height: 46px; }
  .round { font-size: 0.85rem; }
  .round small { display: none; }
  .mack-corner .mack-body { width: 42px; height: 44px; }
}
@media (max-height: 640px) {
  .mack-big .mack-body { width: 120px; height: 126px; }
  .home-hero { margin-block: 0; }
  .logo-main { font-size: 2.1rem; }
}

/* Phone turned sideways: table on the left, controls on the right. */
@media (orientation: landscape) and (max-height: 540px) {
  .game { display: grid; grid-template-columns: 1fr minmax(280px, 42%); grid-template-rows: auto 1fr; }
  .game-top { grid-column: 1; grid-row: 1; padding-top: 4px; }
  .stage { grid-column: 1; grid-row: 2; }
  .panel, .panel.compact {
    grid-column: 2; grid-row: 1 / span 2; height: auto; max-width: none; margin: 0;
    border-radius: 22px 0 0 22px; overflow-y: auto; justify-content: center;
    padding: max(10px, env(safe-area-inset-top, 0px)) var(--gut-r) max(10px, env(safe-area-inset-bottom, 0px)) 14px;
    box-shadow: -1.5px 0 0 var(--line), -10px 0 30px rgba(0, 0, 0, 0.45);
  }
  #menorah { width: 120px; height: 46px; }
  .harder { display: none; }
  .btn-big { min-height: 50px; }
  .meter.big { height: 52px; }
  .home-hero .mack-big .mack-body { width: 96px; height: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .mack .wing { animation: none; }
}
