:root {
  --ink: #1b1233;
  --paper: #fff8e7;
  --pink: #ff3d81;
  --lime: #b6ff3b;
  --yellow: #ffd23f;
  --violet: #7b2cbf;
  --cyan: #35e0ff;
  --border: 3px solid var(--ink);
  --shadow: 0 4px 0 var(--ink);
  --display: 'Secular One', 'Rubik', Arial, sans-serif;
  --body: 'Rubik', 'Heebo', Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0820; color: var(--ink); font-family: var(--body); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; }
#c { width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* מצב ריל: מסגרת אנכית 9:16 לצילום מסך */
.reel #stage { inset: 0; margin: auto; height: 100%; aspect-ratio: 9 / 16; max-width: 100%; }
.reel #hud { display: none; }
.hud-hidden #hud { display: none; }

#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#labels, #bubble { pointer-events: none; }

.topbar { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); inset-inline: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: #fff; border: var(--border);
  border-radius: 999px; box-shadow: var(--shadow); font-family: var(--display); font-size: 17px; line-height: 1; white-space: nowrap;
}
.pill.brand { background: var(--yellow); }
.pill.dark { background: var(--ink); color: var(--paper); border-color: var(--ink); box-shadow: 0 4px 0 #000; }
.pill .ico { font-size: 16px; }
button.pill:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
#menuBtn { flex-basis: auto; margin-inline-start: 0; }

#search {
  position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); display: flex; align-items: stretch; gap: 0;
  background: var(--ink); border: var(--border); border-radius: 18px; box-shadow: 0 5px 0 #000; padding: 6px; direction: ltr;
}
#search .at { display: grid; place-items: center; padding: 0 4px 0 12px; color: var(--lime); font-weight: 700; font-size: 18px; }
#search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff; font-size: 17px; padding: 10px 6px; }
#search input::placeholder { color: #8f86b3; }
#search button {
  direction: rtl; background: var(--pink); color: #fff; border: var(--border); border-color: #000; border-radius: 12px;
  padding: 0 16px; font-family: var(--display); font-size: 17px; white-space: nowrap;
}
#search button:active { transform: translateY(2px); }

#toast {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 14px; border: var(--border); font-family: var(--display); font-size: 17px; text-align: center; max-width: min(420px, 90%);
}

/* כרטיס תוצאה */
#card {
  position: absolute; bottom: calc(84px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); background: var(--paper); border: var(--border); border-radius: 18px; box-shadow: var(--shadow);
  padding: 14px 16px; animation: rise .35s cubic-bezier(.2, 1.4, .4, 1);
}
#card h3 { margin: 0 0 4px; font-family: var(--display); font-size: 22px; }
#card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.chip { background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px; font-size: 14px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip.new { background: var(--lime); }
.chip.guest { background: var(--yellow); }
#card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  background: #fff; border: var(--border); border-radius: 12px; padding: 8px 14px; font-family: var(--display); font-size: 16px; box-shadow: 0 3px 0 var(--ink);
}
.btn.primary { background: var(--pink); color: #fff; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#card .x { position: absolute; top: 8px; inset-inline-start: 10px; border: 0; background: transparent; font-size: 20px; }
#card p { margin: 0; font-size: 14.5px; line-height: 1.45; }

/* תוויות מעל ישיבות */
.label {
  position: absolute; transform: translate(-50%, -100%); background: #fff; border: 2px solid var(--ink); border-radius: 999px;
  padding: 2px 9px; font-size: 12.5px; font-weight: 700; white-space: nowrap; direction: ltr; box-shadow: 0 2px 0 var(--ink);
}
.label.mine { background: var(--pink); color: #fff; font-size: 14px; padding: 4px 12px; z-index: 2; }
.label.demo { opacity: 0.7; }

/* בועת דיבור */
#bubble {
  position: absolute; transform: translate(-50%, -100%); max-width: 240px; background: #fff; border: var(--border); border-radius: 16px;
  padding: 9px 14px; font-family: var(--display); font-size: 17px; text-align: center; box-shadow: var(--shadow);
}
#bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -11px; width: 16px; height: 16px; background: #fff; border: var(--border);
  border-top: 0; border-inline-start: 0; transform: translateX(-50%) rotate(45deg);
}

/* חלון */
#modal { position: absolute; inset: 0; background: rgba(13, 8, 32, .55); display: grid; place-items: center; padding: 14px; backdrop-filter: blur(2px); }
#modal[hidden], #card[hidden], #toast[hidden], #bubble[hidden] { display: none; }
.sheet {
  width: min(460px, 100%); max-height: min(86vh, 720px); display: flex; flex-direction: column; background: var(--paper);
  border: var(--border); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); overflow: hidden; animation: rise .3s cubic-bezier(.2, 1.4, .4, 1);
}
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--yellow); border-bottom: var(--border); padding: 12px 16px; }
.sheet h2 { margin: 0; font-family: var(--display); font-size: 21px; font-weight: 400; }
#modalClose { width: 34px; height: 34px; border-radius: 10px; border: var(--border); background: #fff; font-size: 16px; }
#modalBody { overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sec { font-size: 13px; font-weight: 700; color: #6a5f8c; margin: 6px 2px 0; }
.item {
  display: flex; align-items: center; gap: 12px; text-align: start; width: 100%; background: #fff; border: var(--border); border-radius: 14px;
  padding: 10px 12px; box-shadow: 0 3px 0 var(--ink);
}
.item.hot { background: var(--lime); }
.item:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.item[disabled] { opacity: .55; cursor: default; }
.item .ic { font-size: 26px; flex: none; }
.item b { display: block; font-family: var(--display); font-weight: 400; font-size: 18px; }
.item span.sub { display: block; font-size: 13.5px; color: #4b4268; line-height: 1.35; }
.news { background: #fff; border: var(--border); border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; }
.news .ic { font-size: 26px; }
.news b { font-family: var(--display); font-weight: 400; font-size: 18px; }
.news p { margin: 2px 0 8px; font-size: 14.5px; line-height: 1.4; }
.para { font-size: 15px; line-height: 1.55; margin: 0; }
.note { background: #fff; border: 2px dashed var(--ink); border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.45; }
.list { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 7px 12px; direction: ltr; text-align: left; }
.person small { color: #6a5f8c; direction: rtl; }

/* טעינה */
#loader { position: absolute; inset: 0; background: var(--ink); color: var(--paper); display: grid; place-items: center; transition: opacity .6s; text-align: center; padding: 24px; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-in h1 { font-family: var(--display); font-weight: 400; font-size: clamp(24px, 6vw, 34px); margin: 14px 0; color: var(--yellow); }
.spin { font-size: 56px; animation: wob 1s ease-in-out infinite; }
#loaderLines { list-style: none; padding: 0; margin: 0; font-size: 16px; line-height: 1.9; color: #cfc6ee; min-height: 120px; }
#loaderLines li { animation: rise .3s both; }
#loaderLines li::before { content: '✓ '; color: var(--lime); }

@keyframes rise { from { opacity: 0; transform: translate(var(--tx, 0), 10px) scale(.96); } to { opacity: 1; transform: translate(var(--tx, 0), 0) scale(1); } }
@keyframes wob { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg) translateY(-6px); } }
#card, #search { --tx: -50%; }

@media (max-width: 520px) {
  .pill { font-size: 15px; padding: 6px 11px; }
  #search button { font-size: 15px; padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
