/* לוח שעם בחדר ההפסקה של המוקד: חידה מוצמדת בנעץ, פתקים של מי שענה, חותמת כשהזמן נגמר. */
:root {
  --cork: #b9895a;
  --cork-deep: #94663a;
  --cork-light: #d2a876;
  --paper: #fdfaf2;
  --paper-edge: #e9e1cc;
  --rule: #c6dbee;
  --margin: #efa9a9;
  --ink: #1d3a8f;          /* עט כחול */
  --text: #2c241d;
  --muted: #6f6253;
  --red: #c8102e;          /* חותמת + כפתור, הצבע הבולט היחיד */
  --red-deep: #8d0a1f;
  --tape: rgba(244, 236, 205, .82);
  --n1: #ffe45c; --n2: #ff9fc2; --n3: #8fe3bf; --n4: #a3d2ff; --n5: #ffc078;
  --gold: #f2c230; --silver: #cfd6dc; --bronze: #d99358;

  --f-display: "Suez One", "Arial Hebrew", serif;
  --f-hand: "Karantina", "Arial Narrow", sans-serif;
  --f-body: "Varela Round", "Arial Hebrew", Arial, sans-serif;

  --shadow-paper: 0 1px 0 rgba(255,255,255,.4) inset, 0 14px 22px -14px rgba(52, 28, 6, .75), 0 2px 3px rgba(52, 28, 6, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--cork);
  /* מרקם שעם: רעש אקראי (feTurbulence) במקום רשת נקודות, כדי שלא ייראה כמו טפט */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .2 0 0 0 0 .08 0 0 0 1.6 -.55'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='310' height='310'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.35' numOctaves='3' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .8 0 0 0 0 .6 0 0 0 1.4 -.72'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.14), transparent 65%);
  background-size: 260px 260px, 310px 310px, 100% 100%;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(env(safe-area-inset-top, 0px) + 20px) calc(env(safe-area-inset-bottom, 0px) + 48px);
}

.wrap { max-width: 680px; margin-inline: auto; display: grid; gap: 34px; }
.wrap.wide { max-width: 960px; }

/* ---------- header: פס מסקינטייפ ---------- */
.board-title {
  justify-self: center;
  position: relative;
  margin: 8px 0 0;
  padding: 8px 26px 6px;
  background: var(--tape);
  font: 400 clamp(1.9rem, 7vw, 2.6rem)/1.1 var(--f-display);
  color: var(--text);
  transform: rotate(-1.6deg);
  box-shadow: 0 3px 6px -3px rgba(52, 28, 6, .45);
  clip-path: polygon(1% 4%, 4% 0, 8% 5%, 13% 0, 19% 4%, 100% 0, 98% 30%, 100% 62%, 97% 100%, 91% 95%, 85% 100%, 0 100%, 2% 66%, 0 35%);
}
.board-title small { display: block; font: 400 .95rem/1.4 var(--f-body); color: var(--muted); text-align: center; }

/* ---------- נייר עם נעץ ---------- */
.card {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(to left, transparent 42px, var(--margin) 42px 44px, transparent 44px),
    repeating-linear-gradient(to bottom, transparent 0 33px, var(--rule) 33px 34px);
  background-position: 0 18px;
  padding: 40px 62px 30px 26px;
  box-shadow: var(--shadow-paper);
  border-radius: 2px;
}
.card.tilt-r { transform: rotate(.7deg); }
.card.tilt-l { transform: rotate(-.6deg); }
.card.plain { background-image: none; padding: 34px 26px 26px; }
.pin {
  position: absolute; top: 10px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a8a 0 18%, var(--red) 45%, var(--red-deep) 100%);
  box-shadow: 0 4px 4px -1px rgba(40, 10, 0, .45);
}
.pin.blue { background: radial-gradient(circle at 35% 30%, #a9c2ff 0 18%, #2d55c9 45%, #1a2f78 100%); }
.pin.green { background: radial-gradient(circle at 35% 30%, #b7f0c9 0 18%, #2a9a58 45%, #155a33 100%); }

h1, h2, h3 { font-family: var(--f-display); font-weight: 400; line-height: 1.25; margin: 0; text-wrap: balance; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.ink { color: var(--ink); }

/* ---------- ספירה לאחור ---------- */
.opens-at { font: 400 clamp(1.5rem, 5.5vw, 2rem)/1.3 var(--f-display); color: var(--text); }
.opens-at b { color: var(--ink); font-weight: 400; }
.countdown { display: flex; gap: clamp(10px, 4vw, 28px); align-items: flex-start; direction: ltr; justify-content: center; margin-top: 18px; }
.countdown .unit { display: grid; justify-items: center; }
.countdown .num { font: 700 clamp(4.2rem, 20vw, 7.6rem)/.9 var(--f-hand); color: var(--ink); font-variant-numeric: tabular-nums; }
.countdown .lbl { font-size: .85rem; color: var(--muted); direction: rtl; }
.countdown .sep { font: 700 clamp(3rem, 14vw, 5.5rem)/.9 var(--f-hand); color: var(--ink); opacity: .45; }

/* ---------- חידה ---------- */
.question { font: 400 clamp(1.45rem, 5vw, 1.9rem)/1.55 var(--f-display); white-space: pre-wrap; overflow-wrap: anywhere; }
.question-img { display: block; margin-top: 16px; max-width: 100%; max-height: 60vh; border: 8px solid #fff; box-shadow: 0 8px 14px -8px rgba(40,20,0,.6); transform: rotate(-1deg); }
.timer-strip { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.timer-strip .left { font: 700 2.6rem/1 var(--f-hand); color: var(--red); font-variant-numeric: tabular-nums; direction: ltr; }
.timer-strip .left.calm { color: var(--ink); }

/* ---------- טופס: כמו למלא בעט ---------- */
form { display: grid; gap: 22px; margin-top: 26px; }
.field { display: grid; gap: 4px; }
.field label { font-size: .95rem; color: var(--muted); }
.field input, .field textarea, .field select {
  font: 400 1.35rem/1.4 var(--f-body);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px solid #9fb6cf;
  padding: 6px 2px;
  border-radius: 0;
  width: 100%;
  min-width: 0;
}
.field textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: #7a6d5e; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-bottom-color: var(--ink); background: rgba(29, 58, 143, .05); }
.hint { font-size: .85rem; color: var(--muted); }

.btn {
  --b: var(--red); --bd: var(--red-deep);
  appearance: none; border: 0; cursor: pointer;
  font: 400 1.25rem/1 var(--f-display);
  color: #fff; background: var(--b);
  padding: 15px 26px 13px; border-radius: 6px;
  box-shadow: 0 5px 0 var(--bd), 0 10px 14px -6px rgba(60, 10, 0, .5);
  transition: transform .08s ease, box-shadow .08s ease;
  justify-self: start; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--bd), 0 4px 8px -4px rgba(60, 10, 0, .5); }
.btn:disabled { filter: grayscale(.6) opacity(.7); cursor: wait; }
.btn.ghost { --b: transparent; --bd: transparent; color: var(--ink); box-shadow: none; text-decoration: underline; text-underline-offset: 4px; padding: 8px 4px; font-family: var(--f-body); font-size: 1rem; }
.btn.small { font-size: 1rem; padding: 9px 14px 8px; box-shadow: 0 3px 0 var(--bd); }
.btn.blue { --b: #2d55c9; --bd: #1a2f78; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.btn:focus-visible { outline-color: var(--text); }

.error { color: var(--red); font-weight: 700; }

/* ---------- חותמת ---------- */
.stamp {
  display: inline-block;
  font: 400 1.5rem/1.1 var(--f-display);
  color: var(--red);
  border: 4px double var(--red);
  border-radius: 8px;
  padding: 8px 16px 6px;
  transform: rotate(-6deg);
  mix-blend-mode: multiply;
  opacity: .9;
  letter-spacing: .02em;
}
.stamp.ink-stamp { color: var(--ink); border-color: var(--ink); }
.stamp.corner { position: absolute; top: 18px; left: 18px; font-size: 1.2rem; }
.stamp-in { animation: stamp .38s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes stamp { from { transform: rotate(-14deg) scale(2.1); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: .9; } }

/* ---------- פתקים ---------- */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* כל טקסט שיושב על השעם נכתב על פס מסקינטייפ: טקסט בהיר על שעם לא עובר ניגודיות */
.tape-label, .board-head h2, .empty-note, details.prev > summary {
  display: inline-block; background: var(--tape); color: var(--text); padding: 6px 16px 4px;
  box-shadow: 0 3px 6px -3px rgba(52, 28, 6, .45); transform: rotate(-1deg);
}
.board-head h2 { font-size: 1.35rem; }
.count-badge { font: 700 1.6rem/1 var(--f-hand); background: var(--paper); color: var(--ink); padding: 6px 12px 4px; border-radius: 50px; text-shadow: none; box-shadow: var(--shadow-paper); }
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 18px 14px; margin-top: 14px; padding: 0; list-style: none; }
.note {
  position: relative;
  background: var(--c, var(--n1));
  padding: 20px 12px 12px;
  min-height: 104px;
  transform: rotate(var(--r, -1deg));
  box-shadow: 0 10px 12px -8px rgba(52, 28, 6, .7);
  display: grid; align-content: center; gap: 2px;
}
.note::before { content: ""; position: absolute; top: -9px; left: 50%; width: 58px; height: 20px; margin-left: -29px; background: var(--tape); transform: rotate(calc(var(--r, 0deg) * -2)); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.note .who { font: 700 1.9rem/1 var(--f-hand); color: #2a1f14; overflow-wrap: anywhere; }
.note .did { font-size: .85rem; color: #4a3d2e; }
.note.me { outline: 3px dashed rgba(29, 58, 143, .6); outline-offset: 3px; }
.note.fresh { animation: drop .45s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes drop { from { transform: translateY(-30px) rotate(calc(var(--r, 0deg) + 10deg)); opacity: 0; } to { transform: rotate(var(--r, -1deg)); opacity: 1; } }
.empty-note { margin-top: 14px; transform: rotate(.6deg); }

/* ---------- תוצאות ---------- */
.reveal-label { font-size: .95rem; color: var(--muted); }
.reveal { font: 400 clamp(2rem, 8vw, 3rem)/1.2 var(--f-display); color: var(--ink); margin-top: 4px; overflow-wrap: anywhere; }
.results { list-style: none; margin: 18px 0 0; padding: 0; display: grid; }
.results li { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 68px; padding: 8px 0; }
.results li + li { border-top: 1px dashed #d8ccb2; }
.rank { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font: 700 1.6rem/1 var(--f-hand); background: #efe6d1; color: var(--text); padding-top: 3px; }
.rank.r1 { background: var(--gold); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--gold); }
.rank.r2 { background: var(--silver); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--silver); }
.rank.r3 { background: var(--bronze); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--bronze); }
.rank.x { background: transparent; color: var(--red); font-size: 1.9rem; }
.r-name { font: 400 1.2rem/1.25 var(--f-display); overflow-wrap: anywhere; }
.r-ans { font-size: .92rem; color: var(--muted); overflow-wrap: anywhere; }
.r-time { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-time b { display: block; text-align: left; font: 700 1.5rem/1 var(--f-hand); color: var(--ink); }
.r-time span { font-size: .8rem; color: var(--muted); }
.wrong-title { margin-top: 26px; font: 400 1.1rem/1.3 var(--f-display); color: var(--red); }
.results.wrong .r-name { color: var(--muted); }

details.prev > summary { cursor: pointer; list-style: none; font: 400 1.2rem/1.4 var(--f-display); }
details.prev > summary::-webkit-details-marker { display: none; }
details.prev > summary::before { content: "+"; display: inline-block; width: 1em; margin-inline-end: 6px; text-align: center; }
details.prev[open] > summary::before { content: "\2212"; }
details.prev > .card { margin-top: 18px; }

/* ---------- טעינה ---------- */
.skeleton { height: 220px; display: grid; place-items: center; color: var(--muted); }
.conn { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); left: max(12px, env(safe-area-inset-left, 0px)); background: var(--paper); color: var(--text); padding: 6px 12px; border-radius: 4px; font-size: .85rem; box-shadow: var(--shadow-paper); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 480px) {
  .card { padding: 38px 52px 26px 18px; background-image: linear-gradient(to left, transparent 34px, var(--margin) 34px 36px, transparent 36px), repeating-linear-gradient(to bottom, transparent 0 33px, var(--rule) 33px 34px); }
  .card.plain { padding: 32px 18px 22px; }
  .notes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results li { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; }
  .rank { width: 36px; height: 36px; font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .stamp-in, .note.fresh { animation: none; }
  .btn { transition: none; }
}

/* ---------- אחרי שליחה ---------- */
.locked { display: grid; gap: 14px; justify-items: start; margin-top: 28px; }

/* ---------- מסך ניהול ---------- */
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 180px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 6px 0 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--n1); padding: 5px 6px 5px 12px; font-size: 1rem; box-shadow: 0 4px 6px -4px rgba(52, 28, 6, .6); transform: rotate(-.6deg); }
.chip:nth-child(2n) { background: var(--n3); transform: rotate(.7deg); }
.chip:nth-child(3n) { background: var(--n4); }
.chip button { border: 0; background: rgba(0,0,0,.08); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; color: var(--text); }
.tester { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.tester .verdict { font: 400 1.05rem/1.2 var(--f-display); }
.verdict.yes { color: #1d7a45; }
.verdict.no { color: var(--red); }
.admin-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; }
.admin-list > li { padding: 14px 0; display: grid; gap: 8px; }
.admin-list > li + li { border-top: 1px dashed #d8ccb2; }
.admin-list .meta { font-size: .9rem; color: var(--muted); }
.admin-list .q { font: 400 1.15rem/1.4 var(--f-display); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; font: 400 .85rem/1 var(--f-display); padding: 5px 9px 4px; border-radius: 3px; border: 2px solid currentColor; transform: rotate(-2deg); }
.tag.SCHEDULED { color: var(--ink); }
.tag.ACTIVE { color: #1d7a45; }
.tag.CLOSED { color: var(--muted); }
.actions { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; }
.table-wrap { overflow-x: auto; margin-top: 14px; }
table.subs { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 520px; }
table.subs th { text-align: right; font: 400 .95rem/1.3 var(--f-display); color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--paper-edge); }
table.subs td { padding: 8px; border-bottom: 1px dashed #e3d8c0; vertical-align: middle; overflow-wrap: anywhere; }
table.subs td.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; white-space: nowrap; }
table.subs select { font: inherit; padding: 4px; border: 1px solid #c9bda4; background: #fff; border-radius: 4px; }
.ok-mark { color: #1d7a45; font-weight: 700; }
.no-mark { color: var(--red); font-weight: 700; }
.confirm { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #fff0f0; padding: 6px 10px; border-radius: 4px; }
.toast { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); right: max(16px, env(safe-area-inset-right, 0px)); background: var(--paper); padding: 10px 16px; box-shadow: var(--shadow-paper); font: 400 1.05rem/1.3 var(--f-display); transform: rotate(-1deg); z-index: 5; }
.preview-img { max-width: 180px; max-height: 140px; border: 6px solid #fff; box-shadow: 0 6px 10px -6px rgba(40,20,0,.6); display: block; margin-top: 8px; }
.field input[type="file"] { font-size: 1rem; border-bottom: 0; color: var(--muted); padding: 4px 0; }
.field input[type="file"]::file-selector-button {
  font: 400 1rem/1 var(--f-display); color: #fff; background: #2d55c9; border: 0; border-radius: 6px;
  padding: 9px 14px 8px; margin-inline-end: 12px; cursor: pointer; box-shadow: 0 3px 0 #1a2f78;
}
