/* Abu Rob style: loud yellow, heavy black lettering, thick black outlines, wavy rings. */
:root {
  color-scheme: light;
  --yellow: #ffe94d;
  --yellow-soft: #fff6b0;
  --yellow-deep: #f5cf00;
  --ink: #111111;
  --ink-soft: #3d3d3d;
  --paper: #ffffff;
  --line: 3px solid var(--ink);
  --hard: 5px 5px 0 var(--ink);
  --hard-sm: 3px 3px 0 var(--ink);
  --radius: 22px;
  --display: "Lalezar", "Cairo", system-ui, sans-serif;
  --latin: "Lilita One", "Lalezar", system-ui, sans-serif;
  --body: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }

body {
  margin: 0;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.6;
  overflow-x: clip;
  padding-bottom: 150px; /* room for the vote tray */
}

button { font-family: inherit; color: inherit; }
.nowrap { white-space: nowrap; }

/* ---------- Floating pastries ---------- */
/* Behind the content while voting; in front (and grabbable) at the top of the page. */
.floaters {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.floaters.play { z-index: 15; }
.floaters.play .floater { pointer-events: auto; cursor: grab; touch-action: none; }
.floaters.play .floater.grabbed { cursor: grabbing; }

.floater {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--size, 70px);
  height: var(--size, 70px);
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.floater .pic,
.flying {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  transition: scale 0.15s;
}
.floater .pic img,
.flying img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(4px 5px 0 rgba(17, 17, 17, 0.85));
  pointer-events: none;
  -webkit-user-drag: none;
}
.floater .pic span,
.flying span {
  font-size: calc(var(--size, 70px) * 0.78);
  line-height: 1;
  filter: drop-shadow(3px 4px 0 rgba(17, 17, 17, 0.85));
}
.floater.grabbed .pic { scale: 1.1; }
.floater.grabbed .pic img { filter: drop-shadow(10px 14px 0 rgba(17, 17, 17, 0.6)); }
.floater .pic.pulse { animation: pulse 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pulse { 40% { scale: 1.2; } }

.floater .tag {
  position: absolute;
  top: calc(100% - 6px);
  left: 50%;
  translate: -50% 0;
  white-space: nowrap;
  background: var(--ink);
  color: var(--yellow);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 9px;
  border-radius: 999px;
  line-height: 1.7;
  pointer-events: none;
}

.flying {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--size, 70px);
  height: var(--size, 70px);
  z-index: 80;
  pointer-events: none;
}

.play-hint {
  margin: -6px auto 18px;
  font-weight: 800;
  font-size: 0.95rem;
}

/* Everything readable sits above the back floaters. */
.topbar, .hero, main, .footer { position: relative; z-index: 1; }

/* ---------- Top bar ---------- */
.topbar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  font-family: var(--latin);
  font-size: 1.5rem;
  letter-spacing: 0.5px;
  line-height: 1;
}
.brand b { font-weight: 400; color: var(--paper); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }

.fan-chip {
  display: inline-block;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--hard-sm);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 2px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Hero ---------- */
.hero {
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 16px 8px;
  text-align: center;
}

.rings {
  position: absolute;
  inset: -80px 0 auto;
  height: 620px;
  overflow: hidden;
  color: var(--ink);
  opacity: 0.22;
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at 50% 35%, #000 30%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 35%, #000 30%, transparent 72%);
}
.rings svg {
  width: 100%;
  height: 100%;
  animation: spin 160s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.3rem, 13vw, 6.4rem);
  line-height: 1.05;
  margin: 8px 0 6px;
  color: var(--ink);
  text-shadow: 4px 4px 0 var(--paper);
}
.title-emoji {
  display: inline-block;
  animation: wobble 2.6s ease-in-out infinite;
  text-shadow: none;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(12deg) scale(1.08); }
}

.promise-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 6px auto 22px;
}
.host {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: var(--line);
  box-shadow: var(--hard-sm);
  background: var(--paper);
  rotate: 5deg;
}
@media (max-width: 480px) {
  .promise-wrap { gap: 8px; }
  .host { width: 62px; height: 62px; }
}

.promise {
  display: inline-block;
  font-size: clamp(1.05rem, 3.6vw, 1.3rem);
  margin: 0;
  max-width: 36ch;
  background: var(--paper);
  border: var(--line);
  box-shadow: var(--hard);
  border-radius: 18px;
  padding: 10px 18px;
  rotate: -1.2deg;
}
.promise q { font-weight: 800; }
.promise strong {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.35em;
  background: var(--yellow);
  padding: 0 8px;
  border-radius: 8px;
}

/* ---------- Shame counter ---------- */
.shame {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 18px 14px 20px;
  box-shadow: 6px 6px 0 var(--paper);
  position: relative;
  overflow: hidden;
}
.shame::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-45deg, transparent 0 18px, rgba(255, 233, 77, 0.06) 18px 36px);
  pointer-events: none;
}
.shame-line {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.25rem, 4.6vw, 1.95rem);
  line-height: 1.5;
  margin: 0 0 14px;
  position: relative;
}
#shame-text { color: var(--yellow); }

.clock {
  display: flex;
  justify-content: center;
  gap: clamp(6px, 2vw, 14px);
  position: relative;
}
.unit {
  background: rgba(255, 233, 77, 0.07);
  border: 2px solid rgba(255, 233, 77, 0.35);
  border-radius: 14px;
  min-width: 0;
  flex: 1 1 0;
  max-width: 100px;
  padding: 8px 4px 4px;
}
.unit b {
  display: block;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.7rem, 7.4vw, 2.8rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--yellow);
}
.unit span { font-size: 0.8rem; opacity: 0.8; }
.unit:last-child { background: var(--yellow); border-color: var(--yellow); }
.unit:last-child b, .unit:last-child span { color: var(--ink); opacity: 1; }

/* ---------- Intro ---------- */
main { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.intro { text-align: center; padding: 30px 0 8px; }

.section-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.75rem, 6.4vw, 2.6rem);
  margin: 0 0 10px;
  line-height: 1.3;
}
.hint {
  margin: 6px auto 12px;
  max-width: 46ch;
  font-weight: 600;
}

.stats {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  background: var(--paper);
  border: var(--line);
  box-shadow: var(--hard-sm);
  border-radius: 999px;
  padding: 4px 18px;
  font-weight: 700;
}
.stats b { font-variant-numeric: tabular-nums; font-weight: 800; }

/* ---------- Pastry grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 20px;
  padding: 22px 0 34px;
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}

.pastry {
  position: relative;
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius);
  padding: 10px 10px 12px;
  box-shadow: var(--hard);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.pastry:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.pastry.picked { background: var(--yellow-soft); }
.pastry.leader { box-shadow: 7px 7px 0 var(--ink), 0 0 0 4px var(--paper), 0 0 0 7px var(--ink); }

.rank {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  background: var(--ink);
  color: var(--yellow);
  font-family: var(--latin);
  font-size: 0.95rem;
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 6px;
}
.pastry.leader .rank { background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); }

.stage {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 55%, var(--yellow-soft) 0 38%, transparent 39%),
    repeating-radial-gradient(circle at 50% 55%, transparent 0 14px, rgba(17, 17, 17, 0.06) 14px 15.5px);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

.crown {
  position: absolute;
  top: -10px;
  left: 50%;
  translate: -50% 0;
  font-size: 2rem;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s;
  filter: drop-shadow(2px 2px 0 var(--ink));
}
.pastry.leader .crown { opacity: 1; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-8deg); } }

.piece {
  width: 92%;
  height: 92%;
  display: grid;
  place-items: center;
  transform: scale(0.8); /* every card the same size — the floating pastries show the votes */
}
.piece > * { animation: idle 3.2s ease-in-out infinite; }
.pastry:nth-child(2n) .piece > * { animation-delay: -1.1s; }
.pastry:nth-child(3n) .piece > * { animation-delay: -2.2s; }
@keyframes idle {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6%) rotate(3deg); }
}
.piece img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(4px 6px 0 rgba(17, 17, 17, 0.9));
  pointer-events: none;
}
.piece .emoji {
  font-size: clamp(5rem, 22vw, 9rem);
  line-height: 1;
  filter: drop-shadow(4px 6px 0 rgba(17, 17, 17, 0.9));
}
.piece.pop { animation: pop 0.5s ease; }
@keyframes pop { 30% { filter: brightness(1.25); } }

.name {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.55rem;
  text-align: center;
  margin: 4px 0 0;
  line-height: 1.3;
}

.meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 800;
  margin: 2px 2px 4px;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--ink) 0 6px, #3b3b3b 6px 12px);
  transition: width 0.9s ease;
}

.vote-btn {
  margin-top: 10px;
  border: var(--line);
  border-radius: 14px;
  padding: 7px 8px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.25rem;
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.vote-btn:hover { background: var(--yellow-deep); }
.vote-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.vote-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.vote-btn .count-pill {
  background: var(--ink);
  color: var(--yellow);
  border-radius: 999px;
  padding: 0 9px;
  margin-inline-start: 6px;
  font-family: var(--body);
  font-weight: 800;
  font-size: 0.85rem;
}
.voted-mode .vote-btn { display: none; }

/* ---------- Vote tray ---------- */
.tray {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: var(--line);
}
.tray-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.slots { display: flex; align-items: center; gap: 10px; min-width: 0; }
.slot {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px dashed var(--ink);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: var(--yellow-soft);
  overflow: hidden;
}
.slot.filled { border-style: solid; background: var(--yellow); box-shadow: var(--hard-sm); animation: pop-in 0.3s ease; }
.slot img { width: 86%; height: 86%; object-fit: contain; }
@keyframes pop-in { from { transform: scale(0.5) rotate(-20deg); } }
.slots-label { font-weight: 800; font-size: 0.95rem; line-height: 1.3; }

.tray-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.btn {
  border: var(--line);
  border-radius: 14px;
  padding: 9px 18px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.btn.primary {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.25rem;
  padding: 6px 20px;
}
.btn.primary:hover { background: var(--yellow-deep); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.btn.ghost:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn.loading { pointer-events: none; opacity: 0.7; }

.turnstile-box { display: flex; justify-content: center; }
.turnstile-box:empty { display: none; }
.tray-error {
  margin: 6px auto 0;
  max-width: 1040px;
  font-weight: 800;
  text-align: center;
  font-size: 0.9rem;
  background: var(--ink);
  color: var(--yellow);
  border-radius: 10px;
  padding: 4px 10px;
}
.tray-error:empty { display: none; }

@media (max-width: 420px) {
  .slot { width: 46px; height: 46px; font-size: 1.35rem; }
  .btn { padding: 8px 12px; font-size: 0.95rem; }
  .btn.primary { font-size: 1.1rem; padding: 6px 14px; }
  .slots-label { display: none; }
  .brand { font-size: 1.25rem; }
  .fan-chip { font-size: 0.72rem; padding: 2px 9px; }
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17, 17, 17, 0.6); }
.modal-card {
  position: relative;
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  text-align: center;
  box-shadow: 8px 8px 0 var(--yellow), 8px 8px 0 3px var(--ink);
  animation: rise 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes rise { from { transform: translateY(30px) scale(0.95); opacity: 0; } }
.modal-x {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}
.modal-title { font-family: var(--display); font-weight: 400; font-size: 2.1rem; margin: 0 0 12px; }
.card-preview img {
  width: 100%;
  max-width: 300px;
  border-radius: 16px;
  border: var(--line);
  box-shadow: var(--hard);
  display: block;
  margin: 0 auto;
  aspect-ratio: 4 / 5;
  background: var(--yellow);
}
.save-hint { display: none; margin: 10px 0 0; font-size: 0.85rem; font-weight: 700; opacity: 0.75; }
@media (pointer: coarse) { .save-hint { display: block; } }
.btn:disabled { opacity: 0.5; cursor: wait; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  translate: -50% 20px;
  background: var(--ink);
  color: var(--yellow);
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 800;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, translate 0.25s;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 10px 16px 30px; font-size: 0.92rem; font-weight: 600; max-width: 640px; margin: 0 auto; }
.footer p { margin: 4px 0; }
.footer .muted { opacity: 0.75; }
.footer .small { font-size: 0.82rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
