:root {
  --navy: #0c2e5d;
  --deep-blue: #133e76;
  --card-blue: #071b35;
  --card-blue-bottom: #06172e;
  --gold: #c9a35d;
  --light-gold: #e5c98b;
  --white: #ffffff;
  --graphite: #2f3542;
  --card-width: min(12.4vw, 34vh);
  --card-radius: clamp(12px, 1.15vw, 24px);
  --page-x: clamp(24px, 4.1vw, 78px);
  --page-y: clamp(20px, 3.4vh, 46px);
  --flip-duration: 340ms;
}

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

html {
  height: 100%;
  background: var(--navy);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--white);
  background:
    radial-gradient(circle at 9% 48%, rgba(24, 82, 143, 0.48), transparent 33%),
    radial-gradient(circle at 91% 32%, rgba(24, 91, 157, 0.38), transparent 37%),
    linear-gradient(118deg, #08264e 0%, var(--navy) 46%, var(--deep-blue) 100%);
  font-family: "Avenir Next", Avenir, Montserrat, "Segoe UI", Arial, sans-serif;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  background: #0a2a55;
  opacity: 0;
  transition: opacity 600ms ease;
}

body.is-loading::after {
  opacity: 1;
}

.background-art {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.background-art::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image: linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, transparent, #000 26%, #000 76%, transparent);
}

.background-art__glow {
  position: absolute;
  width: 42vw;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
}

.background-art__glow--left {
  top: 18%;
  left: -22%;
  background: #2c79c2;
}

.background-art__glow--right {
  top: -17%;
  right: -18%;
  background: #1b73c3;
}

.background-art__symbol {
  position: absolute;
  top: 4vh;
  right: -8vw;
  width: min(61vw, 930px);
  opacity: 0.045;
  filter: grayscale(1) brightness(0) invert(1);
  transform: rotate(-1deg);
}

.background-art__line {
  position: absolute;
  right: -10vw;
  width: 73vw;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(229, 201, 139, 0.16), transparent);
  transform-origin: center;
}

.background-art__line--one {
  top: 29%;
  transform: rotate(-32deg);
}

.background-art__line--two {
  top: 66%;
  transform: rotate(24deg);
  opacity: 0.4;
}

.clock-app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding: var(--page-y) var(--page-x) clamp(26px, 4.6vh, 58px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  gap: 32px;
  min-height: clamp(82px, 11.5vh, 132px);
}

.brand {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.brand__logo {
  display: block;
  width: clamp(310px, 28vw, 535px);
  height: auto;
  max-height: clamp(78px, 10.5vh, 120px);
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 5px 14px rgba(0, 0, 0, 0.12));
}

.current-date {
  max-width: 52vw;
  margin-top: clamp(15px, 2.5vh, 30px);
  color: rgba(255, 255, 255, 0.94);
  font-size: clamp(10px, 1vw, 18px);
  font-weight: 500;
  letter-spacing: clamp(0.18em, 0.36vw, 0.42em);
  line-height: 1.4;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.daily-message {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: clamp(68px, 10.5vh, 116px);
  padding: 0 5vw clamp(6px, 1vh, 12px);
  text-align: center;
}

.daily-message.is-changing {
  animation: message-in 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.daily-message__label {
  display: block;
  margin-bottom: clamp(8px, 1.1vh, 14px);
  color: var(--light-gold);
  font-size: clamp(9px, 0.83vw, 15px);
  font-weight: 650;
  letter-spacing: clamp(0.34em, 0.48vw, 0.58em);
  line-height: 1;
  text-transform: uppercase;
}

.daily-message__text {
  max-width: 1500px;
  margin: 0;
  color: rgba(255, 255, 255, 0.97);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2vw, 38px);
  font-weight: 400;
  letter-spacing: 0.012em;
  line-height: 1.2;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.16);
}

.clock-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: clamp(8px, 1.2vh, 16px) 0 clamp(14px, 2vh, 24px);
  perspective: 1600px;
}

.clock-scene {
  --scene-scale: 1;
  --digits-width: 80vw;
  --mascot-height: calc(var(--card-width) * 2.7);
  --mascot-width: calc(var(--mascot-height) * 2 / 3);

  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--digits-width) + var(--mascot-width) * 0.69);
  height: var(--mascot-height);
  transform: translate(-50%, -50%) scale(var(--scene-scale));
  transform-origin: center center;
}

.clock-mascot {
  position: absolute;
  top: 0;
  left: calc(var(--digits-width) - var(--mascot-width) * 0.31);
  z-index: 9;
  display: block;
  width: var(--mascot-width);
  height: var(--mascot-height);
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.flip-clock {
  position: absolute;
  top: calc(var(--mascot-height) * 0.27);
  left: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 3.4vw, 80px);
  width: max-content;
  max-width: none;
}

.digit-group {
  display: flex;
  min-width: 0;
  gap: clamp(6px, 0.55vw, 12px);
}

.flip-card {
  position: relative;
  width: var(--card-width);
  aspect-ratio: 0.73;
  border: 1px solid rgba(229, 201, 139, 0.2);
  border-radius: var(--card-radius);
  background: var(--card-blue);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.08) inset,
    0 -1px 0 rgba(0, 0, 0, 0.4) inset,
    0 18px 28px rgba(0, 8, 25, 0.27),
    0 4px 8px rgba(0, 8, 25, 0.34);
  transform: translateZ(0);
  isolation: isolate;
}

.flip-card::before {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  z-index: 3;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, #020915, rgba(0, 0, 0, 0.72), #020915);
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.045),
    0 1px 0 rgba(0, 0, 0, 0.48);
  transform: translateY(-1px);
}

.flip-card::after {
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.045), transparent 24%),
    radial-gradient(circle at 50% 12%, rgba(30, 88, 145, 0.16), transparent 48%);
}

.card-half,
.flip-panel {
  position: absolute;
  right: 0;
  left: 0;
  height: 50%;
  overflow: hidden;
  background: linear-gradient(145deg, #0a213f 0%, var(--card-blue) 62%, #06162c 100%);
}

.card-half--top,
.flip-panel--top {
  top: 0;
  border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0;
}

.card-half--bottom,
.flip-panel--bottom {
  bottom: 0;
  border-radius: 0 0 calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px);
  background: linear-gradient(145deg, #071b35 0%, var(--card-blue-bottom) 100%);
}

.card-half__number,
.flip-panel__number {
  position: absolute;
  left: 0;
  display: grid;
  width: 100%;
  height: 200%;
  place-items: center;
  color: var(--white);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  font-size: calc(var(--card-width) * 1.16);
  font-stretch: condensed;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.12),
    0 8px 18px rgba(0, 0, 0, 0.2);
  transform: scaleX(0.82);
  transform-origin: center;
  user-select: none;
}

.card-half--top .card-half__number,
.flip-panel--top .flip-panel__number {
  top: 0;
}

.card-half--bottom .card-half__number,
.flip-panel--bottom .flip-panel__number {
  bottom: 0;
}

.flip-panel {
  z-index: 2;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  will-change: transform;
}

.flip-panel--top {
  transform-origin: center bottom;
  animation: flip-fold var(--flip-duration) cubic-bezier(0.55, 0.08, 0.68, 0.53) forwards;
}

.flip-panel--bottom {
  z-index: 4;
  transform: rotateX(90deg);
  transform-origin: center top;
  animation: flip-unfold var(--flip-duration) cubic-bezier(0.22, 0.61, 0.36, 1)
    var(--flip-duration) forwards;
}

.flip-card__hinge {
  position: absolute;
  top: 50%;
  z-index: 8;
  width: clamp(5px, 0.42vw, 9px);
  height: clamp(28px, 3.8vw, 55px);
  border: 1px solid rgba(255, 244, 209, 0.52);
  border-radius: 2px;
  background: linear-gradient(90deg, #9c7228, #f0d591 50%, #8b651f);
  box-shadow:
    0 0 0 2px rgba(1, 11, 26, 0.88),
    0 4px 8px rgba(0, 0, 0, 0.36),
    0 0 9px rgba(229, 201, 139, 0.2);
  transform: translateY(-50%);
}

.flip-card__hinge--left {
  left: clamp(-4px, -0.2vw, -2px);
}

.flip-card__hinge--right {
  right: clamp(-4px, -0.2vw, -2px);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 2.2vw, 46px);
  min-height: clamp(42px, 6vh, 66px);
}

.footer__line {
  width: clamp(62px, 7vw, 132px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--light-gold));
}

.footer__line:last-child {
  background: linear-gradient(90deg, var(--light-gold), transparent);
}

.footer__slogan {
  margin: 0;
  color: var(--light-gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(12px, 1.3vw, 24px);
  font-weight: 400;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.fullscreen-button {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  place-items: center;
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(229, 201, 139, 0.34);
  border-radius: 50%;
  outline: none;
  background: rgba(3, 20, 43, 0.46);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.17);
  opacity: 0.34;
  backdrop-filter: blur(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.fullscreen-button:hover,
.fullscreen-button:focus-visible {
  border-color: rgba(229, 201, 139, 0.85);
  background: rgba(3, 20, 43, 0.78);
  opacity: 1;
  transform: translateY(-2px);
}

.fullscreen-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(229, 201, 139, 0.32);
}

.fullscreen-button__icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.fullscreen-button__icon--exit {
  display: none;
}

.fullscreen-button[aria-pressed="true"] .fullscreen-button__icon--enter {
  display: none;
}

.fullscreen-button[aria-pressed="true"] .fullscreen-button__icon--exit {
  display: block;
}

.noscript-warning {
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: 20px;
  z-index: 30;
  padding: 14px 18px;
  color: #231a0b;
  border-radius: 8px;
  background: var(--light-gold);
  font-size: 14px;
  text-align: center;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes flip-fold {
  0% {
    filter: brightness(1);
    transform: rotateX(0deg);
  }

  100% {
    filter: brightness(0.55);
    transform: rotateX(-90deg);
  }
}

@keyframes flip-unfold {
  0% {
    filter: brightness(0.58);
    transform: rotateX(90deg);
  }

  100% {
    filter: brightness(1);
    transform: rotateX(0deg);
  }
}

@keyframes message-in {
  0% {
    opacity: 0;
    transform: translateY(-7px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-aspect-ratio: 4 / 3) {
  :root {
    --card-width: min(14vw, 28vh);
    --page-x: clamp(18px, 3vw, 42px);
  }

  .topbar {
    align-items: center;
  }

  .brand__logo {
    width: clamp(235px, 42vw, 400px);
  }

  .flip-clock {
    gap: clamp(10px, 2vw, 28px);
  }
}

@media (max-width: 700px) {
  :root {
    --card-width: 14.2vw;
    --card-radius: 10px;
    --page-y: 18px;
  }

  .clock-app {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topbar {
    display: grid;
    justify-items: center;
    gap: 5px;
    min-height: 112px;
  }

  .brand__logo {
    width: min(78vw, 380px);
    object-position: center;
  }

  .current-date {
    max-width: 100%;
    margin-top: 0;
    font-size: 9px;
    letter-spacing: 0.18em;
    text-align: center;
  }

  .daily-message {
    min-height: 86px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .daily-message__text {
    font-size: clamp(15px, 4.4vw, 22px);
  }

  .flip-clock {
    gap: 1.8vw;
  }

  .digit-group {
    gap: 0.5vw;
  }

  .flip-card__hinge {
    width: 4px;
    height: 23px;
  }

  .footer {
    gap: 12px;
  }

  .footer__line {
    width: 28px;
  }

  .footer__slogan {
    max-width: 70vw;
    font-size: 10px;
    white-space: normal;
  }
}

@media (max-height: 820px) and (min-aspect-ratio: 4 / 3) {
  :root {
    --card-width: min(11.8vw, 31vh);
    --page-y: 18px;
  }

  .topbar {
    min-height: 78px;
  }

  .brand__logo {
    max-height: 76px;
  }

  .current-date {
    margin-top: 10px;
  }

  .daily-message {
    min-height: 66px;
  }

  .daily-message__label {
    margin-bottom: 6px;
  }

  .clock-stage {
    padding-top: 5px;
    padding-bottom: 8px;
  }

  .footer {
    min-height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --flip-duration: 1ms;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}
