:root {
  --bg: #16121c;
  --surface: #221c2b;
  --surface-2: #2d2638;
  --line: #3b3348;
  --text: #f4eef8;
  --muted: #a99db8;
  --accent: #ff7a59;      /* שקיעה בחוף */
  --accent-2: #ffb547;
  --ok: #3ecf8e;
  --bad: #ef5a6f;
  --near: #f2c94c;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  isolation: isolate;
  font-family: 'Rubik', system-ui, sans-serif;
  display: flex; flex-direction: column; align-items: center;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }

/* ---------- כותרת ---------- */
.top {
  width: 100%; max-width: 520px; padding: 14px 16px 8px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { text-align: center; }
.brand h1 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: -.5px; line-height: 1; }
.brand .q { color: var(--accent); }
.brand .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; display: grid; place-items: center; font-weight: 700;
}
.icon-btn:hover { background: var(--surface); }

/* ---------- ניחושים ---------- */
main { width: 100%; max-width: 520px; padding: 16px; }
.guesses { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.guesses li {
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  font-size: 15px; background: rgba(255,255,255,.015);
}
.guesses li.current { border-color: var(--muted); }
.guesses li .mark { width: 18px; text-align: center; flex: none; }
.guesses li.wrong { border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.guesses li.wrong .mark { color: var(--bad); }
.guesses li.near { border-color: color-mix(in srgb, var(--near) 60%, transparent); }
.guesses li.near .mark { color: var(--near); }
.guesses li.skip { color: var(--muted); }
.guesses li.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.guesses li.right .mark { color: var(--ok); }
.guesses .artist { color: var(--muted); font-size: 13px; }

/* ---------- סוף משחק ---------- */
.end {
  margin-top: 18px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center;
}
.end .cover { width: 84px; height: 84px; border-radius: 8px; object-fit: cover; }
.end-title { font-size: 20px; font-weight: 700; }
.end-artist { color: var(--muted); margin-top: 2px; }
.links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.links:empty { display: none; }
.links a {
  flex: 1 1 0; min-width: 96px; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 12px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 500;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
}
.links a:hover { border-color: var(--muted); }
.links a svg { width: 18px; height: 18px; flex: none; }
.links .yt svg { color: #ff4e45; } .links .sn svg { color: var(--accent-2); } .links .wiki svg { color: var(--text); }
.links .dz { flex: 0 0 auto; min-width: 0; color: var(--muted); font-size: 12px; background: transparent; border-color: transparent; }
.end-msg { grid-column: 1 / -1; margin: 0; font-size: 15px; }
.end .btn { grid-column: 1 / -1; }
.next { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 14px; }
#countdown { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }

/* ---------- נגן ---------- */
.player {
  width: 100%; max-width: 520px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  /* בלי רקע משלו, כדי שהרקע של הדף ימשיך מאחור בלי "מלבן" */
}
.bar {
  position: relative; height: 12px; border-radius: 6px; overflow: hidden;
  background: var(--surface-2);
}
.bar-unlocked, .bar-progress { position: absolute; top: 0; bottom: 0; right: 0; width: 0; }
.bar-unlocked { background: #4a3f5a; transition: width .35s ease; }
.bar-progress { background: linear-gradient(to left, var(--accent), var(--accent-2)); }
.ticks { position: absolute; inset: 0; }
.ticks i { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bg); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.controls { display: flex; justify-content: center; margin: 4px 0 12px; }
.play {
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--accent); color: #1a0f12; display: grid; place-items: center;
  box-shadow: 0 6px 24px -6px var(--accent);
  transition: transform .1s;
}
.play:not(:disabled):active { transform: scale(.94); }
.play svg { width: 28px; height: 28px; }
.play .i-pause { display: none; }
.play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }
/* במצב RTL החץ של play צריך להצביע ימינה=קדימה לפי מוסכמת נגנים; משאירים כרגיל */

.search { position: relative; }
#input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; outline: none;
}
#input:focus { border-color: var(--accent); }
.suggest {
  position: absolute; bottom: calc(100% + 6px); right: 0; left: 0;
  margin: 0; padding: 4px; list-style: none; max-height: 260px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 -10px 30px rgba(0,0,0,.4); z-index: 5;
}
.suggest li { padding: 10px 10px; border-radius: 7px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: #3b3149; }
.suggest .artist { color: var(--muted); font-size: 13px; margin-inline-start: 6px; }
.suggest .empty { color: var(--muted); cursor: default; }

.actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }
.btn {
  height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 500;
  border: 1px solid var(--line); background: transparent;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0f12; font-weight: 700; }
.btn.ghost:hover { background: var(--surface); }
.actions .btn { white-space: nowrap; padding: 0 14px; }
.actions .hint-btn { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; color: var(--near); border-color: color-mix(in srgb, var(--near) 40%, var(--line)); }
.hint-chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0 auto 12px; width: fit-content; padding: 6px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--near) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--near) 45%, transparent);
  color: var(--near); font-size: 14px;
}
.hint-chip b { color: var(--text); font-weight: 700; }
.status { min-height: 20px; text-align: center; color: var(--muted); font-size: 14px; margin-top: 8px; }

/* ---------- דיאלוגים ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  color: var(--text); width: min(92vw, 400px); padding: 22px;
}
dialog::backdrop { background: rgba(10, 6, 14, .7); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
dialog p { line-height: 1.55; margin: 0 0 10px; }
dialog .small { color: var(--muted); font-size: 13px; }
dialog form { margin-top: 14px; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 6px; margin-bottom: 16px; }
.stats b { display: block; font-size: 26px; font-weight: 700; }
.stats span { font-size: 12px; color: var(--muted); }
.dist { display: grid; gap: 4px; }
.dist .row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist .lbl { width: 14px; text-align: center; color: var(--muted); }
.dist .fill { background: var(--surface-2); padding: 2px 8px; border-radius: 4px; min-width: 24px; text-align: left; }
.dist .fill.hl { background: var(--accent); color: #1a0f12; font-weight: 700; }

.toast {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-weight: 500; z-index: 50; animation: fade 2s forwards;
}
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- חגיגת ניצחון ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
.win-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px;
  background: rgba(10, 6, 14, .55); animation: fadein .25s ease;
}
@keyframes fadein { from { opacity: 0; } }
.win {
  width: min(92vw, 400px); text-align: center; padding: 26px 22px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
.win .btn { margin-top: 16px; min-width: 140px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-badge { font-size: 44px; line-height: 1; margin-bottom: 6px; animation: wiggle 1s ease-in-out .3s 2; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
.win h2 { font-size: 28px; font-weight: 900; margin: 0 0 4px; color: var(--accent); }
.win-song { color: var(--muted); font-size: 15px; margin-bottom: 4px; }
.win-song b { color: var(--text); }
.trivia {
  margin-top: 16px; padding: 14px 16px; border-radius: 12px; text-align: right;
  background: color-mix(in srgb, var(--near) 9%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--near) 35%, transparent);
}
.trivia-head { color: var(--near); font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.trivia-text { margin: 0; line-height: 1.65; min-height: 3.3em; font-size: 16px; }
.trivia-text .untyped { color: transparent; }
.trivia-text.typing .typed::after {
  content: ''; display: inline-block; width: 2px; height: 1.1em; margin-inline-start: 2px;
  background: var(--near); vertical-align: text-bottom; animation: caret .8s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .win, .win-badge, .win-overlay { animation: none; }
}

/* ---------- רקע ---------- */
/* דרך האמצע: הזוהר הסגול מהגרסה הראשונה למעלה, ועוד שני כתמי צבע עדינים. הכל קבוע, בלי תנועה.
   העוצמה של הכתמים נקבעת ב---bg-glow (0% = בלי כתמים). */
:root { --bg-glow: 9%; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 500px at 50% -200px, #3a2140 0%, transparent 70%),
    radial-gradient(50% 40% at 0% 35%, color-mix(in srgb, var(--accent) var(--bg-glow), transparent), transparent 70%),
    radial-gradient(50% 40% at 100% 75%, color-mix(in srgb, #7a5cff var(--bg-glow), transparent), transparent 70%);
}

/* כפתור הנגינה "נושם" כשהוא מחכה ללחיצה */
.play:not(.playing):not(:disabled) { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 6px 24px -6px var(--accent), 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  50% { box-shadow: 0 6px 24px -6px var(--accent), 0 0 0 12px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* ---------- VIP ---------- */
.vip-badge {
  display: inline-block; vertical-align: super; margin-inline-start: 6px;
  font-size: 11px; font-weight: 900; letter-spacing: 1px; padding: 2px 6px; border-radius: 6px;
  color: #1a0f12; background: linear-gradient(135deg, #ffd86b, #ffb547 50%, #ff9a3c);
  box-shadow: 0 0 14px -2px #ffb547;
}
.vip-chip {
  display: flex; justify-content: center; margin: 0 auto 12px; width: fit-content;
  padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
  color: #ffd86b; background: color-mix(in srgb, #ffb547 12%, transparent);
  border: 1px solid color-mix(in srgb, #ffb547 45%, transparent);
}
.end .vip-next {
  grid-column: 1 / -1; border: none; color: #1a0f12; font-weight: 700;
  background: linear-gradient(135deg, #ffd86b, #ffb547 50%, #ff9a3c);
  box-shadow: 0 6px 22px -8px #ffb547;
}
.end .vip-back { grid-column: 1 / -1; }
body.vip-mode .guesses li.current { border-color: #ffb547; }

/* ---------- קרדיטים ---------- */
.credits { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--muted); opacity: .8; }

.links .genius svg { color: #ffff64; }

@media (prefers-reduced-motion: reduce) {
  .play:not(.playing):not(:disabled) { animation: none !important; }
}
