/* דונקי אונליין – המותג: ליים + שחור. השולחן הוא משטח ליים מלא, הקלפים "מדבקות" לבנות עם קו שחור עבה. */

:root {
  --lime: #e7fc4a;
  --lime-deep: #c9df2a;
  --ink: #000;
  --paper: #fff;
  --hot: #ff4d2e;
  --muted: #4a4f1a;
  /* צבעי המספרים – נדגמו מהקלפים האמיתיים: 1–5 קרים (תכלת→סגול), 6–10 חמים (ירוק→אדום) */
  --n1: #63cde6; --n2: #4f6ad0; --n3: #2a00c3; --n4: #9b4aa4; --n5: #732983;
  --n6: #00c620; --n7: #56f80a; --n8: #e6d800; --n9: #ff800b; --n10: #ed3e2a;
  --display: 'Karantina', 'Arial Hebrew', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Fredoka', 'Arial Hebrew', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --line: 3px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--lime);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

#app { height: 100%; max-width: 560px; margin: 0 auto; }
.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- כפתורים ---------- */
.btn {
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 1rem;
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .4; box-shadow: none; cursor: default; }
.btn-ink { background: var(--ink); color: var(--lime); }
.btn-lime { background: var(--lime); }
.btn-ghost { background: transparent; color: var(--lime); border-color: var(--lime); box-shadow: none; }
.btn-ghost:disabled { opacity: .3; }
.btn-outline { background: transparent; box-shadow: none; }
.link { background: none; border: 0; padding: 6px 2px; text-decoration: underline; text-underline-offset: 4px; font-weight: 500; color: var(--ink); }

/* ---------- כניסה ---------- */
.welcome { margin: auto; padding: 28px 24px calc(28px + var(--safe-bottom)); width: 100%; }
.logo { font-family: var(--display); font-weight: 700; line-height: .8; margin: 0 0 18px; }
.logo span { display: block; font-size: clamp(6rem, 34vw, 11rem); letter-spacing: -.01em; }
.logo small { display: block; font-size: clamp(2rem, 10vw, 3.2rem); font-weight: 400; margin-top: 6px; }
.pitch { font-size: 1.15rem; max-width: 30ch; margin: 0 0 28px; }
#form-name { display: grid; gap: 10px; }
#form-name label { font-weight: 600; }
#form-name input {
  font: inherit; font-size: 1.2rem; padding: 14px 16px; border: var(--line) solid var(--ink);
  border-radius: 14px; background: var(--paper); color: var(--ink); width: 100%;
}
.hero { display: block; width: min(52vw, 220px); height: auto; margin: 0 0 -6px; }
.rules-page { width: 100%; height: auto; border-radius: 12px; border: 2px solid var(--ink); }
.seats-preview i.on { background-image: var(--back); background-size: cover; background-position: center; }
.fineprint { font-size: .85rem; color: var(--muted); margin-top: 22px; max-width: 40ch; }

/* ---------- פס עליון ---------- */
.bar {
  background: var(--ink); color: var(--lime);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  flex: none;
}
.bar-logo { font-family: var(--display); font-weight: 700; font-size: 2.2rem; line-height: 1; }
.wallet, .bar-pot, .bar-clock { font-weight: 600; font-variant-numeric: tabular-nums; }
.wallet::before { content: '🪙 '; }
.bar-btn { background: none; border: 0; color: var(--lime); font-size: 1.3rem; padding: 4px 8px; }

/* ---------- לובי ---------- */
.lobby { flex: 1; min-height: 0; padding: 20px 18px calc(28px + var(--safe-bottom)); overflow-y: auto; display: grid; gap: 14px; align-content: start; grid-auto-rows: max-content; }
.lobby h2 { font-family: var(--display); font-size: 3rem; line-height: .95; margin: 0; font-weight: 700; }
.lobby h3 { font-size: 1.1rem; margin: 10px 0 0; }
.bonus-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bonus-row.single { grid-template-columns: 1fr; }
.email-cta { text-align: start; line-height: 1.3; }
.email-cta small { display: block; font-weight: 500; font-size: .85rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; line-height: 1.35; }
.check input { width: 22px; height: 22px; flex: none; margin: 2px 0 0; accent-color: var(--ink); }
.field input[type='email'] { font: inherit; font-size: 1.1rem; padding: 12px 14px; border: var(--line) solid var(--ink); border-radius: 14px; width: 100%; direction: ltr; text-align: left; }
.fineprint a { color: inherit; }
.bonus-row .btn { padding: 10px 8px; font-size: .95rem; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: var(--line) solid var(--ink); border-radius: 14px; overflow: hidden; background: var(--paper); }
.segmented button { border: 0; background: none; padding: 10px 6px; font-weight: 600; }
.segmented button + button { border-inline-start: var(--line) solid var(--ink); }
.segmented button[aria-checked='true'] { background: var(--ink); color: var(--lime); }
.tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tier {
  text-align: start; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 16px;
  padding: 12px 14px; box-shadow: 4px 4px 0 var(--ink); display: grid; gap: 2px;
}
.tier:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.tier:disabled { opacity: .45; box-shadow: none; }
.tier b { font-family: var(--display); font-size: 2.6rem; line-height: .9; font-weight: 700; }
.tier span { font-size: .9rem; }
.tier:last-child:nth-child(odd) { grid-column: 1 / -1; }
.hint { font-size: .9rem; color: var(--muted); margin: 0; }
.links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; }

/* ---------- המתנה ---------- */
.queue { margin: auto; padding: 24px; text-align: center; display: grid; gap: 16px; justify-items: center; }
.queue h2 { font-family: var(--display); font-size: 3.4rem; line-height: .95; margin: 0; }
.seats-preview { display: flex; gap: 10px; }
.seats-preview i {
  width: 46px; height: 64px; border: var(--line) dashed var(--ink); border-radius: 10px; display: grid; place-items: center;
  font-style: normal; font-size: 1.4rem;
}
.seats-preview i.on { border-style: solid; background: var(--paper); box-shadow: 3px 3px 0 var(--ink); }

/* ---------- חדר השולחנות ---------- */
.rooms { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-bottom)); display: grid; gap: 14px; align-content: start; grid-auto-rows: max-content; }
.rooms-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
#rooms-list { display: grid; gap: 12px; }
.room-card { background: var(--paper); border: var(--line) solid var(--ink); border-radius: 16px; padding: 12px 14px; box-shadow: 4px 4px 0 var(--ink); display: grid; gap: 8px; }
.room-card.playing { opacity: .6; box-shadow: none; }
.room-card h4 { margin: 0; font-size: 1.1rem; }
.room-card .by { font-size: .9rem; color: var(--muted); }
.room-card .btn { padding: 9px 14px; box-shadow: 3px 3px 0 var(--ink); }
.room-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: inherit; }
.rooms-empty { text-align: center; padding: 28px 12px; border: var(--line) dashed var(--ink); border-radius: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .95rem; }
.field small { color: var(--muted); }
.field input[type='text'] { font: inherit; padding: 11px 13px; border: var(--line) solid var(--ink); border-radius: 12px; width: 100%; }
.segmented.wrap { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
.segmented.wrap button { border-inline-start: 0 !important; border: 1px solid var(--ink); }
.segmented button:disabled { opacity: .35; }
.kick { border: 2px solid var(--ink); background: none; border-radius: 8px; font-size: .8rem; padding: 2px 8px; }

/* ---------- שולחן פרטי ---------- */
.room-code { font-family: var(--display); font-weight: 700; font-size: 3.6rem; line-height: 1; letter-spacing: .08em; direction: ltr; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 18px; padding: 6px 22px 10px; box-shadow: 5px 5px 0 var(--ink); }
#screen-room { overflow-y: auto; }
#screen-room .queue { gap: 12px; padding: 18px 20px calc(18px + var(--safe-bottom)); }
#screen-room .queue h2 { font-size: 2.6rem; }
#screen-room .room-chips { justify-content: center; }
#screen-room .queue p { margin: 0; }
#screen-room .rank { width: min(320px, 100%); text-align: start; }
#screen-room .btn { width: min(320px, 100%); }
.code-input { font: inherit; font-size: 1.6rem; letter-spacing: .2em; text-transform: uppercase; text-align: center; direction: ltr; padding: 12px; border: var(--line) solid var(--ink); border-radius: 14px; width: 100%; }

/* ---------- שולחן ---------- */
#screen-table { background: var(--lime); position: relative; }
.opponents { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; flex: none; }
.opp {
  flex: 1 0 0; min-width: 104px; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 14px;
  padding: 8px 10px; display: grid; gap: 4px; position: relative;
}
.opponents.many { gap: 6px; padding: 8px; }
.opponents.many .opp { min-width: 0; padding: 6px 7px; }
.opponents.many .opp-name { font-size: .8rem; }
.opponents.many .opp-cards { font-size: 1.6rem; }
.opponents.many .opp-cards small { display: none; }
.opponents.many .btn-catch { font-size: .72rem; padding: 3px 4px; }
.opp.turn { box-shadow: 0 0 0 4px var(--ink); }
.opp.left { opacity: .55; }
.opp-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp-cards { font-family: var(--display); font-size: 2rem; line-height: .9; font-weight: 700; }
.opp-cards small { font-family: var(--body); font-size: .8rem; font-weight: 500; margin-inline-start: 4px; }
.opp-flag { position: absolute; inset-block-start: -10px; inset-inline-end: 8px; background: var(--ink); color: var(--lime); font-family: var(--display); font-size: 1.2rem; line-height: 1; padding: 3px 8px; border-radius: 8px; transform: rotate(-4deg); }
.btn-catch { border: 2px solid var(--ink); border-radius: 10px; background: var(--hot); color: #fff; font-weight: 600; font-size: .85rem; padding: 4px 6px; }

.felt { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px 14px; }
.piles { display: flex; align-items: center; gap: 18px; direction: ltr; }
.pile { width: 92px; height: 130px; border-radius: 14px; border: var(--line) solid var(--ink); display: grid; place-items: center; position: relative; }
.pile-draw { background: var(--ink); color: var(--lime); box-shadow: 4px 4px 0 var(--lime-deep), 7px 7px 0 var(--ink); font-family: var(--display); font-size: 2rem; }
.pile-draw::before { content: '🐴'; position: absolute; inset-block-start: 14px; font-size: 1.8rem; }
.pile-draw span { margin-top: 40px; }
.pile-draw.can { animation: nudge 1.6s ease-in-out infinite; }
.pile-top { border-style: dashed; background: transparent; }
.pile-top .card { position: absolute; inset: -3px; width: auto; height: auto; margin: 0; }
.rules-now { display: grid; gap: 6px; direction: rtl; min-width: 86px; }
.chip { background: var(--ink); color: var(--lime); border-radius: 999px; padding: 4px 10px; font-size: .85rem; font-weight: 600; white-space: nowrap; text-align: center; }
.chip.alt { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); }
.chip.warn { background: var(--hot); color: #fff; }
.status { margin: 0; font-weight: 600; text-align: center; min-height: 1.5em; max-width: 34ch; }
.turnbar { width: min(280px, 80%); height: 8px; border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; background: var(--paper); }
.turnbar i { display: block; height: 100%; width: 0; background: var(--ink); }

.tray { background: var(--ink); flex: none; padding: 10px 0 calc(10px + var(--safe-bottom)); border-radius: 22px 22px 0 0; }
.hand { display: flex; gap: 0; overflow-x: auto; padding: 22px 16px 10px; scrollbar-width: none; direction: ltr; min-height: 150px; }
.hand::-webkit-scrollbar { display: none; }
.hand .card { flex: none; margin-inline-end: var(--overlap, -34px); transition: transform .12s ease; }
.hand .card:last-child { margin-inline-end: 0; }
.hand .card.sel { transform: translateY(-18px); z-index: 2; }
.hand .card.dim { filter: grayscale(.85) brightness(.75); }
.hand .card.new { animation: drop .35s ease-out; }
.actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; padding: 4px 16px 0; }
.actions:has(#btn-pass:not([hidden])) { grid-template-columns: 1.4fr 1fr 1fr; }
.actions .btn-lime { box-shadow: 4px 4px 0 var(--lime-deep); }

/* ---------- קלפים ---------- */
.card {
  width: 84px; height: 118px; border-radius: 12px; border: var(--line) solid var(--ink); background: var(--paper);
  position: relative; display: grid; place-items: center; padding: 0; color: var(--ink);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .9); user-select: none; direction: ltr;
}
.card .idx { position: absolute; inset-block-start: 4px; left: 7px; font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1; }
.card .big { font-family: var(--display); font-weight: 700; font-size: 4.6rem; line-height: 1; }
.card.num { color: var(--c); }
.card.num::after { content: ''; position: absolute; inset-inline: 8px; inset-block-end: 8px; height: 10px; border-radius: 6px; background: var(--c); }
.card.sp { background: var(--ink); color: var(--lime); border-color: var(--lime); box-shadow: 0 0 0 2px var(--ink); }
.card.sp .idx { font-size: 1.25rem; font-family: var(--body); left: 5px; }
.card.sp .big { font-size: 2.6rem; }
.card.sp .name { position: absolute; inset-inline: 4px; inset-block-end: 7px; font-size: .78rem; font-weight: 600; text-align: center; direction: rtl; line-height: 1.1; }
.card.mini { width: 58px; height: 82px; border-radius: 9px; }
.card.mini .big { font-size: 3rem; }
.card.mini.sp .big { font-size: 1.7rem; }
.card.mini .idx, .card.mini .name { display: none; }

/* קלף עם אמנות אמיתית (תמונה מ-client/cards) */
.card.art { padding: 0; overflow: hidden; background: var(--paper); }
.card.art::after { display: none; }
.card.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.card.art .idx { z-index: 1; inset-block-start: 3px; left: 3px; background: var(--ink); color: var(--lime); border-radius: 7px; padding: 1px 6px; font-size: 1.15rem; line-height: 1.1; }
.card.art .idx.txt { font-family: var(--body); font-weight: 600; font-size: .68rem; padding: 3px 5px; direction: rtl; }
.card.mini.art .idx, .pile-top .card.art .idx { display: none; }
.card.art { border-width: 2px; }
.pile-draw.art { background-size: cover; background-position: center; color: #fff; text-shadow: 0 1px 3px #000; }
.pile-draw.art::before { content: none; }

/* ---------- "דונקי!" – הרגע היחיד שצועק ---------- */
.donkey-call {
  position: absolute; inset-inline: 0; margin-inline: auto; inset-block-end: 236px; width: max-content; z-index: 5;
  font-family: var(--display); font-weight: 700; font-size: 4.2rem; line-height: 1; padding: 6px 30px 10px;
  background: var(--hot); color: #fff; border: 4px solid var(--ink); border-radius: 20px; box-shadow: 6px 6px 0 var(--ink);
  transform: rotate(-5deg); animation: shout .7s ease-in-out infinite alternate;
}

/* ---------- גיליון תחתון ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  background: var(--paper); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; border-radius: 22px 22px 0 0;
  border: var(--line) solid var(--ink); border-bottom: 0; padding: 22px 20px calc(22px + var(--safe-bottom)); display: grid; gap: 14px;
}
.sheet h2 { font-family: var(--display); font-size: 3rem; line-height: .95; margin: 0; }
.sheet p { margin: 0; }
.sheet .row { display: grid; gap: 10px; }
.sheet .cards { display: flex; flex-wrap: wrap; gap: 6px; direction: ltr; }
.delta { font-family: var(--display); font-size: 4.4rem; line-height: .9; font-weight: 700; }
.delta.minus { color: var(--hot); }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rank li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 12px; }
.rank li.me { background: var(--lime); }
.rules-text h4 { margin: 12px 0 4px; }
.rules-text ul { margin: 0; padding-inline-start: 20px; }
.ad-box { border: var(--line) dashed var(--ink); border-radius: 14px; padding: 28px 12px; text-align: center; background: #f4f4f4; }

.toast {
  position: fixed; inset-inline: 0; margin-inline: auto; width: max-content; max-width: 86vw; inset-block-start: calc(168px + var(--safe-top));
  background: var(--ink); color: var(--lime); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 30; text-align: center;
}
.offline { position: fixed; inset-inline: 0; inset-block-end: 0; background: var(--hot); color: #fff; text-align: center; padding: 8px; font-weight: 600; z-index: 40; }

/* מסך מנוחה: הלקוח התנתק אחרי חוסר פעילות כדי שהשרת יוכל להירדם */
.sleep { position: fixed; inset: 0; z-index: 50; background: var(--lime); display: grid; place-items: center; text-align: center; padding: 24px; }
.sleep p { font-family: var(--display); font-size: 3rem; line-height: 1; margin: 0; }

@keyframes shout { from { transform: rotate(-5deg) scale(1); } to { transform: rotate(-3deg) scale(1.07); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (min-height: 760px) {
  .card { width: 92px; height: 130px; }
  .hand { min-height: 164px; }
  .donkey-call { inset-block-end: 252px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
