:root {
  color-scheme: light;
  --bg-1: #ffffff;
  --bg-2: #f4f4f4;
  --bg-3: #ededed;
  --ambient-1: rgba(0, 0, 0, 0.06);
  --ambient-2: rgba(0, 0, 0, 0.05);
  --glow: #111111;
  --text: #0a0a0a;
  --muted: #4a4a4a;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: rgba(255, 255, 255, 1);
  --outline: rgba(0, 0, 0, 0.08);
  --highlight: rgba(0, 0, 0, 0.12);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.1);
  --icon-card-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(240, 240, 240, 0.92));
  --icon-card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --focus-border-strong: rgba(0, 0, 0, 0.18);
  --hover-border-strong: rgba(0, 0, 0, 0.2);
  --active-shadow: 0 18px 38px rgba(0, 0, 0, 0.12);
  --modal-bg: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.35));
  --confirm-card-bg: linear-gradient(150deg, rgba(255, 255, 255, 0.98), rgba(242, 242, 242, 0.92));
  --confirm-card-border: rgba(0, 0, 0, 0.14);
  --confirm-card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  --blur: blur(10px);
  --title-size: clamp(40px, 6vw, 64px);
  --title-offset: 32px;
  --splash-duration: 1800ms;
  --intro-overlap: 260ms;
  --menu-entrance-delay: 260ms;
  --motion-smooth: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-1: #0c1118;
  --bg-2: #111925;
  --bg-3: #161f2f;
  --ambient-1: rgba(125, 174, 255, 0.14);
  --ambient-2: rgba(102, 215, 255, 0.11);
  --glow: #ecf3ff;
  --text: #e5eefc;
  --muted: #9bb0ce;
  --panel: rgba(20, 27, 39, 0.88);
  --panel-strong: rgba(30, 39, 55, 0.96);
  --outline: rgba(173, 200, 243, 0.24);
  --highlight: rgba(191, 219, 255, 0.18);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.42);
  --icon-card-bg: linear-gradient(160deg, rgba(33, 44, 64, 0.95), rgba(21, 30, 47, 0.96));
  --icon-card-inset: inset 0 1px 0 rgba(214, 231, 255, 0.13);
  --focus-border-strong: rgba(209, 227, 255, 0.48);
  --hover-border-strong: rgba(209, 227, 255, 0.44);
  --active-shadow: 0 18px 38px rgba(0, 0, 0, 0.3);
  --modal-bg: radial-gradient(circle at 50% 45%, rgba(9, 16, 30, 0.4), rgba(4, 8, 16, 0.72));
  --confirm-card-bg: linear-gradient(150deg, rgba(27, 36, 52, 0.98), rgba(19, 27, 41, 0.94));
  --confirm-card-border: rgba(176, 206, 255, 0.26);
  --confirm-card-inset: inset 0 1px 0 rgba(222, 236, 255, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  color: var(--text);
  overflow-x: hidden;
  overflow-y: hidden;
  background-attachment: fixed;
  overscroll-behavior-x: none;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
}

img {
  max-width: 100%;
  display: block;
}

button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.phi-splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
  animation: splash-fade var(--splash-duration) cubic-bezier(0.3, 0, 0.2, 1) forwards;
}

.phi-mark {
  width: clamp(120px, 16vw, 180px);
  height: auto;
  overflow: visible;
}

.phi-elem {
  stroke: var(--glow);
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: center;
  will-change: transform, opacity, stroke-dashoffset, stroke-dasharray;
}

.phi-ring {
  --start-x: 55vw;
  --start-y: -55vh;
  stroke-dasharray: 280;
  stroke-dashoffset: 280;
  animation: phi-drift var(--splash-duration) cubic-bezier(0.3, 0, 0.2, 1) forwards,
    phi-ring-draw var(--splash-duration) cubic-bezier(0.3, 0, 0.2, 1) forwards;
}

.phi-stem {
  --start-x: -55vw;
  --start-y: 55vh;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: phi-drift var(--splash-duration) cubic-bezier(0.3, 0, 0.2, 1) forwards,
    phi-stem-draw var(--splash-duration) cubic-bezier(0.3, 0, 0.2, 1) forwards;
}

.backdrop {
  display: none;
}

.intro {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--title-offset) 40px 0;
  display: flex;
  justify-content: flex-start;
  gap: 24px;
  pointer-events: none;
  z-index: 2;
}

.title-card {
  text-align: left;
  opacity: 0;
  transform: translate3d(0, 10px, 0);
  filter: blur(3px);
  transition: opacity 700ms var(--motion-smooth), transform 900ms var(--motion-smooth),
    filter 560ms ease-out;
}

.title-card h1 {
  margin: 0;
  font-size: var(--title-size);
  font-weight: 700;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--glow);
  text-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
}

.intro.is-visible .title-card {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  filter: blur(0);
}

.hud {
  position: absolute;
  top: calc(var(--title-offset) + (var(--title-size) * 0.5));
  right: 4%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, calc(-50% + 8px), 0);
  filter: blur(2px);
  transition: opacity 480ms ease-out, transform 700ms var(--motion-smooth), filter 480ms ease-out;
}

.hud.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, -50%, 0);
  filter: blur(0);
}

.clock {
  min-width: 120px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 8px 14px;
  background: var(--panel);
  backdrop-filter: var(--blur);
  text-align: right;
  letter-spacing: 0.08em;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.xmb {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(0.994);
  filter: blur(7px);
  transition: opacity 720ms ease-out, transform 880ms var(--motion-smooth), filter 640ms ease-out;
  pointer-events: none;
  z-index: 1;
}

.xmb.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

.xmb-main {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: clamp(28px, 4vw, 64px);
  align-items: flex-start;
  width: min(1200px, 92vw);
  min-height: 540px;
}

.xmb-title {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  min-height: 440px;
  opacity: 0.32;
  transform: translateY(16px);
  filter: saturate(0.7);
  transition: transform 200ms ease, opacity 200ms ease, filter 200ms ease;
}

.xmb-title.is-active {
  opacity: 1;
  transform: translateY(0);
  filter: saturate(1);
}

.category-chip:focus-visible {
  outline: 2px solid var(--outline);
  outline-offset: 8px;
}

.category-chip:hover .category-icon {
  transform: scale(1.03);
}

.category-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.category-icon {
  width: 82px;
  height: 82px;
  border-radius: 20px;
  padding: 14px;
  background: var(--icon-card-bg);
  border: 1px solid var(--outline);
  box-shadow: var(--icon-card-inset), var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 160ms ease;
}

.category-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--text);
  mask-image: var(--icon-url);
  mask-size: 56%;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: var(--icon-url);
  -webkit-mask-size: 56%;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  opacity: 0.65;
  transition: opacity 180ms ease;
}

.xmb-title.is-active .category-icon {
  transform: scale(1.05);
  border-color: var(--focus-border-strong);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.14), var(--icon-card-inset);
}

.xmb-title.is-active .category-icon::after {
  opacity: 0.94;
}

.title-label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 160ms ease;
}

.xmb-title.is-active .title-label {
  opacity: 0.86;
  color: var(--text);
}

.xmb-contents {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  width: 340px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  filter: blur(2px);
  transition: opacity 180ms ease, filter 200ms ease, transform 220ms ease;
}

.xmb-title.is-active .xmb-contents {
  opacity: 1;
  pointer-events: auto;
  filter: none;
  transform: translateX(-50%) translateY(0);
}

.submenu {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--outline);
  background: var(--panel);
  box-shadow: var(--shadow);
  opacity: 0.6;
  transform: translateY(0);
  transition: transform 200ms ease, opacity 180ms ease, border-color 160ms ease,
    background 180ms ease;
}

.submenu:hover,
.submenu:focus-visible {
  opacity: 0.9;
  border-color: var(--hover-border-strong);
  transform: translateY(-2px);
}

.submenu.is-active {
  opacity: 1;
  background: var(--panel-strong);
  border-color: var(--focus-border-strong);
  box-shadow: var(--active-shadow);
  transform: translateY(0) scale(1.01);
}

.submenu .thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.15), transparent 60%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid var(--outline);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.submenu .thumb img {
  width: 60%;
  height: 60%;
  object-fit: contain;
}

:root[data-theme="dark"] .submenu .thumb img.icon-asset {
  filter: brightness(0) invert(1) opacity(0.92);
}

.submenu .meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-title {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
}

.meta-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.noscript {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: #400;
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--modal-bg);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 5;
}

.confirm-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.confirm-card {
  background: var(--confirm-card-bg);
  border: 1px solid var(--confirm-card-border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.2),
    var(--confirm-card-inset);
  min-width: 280px;
  max-width: 340px;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.confirm-card.about-card {
  max-width: 480px;
  min-width: 340px;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-scroll {
  max-height: 240px;
  overflow: auto;
  padding: 0;
  color: var(--text);
  line-height: 1.5;
  outline: none;
}

.confirm-modal.is-visible .confirm-card {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.confirm-text {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--outline);
  background: var(--panel);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  border-color: var(--hover-border-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.btn.solid {
  background: linear-gradient(135deg, #0f0f0f, #1a1a1a);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.65);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
}

.btn.ghost {
  background: var(--panel);
  color: var(--text);
}

@media (max-width: 1100px) {
  .xmb-main {
    gap: clamp(20px, 3vw, 40px);
  }

  .xmb-contents {
    width: 300px;
  }
}

@media (max-width: 820px) {
  :root {
    --mobile-tile: 112px;
    --mobile-offset: 32vw;
    --mobile-carousel-height: 168px;
    --mobile-carousel-shift: 22px;
    --mobile-stack-shift: 10px;
  }

  body {
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    touch-action: pan-y;
  }

  .intro {
    position: static;
    padding: 24px 16px 0;
    justify-content: center;
  }

  .title-card {
    text-align: center;
  }

  .title-card h1 {
    font-size: clamp(42px, 11vw, 64px);
  }

  .hud {
    position: static;
    transform: none;
    align-items: center;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  .hud.is-visible {
    transform: none;
  }

  .clock {
    width: fit-content;
    max-width: 82vw;
    min-width: 0;
    text-align: center;
    font-size: 12px;
    padding: 8px 14px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .xmb {
    padding: calc(12px + var(--mobile-stack-shift)) 0 48px;
    display: flex;
    align-items: flex-start;
    width: 100%;
    flex-direction: column;
    justify-content: flex-start;
  }

  .xmb-main {
    position: relative;
    display: block;
    width: 100%;
    margin: var(--mobile-carousel-shift) auto 0;
    height: calc(var(--mobile-carousel-height) - var(--mobile-carousel-shift));
    min-height: calc(var(--mobile-carousel-height) - var(--mobile-carousel-shift));
    overflow: visible;
    touch-action: pan-y;
    order: 1;
    padding-top: 10px;
  }

  .category-chip,
  .submenu {
    -webkit-tap-highlight-color: transparent;
  }

  .category-chip:focus,
  .submenu:focus {
    outline: none;
  }

  .xmb-main.dragging .xmb-title {
    transition: none;
  }

  .xmb-contents {
    display: none !important;
  }

  .xmb-title {
    min-height: auto;
    opacity: 0.4;
    pointer-events: none;
    filter: saturate(0.8);
    transition:
      transform 260ms cubic-bezier(0.22, 1.22, 0.25, 1),
      opacity 200ms ease,
      filter 200ms ease;
    width: var(--mobile-tile);
    text-align: center;
    display: none;
    position: absolute;
    top: 0;
    touch-action: pan-y;
    left: 50%;
    will-change: transform;
    transform: translate3d(calc(-50% + var(--slot-x, 0px) + var(--mobile-drag, 0px)),
        0,
        0) scale(0.94);
  }

  .category-icon {
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }

  .xmb-title.is-active .category-icon {
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.92);
  }

  .title-label {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 160ms ease, transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .xmb-title.is-active .title-label {
    opacity: 0.92;
    transform: translateY(0);
  }

  .xmb-main.dragging .title-label {
    opacity: 0 !important;
    transform: translateY(-8px);
    transition-delay: 0ms !important;
  }

  .xmb-main.settling .xmb-title.is-active .title-label {
    transition-delay: 110ms;
  }

  .xmb-title[data-distance="0"] {
    opacity: 1;
    pointer-events: auto;
    filter: saturate(1);
    display: flex;
    transform: translate3d(calc(-50% + var(--slot-x, 0px) + var(--mobile-drag, 0px)),
        0,
        0) scale(1.05);
    z-index: 3;
  }

  .xmb-title[data-distance="-1"],
  .xmb-title[data-distance="1"] {
    opacity: 0.85;
    pointer-events: auto;
    display: flex;
    z-index: 2;
  }

  .xmb-title[data-distance="-2"],
  .xmb-title[data-distance="2"] {
    opacity: 0.45;
    pointer-events: none;
    display: flex;
    z-index: 1;
    transform: translate3d(calc(-50% + var(--slot-x, 0px) + var(--mobile-drag, 0px)),
        0,
        0) scale(0.84);
  }

  .xmb-title[data-distance="-1"] {
    transform: translate3d(calc(-50% + var(--slot-x, 0px) + var(--mobile-drag, 0px)),
        0,
        0) scale(0.92);
  }

  .xmb-title[data-distance="1"] {
    transform: translate3d(calc(-50% + var(--slot-x, 0px) + var(--mobile-drag, 0px)),
        0,
        0) scale(0.92);
  }

  .mobile-items {
    order: 2;
    align-self: stretch;
    width: 100%;
    margin: 0 auto 0;
    padding-bottom: 60px;
  }

  .mobile-items-list {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    width: min(520px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .mobile-items-list .submenu {
    width: 100%;
  }

  .mobile-items-list .submenu .meta {
    align-items: flex-start;
    text-align: left;
  }

  .mobile-items-list .submenu .meta-title,
  .mobile-items-list .submenu .meta-sub {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes phi-drift {
  0% {
    transform: translate(var(--start-x), var(--start-y));
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  40% {
    transform: translate(0, 0);
    opacity: 1;
  }

  60% {
    transform: translate(0, 0);
    opacity: 1;
  }

  100% {
    transform: translate(var(--start-x), var(--start-y));
    opacity: 0;
  }
}

@keyframes splash-fade {

  0%,
  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes phi-ring-draw {
  0% {
    stroke-dashoffset: 280;
  }

  40% {
    stroke-dashoffset: 0;
  }

  70% {
    stroke-dashoffset: 0;
  }

  100% {
    stroke-dashoffset: -280;
  }
}

@keyframes phi-stem-draw {
  0% {
    stroke-dashoffset: 200;
  }

  35% {
    stroke-dashoffset: 0;
  }

  70% {
    stroke-dashoffset: 0;
  }

  100% {
    stroke-dashoffset: -200;
  }
}
