/* ==========================================================================
   פוקר לילדים — עיצוב משותף
   RTL, מגע-ראשון, מטרה: ילדים בני 9 על טאבלט או טלפון.
   כללי אצבע: אזור מגע מינימלי 48px, ניגודיות גבוהה, אפס טקסט זעיר.
   ========================================================================== */

:root {
  --bg-0: #0e1b2a;
  --bg-1: #14293f;
  --felt-0: #10603f;
  --felt-1: #0a4530;
  --card-bg: #fdfcf7;
  --ink: #14202e;
  --ink-soft: #5b6b7d;
  --paper: #ffffff;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-dark: rgba(11, 25, 40, 0.88);

  --amber: #ffb020;
  --amber-dark: #e08a00;
  --grass: #3ec46d;
  --grass-dark: #2a9c52;
  --coral: #ff6b5e;
  --coral-dark: #e04a3c;
  --sky: #46b8f0;
  --violet: #9b6cf0;

  --red-suit: #d6283c;
  --black-suit: #1c2733;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --shadow-1: 0 2px 6px rgba(0, 0, 0, .18);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-3: 0 18px 48px rgba(0, 0, 0, .40);

  --font: system-ui, -apple-system, 'Segoe UI', 'Arial Hebrew', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: linear-gradient(160deg, var(--bg-0), var(--bg-1) 60%, #0b2233);
  color: #eaf2f8;
  overscroll-behavior: none;
  /* רשת ביטחון: שום דבר לא אמור לגלוש הצידה, ואם כן — לא נותנים לדף להתנדנד */
  overflow-x: hidden;
}

body { font-size: 17px; line-height: 1.5; }

h1, h2, h3 { margin: 0 0 .4em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .6em; }

/* ------------------------------------------------------------------ כפתורים */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-height: 52px;
  padding: 0 1.4em;
  border: none;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #fff, #e8eef4);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: var(--shadow-1), inset 0 -3px 0 rgba(0, 0, 0, .12);
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
  user-select: none;
}
.btn:active { transform: translateY(2px); box-shadow: var(--shadow-1); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.btn-primary { background: linear-gradient(180deg, var(--amber), var(--amber-dark)); color: #3a2400; }
.btn-go      { background: linear-gradient(180deg, var(--grass), var(--grass-dark)); color: #04220f; }
.btn-danger  { background: linear-gradient(180deg, var(--coral), var(--coral-dark)); color: #3a0a05; }
.btn-cool    { background: linear-gradient(180deg, var(--sky), #2a90c8); color: #04202e; }
.btn-ghost {
  background: rgba(255, 255, 255, .10);
  color: #eaf2f8;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .22);
}
.btn-lg { min-height: 66px; font-size: 1.25rem; border-radius: var(--r-lg); }
.btn-sm { min-height: 40px; font-size: .95rem; padding: 0 1em; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* --------------------------------------------------------------- קלפי משחק */

.card {
  --w: 62px;
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  border-radius: calc(var(--w) * .13);
  background: var(--card-bg);
  box-shadow: var(--shadow-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  /* קלפים נקראים תמיד משמאל לימין, גם בממשק עברי */
  direction: ltr;
  font-weight: 900;
  line-height: 1;
  flex: none;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card .rank { font-size: calc(var(--w) * .40); }
.card .suit { font-size: calc(var(--w) * .36); margin-top: .08em; }
.card .corner {
  position: absolute;
  top: 4%;
  inset-inline-start: 7%;
  font-size: calc(var(--w) * .22);
  opacity: .85;
}
.card.red   { color: var(--red-suit); }
.card.black { color: var(--black-suit); }

.card.back {
  background:
    repeating-linear-gradient(45deg, #2b5fa8 0 6px, #24518f 6px 12px);
  box-shadow: var(--shadow-2), inset 0 0 0 3px rgba(255, 255, 255, .5);
}
.card.back::after {
  content: '♠';
  font-size: calc(var(--w) * .42);
  color: rgba(255, 255, 255, .55);
}
.card.empty {
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .14);
}
.card.winning {
  transform: translateY(-10px) scale(1.06);
  box-shadow: 0 0 0 4px var(--amber), var(--shadow-3);
  z-index: 2;
}
.card.dealt { animation: deal .32s cubic-bezier(.2, .9, .3, 1.2) backwards; }
@keyframes deal {
  from { opacity: 0; transform: translateY(-40px) rotate(-12deg) scale(.7); }
}

.card-row { display: flex; gap: 6px; align-items: center; }

/* ------------------------------------------------------------------ פאנלים */

.panel {
  background: var(--panel-dark);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .08);
}
.panel-light { background: var(--panel); color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  padding: .28em .8em;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill.amber { background: rgba(255, 176, 32, .22); color: #ffd27a; }
.pill.grass { background: rgba(62, 196, 109, .20); color: #8ef0b0; }
.pill.coral { background: rgba(255, 107, 94, .20); color: #ffab9f; }

/* ------------------------------------------------------------ מד עוצמת יד */

/* הצבע נקבע ב-JS לפי הערך עצמו. קודם היה כאן גרדיאנט קבוע, ומכיוון
   שהוא נמתח על רוחב המילוי, יד של 15% ויד של 90% נראו כמעט זהות. */
.meter {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .38);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .4);
}
.meter > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--grass);
  transition: width .4s cubic-bezier(.3, .8, .3, 1), background-color .4s ease;
}
.meter-tick {
  position: absolute;
  inset-block: 0;
  width: 2px;
  background: rgba(255, 255, 255, .3);
  pointer-events: none;
}

/* -------------------------------------------------------------------- שונות */

.row { display: flex; gap: 10px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { justify-content: center; }
.muted { color: var(--ink-soft); }
.dim { opacity: .68; }
.tiny { font-size: .85rem; }
.big-num { font-size: 1.6rem; font-weight: 900; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

.chip-amount {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  font-weight: 900;
  color: var(--amber);
}
.chip-amount::before { content: '🪙'; font-size: .9em; }

.toast {
  position: fixed;
  inset-block-start: 16px;
  inset-inline: 0;
  margin: auto;
  width: max-content;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: var(--r-md);
  background: var(--coral);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-3);
  z-index: 999;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px); } }

/* --------------------------------------------------------------- מודאלים */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 14, 24, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 500;
  animation: fade .2s ease;
  overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1b3350, #142a42);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-3);
  border: 1px solid rgba(255, 255, 255, .1);
}
.modal h2 { text-align: center; }

/* ------------------------------------------------------------------ מוזיקה */

.audio-fab {
  position: fixed;
  inset-block-end: 14px;
  inset-inline-start: 14px;
  z-index: 400;
  display: flex;
  gap: 8px;
  align-items: center;
}
.audio-fab .btn { min-height: 48px; width: 48px; padding: 0; font-size: 1.3rem; border-radius: 50%; }
.audio-tracks {
  display: flex;
  gap: 6px;
  background: var(--panel-dark);
  padding: 6px;
  border-radius: 999px;
  box-shadow: var(--shadow-2);
}

/* ------------------------------------------------------------ דף הזמנה */

/* מעוצב קודם כל להדפסה: הרבה ילדים בגיל הזה בלי ווטסאפ, אז הדרך
   המעשית להזמין חבר היא דף מודפס עם QR וקוד גדול. */
.invite-sheet {
  background: #fff;
  color: #14202e;
  border-radius: var(--r-lg);
  padding: 20px 18px;
  text-align: center;
}
.invite-title { font-size: 1.5rem; font-weight: 900; margin-block-end: 2px; }
.invite-sub { font-size: .95rem; color: #5b6b7d; margin-block-end: 12px; }

.qr-box {
  display: flex;
  justify-content: center;
  margin: 10px auto 14px;
}
.qr-box svg { width: min(260px, 62vw); height: auto; display: block; }

.invite-howto {
  font-size: .92rem;
  color: #3c4a5a;
  text-align: start;
  max-width: 300px;
  margin: 0 auto 10px;
  line-height: 1.7;
}

.invite-code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: clamp(2.2rem, 11vw, 3.2rem);
  font-weight: 900;
  letter-spacing: .18em;
  direction: ltr;
  padding: .1em .2em;
  border: 3px dashed #14202e;
  border-radius: var(--r-md);
  display: inline-block;
  margin-block-end: 10px;
}
.invite-url {
  font-size: .9rem;
  direction: ltr;
  word-break: break-all;
  color: #3c4a5a;
  margin-block-end: 12px;
}
.invite-when { font-size: 1rem; font-weight: 700; }
.invite-blank { border-block-end: 2px solid #14202e; padding: 0 1.4em; }

@media print {
  /* בהדפסה נשאר רק דף ההזמנה עצמו */
  body { background: #fff !important; color: #000 !important; }
  body > *:not(.overlay) { display: none !important; }
  .overlay {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
  }
  .modal {
    box-shadow: none !important;
    background: #fff !important;
    max-height: none !important;
    padding: 0 !important;
    width: 100% !important;
    border: none !important;
  }
  .modal > h2, .no-print, .audio-fab, .toast { display: none !important; }
  .invite-sheet { border: 2px solid #000; border-radius: 12px; }
  .qr-box svg { width: 46mm; }
  @page { margin: 14mm; }
}

/* --------------------------------------------------------------- נגישות */

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
