@font-face {
  font-family: "Allo";
  src: url("/fonts/AlloVariableFriendly.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: "Allo", system-ui, -apple-system, sans-serif;
  font-weight: 500;
  color: #1d1d1f;
  background: #f5f5f7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  min-height: 100%;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top))
    max(1.25rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1.25rem, env(safe-area-inset-left));
}

/* Kill FlipDown floats everywhere */
.flipdown,
.flipdown .rotor-group,
.flipdown .rotor {
  float: none !important;
}

.flipdown.flipdown__theme-light {
  font-family: "Allo", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-feature-settings: "tnum" 1;
}

.flipdown.flipdown__theme-light .rotor-group-heading:before {
  color: #86868b;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.flipdown.flipdown__theme-light .rotor,
.flipdown.flipdown__theme-light .rotor-top,
.flipdown.flipdown__theme-light .rotor-leaf-front {
  color: #1d1d1f;
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px rgba(0, 0, 0, 0.07);
}

.flipdown.flipdown__theme-light .rotor-bottom,
.flipdown.flipdown__theme-light .rotor-leaf-rear {
  color: #1d1d1f;
  background-color: #fbfbfd;
}

.flipdown.flipdown__theme-light .rotor:after {
  border-top: solid 1px rgba(0, 0, 0, 0.08);
}

/* Desktop / tablet landscape: one centered row */
@media (min-width: 641px) {
  .flipdown {
    width: auto !important;
    height: auto !important;
    display: flex !important;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 1.25rem;
  }

  .flipdown .rotor-group {
    padding-right: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .flipdown .rotor-group-heading:before {
    font-size: 0.7rem;
    height: 1.5rem !important;
    line-height: 1.5rem !important;
  }

  .flipdown .rotor-group:nth-child(n + 2):nth-child(-n + 3):before,
  .flipdown .rotor-group:nth-child(n + 2):nth-child(-n + 3):after {
    display: none !important;
  }

  .flipdown .rotor-digits {
    display: flex;
    gap: 0.35rem;
  }

  /* rotors are direct children after heading — wrap via flex on group */
  .flipdown .rotor-group {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 0.35rem;
    justify-items: center;
  }

  .flipdown .rotor-group-heading {
    grid-column: 1 / -1;
  }

  /* soft colon between groups via gap + pseudo on group 2 and 3 */
  .flipdown .rotor-group:nth-child(2),
  .flipdown .rotor-group:nth-child(3) {
    position: relative;
  }

  .flipdown .rotor-group:nth-child(2)::after,
  .flipdown .rotor-group:nth-child(3)::after {
    content: "";
    position: absolute;
    right: -0.85rem;
    top: 58%;
    width: 0.35rem;
    height: 0.35rem;
    border-radius: 50%;
    background: #d2d2d7;
    box-shadow: 0 0.85rem 0 #d2d2d7;
    transform: translateY(-50%);
  }

  .flipdown .rotor {
    width: 3.25rem !important;
    height: 5rem !important;
    margin: 0 !important;
    font-size: 2.75rem !important;
    border-radius: 8px;
  }

  .flipdown .rotor-leaf,
  .flipdown .rotor-leaf-front,
  .flipdown .rotor-leaf-rear,
  .flipdown .rotor-top,
  .flipdown .rotor-bottom,
  .flipdown .rotor:after {
    width: 100% !important;
  }

  .flipdown .rotor-leaf {
    height: 100% !important;
  }

  .flipdown .rotor-leaf-front,
  .flipdown .rotor-leaf-rear,
  .flipdown .rotor-top,
  .flipdown .rotor-bottom,
  .flipdown .rotor:after {
    height: 50% !important;
  }

  .flipdown .rotor-leaf-front,
  .flipdown .rotor-top {
    line-height: 5rem !important;
    border-radius: 8px 8px 0 0;
  }

  .flipdown .rotor-leaf-rear,
  .flipdown .rotor-bottom {
    line-height: 0 !important;
    border-radius: 0 0 8px 8px;
  }
}

@media (min-width: 900px) {
  .flipdown {
    gap: 1.75rem;
  }

  .flipdown .rotor {
    width: 3.75rem !important;
    height: 5.75rem !important;
    font-size: 3.15rem !important;
  }

  .flipdown .rotor-leaf-front,
  .flipdown .rotor-top {
    line-height: 5.75rem !important;
  }

  .flipdown .rotor-group:nth-child(2)::after,
  .flipdown .rotor-group:nth-child(3)::after {
    right: -1.1rem;
  }
}

/* Phone: days full-width on top; H:M:S row below */
@media (max-width: 640px) {
  .flipdown {
    width: 100% !important;
    max-width: 26rem;
    height: auto !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr;
    column-gap: 0.55rem;
    row-gap: 1.75rem;
    overflow: visible;
  }

  .flipdown .rotor-group {
    padding-right: 0 !important;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 0.4rem;
    justify-items: center;
  }

  .flipdown .rotor-group:first-child {
    grid-column: 1 / -1;
    column-gap: 0.55rem;
  }

  .flipdown .rotor-group-heading {
    grid-column: 1 / -1;
    width: 100%;
  }

  .flipdown .rotor-group-heading:before {
    height: 1.4rem !important;
    line-height: 1.4rem !important;
    font-size: 0.68rem !important;
  }

  .flipdown .rotor-group:nth-child(n + 2):nth-child(-n + 3):before,
  .flipdown .rotor-group:nth-child(n + 2):nth-child(-n + 3):after {
    display: none !important;
  }

  .flipdown .rotor-leaf,
  .flipdown .rotor-leaf-front,
  .flipdown .rotor-leaf-rear,
  .flipdown .rotor-top,
  .flipdown .rotor-bottom,
  .flipdown .rotor:after {
    width: 100% !important;
  }

  .flipdown .rotor-leaf {
    height: 100% !important;
  }

  .flipdown .rotor-leaf-front,
  .flipdown .rotor-leaf-rear,
  .flipdown .rotor-top,
  .flipdown .rotor-bottom,
  .flipdown .rotor:after {
    height: 50% !important;
  }

  /* Days — wide hero digits */
  .flipdown .rotor-group:first-child .rotor {
    width: min(42vw, 9.5rem) !important;
    height: min(28vw, 6.5rem) !important;
    margin: 0 !important;
    font-size: min(16vw, 3.75rem) !important;
    border-radius: 14px;
  }

  .flipdown .rotor-group:first-child .rotor-leaf-front,
  .flipdown .rotor-group:first-child .rotor-top {
    line-height: min(28vw, 6.5rem) !important;
    border-radius: 14px 14px 0 0;
  }

  .flipdown .rotor-group:first-child .rotor-leaf-rear,
  .flipdown .rotor-group:first-child .rotor-bottom {
    line-height: 0 !important;
    border-radius: 0 0 14px 14px;
  }

  /* Hours / minutes / seconds — compact row */
  .flipdown .rotor-group:not(:first-child) .rotor {
    width: clamp(2.35rem, 11.5vw, 3rem) !important;
    height: clamp(3.6rem, 18vw, 4.6rem) !important;
    margin: 0 !important;
    font-size: clamp(1.7rem, 8.5vw, 2.25rem) !important;
    border-radius: 10px;
  }

  .flipdown .rotor-group:not(:first-child) .rotor-leaf-front,
  .flipdown .rotor-group:not(:first-child) .rotor-top {
    line-height: clamp(3.6rem, 18vw, 4.6rem) !important;
    border-radius: 10px 10px 0 0;
  }

  .flipdown .rotor-group:not(:first-child) .rotor-leaf-rear,
  .flipdown .rotor-group:not(:first-child) .rotor-bottom {
    line-height: 0 !important;
    border-radius: 0 0 10px 10px;
  }
}
