:root {
  --ink: #111820;
  --ink-2: #27313c;
  --paper: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #edf1f4;
  --teal: #087f8c;
  --teal-light: #d9f0f1;
  --coral: #e6544f;
  --amber: #f2b134;
  --green: #2f9b65;
  --blue: #3478b8;
  --violet: #7357b2;
  --line: #d8dee4;
  --muted: #65717e;
  --shadow: 0 16px 40px rgba(17, 24, 32, 0.12);
  color-scheme: light;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); }
button, input, output { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.app-shell { min-height: 100vh; }
.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px max(20px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}
.brand, .topbar-tools, .player-identity, .section-heading, .question-kicker, .player-scorebar { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 6px; background: var(--ink); color: var(--amber); font-weight: 900; }
.brand h1 { margin: 0; font-size: 1.5rem; line-height: 1; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }
.topbar-tools { gap: 8px; }
.icon-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-weight: 900; }
.connection { padding: 7px 10px; border-radius: 999px; background: #fce8e7; color: #a33732; font-size: 0.78rem; font-weight: 800; }
.connection.is-online { background: #def2e7; color: #1d7348; }
.game-progress { position: fixed; z-index: 25; top: 71px; left: 0; width: 100%; height: 3px; background: var(--line); }
.game-progress span { display: block; height: 100%; background: var(--teal); transition: width 400ms ease; }

.stage { width: min(1440px, calc(100vw - 32px)); margin: 0 auto; padding: 32px 0 56px; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--teal); font-size: 0.78rem; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
.hero-title { max-width: 850px; margin: 0; font-size: 4.8rem; line-height: 0.98; letter-spacing: 0; }
.hero-copy { max-width: 700px; color: var(--muted); font-size: 1.18rem; line-height: 1.55; }
.section-heading { justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2, .section-heading h3 { margin: 0; }
.section-heading strong { font-size: 3.5rem; line-height: 1; }
.section-heading strong small { color: var(--muted); font-size: 1rem; }

.setup-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 30px; align-items: start; }
.setup-main { min-width: 0; }
.setup-main .section-heading { margin-top: 34px; }
.category-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.category-button { position: relative; min-height: 78px; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: right; font-weight: 850; transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease; }
.category-button:hover { transform: translateY(-2px); box-shadow: 0 9px 20px rgba(17, 24, 32, 0.09); }
.category-button.is-active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: var(--teal-light); }
.category-check { display: grid; width: 24px; height: 24px; margin-bottom: 12px; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.category-button.is-active .category-check { background: var(--teal); color: #fff; }
.control-panel, .join-board, .leader-panel, .question-panel, .join-panel, .report-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.setup-controls { position: sticky; top: 100px; display: grid; gap: 20px; padding: 24px; }
.setup-controls h3 { margin: 0; font-size: 1.55rem; }
.field-group { display: grid; gap: 9px; margin: 0; }
.field-label { font-weight: 850; }
.text-input { width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.custom-field { max-width: 620px; margin-top: 18px; }
.range-row { display: grid; grid-template-columns: 1fr 94px; gap: 12px; align-items: center; }
.range-row input { width: 100%; accent-color: var(--teal); }
.range-row output { padding: 9px; border-radius: 6px; background: var(--surface-2); text-align: center; font-weight: 900; }
.setup-summary { display: flex; flex-wrap: wrap; gap: 7px; }
.setup-summary span { padding: 7px 9px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 800; }

.primary-button, .ghost-button, .tool-button, .moderation-row button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 15px; border-radius: 6px; font-weight: 850; transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease; }
.primary-button { background: var(--ink); color: #fff; box-shadow: 0 8px 18px rgba(17, 24, 32, 0.2); }
.primary-button:hover, .ghost-button:hover, .tool-button:hover { transform: translateY(-1px); }
.ghost-button, .tool-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.danger-text { color: #bd3934; }
.full-button { width: 100%; }
.create-button { min-height: 54px; font-size: 1.05rem; }
.spinner { width: 18px; height: 18px; margin-left: 9px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 700ms linear infinite; }

.lobby-layout { position: relative; display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 26px; }
.join-board { position: sticky; top: 100px; align-self: start; padding: 22px; text-align: center; }
.qr-image { display: block; width: min(100%, 260px); aspect-ratio: 1; margin: 0 auto 14px; padding: 8px; background: #fff; }
.pin { font-size: 4.4rem; line-height: 1; font-weight: 950; letter-spacing: 5px; }
.join-url { margin: 8px 0 18px; direction: ltr; color: var(--muted); font-size: 0.82rem; }
.lobby-room { min-width: 0; }
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; }
.player-card { display: grid; gap: 7px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); animation: playerIn 350ms cubic-bezier(.2,.8,.2,1) both; }
.player-card.is-connected { border-top: 3px solid var(--green); }
.player-photo, .avatar-fallback { width: 100%; aspect-ratio: 1; border-radius: 5px; object-fit: cover; }
.avatar-fallback { display: grid; place-items: center; background: var(--teal-light); color: var(--teal); font-size: 2.8rem; font-weight: 950; }
.player-name, .score-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.player-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.76rem; }
.moderation-row { display: flex; gap: 4px; }
.moderation-row button { flex: 1; min-height: 28px; padding: 4px; border: 1px solid var(--line); background: var(--surface-2); font-size: 0.68rem; }
.reaction-layer { position: fixed; inset: 80px 0 0; z-index: 30; pointer-events: none; overflow: hidden; }
.reaction-bubble { position: absolute; left: var(--x); bottom: -80px; display: grid; min-width: 120px; padding: 11px 14px; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: var(--shadow); animation: reactionUp 5.5s ease-out forwards; }
.reaction-bubble span { color: #bac3cc; font-size: 0.72rem; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; }
.question-panel { display: grid; gap: 20px; min-height: 650px; padding: 26px; align-content: start; box-shadow: none; }
.question-panel.is-final, .player-question.is-final { border-color: var(--amber); box-shadow: inset 0 4px 0 var(--amber); }
.question-kicker { justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.82rem; font-weight: 850; }
.question-title, .player-question h2 { margin: 0; font-size: 3.3rem; line-height: 1.08; letter-spacing: 0; }
.timer { position: relative; height: 16px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.timer span { display: block; width: var(--progress, 100%); height: 100%; background: var(--green); transition: width 200ms linear, background 200ms ease; }
.timer span[style*="--progress:2"], .timer span[style*="--progress:1"], .timer span[style*="--progress:0"] { background: var(--coral); }
.timer b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font-size: 0.68rem; }
.timer.is-paused span { background: var(--amber); animation: timerPulse 1.2s ease-in-out infinite; }
.answers-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.answers-grid.two-answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.answer-tile, .answer-button { position: relative; display: flex; min-height: 120px; align-items: center; gap: 14px; padding: 20px; border-radius: 6px; color: #fff; font-size: 1.25rem; font-weight: 900; text-align: right; overflow-wrap: anywhere; transition: transform 140ms ease, filter 200ms ease, opacity 200ms ease; }
.answer-button:hover { transform: translateY(-3px); filter: brightness(1.05); }
.answer-button:nth-child(1), .answer-tile:nth-child(1) { background: var(--coral); }
.answer-button:nth-child(2), .answer-tile:nth-child(2) { background: var(--blue); }
.answer-button:nth-child(3), .answer-tile:nth-child(3) { background: var(--amber); color: var(--ink); }
.answer-button:nth-child(4), .answer-tile:nth-child(4) { background: var(--green); }
.answer-symbol { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 2px solid currentColor; border-radius: 4px; }
.answer-button.is-selected { outline: 5px solid var(--ink); outline-offset: 3px; transform: scale(0.98); }
.answer-tile.is-correct { box-shadow: inset 0 0 0 5px #fff, 0 0 0 3px var(--green); animation: correctPulse 650ms ease both; }
.answer-tile.is-wrong { filter: grayscale(0.75); opacity: 0.38; }
.ordering-input, .ordering-reveal { display: grid; gap: 10px; }
.ordering-input button, .ordering-reveal div { display: flex; min-height: 66px; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); text-align: right; font-weight: 850; }
.ordering-input button span, .ordering-reveal div span { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; background: var(--surface-2); }
.ordering-input button.is-ranked { border-color: var(--teal); background: var(--teal-light); }
.ordering-input button.is-ranked span { background: var(--teal); color: #fff; }
.explanation { margin: 0; padding: 14px 16px; border-right: 4px solid var(--teal); background: var(--teal-light); line-height: 1.5; }
.host-toolbar, .host-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.leader-panel { align-self: start; padding: 18px; box-shadow: none; }
.leaderboard, .mini-leaderboard { display: grid; gap: 7px; }
.score-row { display: grid; grid-template-columns: 24px 38px minmax(0,1fr) auto auto; gap: 8px; align-items: center; min-height: 52px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.score-row img, .score-avatar { width: 38px; height: 38px; border-radius: 4px; object-fit: cover; }
.score-avatar { display: grid; place-items: center; background: var(--teal-light); color: var(--teal); font-weight: 900; }
.rank { color: var(--muted); font-weight: 900; }
.streak-badge { padding: 3px 6px; border-radius: 4px; background: #fff0cc; color: #8b6000; font-size: 0.7rem; font-weight: 900; }

.join-panel { width: min(560px, 100%); margin: 4vh auto 0; padding: 28px; }
.join-panel h2 { margin: 0 0 22px; font-size: 2.4rem; }
.camera-box { position: relative; min-height: 230px; margin: 18px 0; overflow: hidden; border-radius: 6px; background: var(--ink); }
.camera-box video, .camera-box img { width: 100%; height: 100%; min-height: 230px; object-fit: cover; }
.camera-box span { position: absolute; right: 12px; bottom: 12px; padding: 6px 9px; border-radius: 4px; background: rgba(17,24,32,0.78); color: #fff; font-size: 0.75rem; }
.player-lobby, .player-wager, .player-question, .player-result, .wager-stage, .end-stage { width: min(920px, 100%); min-height: calc(100vh - 150px); margin: 0 auto; display: grid; align-content: center; gap: 20px; text-align: center; }
.player-identity { justify-content: center; gap: 16px; }
.player-identity .player-photo, .player-identity .avatar-fallback { width: 76px; height: 76px; }
.player-identity h2 { margin: 3px 0 0; font-size: 2.2rem; }
.waiting-wave { display: flex; height: 80px; align-items: center; justify-content: center; gap: 7px; }
.waiting-wave i { width: 7px; height: 24px; border-radius: 8px; background: var(--teal); animation: wave 1s ease-in-out infinite; }
.waiting-wave i:nth-child(2) { animation-delay: 100ms; }.waiting-wave i:nth-child(3) { animation-delay: 200ms; }.waiting-wave i:nth-child(4) { animation-delay: 300ms; }.waiting-wave i:nth-child(5) { animation-delay: 400ms; }
.reaction-picker { display: grid; gap: 10px; }
.reaction-picker div { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.reaction-picker button { min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-weight: 850; }
.player-scorebar { justify-content: space-between; gap: 12px; }
.player-question { text-align: right; align-content: start; padding-top: 20px; }
.player-question .question-type { color: var(--teal); font-size: 0.82rem; font-weight: 900; }
.locked-answer { padding: 18px; border: 1px solid var(--teal); border-radius: 6px; background: var(--teal-light); color: var(--teal); text-align: center; font-size: 1.2rem; font-weight: 900; animation: lockedIn 300ms ease both; }
.current-score, .final-player-score { font-size: 4rem; font-weight: 950; }
.current-score small, .final-player-score small { color: var(--muted); font-size: 1rem; }
.player-wager input[type="range"] { width: 100%; accent-color: var(--amber); }
.player-wager output { font-size: 3rem; font-weight: 950; }
.result-mark { display: grid; width: 92px; height: 92px; margin: 0 auto; place-items: center; border-radius: 50%; background: var(--green); color: #fff; font-size: 4rem; font-weight: 950; animation: resultPop 500ms cubic-bezier(.15,.8,.2,1.3) both; }
.player-result.is-failure .result-mark { background: var(--coral); }
.player-result h2 { margin: 0; font-size: 3.5rem; }
.points-earned { font-size: 2.5rem; font-weight: 950; }
.correct-answer { padding: 15px; border-radius: 6px; background: var(--surface-2); font-weight: 850; }

.wager-stage h2, .end-stage > h2 { margin: 0; font-size: 4.8rem; }
.wager-count { display: grid; }
.wager-count strong { font-size: 6rem; line-height: 1; }
.wager-count span { color: var(--muted); }
.wager-players { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.wager-players span { padding: 8px 11px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.wager-players span.is-ready { background: #def2e7; color: #1d7348; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); align-items: end; justify-content: center; gap: 14px; margin: 20px 0 36px; }
.podium-card { position: relative; display: grid; gap: 8px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); animation: podiumRise 700ms cubic-bezier(.2,.8,.2,1) both; }
.podium-card.place-1 { min-height: 320px; border-top: 7px solid var(--amber); }.podium-card.place-2 { min-height: 270px; border-top: 7px solid #9ba7b2; }.podium-card.place-3 { min-height: 230px; border-top: 7px solid #bd7b4a; }
.podium-card .player-photo, .podium-card .avatar-fallback { width: 110px; height: 110px; margin: 0 auto; }
.podium-card h3 { margin: 0; }.podium-card strong { font-size: 1.8rem; }
.podium-place { position: absolute; top: -20px; left: 50%; display: grid; width: 42px; height: 42px; place-items: center; transform: translateX(-50%); border-radius: 50%; background: var(--ink); color: #fff; font-weight: 950; }
.report-panel { padding: 20px; text-align: right; box-shadow: none; }
.report-table { min-width: 700px; }.report-panel { overflow-x: auto; }
.report-row { display: grid; grid-template-columns: 40px minmax(320px,1fr) 90px 110px; gap: 12px; align-items: center; padding: 11px 8px; border-bottom: 1px solid var(--line); }
.report-row > span:nth-child(2) { display: grid; gap: 4px; }.report-row small { color: var(--muted); }
.report-head { color: var(--muted); font-size: 0.75rem; font-weight: 900; }
.confetti { position: fixed; inset: 72px 0 0; z-index: -1; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; left: calc(var(--i) * 2.7%); width: 8px; height: 16px; background: var(--coral); animation: confettiFall 3.2s linear infinite; animation-delay: calc(var(--i) * -0.11s); }
.confetti i:nth-child(3n) { background: var(--teal); }.confetti i:nth-child(3n+1) { background: var(--amber); }

.accessibility-panel { position: fixed; z-index: 50; top: 64px; left: 20px; width: 260px; padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.accessibility-panel[hidden] { display: none; }
.toggle-row { display: flex; justify-content: space-between; gap: 14px; padding-top: 14px; font-weight: 750; }
.toggle-row input { width: 42px; accent-color: var(--teal); }
.empty-state { display: grid; min-height: 280px; place-items: center; border: 2px dashed var(--line); border-radius: 8px; color: var(--muted); font-weight: 850; }
.pulse-border { animation: borderPulse 2s ease-in-out infinite; }
.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: 420px; padding: 13px 16px; border-radius: 6px; background: var(--ink); color: #fff; box-shadow: var(--shadow); animation: toastIn 250ms ease both; }
.entrance { animation: entrance 350ms ease both; }

.large-text { font-size: 19px; }
.high-contrast { --paper: #fff; --surface: #fff; --surface-2: #edf0f2; --ink: #000; --muted: #303030; --line: #4d4d4d; --teal: #00626b; --coral: #b8221d; --blue: #005a9c; --green: #08783f; }

@keyframes entrance { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes playerIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes reactionUp { 0% { opacity: 0; transform: translateY(0) scale(.85); } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-75vh) scale(1.08); } }
@keyframes wave { 0%,100% { height: 22px; } 50% { height: 62px; } }
@keyframes correctPulse { 50% { transform: scale(1.025); } }
@keyframes timerPulse { 50% { opacity: .55; } }
@keyframes lockedIn { from { opacity: 0; transform: scale(.96); } }
@keyframes resultPop { from { opacity: 0; transform: scale(.3) rotate(-12deg); } }
@keyframes podiumRise { from { opacity: 0; transform: translateY(80px); } }
@keyframes confettiFall { to { transform: translateY(110vh) rotate(620deg); } }
@keyframes borderPulse { 50% { border-color: var(--teal); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

@media (max-width: 1050px) {
  .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-layout { grid-template-columns: 1fr; }
  .leader-panel { order: 2; }
}

@media (max-width: 800px) {
  .stage { width: min(100% - 24px, 720px); padding-top: 20px; }
  .topbar { min-height: 64px; padding: 10px 12px; }.game-progress { top: 63px; }
  .brand p, .connection { display: none; }
  .brand h1 { font-size: 1.15rem; }.brand-mark { width: 38px; height: 38px; }
  .setup-layout, .lobby-layout { grid-template-columns: 1fr; }
  .setup-controls, .join-board { position: static; }
  .hero-title { font-size: 3.1rem; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .question-panel { min-height: 0; padding: 16px; }.question-title, .player-question h2 { font-size: 2.1rem; }
  .answers-grid, .answers-grid.two-answers { grid-template-columns: 1fr; }
  .answer-button, .answer-tile { min-height: 78px; padding: 14px; font-size: 1rem; }
  .question-kicker { display: grid; grid-template-columns: 1fr auto; }.question-kicker span:nth-child(2) { display: none; }
  .player-question { min-height: calc(100vh - 105px); padding-top: 4px; }
  .player-scorebar { font-size: .82rem; }
  .podium { grid-template-columns: 1fr; align-items: stretch; }.podium-card { min-height: 0 !important; }
  .wager-stage h2, .end-stage > h2 { font-size: 3rem; }
  .accessibility-panel { top: 58px; left: 10px; width: min(280px, calc(100vw - 20px)); }
}

@media (max-width: 420px) {
  .category-grid { grid-template-columns: 1fr 1fr; }.category-button { min-height: 70px; padding: 11px; font-size: .86rem; }
  .hero-title { font-size: 2.55rem; }.join-panel { padding: 18px; }
  .host-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
}

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