:root {
  --betar-purple: #5915ca;
  --betar-purple-dark: #3d0a8f;
  --betar-yellow: #fef416;
  --bg: #f7f8fa;
  --text: #111827;
  --muted: #6b7280;
  --blue: #5915ca;
  --blue-dark: #3d0a8f;
  --gold: #d6a632;
  --green: #15803d;
  --red: #b91c1c;
  --white: #ffffff;
  --border: #e5e7eb;
  --font-display: "Waffle Soft", "Outfit", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face {
  font-family: "Waffle Soft";
  src: url("../fonts/waffle-soft.otf") format("opentype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Outfit";
  src: url("../fonts/outfit-700.woff2") format("woff2");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-600.woff2") format("woff2");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

body.is-shaking {
  animation: screen-shake 0.42s cubic-bezier(.36,.07,.19,.97) both;
}

body.scanner-open {
  overflow: hidden;
}

a {
  color: inherit;
}

.screen {
  min-height: 100dvh;
  max-height: 100dvh;
  width: 100vw;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.screen.scroll {
  max-height: none;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--blue-dark);
  font-family: var(--font-display);
}

.brand-mark {
  width: 54px;
  height: 44px;
  border-radius: 14px;
  background: var(--betar-purple);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  flex: 0 0 auto;
}

.brand-logo {
  width: 100%;
  height: auto;
  max-height: 30px;
  display: block;
  object-fit: contain;
}

.brand-text {
  display: grid;
  gap: 1px;
}

.brand-text strong {
  color: var(--betar-purple-dark);
  font-size: 15px;
  line-height: 1;
}

.brand-text span {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.1;
}

h3 {
  font-family: var(--font-display);
  font-size: 18px;
}

p {
  font-size: 16px;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.big-tile {
  flex: 1;
  border-radius: 24px;
  background: var(--white);
  padding: 22px;
  display: flex;
  justify-content: center;
  text-align: center;
  border: 1px solid var(--border);
  overflow: hidden;
}

.mission-tile {
  align-items: stretch;
  text-align: left;
}

.clue-tile {
  padding: 16px;
}

.clue-tile .stack {
  width: 100%;
  gap: 10px;
}

.clue-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-height: 0;
}

.clue-card {
  position: relative;
  min-height: 132px;
  border-radius: 16px;
  border: 1px solid #ded7ff;
  background: var(--text);
  padding: 0;
  display: block;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.04);
  cursor: pointer;
}

.clue-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.58), rgba(17, 24, 39, 0.08) 42%, rgba(17, 24, 39, 0.7));
  pointer-events: none;
}

.clue-image {
  width: 100%;
  height: 100%;
  min-height: 132px;
  display: block;
  object-fit: cover;
  filter: saturate(1.04) contrast(1.03);
}

.clue-card-head {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  right: 8px;
  gap: 6px;
  justify-content: flex-end;
}

.clue-card.is-start {
  border-color: var(--betar-purple);
  background: #fbf9ff;
  box-shadow: inset 0 0 0 2px rgba(89, 21, 202, 0.08);
}

.clue-card.is-done {
  opacity: 0.56;
}

.clue-card.is-revealed {
  opacity: 1;
}

.clue-help-button {
  min-width: 58px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: var(--betar-yellow);
  color: var(--betar-purple-dark);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 8px 9px;
  text-align: center;
  position: relative;
  z-index: 3;
}

.clue-help-button:disabled {
  opacity: 0.42;
}

.clue-prompt {
  position: absolute;
  z-index: 2;
  left: 10px;
  right: 10px;
  bottom: 10px;
  color: var(--white);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
  transition: opacity 0.18s ease;
}

.clue-text {
  position: absolute;
  z-index: 2;
  inset: 0;
  padding: 48px 10px 10px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(180deg, rgba(61, 10, 143, 0.72), rgba(17, 24, 39, 0.86));
  color: var(--white);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.clue-text p {
  font-size: 12.5px;
  line-height: 1.18;
  font-weight: 850;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.clue-card.is-revealed .clue-text {
  opacity: 1;
  transform: translateY(0);
}

.clue-card.is-revealed .clue-prompt {
  opacity: 0;
}

.counter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.counter-item {
  min-height: 86px;
  border-radius: 18px;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.counter-item strong {
  font-size: 28px;
  line-height: 1;
}

.shekel {
  color: var(--gold);
}

.main-action,
.secondary-action,
.danger-action,
.answer-button,
.link-button {
  font-family: var(--font-display);
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: 20px;
  color: var(--white);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 16px;
}

.with-icon {
  gap: 12px;
}

.button-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.icon-qr {
  background: currentColor;
  -webkit-mask: url("../icons/qr-code.svg") center / contain no-repeat;
  mask: url("../icons/qr-code.svg") center / contain no-repeat;
}

.main-action {
  background: var(--blue);
  color: var(--betar-yellow);
}

.secondary-action {
  background: var(--text);
}

.danger-action {
  background: var(--red);
}

.small-link {
  min-height: 48px;
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-display);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field,
select,
textarea {
  width: 100%;
  min-height: 62px;
  border: 2px solid var(--border);
  border-radius: 18px;
  background: var(--white);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  padding: 14px 16px;
}

textarea {
  min-height: 84px;
  resize: none;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-tabs label {
  min-height: 58px;
  border-radius: 18px;
  background: var(--white);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.mode-tabs input {
  display: none;
}

.mode-tabs input:checked + span {
  color: var(--blue);
}

.mode-tabs label:has(input:checked) {
  border-color: var(--blue);
}

.message {
  min-height: 56px;
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--border);
  transform-origin: center;
}

.message.error {
  color: var(--red);
  border-color: #fecaca;
  animation: message-pop 0.28s ease-out;
}

.message.error::before {
  content: "×";
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
}

.message.success {
  color: var(--green);
  border-color: #bbf7d0;
  animation: message-success 0.44s ease-out;
}

.message.success::before {
  content: "✓";
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--green);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1;
}

.scanner-box {
  flex: 1;
  min-height: 0;
  border-radius: 24px;
  overflow: hidden;
  background: #000;
  border: 0;
}

#reader,
#inline-reader,
#inline-reader video,
#reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(17, 24, 39, 0.82);
  padding: 14px;
}

.scanner-panel {
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: var(--bg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.scanner-topbar h1 {
  font-size: 26px;
}

.inline-scanner-box {
  min-height: 0;
}

.quiz-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  flex: 1;
}

.progress {
  height: 10px;
  border-radius: 99px;
  background: #dbeafe;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
}

.question-card {
  flex: 1;
  min-height: 0;
  border-radius: 24px;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-title {
  font-size: 22px;
  line-height: 1.14;
  font-weight: 850;
}

.answers {
  display: grid;
  gap: 10px;
  flex: 1;
}

.answer-button {
  min-height: 62px;
  border-radius: 18px;
  background: var(--white);
  color: var(--text);
  border: 2px solid var(--border);
  font-size: 17px;
  line-height: 1.15;
  justify-content: flex-start;
}

.answer-button.selected {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue-dark);
}

.admin-page {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  min-height: 100dvh;
  padding: 18px;
}

.admin-grid {
  display: grid;
  gap: 14px;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.panel {
  border-radius: 18px;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 16px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.qr-download-grid {
  display: grid;
  gap: 10px;
}

.qr-download-card {
  grid-template-columns: 1fr;
}

.qr-download-card .muted {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  letter-spacing: 0;
}

.qr-download-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.qr-download-actions .small-link {
  justify-content: center;
  font-family: var(--font-display);
  color: var(--betar-purple-dark);
  font-weight: 900;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #eff6ff;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 13px;
}

.brand-footer {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: auto;
  text-align: center;
}

.action-stack {
  display: grid;
  gap: 10px;
}

.help-action {
  min-height: 58px;
  border-radius: 18px;
  background: var(--white);
  color: var(--betar-purple-dark);
  border: 2px solid #ded7ff;
  font-size: 17px;
}

.score-grid {
  display: grid;
  gap: 10px;
}

.score-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border-radius: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 14px;
}

.score-rank {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--betar-purple);
  color: var(--betar-yellow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 900;
}

.score-total {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  color: var(--betar-purple-dark);
}

.result-card.success-state {
  position: relative;
  overflow: hidden;
  animation: result-rise 0.52s ease-out both;
}

.result-card.success-state::after {
  content: "";
  position: absolute;
  inset: auto -20% -42% -20%;
  height: 70%;
  background: radial-gradient(circle at 50% 0%, rgba(254, 244, 22, 0.38), transparent 58%);
  pointer-events: none;
}

.feedback-cross {
  position: fixed;
  z-index: 1000;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 58px;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 18px 42px rgba(185, 28, 28, 0.28);
  animation: cross-burst 0.72s ease-out forwards;
}

.firework-layer {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  overflow: hidden;
}

.firework-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4px 0 0 -4px;
  border-radius: 999px;
  box-shadow: 0 0 14px currentColor;
  animation: spark-pop 0.9s cubic-bezier(.15,.72,.22,1) forwards;
}

@keyframes screen-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-8px, 0, 0) rotate(-0.4deg); }
  30% { transform: translate3d(7px, 0, 0) rotate(0.35deg); }
  45% { transform: translate3d(-5px, 0, 0) rotate(-0.25deg); }
  60% { transform: translate3d(4px, 0, 0) rotate(0.18deg); }
  75% { transform: translate3d(-2px, 0, 0); }
}

@keyframes message-pop {
  0% { transform: scale(0.96); }
  65% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

@keyframes message-success {
  0% { transform: translateY(8px) scale(0.97); }
  65% { transform: translateY(-2px) scale(1.018); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes result-rise {
  0% { transform: translateY(14px) scale(0.985); opacity: 0.4; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes cross-burst {
  0% { transform: scale(0.5) rotate(-14deg); opacity: 0; }
  35% { transform: scale(1.12) rotate(5deg); opacity: 1; }
  100% { transform: scale(0.86) rotate(0); opacity: 0; }
}

@keyframes spark-pop {
  0% {
    transform: translate3d(0, 0, 0) scale(0.8);
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--x), var(--y), 0) scale(0.15);
    opacity: 0;
  }
}

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

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.inline-form {
  display: grid;
  gap: 10px;
}

button:disabled,
.main-action:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

@media (min-width: 760px) {
  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .admin-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .admin-grid .wide {
    grid-column: 1 / -1;
  }
}
