:root {
  --ink: #f4f7fb;
  --ink-dim: #a9b6c7;
  --accent: #39a7ff;
  --accent-deep: #1d6fd0;
  --good: #3ddc97;
  --bad: #ff6b6b;
  --glass: rgba(11, 18, 42, 0.74);
  --glass-line: rgba(226, 186, 120, 0.22);
  --radius: 20px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

/* the hidden attribute must win over any display rule below */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #0a121c;
  -webkit-font-smoothing: antialiased;
}

/* ---------- background ---------- */
.bg, .scrim {
  position: fixed;
  inset: 0;
  z-index: -2;
}

.bg {
  background-color: #1e2f86;              /* the artwork's blue, shown while it loads */
  background-image: url("assets/bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.scrim {
  z-index: -1;
  background:
    radial-gradient(130% 100% at 50% 20%, rgba(10, 18, 56, 0) 0%, rgba(5, 9, 30, 0.42) 78%),
    linear-gradient(180deg, rgba(8, 14, 40, 0.1), rgba(4, 8, 24, 0.4));
}

/* ---------- layout ---------- */
.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.screen {
  display: none;
  width: 100%;
}

.screen.is-active {
  display: grid;
  place-items: center;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.card {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.2);
  padding: 36px;
}

.card--narrow { max-width: 460px; }
.card--wide   { max-width: 880px; }

/* content-dense cards sit on a stronger backing so the artwork cannot run through the text */
.card--wide  { background: rgba(9, 15, 38, 0.94); }
.card--admin { background: rgba(8, 13, 34, 0.965); }
.card--center { text-align: center; }

/* ---------- type ---------- */
.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

h1, h2 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.sub {
  margin: 0 0 24px;
  color: var(--ink-dim);
  font-size: 15px;
}

.note {
  margin: 18px 0 0;
  font-size: 12px;
  color: rgba(169, 182, 199, 0.75);
  text-align: center;
}

.error {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bad);
  text-align: center;
}

/* ---------- pin ---------- */
.pin {
  display: block;
  margin-bottom: 20px;
}

.pin__input {
  width: 100%;
  padding: 16px 12px;
  text-align: center;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.22em;
  text-indent: 0.22em;                /* keeps the spaced digits optically centred */
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--glass-line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.pin__input::placeholder {
  color: rgba(169, 182, 199, 0.35);
  font-weight: 600;
}

.pin__input:focus {
  border-color: var(--accent);
  background: rgba(57, 167, 255, 0.12);
  box-shadow: 0 0 0 4px rgba(57, 167, 255, 0.18);
}

.pin.is-bad .pin__input {
  border-color: var(--bad);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.16);
}

.pin.is-bad { animation: shake 0.42s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 650;
  padding: 13px 26px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, filter 0.18s, background 0.18s, opacity 0.18s;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 10px 26px rgba(29, 111, 208, 0.38);
}

.btn--primary:not(:disabled):hover { filter: brightness(1.08); }

.btn--ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--glass-line);
}

.btn--ghost:not(:disabled):hover { background: rgba(255, 255, 255, 0.14); }

.btn--block { width: 100%; }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}

/* ---------- steps ---------- */
.steps {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.step__dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid var(--glass-line);
  transition: all 0.25s;
}

.step__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  white-space: nowrap;
}

.step__line {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.step.is-current .step__dot {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 5px rgba(57, 167, 255, 0.18);
}

.step.is-current .step__label { color: var(--ink); }

.step.is-done .step__dot {
  color: #04120c;
  background: var(--good);
  border-color: var(--good);
}

.step.is-done .step__line { background: rgba(61, 220, 151, 0.5); }

/* ---------- candidate grid ---------- */
.vote__head { margin-bottom: 22px; }

.grid {
  display: grid;
  /* one column per candidate, so a two-horse race does not stretch across the card */
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 16px;
  max-width: calc(var(--cols, 4) * 212px);
  margin: 0 auto;
}

.cand {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 14px 18px;
  font: inherit;
  color: var(--ink);
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid var(--glass-line);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s, opacity 0.18s;
}

.cand:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.09);
}

.cand__photo {
  width: 104px;
  height: 104px;
  margin-bottom: 12px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18), 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.2s;
}

.cand__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cand__name { font-size: 15px; font-weight: 700; }

.cand__tag {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-dim);
}

.cand__check {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--good);
  color: #04120c;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.2s;
}

.cand[aria-checked="true"] {
  border-color: var(--accent);
  background: rgba(57, 167, 255, 0.14);
  box-shadow: 0 0 0 4px rgba(57, 167, 255, 0.16);
}

.cand[aria-checked="true"] .cand__photo {
  box-shadow: 0 0 0 3px var(--accent), 0 10px 22px rgba(0, 0, 0, 0.4);
}

.cand[aria-checked="true"] .cand__check {
  opacity: 1;
  transform: none;
}

.grid.has-pick .cand:not([aria-checked="true"]) { opacity: 0.58; }
.grid.has-pick .cand:not([aria-checked="true"]):hover { opacity: 0.85; }

.cand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- review + summary ---------- */
.review, .summary {
  list-style: none;
  margin: 0;
  padding: 0;
}

.review li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.review li:last-child { border-bottom: 0; }

.review__photo {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.review__photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

.review__text { flex: 1; min-width: 0; }

.review__post {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.review__name { display: block; font-size: 16px; font-weight: 700; }

.review__change {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.review__change:hover { background: rgba(57, 167, 255, 0.14); }

.summary {
  margin: 18px 0 26px;
  font-size: 14px;
  color: var(--ink-dim);
}

.summary li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.summary li:last-child { border-bottom: 0; }
.summary strong { color: var(--ink); font-weight: 650; }

.receipt {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--ink-dim);
}

.receipt strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

/* ---------- success tick ---------- */
.tick {
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
}

.tick svg { width: 100%; height: 100%; }

.tick__ring, .tick__mark {
  fill: none;
  stroke: var(--good);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tick__ring {
  stroke-dasharray: 150;
  stroke-dashoffset: 150;
  animation: draw 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.tick__mark {
  stroke-width: 4;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: draw 0.35s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- voter chip ---------- */
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.who img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.who b { color: var(--ink); font-weight: 700; }

/* ---------- selfie ---------- */
.selfie {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 4px auto 22px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 2px var(--glass-line), 0 18px 40px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.25s;
}

.selfie.is-live { box-shadow: 0 0 0 3px var(--accent), 0 18px 40px rgba(0, 0, 0, 0.45); }
.selfie.is-shot { box-shadow: 0 0 0 3px var(--good), 0 18px 40px rgba(0, 0, 0, 0.45); }

.selfie video,
.selfie img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selfie video { transform: scaleX(-1); }

.selfie__msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 26px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-dim);
  background: rgba(10, 16, 26, 0.86);
}

.actions--center { justify-content: center; }

.linkish {
  font: inherit;
  font-size: 12px;
  color: var(--ink-dim);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.linkish:hover { color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .card { padding: 26px 20px; }
  h1, h2 { font-size: 22px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: none; }
  .cand__photo { width: 88px; height: 88px; }
  .selfie { width: 220px; height: 220px; }
  .steps { gap: 6px; }
  .actions .btn { flex: 1; padding: 13px 14px; }
}

@media (max-width: 560px) {
  .step__label { display: none; }
}

@media (max-width: 420px) {
  .pin__input { font-size: 25px; letter-spacing: 0.16em; text-indent: 0.16em; }
}

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

/* ---------- club logo ---------- */
.logo {
  display: block;
  width: 132px;
  height: 132px;
  margin: 0 auto 14px;
  object-fit: contain;
  /* a soft gold halo keeps the navy shield from sinking into the dark card */
  filter:
    drop-shadow(0 0 12px rgba(230, 190, 120, 0.4))
    drop-shadow(0 0 2px rgba(240, 215, 165, 0.55))
    drop-shadow(0 10px 22px rgba(0, 0, 0, 0.5));
}

.card--center .tick + h2 { margin-top: 2px; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand .logo {
  width: 54px;
  height: 54px;
  margin: 0;
  flex: none;
}

@media (max-width: 560px) {
  .logo { width: 108px; height: 108px; }
  .brand .logo { width: 46px; height: 46px; }
}

.logo--done { width: 88px; height: 88px; margin-bottom: 10px; }

/* ---------- Malayalam ---------- */
/* The script has no case and its conjuncts need room, so the Latin
   letter-spacing and uppercasing are dropped and the line height opened up. */
/* :lang() so the rules reach every element under <html lang="ml">,
   not just the one carrying the attribute. */
:lang(ml) {
  letter-spacing: normal;
  text-transform: none;
  line-height: 1.55;
}

h1:lang(ml),
h2:lang(ml) {
  font-size: 22px;
  line-height: 1.5;
}

.eyebrow:lang(ml) {
  font-size: 13px;
  margin-bottom: 12px;
}

/* the line that tells the voter what to do, under the election title */
.sub--lead {
  margin-bottom: 4px;
  font-size: 16px;
  color: var(--ink);
}

.hint {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--ink-dim);
}

@media (max-width: 560px) {
  h1:lang(ml), h2:lang(ml) { font-size: 20px; }
  .sub--lead { font-size: 15px; }
}

/* ---------- golden popper ---------- */
#confetti {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

/* ---------- locked screen ---------- */
.countdown {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
