:root {
  --mobile-topbar-height: 64px;
  --mobile-touch-size: 48px;
  --mobile-main-button-height: 56px;
  --mobile-safe-top: env(safe-area-inset-top, 0px);
  --mobile-safe-right: env(safe-area-inset-right, 0px);
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-safe-left: env(safe-area-inset-left, 0px);
}

.mobile-topbar,
.mobile-menu,
.mobile-loading-layer {
  display: none;
}

.fixed-animation-layer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: max(18px, var(--mobile-safe-top)) max(18px, var(--mobile-safe-right))
    max(18px, var(--mobile-safe-bottom)) max(18px, var(--mobile-safe-left));
  background: rgba(8, 18, 24, 0.9);
  backdrop-filter: blur(10px);
}

.fixed-animation-card {
  position: relative;
  width: min(960px, 100%);
  max-height: 92svh;
  overflow: hidden;
  border: 1px solid rgba(227, 184, 91, 0.65);
  border-radius: 16px;
  background: #08141c;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.fixed-animation-card video {
  display: block;
  width: 100%;
  max-height: 86svh;
  object-fit: contain;
  background: #050b10;
}

.fixed-animation-layer.is-fullscreen {
  padding: 0;
  background: #050b10;
  backdrop-filter: none;
}

.fixed-animation-layer.is-fullscreen .fixed-animation-card {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.fixed-animation-layer.is-fullscreen .fixed-animation-card video {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
}

.fixed-animation-layer.is-fullscreen .fixed-animation-actions {
  top: max(12px, var(--mobile-safe-top));
  right: max(12px, var(--mobile-safe-right));
}

.fixed-animation-actions {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 10px;
}

.fixed-animation-actions button {
  min-width: 48px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(255, 239, 197, 0.66);
  border-radius: 999px;
  color: #fff8dc;
  background: rgba(20, 31, 34, 0.76);
  font: inherit;
  cursor: pointer;
}

@media (max-width: 700px) {
  html {
    min-width: 320px;
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    font-size: 17px;
  }

  body {
    min-width: 320px;
    height: auto;
    min-height: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }

  body.mobile-menu-open {
    overflow: hidden !important;
  }

  body > main .site-header {
    display: none !important;
  }

  button,
  a,
  input,
  textarea {
    touch-action: manipulation;
  }

  .mobile-topbar {
    position: fixed;
    z-index: 980;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    min-height: calc(var(--mobile-topbar-height) + var(--mobile-safe-top));
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: var(--mobile-safe-top) max(14px, var(--mobile-safe-right)) 0
      max(14px, var(--mobile-safe-left));
    color: #fff3c1;
    background: linear-gradient(180deg, rgba(17, 34, 37, 0.96), rgba(17, 34, 37, 0.82));
    border-bottom: 1px solid rgba(221, 174, 72, 0.34);
    box-shadow: 0 6px 24px rgba(7, 18, 22, 0.24);
    backdrop-filter: blur(12px);
  }

  .mobile-topbar-brand {
    display: inline-flex;
    min-height: var(--mobile-touch-size);
    align-items: center;
    gap: 10px;
    color: inherit;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: 1.16rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-decoration: none;
  }

  .mobile-topbar-seal {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(255, 225, 143, 0.7);
    border-radius: 50%;
    color: #6c471d;
    background: radial-gradient(circle, #fff3be, #d69a3a);
    font-size: 0.84rem;
  }

  .mobile-menu-button {
    min-width: 76px;
    min-height: 48px;
    border: 1px solid rgba(255, 230, 164, 0.62);
    border-radius: 999px;
    color: #fff7d3;
    background: rgba(113, 70, 24, 0.46);
    font: inherit;
    font-weight: 700;
  }

  .mobile-menu[hidden] {
    display: none;
  }

  .mobile-menu {
    position: fixed;
    z-index: 1100;
    inset: 0;
    display: grid;
    padding: max(14px, var(--mobile-safe-top)) max(14px, var(--mobile-safe-right))
      max(14px, var(--mobile-safe-bottom)) max(14px, var(--mobile-safe-left));
    background: rgba(5, 17, 22, 0.66);
    backdrop-filter: blur(8px);
  }

  .mobile-menu-panel {
    align-self: stretch;
    display: flex;
    width: 100%;
    max-width: 520px;
    max-height: calc(100svh - var(--mobile-safe-top) - var(--mobile-safe-bottom) - 28px);
    margin-left: auto;
    flex-direction: column;
    overflow: auto;
    border: 1px solid rgba(224, 181, 83, 0.62);
    border-radius: 18px;
    color: #4f351b;
    background: linear-gradient(180deg, rgba(255, 249, 224, 0.99), rgba(235, 204, 139, 0.98));
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  }

  .mobile-menu-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 10px;
  }

  .mobile-menu-heading strong {
    font-family: "STKaiti", "KaiTi", serif;
    font-size: 1.42rem;
  }

  .mobile-menu-close {
    width: 48px;
    height: 48px;
    border: 1px solid rgba(116, 75, 30, 0.28);
    border-radius: 50%;
    color: #5e3e1c;
    background: rgba(255, 252, 230, 0.76);
    font-size: 1.7rem;
  }

  .mobile-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px 18px 18px;
  }

  .mobile-menu-link {
    display: grid;
    min-height: 84px;
    place-items: center;
    padding: 12px 8px;
    border: 1px solid rgba(129, 85, 32, 0.3);
    border-radius: 13px;
    color: #5b3a1c;
    text-align: center;
    text-decoration: none;
    background: rgba(255, 253, 237, 0.68);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }

  .mobile-menu-link[aria-current="page"] {
    border-color: #8b5b20;
    color: #fff9dc;
    background: linear-gradient(180deg, #9d6a2b, #684018);
    box-shadow: 0 8px 18px rgba(91, 54, 20, 0.24);
  }

  .mobile-menu-footer {
    display: grid;
    gap: 12px;
    margin-top: auto;
    padding: 16px 18px 20px;
    border-top: 1px solid rgba(123, 80, 31, 0.18);
  }

  .mobile-menu-ancestor,
  .mobile-menu-member {
    margin: 0;
    line-height: 1.55;
  }

  .mobile-menu-change,
  .mobile-menu-logout {
    min-height: 48px;
    border: 1px solid rgba(119, 76, 29, 0.3);
    border-radius: 12px;
    color: #68431d;
    background: rgba(255, 251, 229, 0.72);
    font: inherit;
    text-align: center;
    text-decoration: none;
  }

  .mobile-menu-change {
    display: none;
    align-items: center;
    justify-content: center;
  }

  .mobile-menu-change.is-visible {
    display: flex;
  }

  .mobile-loading-layer {
    position: fixed;
    z-index: 1080;
    inset: 0;
    display: none;
    place-items: center;
    padding: 24px;
    color: #fff4c9;
    text-align: center;
    background: rgba(10, 30, 38, 0.82);
    backdrop-filter: blur(8px);
  }

  .mobile-loading-layer.is-visible {
    display: grid;
  }

  .mobile-loading-card {
    display: grid;
    justify-items: center;
    gap: 12px;
  }

  .mobile-loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 239, 190, 0.24);
    border-top-color: #f5cf75;
    border-radius: 50%;
    animation: mobile-spin 850ms linear infinite;
  }

  .mobile-loading-retry {
    display: none;
    min-height: 48px;
    padding: 0 22px;
    border: 1px solid rgba(255, 235, 178, 0.72);
    border-radius: 999px;
    color: #55330f;
    background: #f4ce78;
    font: inherit;
  }

  .mobile-loading-layer.is-slow .mobile-loading-retry {
    display: inline-flex;
    align-items: center;
  }

  .fixed-animation-layer {
    padding: max(10px, var(--mobile-safe-top)) max(10px, var(--mobile-safe-right))
      max(10px, var(--mobile-safe-bottom)) max(10px, var(--mobile-safe-left));
  }

  .fixed-animation-card {
    border-radius: 12px;
  }

  .fixed-animation-card video {
    max-height: calc(100svh - var(--mobile-safe-top) - var(--mobile-safe-bottom) - 20px);
  }
}

@keyframes mobile-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-loading-spinner {
    animation: none;
    border-top-color: rgba(255, 239, 190, 0.7);
  }
}
