/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio.
   Put this @layer first; product CSS outside the layer always wins. */
@layer od-layout {
  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }
  .od-nowrap  { white-space: nowrap; }
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; }

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
/* /OD-LAYOUT-PRIMITIVES v1 */

:root {
  color-scheme: dark;
  --background: #1f2128;
  --foreground: #ffffff;
  --accent: #ff5722;
  --surface: #242731;
  --muted: #b2b3bd;
  --border: #36383e;
  --font-ui: "PingFang SC", "PingFangSC-Regular", "Microsoft YaHei", sans-serif;
  --font-number: "DIN Medium", "PingFang SC", "Microsoft YaHei", sans-serif;
  --content-width: 1312px;
  --header-height: 80px;
  --radius: 8px;
  --ease: 180ms ease-out;
}

@font-face {
  font-family: "DIN Medium";
  src: url("assets/home/fonts/DIN-Medium.ttf") format("truetype");
  font-display: swap;
  font-style: normal;
  font-weight: 500;
}

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

html {
  scroll-behavior: smooth;
  background: var(--background);
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
[tabindex] {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

.page-shell {
  width: min(var(--content-width), calc(100% - 128px));
  margin-inline: auto;
}

.site-header {
  position: fixed;
  z-index: 1000;
  top: 0;
  right: 0;
  left: 0;
  height: var(--header-height);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: var(--background);
}

.header-inner {
  display: flex;
  width: min(1368px, calc(100% - 72px));
  height: 100%;
  margin-inline: auto;
  align-items: center;
}

.brand {
  display: flex;
  width: 126px;
  flex: none;
  align-items: center;
}

.brand img {
  display: block;
  width: 126px;
  height: auto;
}

.primary-nav {
  display: flex;
  height: 100%;
  margin-left: 72px;
  align-items: stretch;
  gap: 44px;
}

.nav-link,
.game-trigger {
  position: relative;
  display: flex;
  min-width: 48px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--ease);
}

.nav-link::after,
.game-trigger::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(.4);
  transition: opacity var(--ease), transform var(--ease);
}

.nav-link[aria-current="page"] {
  color: var(--foreground);
}

.nav-link[aria-current="page"]::after,
.game-nav.is-open .game-trigger::after {
  opacity: 1;
  transform: scaleX(1);
}

.game-nav {
  position: relative;
  display: flex;
}

.game-trigger {
  gap: 6px;
}

.game-trigger img {
  display: block;
  width: 14px;
  height: 14px;
  transition: transform var(--ease);
}

.game-nav.is-open .game-trigger img {
  transform: rotate(180deg);
}

.header-actions {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 16px;
}

.utility-link,
.utility-button {
  display: flex;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.utility-link img,
.utility-button img {
  display: block;
  width: 26px;
  height: 26px;
}

.auth-link {
  display: flex;
  min-width: 84px;
  height: 42px;
  border: 1px solid var(--accent);
  border-radius: 22px;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
  transition: background var(--ease), color var(--ease);
}

.auth-link--primary {
  background: var(--accent);
}

.game-mega {
  position: fixed;
  z-index: 990;
  top: var(--header-height);
  right: 0;
  left: 0;
  padding: 24px 0 28px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity var(--ease), transform var(--ease);
}

.game-nav.is-open .game-mega {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.mega-grid {
  display: grid;
  width: min(var(--content-width), calc(100% - 128px));
  margin-inline: auto;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 12px;
}

.mega-item {
  display: grid;
  min-height: 128px;
  padding: 8px 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--muted);
  cursor: pointer;
  grid-template-rows: 80px auto;
  align-items: center;
  justify-items: center;
  transition: border-color var(--ease), color var(--ease), transform var(--ease);
}

.mega-item img {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.main-content {
  padding-top: var(--header-height);
}

.hero-banner {
  position: relative;
  height: 624px;
  background: var(--surface);
}

.hero-image {
  display: block;
  width: 100%;
  height: 624px;
  object-fit: cover;
  object-position: center;
  opacity: 1;
  transition: opacity 140ms ease-out;
}

.hero-image.is-changing {
  opacity: .18;
}

.hero-thumbs {
  position: absolute;
  right: max(32px, calc((100vw - var(--content-width)) / 2));
  bottom: 28px;
  display: flex;
  gap: 12px;
}

.hero-thumb {
  display: block;
  width: 108px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--foreground) 26%, transparent);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  opacity: .72;
  transition: border-color var(--ease), opacity var(--ease), transform var(--ease);
}

.hero-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-thumb.is-active {
  border-color: var(--accent);
  opacity: 1;
  transform: translateY(-2px);
}

.home-overview {
  min-height: 259px;
  padding: 22px 0 30px;
  background: var(--background);
}

.announcement {
  display: grid;
  width: min(1200px, calc(100% - 160px));
  min-height: 44px;
  margin: 0 auto 18px;
  padding: 10px 22px;
  border-radius: 22px;
  background: var(--surface);
  color: var(--muted);
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.announcement-mark {
  display: flex;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--foreground);
  font-family: var(--font-number);
  font-size: 14px;
  align-items: center;
  justify-content: center;
}

.announcement p {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
}

.category-card {
  position: relative;
  display: grid;
  min-width: 0;
  height: 100px;
  padding: 0 8px 8px;
  overflow: hidden;
  border: 0;
  border-radius: 7px;
  background-color: var(--surface);
  background-image: url("assets/home/images/category-card.png");
  background-position: center;
  background-size: 100% 100%;
  color: var(--foreground);
  cursor: pointer;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  transition: transform 150ms ease-out, filter 150ms ease-out;
}

.category-card img {
  display: block;
  width: 100px;
  height: 100px;
  margin-left: -9px;
  object-fit: contain;
  transition: transform 150ms ease-out;
}

.category-copy {
  display: grid;
  align-content: center;
  gap: 1px;
  text-align: left;
}

.category-copy strong {
  display: block;
  overflow: hidden;
  font-family: var(--font-number);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-copy span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

.category-copy em {
  display: block;
  height: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  line-height: 24px;
  opacity: 0;
  transition: height 150ms ease-out, opacity 150ms ease-out;
}

.download-section {
  padding: 0 0 64px;
  background: var(--background);
}

.download-stage {
  position: relative;
  height: 560px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
}

.download-scene {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.qr-card {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 208px;
  height: 249px;
  padding: 24px;
  border-radius: 24px;
  background: var(--foreground);
  color: var(--background);
  grid-template-rows: auto 160px;
  gap: 17px;
  transform: translate(-50%, -41%);
}

.qr-card strong {
  display: block;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

.qr-card img {
  display: block;
  width: 160px;
  height: 160px;
}

.venue-section {
  background: var(--background);
}

.venue-stage {
  position: relative;
  height: 819px;
  overflow: hidden;
  background: var(--surface);
}

.venue-image {
  display: block;
  width: 100%;
  height: 819px;
  object-fit: cover;
  object-position: center;
}

.venue-tabs {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  height: 90px;
  border-bottom: 1px solid color-mix(in srgb, var(--foreground) 14%, transparent);
  background: color-mix(in srgb, var(--background) 86%, transparent);
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.venue-tab {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  white-space: nowrap;
  transition: color var(--ease);
}

.venue-tab::after {
  position: absolute;
  right: 26%;
  bottom: 0;
  left: 26%;
  height: 3px;
  background: var(--accent);
  content: "";
  opacity: 0;
}

.venue-tab.is-active {
  color: var(--foreground);
}

.venue-tab.is-active::after {
  opacity: 1;
}

.enter-game {
  position: absolute;
  z-index: 2;
  bottom: 154px;
  left: max(78px, calc((100vw - var(--content-width)) / 2 + 12px));
  display: flex;
  min-width: 176px;
  height: 64px;
  padding: 0 34px;
  border: 0;
  border-radius: 32px;
  background: var(--accent);
  color: var(--foreground);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  font-weight: 600;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 32%, transparent);
  transition: transform var(--ease), filter var(--ease);
}

.site-footer {
  min-height: 385px;
  padding: 44px 0 34px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.footer-statement {
  max-width: 920px;
  margin: 0 auto 34px;
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

.footer-rule {
  width: min(960px, calc(100% - 64px));
  height: 1px;
  margin: 0 auto 30px;
  background: var(--border);
}

.regulators {
  display: grid;
  max-width: 770px;
  margin: 0 auto 28px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 72px;
}

.regulator {
  display: grid;
  align-items: center;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
}

.regulator img {
  display: block;
  width: 144px;
  height: auto;
}

.regulator-copy {
  display: grid;
  gap: 2px;
}

.regulator-copy strong,
.regulator-copy span {
  display: block;
}

.regulator-copy strong {
  color: var(--foreground);
  font-size: 14px;
  font-weight: 500;
}

.regulator-copy span {
  font-size: 12px;
}

.copyright {
  margin: 0;
  font-family: var(--font-number);
  font-size: 13px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 1200;
  top: 108px;
  left: 50%;
  display: flex;
  max-width: min(460px, calc(100% - 32px));
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--foreground);
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 36px color-mix(in srgb, var(--background) 76%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity var(--ease), transform var(--ease);
}

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

@media (hover: hover) {
  .nav-link:hover,
  .game-trigger:hover {
    color: var(--foreground);
  }

  .utility-link:hover,
  .utility-button:hover {
    filter: brightness(1.2);
  }

  .auth-link:hover {
    background: var(--accent);
    color: var(--foreground);
  }

  .auth-link--primary:hover,
  .enter-game:hover {
    filter: brightness(1.08);
  }

  .mega-item:hover {
    border-color: var(--accent);
    color: var(--foreground);
    transform: translateY(-3px);
  }

  .hero-thumb:hover {
    border-color: var(--foreground);
    opacity: 1;
  }

  .category-card:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
  }

  .category-card:hover img {
    transform: scale(1.16);
  }

  .category-card:hover .category-copy em {
    height: 24px;
    opacity: 1;
  }

  .venue-tab:hover {
    color: var(--foreground);
  }

  .enter-game:hover {
    transform: translateY(-2px);
  }
}

@media (max-width: 1180px) {
  .primary-nav {
    margin-left: 38px;
    gap: 24px;
  }

  .header-actions {
    gap: 10px;
  }

  .auth-link {
    min-width: 70px;
  }

  .category-grid,
  .mega-grid {
    overflow-x: auto;
    grid-template-columns: repeat(9, 140px);
    scrollbar-width: none;
  }

  .category-grid::-webkit-scrollbar,
  .mega-grid::-webkit-scrollbar {
    display: none;
  }

  .venue-tab {
    font-size: 15px;
  }
}

@media (max-width: 900px) {
  :root {
    --header-height: 72px;
  }

  .header-inner,
  .page-shell {
    width: calc(100% - 32px);
  }

  .primary-nav {
    margin-left: 24px;
    gap: 18px;
  }

  .primary-nav > .nav-link:nth-last-child(-n+2) {
    display: none;
  }

  .header-actions .utility-button {
    display: none;
  }

  .hero-banner,
  .hero-image {
    height: min(52vw, 460px);
    min-height: 360px;
  }

  .hero-thumbs {
    right: 16px;
    bottom: 16px;
  }

  .hero-thumb {
    width: 84px;
    height: 50px;
  }

  .announcement {
    width: calc(100% - 32px);
  }

  .download-stage {
    height: 480px;
  }

  .venue-stage,
  .venue-image {
    height: 660px;
  }

  .venue-tabs {
    overflow-x: auto;
    grid-template-columns: repeat(9, 124px);
  }

  .enter-game {
    bottom: 92px;
    left: 32px;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 64px;
  }

  .header-inner {
    width: calc(100% - 24px);
  }

  .brand,
  .brand img {
    width: 94px;
  }

  .primary-nav {
    margin-left: 16px;
    gap: 12px;
  }

  .primary-nav > .nav-link:not([aria-current="page"]) {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .utility-link,
  .auth-link:not(.auth-link--primary) {
    display: none;
  }

  .auth-link {
    min-width: 64px;
    height: 40px;
  }

  .mega-grid {
    width: calc(100% - 24px);
  }

  .hero-banner,
  .hero-image {
    height: 390px;
    min-height: 0;
  }

  .hero-image {
    object-position: center;
  }

  .hero-thumbs {
    right: 12px;
    left: 12px;
    overflow-x: auto;
    justify-content: flex-end;
  }

  .hero-thumb {
    width: 76px;
    height: 46px;
    flex: none;
  }

  .home-overview {
    padding-top: 16px;
  }

  .announcement {
    width: calc(100% - 24px);
    padding: 10px 14px;
    border-radius: 12px;
    align-items: start;
  }

  .announcement p {
    font-size: 13px;
  }

  .page-shell {
    width: calc(100% - 24px);
  }

  .category-grid {
    margin-right: -12px;
    grid-template-columns: repeat(9, 140px);
  }

  .download-section {
    padding-bottom: 32px;
  }

  .download-stage {
    height: 430px;
    border-radius: 6px;
  }

  .download-scene {
    object-position: center;
  }

  .qr-card {
    width: 176px;
    height: 217px;
    padding: 16px;
    border-radius: 18px;
    grid-template-rows: auto 144px;
    gap: 13px;
  }

  .qr-card img {
    width: 144px;
    height: 144px;
  }

  .venue-stage,
  .venue-image {
    height: 560px;
  }

  .venue-image {
    object-position: 58% center;
  }

  .venue-tabs {
    height: 72px;
    grid-template-columns: repeat(9, 112px);
  }

  .venue-tab {
    font-size: 14px;
  }

  .enter-game {
    bottom: 42px;
    left: 24px;
    min-width: 148px;
    height: 52px;
    border-radius: 26px;
    font-size: 17px;
  }

  .site-footer {
    min-height: 0;
    padding: 36px 20px 28px;
  }

  .regulators {
    max-width: 420px;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .regulator {
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .regulator img {
    width: 120px;
  }
}

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

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