:root {
  --kraft: #CBAE87;
  --kraft-deep: #B8976C;
  --slip: #FFFFFF;
  --ink: #000000;
  --envelope: #8DB8E0;
  --envelope-deep: #6F9FCB;
  --flash: #E3001B;
  --night: #0F1B3D;
  --display: "Karantina", "Arial Narrow", sans-serif;
  --body: "Rubik", "Arial", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--kraft);
  /* Faint cardboard fibre, the material of every Israeli voting booth. */
  background-image:
    repeating-linear-gradient(97deg, rgba(0,0,0,.025) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(3deg, rgba(255,255,255,.05) 0 1px, transparent 1px 11px);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  transition: background-color .9s ease, color .9s ease;
}
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Breaking-news bar */
.flash {
  display: flex; align-items: stretch;
  background: var(--flash); color: #fff;
  font-family: var(--display); font-size: 28px; line-height: 1;
  overflow: hidden; position: relative;
}
.flash-label {
  flex: none; background: #fff; color: var(--flash);
  padding: 10px 18px 8px; font-weight: 700; z-index: 1;
}
.flash-track { flex: 1; overflow: hidden; display: flex; align-items: center; }
.flash-lines {
  display: flex; gap: 56px; white-space: nowrap; padding-inline-start: 24px;
  animation: crawl 60s linear infinite;
}
.flash-lines span { padding-top: 2px; }
@keyframes crawl { from { transform: translateX(0); } to { transform: translateX(50%); } }
.flash-mute {
  flex: none; border: 0; background: rgba(0,0,0,.18); color: #fff; cursor: pointer;
  font-family: var(--body); font-size: 14px; padding: 8px 16px; z-index: 1;
}
.flash-mute:hover { background: rgba(0,0,0,.3); }
.flash.is-muted .flash-lines { animation-play-state: paused; }

main { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* Hero */
.hero { padding: 72px 0 40px; }
.hero h1 {
  font-family: var(--display); font-weight: 700; margin: 0;
  font-size: clamp(76px, 15vw, 190px); line-height: .82; letter-spacing: -.01em;
}
.hero .also {
  font-family: var(--display); font-weight: 400; margin: 10px 0 0;
  font-size: clamp(40px, 7vw, 84px); line-height: .9;
}
.hero p { max-width: 36ch; margin: 26px 0 0; font-size: 20px; }

/* Booth */
.booth { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; padding: 30px 0 70px; align-items: start; }
.booth h2 { font-family: var(--display); font-size: 54px; line-height: .9; margin: 0 0 6px; }
.booth .hint { margin: 0 0 22px; }

.tray {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  background: var(--kraft-deep); padding: 14px; border-radius: 4px;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.15), inset 0 -2px 0 rgba(255,255,255,.2);
}
.slip {
  appearance: none; border: 1px solid rgba(0,0,0,.25); background: var(--slip); color: var(--ink);
  aspect-ratio: 3 / 4; cursor: pointer; padding: 12px 12px 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.slip:hover, .slip:focus-visible { transform: translateY(-5px); }
.slip .code { font-family: var(--display); font-weight: 700; font-size: clamp(46px, 6.5vw, 76px); line-height: .8; }
.slip .name { font-size: 13px; line-height: 1.3; text-align: center; }
.slip.is-cast { visibility: hidden; }

.envelope-col { position: sticky; top: 24px; }
.envelope {
  background: var(--envelope); border-radius: 6px; position: relative;
  aspect-ratio: 4 / 3; overflow: hidden;
  box-shadow: 0 2px 0 var(--envelope-deep);
}
.envelope::before {
  /* the flap */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 52%;
  background: var(--envelope-deep);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  opacity: .55;
}
.envelope .stamp {
  position: absolute; bottom: 16px; inset-inline-start: 18px;
  font-family: var(--display); font-size: 26px; line-height: 1; opacity: .7;
}
.result { margin-top: 18px; min-height: 9em; }
.result h3 { font-family: var(--display); font-size: 40px; line-height: .95; margin: 0 0 8px; }
.result p { margin: 0 0 10px; }
.result .verdict { font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn {
  appearance: none; border: 2px solid var(--ink); background: transparent; color: var(--ink);
  font-family: var(--body); font-size: 16px; font-weight: 500; padding: 9px 18px; cursor: pointer;
}
.btn.solid { background: var(--ink); color: #fff; }
/* WhatsApp's own dark teal: recognizable, and white on it passes contrast. */
.btn.share { background: #075E54; border-color: #075E54; color: #fff; }
.btn.share:hover { background: #054740; border-color: #054740; color: #fff; }
.btn:hover { background: var(--ink); color: #fff; }
.flyer { position: fixed; z-index: 50; pointer-events: none; margin: 0; }

.coffee { border-top: 2px solid var(--ink); padding: 28px 0 34px; }
.coffee h2 { font-family: var(--display); font-size: 48px; line-height: .9; margin: 0 0 8px; }
.coffee p { margin: 0 0 16px; max-width: 46ch; }
a.btn { display: inline-block; text-decoration: none; }
body.night .coffee { border-color: #E7ECF7; }
footer { border-top: 2px solid var(--ink); padding: 20px 0 40px; font-size: 15px; }
footer p { max-width: 70ch; margin: 0; }
footer p.contact { margin-top: 12px; }
footer a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
footer a:hover { text-decoration-thickness: 2px; }

/* Lights out */
body.night { background-color: var(--night); background-image: none; color: #E7ECF7; }
body.night .flash { filter: grayscale(1) brightness(.5); }
body.night .tray, body.night .envelope-col, body.night .hero p, body.night .hint { opacity: .25; transition: opacity .9s ease; }
body.night .btn { border-color: #E7ECF7; color: #E7ECF7; }
body.night .btn:hover { background: #E7ECF7; color: var(--night); }
body.night footer { border-color: #E7ECF7; }
.goodnight { display: none; }
body.night .goodnight { display: block; }
.goodnight {
  position: fixed; inset: auto 0 0 0; padding: 28px 24px 34px; background: var(--night);
  border-top: 1px solid rgba(231,236,247,.25); text-align: center; z-index: 40;
}
.goodnight strong { display: block; font-family: var(--display); font-size: 58px; line-height: .9; font-weight: 400; }
.goodnight p { margin: 8px auto 14px; max-width: 46ch; }

@media (max-width: 820px) {
  .booth { grid-template-columns: 1fr; }
  .envelope-col { position: static; }
  .hero { padding-top: 44px; }
  .flash { font-size: 22px; }
}
@media (max-width: 420px) {
  .tray { gap: 8px; padding: 10px; }
  .slip .name { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash-lines { animation: none; }
  .slip { transition: none; }
  body { transition: none; }
}

/* Language switch: a plain link, top of the hero, on the reading end. */
.lang-switch { display: flex; justify-content: space-between; align-items: baseline; padding-top: 18px; }
.lang-switch .brand { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; }
.lang-switch a { font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.lang-switch a:hover { text-decoration-thickness: 2px; }
body.night .lang-switch a { color: #E7ECF7; }
.hero { padding-top: 40px; }

/* English reads left to right, so its crawl moves the other way. */
[dir="ltr"] .flash-lines { animation-name: crawl-ltr; }
@keyframes crawl-ltr { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Arriving from a friend's share link. */
.friend {
  margin: 28px 0 0; padding: 12px 16px; max-width: 46ch;
  background: var(--slip); border: 2px solid var(--ink); font-weight: 500;
}
.slip.is-friend { outline: 3px dashed var(--ink); outline-offset: 3px; }

/* Live results */
.results { border-top: 2px solid var(--ink); padding: 28px 0 34px; }
.results h2 { font-family: var(--display); font-size: 48px; line-height: .9; margin: 0 0 8px; }
.results .lead { margin: 0 0 18px; font-weight: 500; }
.results ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 720px; }
.results li { display: grid; grid-template-columns: 3.2em minmax(0, 13em) minmax(0, 1fr) 3.4em; align-items: center; gap: 12px; }
.results .r-code { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; }
.results .r-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r-bar { height: 14px; background: var(--kraft-deep); display: block; }
.results .r-bar i { display: block; height: 100%; background: var(--ink); transition: width .6s ease; }
.results .r-pct { font-size: 15px; font-variant-numeric: tabular-nums; text-align: end; }
.results .total, .results .note { margin: 14px 0 0; font-size: 14px; }
body.night .results { border-color: #E7ECF7; opacity: .25; }
body.night .results .r-bar i { background: #E7ECF7; }
@media (max-width: 560px) {
  .results li { grid-template-columns: 2.6em minmax(0, 1fr) 3.2em; }
  .results .r-bar { grid-column: 1 / -1; order: 4; }
  .results ol { gap: 16px; }
  .results li { row-gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { .results .r-bar i { transition: none; } }

/* National tension meter */
.meter {
  display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 32px; align-items: center;
  border-top: 2px solid var(--ink); padding: 28px 0 34px; margin-top: 10px;
}
.meter .gauge { width: 100%; height: auto; display: block; }
/* Before the script runs the needle already sits near the top, where it always is. */
.meter .needle { transform-box: view-box; transform-origin: 100px 100px; transform: rotate(84.6deg); transition: transform .9s cubic-bezier(.3,1.4,.4,1); }
.meter h2 { font-family: var(--display); font-size: 48px; line-height: .9; margin: 0 0 10px; }
.meter-reading { margin: 0 0 6px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.meter-reading strong { font-family: var(--display); font-size: 64px; line-height: .85; color: var(--flash); font-variant-numeric: tabular-nums; }
.meter-reading span { font-family: var(--display); font-size: 30px; line-height: 1; }
.meter-status { margin: 0 0 4px; font-weight: 500; }
.meter-by { margin: 0 0 14px; font-size: 14px; }
body.night .meter { border-color: #E7ECF7; opacity: .25; }
@media (max-width: 640px) {
  .meter { grid-template-columns: 1fr; gap: 16px; }
  .meter .gauge { max-width: 280px; }
}
@media (prefers-reduced-motion: reduce) { .meter .needle { transition: none; } }

/* Game: an apartment block at 2am */
.game {
  display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 40px; align-items: center;
  border-top: 2px solid var(--ink); padding: 28px 0 40px; margin-top: 10px;
}
.game h2 { font-family: var(--display); font-size: 54px; line-height: .9; margin: 0 0 12px; }
.game-side p { margin: 0 0 12px; }
.game-best { font-weight: 500; min-height: 1.6em; }
.tower { min-width: 0; }
.roof { display: block; width: 100%; height: auto; max-height: 44px; }
.building { position: relative; background: var(--night); color: #E7ECF7; padding-bottom: 58px; }
/* The lobby door, lit, because someone always leaves it on. */
.building::after {
  content: ""; position: absolute; bottom: 0; left: 50%; width: 52px; height: 44px; margin-left: -26px;
  background: #3A4A7A; border: 3px solid #0A1230; border-bottom: 0;
}
.game-hud { display: flex; align-items: center; gap: 18px; padding: 12px 18px; border-bottom: 3px solid #0A1230; }
.game-score { margin: 0; display: flex; align-items: baseline; gap: 8px; font-weight: 500; white-space: nowrap; }
.game-score strong { font-family: var(--display); font-size: 40px; line-height: .8; font-variant-numeric: tabular-nums; min-width: 2ch; }
.game-tension { flex: 1; min-width: 0; font-size: 15px; }
.game-tension b { font-variant-numeric: tabular-nums; }
.game-track { height: 12px; border: 2px solid #E7ECF7; margin-top: 3px; }
.game-track i { display: block; height: 100%; width: 0; background: #FFD86B; }
.game-tension.is-hot .game-track i { background: var(--flash); }
.game-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; padding: 18px 18px 0; }
.win {
  appearance: none; aspect-ratio: 5 / 4; min-width: 0; margin: 0; padding: 4px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: #1E2A52; border: 3px solid #0A1230; color: var(--ink); font: inherit; text-align: center; cursor: default;
}
.win .who { font-size: 11px; font-weight: 700; line-height: 1.1; }
.win .says { font-family: var(--display); font-size: 23px; line-height: .95; }
.win.is-lit { background: #FFD86B; box-shadow: 0 0 22px rgba(255, 216, 107, .45); cursor: pointer; animation: win-on .15s ease-out; }
.win.is-hushed .says { color: #E7ECF7; animation: hush .8s ease-out forwards; }
.win:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@keyframes win-on { from { background: #3A4A7A; } }
@keyframes hush { to { opacity: 0; } }
.game-flash {
  position: absolute; top: 64px; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 90%;
  background: var(--flash); color: #fff; font-family: var(--display); font-size: 30px; line-height: 1; padding: 6px 16px 4px;
  pointer-events: none;
}
.game-cover {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center; background: rgba(15, 27, 61, .93);
}
#gameStart { background: rgba(15, 27, 61, .5); }
.game-cover[hidden], .game-flash[hidden] { display: none; }
.game-cover strong { font-family: var(--display); font-size: 52px; line-height: .9; }
.game-cover p { margin: 0; }
.game-verdict { font-weight: 700; }
.game-cover .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
.game-cover .btn.solid { background: #FFD86B; border-color: #FFD86B; color: var(--ink); font-size: 18px; padding: 10px 26px; }
.game-cover .btn.solid:hover { background: #fff; border-color: #fff; }
body.night .game { border-color: #E7ECF7; opacity: .25; }
@media (max-width: 820px) {
  .game { grid-template-columns: 1fr; gap: 14px; }
  .game h2 { font-size: 46px; }
  .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 12px 12px 0; }
  .win { aspect-ratio: 1; }
  .win .says { font-size: 19px; }
  .win .who { font-size: 10px; }
  .game-hud { padding: 10px 12px; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { .win.is-lit { animation: none; } .win.is-hushed .says { animation-duration: .01s; } }
