:root {
  --yellow: #ffcb05;
  --blue: #2a75bb;
  --navy: #1d3a6e;
  --red: #e3350d;
  --bg: #f4f8ff;
  --card: #ffffff;
  --text: #1c2340;
  --muted: #6b7591;
  --green: #22a45d;
  --radius: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Rubik", -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 18px;
  min-height: 100dvh;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
.top {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--yellow);
  box-shadow: 0 3px 0 #e0b000;
}
.top h1 { margin: 0; font-size: 24px; font-weight: 800; color: var(--navy); }
.logo { width: 36px; height: 36px; }
main { max-width: 520px; margin: 0 auto; padding: 16px; }
.screen { display: none; animation: pop .25s ease-out; }
.screen.active { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* סריקה */
.hero { text-align: center; padding-top: 8px; }
.big-hint { font-size: 24px; font-weight: 600; margin: 8px 0 22px; }
.shoot {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin: 0 auto; width: 100%; padding: 30px 10px 26px;
  background: var(--card); border-radius: 32px; border: 4px solid var(--navy);
  box-shadow: 0 8px 0 var(--navy); cursor: pointer; user-select: none;
  transition: transform .1s, box-shadow .1s;
}
.shoot:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--navy); }
.ball, .spin-ball {
  width: 150px; height: 150px; border-radius: 50%; position: relative;
  background: linear-gradient(var(--red) 0 46%, #222 46% 54%, #fff 54%);
  border: 7px solid #222;
}
.ball::after, .spin-ball::after {
  content: ""; position: absolute; inset: 50% auto auto 50%; width: 42px; height: 42px;
  transform: translate(-50%, -50%); border-radius: 50%; background: #fff; border: 7px solid #222;
}
.ball { animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-12deg); } 86% { transform: rotate(10deg); } 94% { transform: rotate(-5deg); } }
.shoot-text { font-size: 34px; font-weight: 800; color: var(--navy); }
.gallery {
  display: inline-block; margin-top: 22px; padding: 14px 22px; border-radius: 999px;
  background: #e6efff; color: var(--blue); font-weight: 600; cursor: pointer;
}
.tip { color: var(--muted); font-size: 16px; margin-top: 22px; line-height: 1.5; }

/* טעינה */
#loading { text-align: center; padding-top: 30px; }
.spin-ball { margin: 0 auto; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 32px; font-weight: 800; color: var(--navy); }
.preview { max-width: 60%; max-height: 260px; border-radius: 14px; opacity: .8; }

/* תוצאה */
#result { text-align: center; }
.card-view img {
  width: 72%; max-width: 300px; border-radius: 16px; display: block; margin: 0 auto;
  box-shadow: 0 10px 24px rgba(20, 40, 90, .25);
}
#result h2 { font-size: 30px; margin: 16px 0 2px; color: var(--navy); }
.muted { color: var(--muted); margin: 0 0 10px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.facts div { background: var(--card); border-radius: 16px; padding: 10px 6px; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.facts span { display: block; font-size: 14px; color: var(--muted); }
.facts b { display: block; font-size: 16px; margin-top: 2px; word-break: break-word; }
.price-box {
  background: var(--yellow); border-radius: var(--radius); padding: 14px; margin: 14px 0;
  box-shadow: 0 5px 0 #e0b000;
}
.price-box span { display: block; font-weight: 600; color: var(--navy); }
.price-box strong { display: block; font-size: 44px; font-weight: 800; color: var(--navy); }
.price-box strong.unknown { font-size: 28px; }
.price-box small { color: #5a4a00; font-size: 13px; }
.warn { background: #fff3cd; color: #7a5b00; padding: 10px; border-radius: 14px; }
.btn {
  display: block; width: 100%; border: 0; border-radius: 20px; padding: 18px; margin: 12px 0;
  font: inherit; font-size: 22px; font-weight: 800; cursor: pointer;
}
.btn:active { transform: translateY(3px); }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 5px 0 #187a44; }
.btn.secondary { background: #e6efff; color: var(--blue); }
.btn:disabled { opacity: .6; }
.wow {
  font-size: 30px; font-weight: 800; color: var(--red); margin-bottom: 10px;
  animation: bounce .6s ease-in-out infinite alternate;
}
@keyframes bounce { from { transform: scale(1); } to { transform: scale(1.12); } }
.shine { animation: shine 1.4s ease-in-out 3; }
@keyframes shine { 50% { filter: brightness(1.35) drop-shadow(0 0 22px gold); transform: rotate(-3deg) scale(1.04); } }

/* שגיאה */
#error { text-align: center; padding-top: 40px; }
.err-emoji { font-size: 90px; }
.err-text { font-size: 24px; font-weight: 600; }

/* אוסף */
.total {
  text-align: center; background: linear-gradient(135deg, var(--blue), var(--navy)); color: #fff;
  border-radius: var(--radius); padding: 18px; box-shadow: 0 6px 0 #142a52;
}
.total span { display: block; font-weight: 600; opacity: .9; }
.total strong { display: block; font-size: 46px; font-weight: 800; color: var(--yellow); }
.total small { opacity: .9; }
.tools { display: flex; gap: 8px; margin: 16px 0 10px; }
.tools input, .tools select {
  font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 16px; border: 2px solid #d5def0; background: #fff;
}
.tools input { flex: 1; min-width: 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 18px;
  padding: 10px; margin-bottom: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.list img { width: 62px; height: 86px; object-fit: cover; border-radius: 8px; background: #eef; flex: none; }
.list .info { flex: 1; min-width: 0; }
.list .nm { font-weight: 800; font-size: 19px; }
.list .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .pr { font-weight: 800; color: var(--green); margin-top: 2px; }
.list .pr.unk { color: var(--muted); font-weight: 600; }
.qty { background: var(--red); color: #fff; border-radius: 999px; padding: 2px 9px; font-size: 15px; margin-inline-start: 6px; }
.del { border: 0; background: #ffe9e5; color: var(--red); font-size: 22px; border-radius: 14px; width: 48px; height: 48px; flex: none; }
.empty { text-align: center; color: var(--muted); font-size: 20px; margin-top: 30px; }

/* ניווט */
.tabs {
  position: fixed; bottom: 0; inset-inline: 0; display: flex; background: #fff;
  border-top: 2px solid #e3e9f5; padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tab {
  flex: 1; border: 0; background: none; font: inherit; font-size: 28px; padding: 10px 0 8px;
  color: var(--muted); display: flex; flex-direction: column; align-items: center;
}
.tab span { font-size: 16px; font-weight: 600; }
.tab.on { color: var(--blue); }
.tab.on span { color: var(--navy); font-weight: 800; }

dialog { border: 0; border-radius: 20px; padding: 14px; max-width: 92vw; }
dialog img { max-width: 100%; max-height: 70vh; border-radius: 12px; display: block; }
dialog::backdrop { background: rgba(10, 20, 50, .6); }
.toast {
  position: fixed; bottom: calc(100px + env(safe-area-inset-bottom)); inset-inline: 20px; text-align: center;
  background: var(--navy); color: #fff; padding: 14px; border-radius: 16px; font-weight: 600; z-index: 9;
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 8; width: 100%; height: 100%; }

/* בחירת משחק (כפתורי מקטע) */
.seg { display: flex; gap: 6px; background: #e6efff; padding: 6px; border-radius: 22px; margin: 0 0 20px; }
.seg button {
  flex: 1; border: 0; background: transparent; font: inherit; font-size: 17px; font-weight: 600;
  padding: 12px 4px; border-radius: 16px; color: var(--blue); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--navy); font-weight: 800; box-shadow: 0 2px 6px rgba(20,40,90,.15); }
.seg.small { margin: 16px 0 0; }
.seg.small button { font-size: 16px; padding: 10px 4px; }
.game-tag { display: inline-block; margin-top: 14px; background: #e6efff; color: var(--navy); font-weight: 600;
  padding: 4px 14px; border-radius: 999px; font-size: 15px; }
.variant { background: #fff0fa; color: #a0217a; font-weight: 600; padding: 8px; border-radius: 14px; margin: 4px 0 0; }
.sub-totals { display: flex; gap: 8px; margin-top: 12px; }
.sub-totals div { flex: 1; background: rgba(255,255,255,.14); border-radius: 14px; padding: 8px 4px; }
.sub-totals span { font-size: 14px; }
.sub-totals b { display: block; font-size: 20px; color: #fff; }

/* כניסה */
.login-box { text-align: center; background: var(--card); border-radius: 28px; padding: 26px 18px;
  margin-top: 20px; box-shadow: 0 6px 0 #d7e1f3; }
.login-emoji { font-size: 70px; }
.login-box input { width: 100%; font: inherit; font-size: 26px; text-align: center; padding: 16px;
  border-radius: 18px; border: 3px solid #d5def0; margin: 6px 0 4px; direction: ltr; }
.login-box input:focus { outline: none; border-color: var(--blue); }
.login-body { padding-bottom: 20px; }
