/* ==========================================================================
   BALLOT DROP — styles
   Sections (in cascade order):
     1. Base & page background
     2. Game frame (.app) and canvas
     3. HUD (score / time / lives / mute)
     4. Overlays & panels (verify, start, results screens)
     5. Typography inside panels
     6. Buttons
     7. Pause screen & toast
     8. Animations
     9. Responsive & accessibility (frame on large screens, reduced motion)
    10. Entry screen: "scan sticker" / "find polling place" choices
   ========================================================================== */

/* ---- 1. Base & page background ---------------------------------------- */
:root {
  font-family: ui-rounded, system-ui, -apple-system, 'Arial Rounded MT Bold', sans-serif;
  color: #1F5FD1;
  background: #0A3161;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* the game never scrolls */
}

button { font: inherit; cursor: pointer; }

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 5%, #1F5FD1 0%, transparent 38%),
    radial-gradient(circle at 90% 80%, #FFF6E0, transparent 40%),
    #0A3161;
}

/* ---- 2. Game frame and canvas ------------------------------------------ */
/* .app is the phone-sized "cabinet"; every screen is positioned inside it. */
.app {
  position: relative;
  width: min(100%, 520px);
  height: 100dvh;
  max-height: 950px;
  overflow: hidden;
  background: #1F5FD1;
  isolation: isolate;
  box-shadow: 0 0 75px #061D3D;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* stop the browser scrolling/zooming while dragging the box */
}

/* ---- 3. HUD ------------------------------------------------------------ */
.hud {
  position: absolute;
  z-index: 3;
  left: 16px;
  right: 16px;
  top: max(16px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat {
  background: #FFFFFF;
  box-shadow: 0 5px 0 #FFF6E0;
  border: 3px solid #061D3D;
  border-radius: 18px;
  padding: 7px 12px;
  min-width: 0;
  flex: 1;
  text-align: center;
}

.stat small {
  display: block;
  font-weight: 900;
  font-size: 10px;
  letter-spacing: 1.3px;
  color: #0A3161;
}

.stat strong {
  font-size: 23px;
  line-height: 1.15;
  white-space: nowrap;
}

.sound {
  border: 3px solid #061D3D;
  background: #FFFFFF;
  border-radius: 15px;
  width: 47px;
  height: 52px;
  font-size: 21px;
  box-shadow: 0 5px 0 #FFF6E0;
}

/* ---- 4. Overlays & panels --------------------------------------------- */
/* Full-screen layers on top of the canvas: #verify, #start and #results. */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #1F5FD1, #0A3161);
  text-align: center;
  color: white;
}

.panel {
  width: 100%;
  max-width: 400px;
  animation: rise .5s cubic-bezier(.2, 1.7, .3, 1);
}

/* Toggled by JS to show/hide any screen element. */
.hidden { display: none !important; }

/* Leftover footer styles (the footer markup has been removed). */
.footer {
  position: absolute;
  z-index: 5;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.footer a {
  pointer-events: auto;
  color: #102b76;
  background: #ffffffd9;
  padding: 7px 13px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 2px 8px #102b7620;
}

/* ---- 5. Typography inside panels -------------------------------------- */
.eyebrow {
  display: inline-block;
  border: 2px solid #ffffff66;
  border-radius: 99px;
  padding: 8px 17px;
  background: #ffffff22;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
}

.title {
  font-size: clamp(54px, 14vw, 88px);
  line-height: .88;
  margin: 20px 0 14px;
  font-weight: 1000;
  letter-spacing: -5px;
  text-shadow: 0 8px 0 #1F5FD1, 3px 11px 0 #0A3161;
}

.title span { color: #ffdf56; }

.tagline {
  font-size: 19px;
  font-weight: 800;
  margin: 22px 0 27px;
}

.box-icon {
  font-size: 83px;
  filter: drop-shadow(0 12px 0 #0A3161);
  animation: bob 2.2s ease-in-out infinite;
}

.note {
  font-size: 13px;
  opacity: .88;
  margin-top: 23px;
  line-height: 1.5;
}

/* Results screen */
.result-score {
  font-size: clamp(74px, 18vw, 105px);
  font-weight: 1000;
  color: #ffdf55;
  line-height: 1;
  margin: 10px 0;
  text-shadow: 0 7px 0 #0A3161;
}

.result-title {
  font-size: 29px;
  font-weight: 1000;
  margin: 12px 0;
}

.best {
  font-weight: 900;
  background: #ffffff29;
  display: inline-block;
  padding: 9px 18px;
  border-radius: 99px;
  margin: 6px 0 24px;
}

/* ---- 6. Buttons -------------------------------------------------------- */
.button {
  border: 3px solid #061D3D;
  background: #FFD700;
  color: #0A3161;
  padding: 17px 27px;
  min-width: 220px;
  border-radius: 21px;
  font-size: 21px;
  font-weight: 1000;
  box-shadow: 0 8px 0 #C9A227, 0 12px 22px #061D3D55;
  transition: transform .15s;
}

.button:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #C9A227;
}

.button.secondary {
  background: #fff;
  box-shadow: 0 7px 0 #FFF6E0;
  font-size: 16px;
  margin-top: 17px;
}

.button:focus-visible,
.sound:focus-visible,
a:focus-visible {
  outline: 4px solid #FFD700;
  outline-offset: 3px;
}

/* ---- 7. Pause screen & toast ------------------------------------------ */
.pause {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #0A3161;
  color: white;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 30px;
  font-weight: 1000;
}

.pause p { font-size: 16px; }

.toast {
  position: absolute;
  z-index: 8;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: #FFFFFF;
  color: #0A3161;
  padding: 12px 19px;
  border-radius: 20px;
  font-weight: 900;
  box-shadow: 0 5px 0 #FFF6E0;
  white-space: nowrap;
}

/* ---- 8. Animations ----------------------------------------------------- */
@keyframes bob {
  50% { transform: translateY(-11px) rotate(-4deg); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(25px) scale(.92); }
  to   { opacity: 1; transform: none; }
}

/* ---- 9. Responsive & accessibility ------------------------------------ */
/* On desktop the cabinet becomes a rounded, bordered card. */
@media (min-width: 700px) {
  .app {
    height: min(94dvh, 900px);
    border: 7px solid #D8284F;
    border-radius: 32px;
  }
}

/* Honour "reduce motion": no CSS animations or transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- 10. Entry screen choices ----------------------------------------- */
/* Two side-by-side options on #verify: scan a sticker, or find a polling place. */
.entry-choices {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin: 12px 0 8px;
}

.entry-choice {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  min-width: 0;
}

.choice-kicker {
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .9px;
  color: #FFD700;
}

.choice-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 78px;
  width: 100%;
  padding: 11px 9px;
  font-size: clamp(12px, 3.5vw, 16px);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  margin: 0 !important;
}

.button.secondary.choice-button {
  font-size: clamp(12px, 3.5vw, 16px);
  box-shadow: 0 8px 0 #FFF6E0;
}

.choice-caption {
  font-size: 12px;
  line-height: 1.25;
  font-weight: 800;
  opacity: .95;
}

/* The status note directly after the (visually hidden) file input. */
.entry-choices + input + .note { margin-top: 18px; }

/* The file input is kept in the DOM but visually hidden; the label acts as its button. */
.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

/* Narrow phones */
@media (max-width: 360px) {
  .overlay { padding: 14px; }
  .entry-choices { gap: 9px; }
  .choice-button { font-size: 12px; padding: 9px 6px; min-height: 84px; }
  .choice-caption { font-size: 11px; }
}

/* Short screens: shrink the #verify screen so everything fits */
@media (max-height: 710px) {
  #verify .title { margin: 12px 0 10px; }
  #verify .box-icon { font-size: 52px; }
  #verify .tagline { margin: 10px 0 14px; font-size: 16px; }
  #verify .note { margin-top: 12px; }
  #verify .entry-choices { margin: 8px 0; }
  #verify .choice-button { min-height: 65px; }
}
