/* ============================================
   ערב משחקים — מערכת עיצוב משותפת
   Shared design system for the board-game hub
   ============================================ */

:root {
  --bg: #0e1118;
  --bg-2: #141926;
  --surface: #1b2232;
  --surface-2: #232c40;
  --line: #2e3a52;
  --text: #ece7da;
  --text-dim: #9aa3b5;
  --gold: #d9ab52;
  --gold-2: #f0c878;
  --red: #d4604f;
  --green: #5fae7a;
  --blue: #5b8fd4;
  --purple: #9b6fd4;
  --teal: #4fb8ae;
  --pink: #d46f9b;
  --orange: #d98a4a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Heebo', 'Rubik', 'Segoe UI', 'Arial Hebrew', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(217, 171, 82, .07), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(91, 143, 212, .06), transparent 60%);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.55;
}

/* ---------- Top bar (game pages) ---------- */
.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: rgba(20, 25, 38, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.top-bar .home-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: .95rem;
  white-space: nowrap;
  transition: color .2s;
}
.top-bar .home-link:hover { color: var(--gold-2); }
.top-bar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .02em;
  flex: 1;
}
.top-bar .accent { color: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .2s, border-color .2s;
  user-select: none;
}
.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  border-color: var(--gold);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(135deg, #b8873b, var(--gold));
  border-color: transparent;
  color: #191204;
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(135deg, #c99a48, var(--gold-2)); }
.btn-danger { background: #5a2c26; border-color: #7d4038; }
.btn-danger:hover:not(:disabled) { border-color: var(--red); }
.btn-small { font-size: .85rem; padding: 6px 14px; }

/* ---------- Panels & cards ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 { margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow);
}
.modal h2 { color: var(--gold); margin-bottom: 12px; }
.modal h3 { margin: 14px 0 6px; color: var(--gold-2); font-size: 1.02rem; }
.modal p, .modal li { color: var(--text); font-size: .95rem; }
.modal ul, .modal ol { padding-inline-start: 22px; margin: 6px 0; }
.modal .modal-close { margin-top: 18px; }

/* ---------- Log / feed ---------- */
.log {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .88rem;
  overflow-y: auto;
  color: var(--text-dim);
}
.log .entry { padding: 3px 0; border-bottom: 1px dashed rgba(46, 58, 82, .5); }
.log .entry:last-child { border-bottom: none; }
.log .entry.important { color: var(--gold-2); font-weight: 600; }

/* ---------- Badges & chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.chip.active { border-color: var(--gold); color: var(--gold-2); }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.flex { display: flex; gap: 12px; }
.flex-col { display: flex; flex-direction: column; gap: 12px; }
.center { display: flex; align-items: center; justify-content: center; }
.grow { flex: 1; }
.muted { color: var(--text-dim); }
.gold-text { color: var(--gold); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3d4c6b; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.85); } 70% { transform: scale(1.04); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 171, 82, .45); } 50% { box-shadow: 0 0 0 8px rgba(217, 171, 82, 0); } }
@keyframes flipIn { 0% { opacity: 0; transform: perspective(700px) rotateY(90deg); } 100% { opacity: 1; transform: perspective(700px) rotateY(0); } }
@keyframes dealIn { 0% { opacity: 0; transform: translateY(-40px) rotate(-6deg) scale(.9); } 100% { opacity: 1; transform: none; } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes glowPulse { 0%, 100% { filter: drop-shadow(0 0 2px rgba(240, 200, 120, .5)); } 50% { filter: drop-shadow(0 0 12px rgba(240, 200, 120, .95)); } }
@keyframes shimmer { 0% { background-position: 200% center; } 100% { background-position: -200% center; } }
@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(-10vh) rotate(0deg); }
  100% { opacity: .15; transform: translateY(105vh) rotate(720deg); }
}
@keyframes bannerSweep {
  0% { opacity: 0; transform: translateX(60vw) skewX(-8deg); }
  15% { opacity: 1; transform: translateX(0) skewX(0); }
  85% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(-60vw) skewX(8deg); }
}
.fade-in { animation: fadeIn .35s ease both; }
.pop-in { animation: popIn .3s ease both; }
.pulse { animation: pulse 1.6s infinite; }
.flip-in { animation: flipIn .45s ease both; }
.deal-in { animation: dealIn .4s cubic-bezier(.2, .8, .3, 1.1) both; }
.floaty { animation: floaty 3.2s ease-in-out infinite; }
.shake { animation: shake .45s ease both; }
.glow-pulse { animation: glowPulse 1.4s ease-in-out infinite; }
.shimmer-text {
  background: linear-gradient(110deg, var(--gold) 35%, #fff2cf 50%, var(--gold) 65%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3s linear infinite;
}
/* staggered entrance for lists/hands: add .stagger to the parent */
.stagger > * { animation: dealIn .4s cubic-bezier(.2, .8, .3, 1.1) both; }
.stagger > *:nth-child(1) { animation-delay: .03s; } .stagger > *:nth-child(2) { animation-delay: .09s; }
.stagger > *:nth-child(3) { animation-delay: .15s; } .stagger > *:nth-child(4) { animation-delay: .21s; }
.stagger > *:nth-child(5) { animation-delay: .27s; } .stagger > *:nth-child(6) { animation-delay: .33s; }
.stagger > *:nth-child(7) { animation-delay: .39s; } .stagger > *:nth-child(8) { animation-delay: .45s; }
.stagger > *:nth-child(9) { animation-delay: .51s; } .stagger > *:nth-child(10) { animation-delay: .57s; }
.stagger > *:nth-child(11) { animation-delay: .63s; } .stagger > *:nth-child(12) { animation-delay: .69s; }
/* confetti: JS creates <div class="confetti-piece"> children inside a fixed full-screen container */
.confetti-piece {
  position: fixed;
  top: 0;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 300;
  animation: confettiFall 2.8s ease-in both;
}
/* full-width turn banner: JS adds/removes .banner-show */
.turn-banner {
  position: fixed;
  top: 42%;
  right: 0;
  left: 0;
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold-2);
  text-shadow: 0 4px 24px rgba(0, 0, 0, .8);
  background: linear-gradient(90deg, transparent, rgba(20, 25, 38, .95) 25%, rgba(20, 25, 38, .95) 75%, transparent);
  padding: 18px 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
}
.turn-banner.banner-show { animation: bannerSweep 1.5s ease both; }

/* ---------- 3D layer: shared utilities ---------- */
/* a "table" wrapper: gives children a physical-board perspective */
.stage-3d {
  perspective: 1500px;
  perspective-origin: 50% 30%;
}
/* subtle physical tilt for boards — keep text panels OUT of this */
.board-3d {
  transform: rotateX(7deg);
  transform-style: preserve-3d;
  box-shadow:
    0 22px 40px -18px rgba(0, 0, 0, .75),
    0 40px 90px -30px rgba(0, 0, 0, .6);
  transition: transform .5s ease;
}
.board-3d:hover { transform: rotateX(4.5deg); }
/* glass panel */
.glass {
  background: rgba(27, 34, 50, .55);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(240, 200, 120, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 10px 30px rgba(0, 0, 0, .45);
}
/* extruded physical chip/token */
.chip-3d {
  box-shadow:
    0 1px 0 rgba(0, 0, 0, .35),
    0 2px 0 rgba(0, 0, 0, .32),
    0 3px 0 rgba(0, 0, 0, .28),
    0 4px 1px rgba(0, 0, 0, .25),
    0 6px 10px rgba(0, 0, 0, .45);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .22), transparent 45%);
}
/* soft contact shadow under floating pieces */
.contact-shadow { position: relative; }
.contact-shadow::after {
  content: '';
  position: absolute;
  inset-inline: 12%;
  bottom: -7px;
  height: 9px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .55), transparent 70%);
  border-radius: 50%;
  z-index: -1;
}
/* two-face 3D flip card: .card3d > .card3d-inner > (.card3d-front + .card3d-back) */
.card3d { perspective: 900px; }
.card3d-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.3, .9, .35, 1.05);
}
.card3d.flipped .card3d-inner { transform: rotateY(180deg); }
.card3d-front, .card3d-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.card3d-back { position: absolute; inset: 0; transform: rotateY(180deg); }
/* gloss sweep on hover: add to cards/tiles */
.gloss { position: relative; overflow: hidden; }
.gloss::before {
  content: '';
  position: absolute;
  inset: -60% auto auto -60%;
  width: 60%;
  height: 220%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .14), transparent);
  transform: rotate(18deg) translateX(-220%);
  transition: transform .7s ease;
  pointer-events: none;
}
.gloss:hover::before { transform: rotate(18deg) translateX(460%); }
/* interactive 3D hover tilt (JS-free, center-pivot) */
.tilt-3d { transition: transform .25s ease, box-shadow .25s ease; transform-style: preserve-3d; }
.tilt-3d:hover {
  transform: perspective(700px) rotateX(6deg) translateY(-6px) scale(1.03);
  box-shadow: 0 18px 34px -12px rgba(0, 0, 0, .7);
}
/* board top-light */
.toplight { position: relative; }
.toplight::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 60% at 50% -10%, rgba(255, 240, 200, .10), transparent 55%);
  pointer-events: none;
  border-radius: inherit;
}
/* vignette over the whole page (append once) */
.vignette::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(130% 100% at 50% 40%, transparent 55%, rgba(0, 0, 0, .5));
  pointer-events: none;
  z-index: 5;
}

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