:root {
  --ink: #1e1748;
  --purple: #6c4dff;
  --purple-soft: #b89cff;
  --cyan: #34d8ff;
  --lime: #d9ff39;
  --page-padding: 16px;
  --shadow: 0 6px 20px rgba(70, 50, 150, 0.09);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  background: #fff;
}

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background-color: #fff;
  background-image: url("assets/bg.jpg");
  background-position: top center;
  background-repeat: no-repeat;
  background-size: 100% auto;
  box-shadow: 0 0 38px rgba(35, 29, 74, 0.12);
}

main {
  padding: max(4px, env(safe-area-inset-top)) var(--page-padding) 126px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: auto;
  max-width: 168px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(91, 62, 198, 0.18));
}

.pressable {
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.pressable:active {
  transform: scale(0.97);
}

.pressable:focus-visible {
  outline: 3px solid rgba(52, 216, 255, 0.72);
  outline-offset: 2px;
}

.search-bar {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 0 14px;
  border: 1px solid rgba(139, 109, 255, 0.25);
  border-radius: 16px;
  color: #9695ad;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(84, 58, 167, 0.12), inset 0 1px 0 #fff;
  font-size: 13px;
  text-align: left;
}

.search-icon {
  position: relative;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid #807c96;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 2px;
  right: -5px;
  bottom: -2px;
  border-radius: 2px;
  background: #807c96;
  transform: rotate(45deg);
}

.search-icon {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid #807c96;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  right: -6px;
  bottom: -3px;
  border-radius: 2px;
  background: #807c96;
  transform: rotate(45deg);
}

.hero {
  margin-top: -7px;
}

.hero-button {
  width: 100%;
  display: block;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hero-button img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  margin-top: -11px;
}

.quick-card {
  min-width: 0;
  aspect-ratio: 0.78;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 15px;
  background: transparent;
  filter: drop-shadow(0 5px 9px rgba(64, 43, 130, 0.1));
}

.quick-card img,
.companion-card img,
.game-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.section {
  scroll-margin-top: 16px;
  margin-top: 19px;
}

.companions {
  margin-top: 9px;
}

.section-heading {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.section-heading > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-heading h2 {
  margin: 0;
  color: #171238;
  font-size: clamp(21px, 5.8vw, 25px);
  font-weight: 900;
  letter-spacing: -0.7px;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(184, 156, 255, 0.14);
}

.heading-mark {
  width: 7px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: linear-gradient(180deg, #7d59ff, #bea7ff);
  box-shadow: 0 3px 8px rgba(108, 77, 255, 0.25);
  transform: skew(-6deg);
}

.sparkles {
  color: #8667ff;
  font-size: 18px;
}

.more-button {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1.5px solid #b89cff;
  border-radius: 999px;
  color: #7b5be8;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 3px 9px rgba(99, 71, 188, 0.08);
  font-size: 12px;
  font-weight: 700;
}

.more-button span {
  margin-left: 2px;
  font-weight: 900;
}

.companion-list {
  display: flex;
  gap: 9px;
  margin-inline: calc(var(--page-padding) * -1);
  padding: 2px var(--page-padding) 5px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
}

.companion-list::-webkit-scrollbar {
  display: none;
}

.companion-card {
  width: 127px;
  height: 166px;
  flex: 0 0 127px;
  padding: 0;
  overflow: hidden;
  scroll-snap-align: start;
  border: 0;
  border-radius: 17px;
  background: transparent;
  filter: drop-shadow(0 7px 9px rgba(67, 51, 136, 0.12));
}

.scroll-hint {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 2px;
}

.scroll-hint i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #dedee8;
}

.scroll-hint i:first-child {
  width: 18px;
  border-radius: 10px;
  background: linear-gradient(90deg, #2ad7f8, #52e8ef);
}

.game-section {
  margin-top: 13px;
}

.game-heading {
  margin-bottom: 5px;
}

.game-heading h2 {
  font-size: clamp(25px, 7vw, 29px);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 7px;
  row-gap: 2px;
  align-items: start;
}

.game-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.game-card img {
  height: auto;
  filter: drop-shadow(0 5px 6px rgba(68, 47, 145, 0.08));
}

.game-card-zone img {
  border-radius: 14px;
}

.game-viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
}

.game-viewer[hidden] {
  display: none !important;
}

.game-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 12, 42, 0.78);
  backdrop-filter: blur(4px);
}

.game-viewer-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.game-viewer-media {
  width: 100%;
  max-height: calc(100vh - 86px);
  overflow: auto;
  background: transparent;
  scrollbar-width: none;
}

.game-viewer-media::-webkit-scrollbar {
  display: none;
}

.game-viewer-image {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
}

.game-viewer-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin-top: 12px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(36, 25, 82, 0.82);
  box-shadow: 0 4px 12px rgba(24, 16, 58, 0.28);
  font-size: 26px;
  line-height: 1;
}

.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 0;
  width: min(100%, 430px);
  height: calc(98px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateX(-50%);
  filter: drop-shadow(0 -8px 18px rgba(56, 43, 116, 0.1));
}

.bottom-nav::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 45px 0 0;
  background: rgba(255, 255, 255, 0.96);
}

.bottom-nav-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  background: url("assets/bottom-nav.png") center / 100% auto no-repeat;
  pointer-events: none;
}

.nav-hit {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
}

.nav-hit-center {
  transform-origin: center 65%;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(108px + env(safe-area-inset-bottom));
  max-width: min(310px, calc(100vw - 48px));
  padding: 9px 16px;
  border: 1px solid rgba(184, 156, 255, 0.45);
  border-radius: 999px;
  color: #fff;
  background: rgba(36, 25, 82, 0.9);
  box-shadow: 0 8px 24px rgba(28, 18, 70, 0.18);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 365px) {
  :root {
    --page-padding: 13px;
  }

  .quick-actions {
    gap: 2px;
  }

  .game-grid {
    column-gap: 5px;
    row-gap: 1px;
  }

  .more-button {
    padding-inline: 9px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .pressable,
  .toast {
    transition: none;
  }
}
