:root {
  --ink-950: #0c0a09;
  --ink-900: #14110f;
  --ink-850: #1b1714;
  --ink-800: #241e1a;
  --ink-700: #332b24;

  --ivory: #f0e8da;
  --ivory-muted: #b0a493;
  --ivory-dim: #8a7f70;

  --brass: #c9a661;
  --brass-bright: #e3c687;
  --brass-line: rgba(201, 166, 97, 0.24);
  --brass-line-strong: rgba(201, 166, 97, 0.5);
  --brass-wash: rgba(201, 166, 97, 0.09);

  --cinnabar: #a62c22;
  --cinnabar-hi: #c2392d;
  --cinnabar-deep: #751b14;

  --celadon: #5a9e8f;

  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  min-height: 100%;
  background-color: var(--ink-950);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(166, 44, 34, 0.14) 0%, transparent 65%),
    radial-gradient(ellipse 65% 45% at 85% 10%, rgba(201, 166, 97, 0.07) 0%, transparent 60%),
    linear-gradient(180deg, #120f0d 0%, #0b0908 100%);
  color: var(--ivory);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}

/* 细微的纸张颗粒质感 */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.ico {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.portal-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  gap: 22px;
}

/* ==================== 页头 ==================== */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--brass-line);
  position: relative;
}

.portal-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 72px;
  height: 1px;
  background: var(--brass);
  opacity: 0.65;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.seal-mark {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  background: linear-gradient(160deg, var(--cinnabar-hi) 0%, var(--cinnabar-deep) 100%);
  border: 1px solid rgba(227, 198, 135, 0.55);
  box-shadow:
    inset 0 0 0 2.5px rgba(20, 12, 10, 0.32),
    0 8px 20px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.seal-mark span {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: #f7ebd4;
  line-height: 1.05;
}

.brand-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ivory);
  line-height: 1.15;
}

.brand-en {
  font-size: 10px;
  letter-spacing: 2.6px;
  color: var(--brass);
  opacity: 0.85;
  font-weight: 600;
}

.portal-sub {
  font-size: 12.5px;
  color: var(--ivory-muted);
  margin-top: 5px;
  letter-spacing: 0.4px;
}

.ghost-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--brass-line);
  background: rgba(27, 23, 20, 0.85);
  color: var(--brass-bright);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}

.ghost-action:active {
  transform: scale(0.97);
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  list-style: none;
  margin-top: -6px;
}

.feature-row li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.6px;
  color: var(--ivory-muted);
}

.feature-row li::before {
  content: "";
  width: 5px;
  height: 5px;
  transform: rotate(45deg);
  background: var(--brass);
  opacity: 0.8;
}

/* ==================== 分类筛选 ==================== */
.category-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-pill {
  padding: 7px 14px;
  border-radius: 4px;
  border: 1px solid var(--brass-line);
  background: var(--ink-900);
  color: var(--ivory-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.cat-pill.active {
  border-color: var(--brass);
  background: var(--brass-wash);
  color: var(--brass-bright);
}

/* ==================== 游戏列表 ==================== */
.portal-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-ornament {
  width: 6px;
  height: 6px;
  transform: rotate(45deg);
  background: var(--brass);
  box-shadow: 0 0 8px rgba(201, 166, 97, 0.45);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ivory);
}

.section-meta {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--ivory-dim);
  font-variant-numeric: tabular-nums;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.noscript-tip {
  font-size: 13px;
  color: var(--ivory-muted);
  line-height: 1.7;
}

/* ==================== 游戏卡片 ==================== */
.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, rgba(28, 23, 20, 0.96) 0%, rgba(19, 16, 14, 0.98) 100%);
  border: 1px solid var(--brass-line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.24s ease, box-shadow 0.24s ease;
}

.card-cover {
  position: relative;
  display: block;
  flex: none;
  height: 190px;
  color: inherit;
  text-decoration: none;
  background: linear-gradient(180deg, #1b1412 0%, #120f0d 100%);
  border-bottom: 1px solid var(--brass-line);
  overflow: hidden;
}

.cover-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.theme-slate .card-cover,
.theme-chalk .card-cover {
  border-bottom-color: rgba(216, 180, 106, 0.28);
}

.cover-index,
.cover-cat-seal {
  position: absolute;
  top: 12px;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 3px 9px;
  border-radius: 3px;
  background: rgba(12, 10, 9, 0.78);
  border: 1px solid var(--brass-line);
}

.cover-index {
  left: 12px;
  color: var(--brass-bright);
  font-weight: 700;
  letter-spacing: 1.6px;
}

.cover-cat-seal {
  right: 12px;
  color: var(--ivory-muted);
}

.cover-last {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 9px;
  border-radius: 3px;
  background: var(--brass);
  color: #1a130c;
}

/* 没有专属封面时的文字徽记兜底 */
.cover-pieces {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.art-token {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #c03a2d 0%, #8f2219 58%, #5e130d 100%);
  border: 2px solid #cfa960;
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.65),
    inset 0 2px 3px rgba(255, 236, 195, 0.28),
    inset 0 0 0 5px rgba(20, 10, 8, 0.24),
    inset 0 0 0 6px rgba(227, 198, 135, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 700;
  color: #f8eed9;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

.art-token.hero {
  width: 72px;
  height: 72px;
  font-size: 32px;
}

.art-token.side {
  opacity: 0.9;
}

/* 卡片内容 */
.card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 20px 22px 22px;
  gap: 12px;
  min-width: 0;
}

.card-kicker {
  font-size: 10px;
  letter-spacing: 2.2px;
  color: var(--brass);
  opacity: 0.85;
  font-weight: 600;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ivory);
  margin-top: 3px;
  line-height: 1.25;
}

.card-tagline {
  margin-top: 6px;
  font-size: 13px;
  letter-spacing: 0.8px;
  color: var(--brass-bright);
}

.card-desc {
  font-size: 13px;
  line-height: 1.75;
  color: var(--ivory-muted);
}

.card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.meta-chip {
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--ivory-muted);
  background: rgba(12, 10, 9, 0.65);
  border: 1px solid rgba(201, 166, 97, 0.16);
  padding: 4px 10px;
  border-radius: 4px;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: var(--brass-bright);
  padding: 8px 10px;
  border-radius: 5px;
  background: var(--brass-wash);
  border: 1px solid rgba(201, 166, 97, 0.16);
}

.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6fd1a6;
  box-shadow: 0 0 8px rgba(111, 209, 166, 0.7);
  flex-shrink: 0;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
}

.btn-enter {
  flex: 1 1 auto;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  border-radius: 6px;
  border: 1px solid rgba(227, 198, 135, 0.42);
  background: linear-gradient(180deg, var(--cinnabar-hi) 0%, var(--cinnabar) 52%, var(--cinnabar-deep) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 232, 194, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.42);
  color: #faf2e3;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-decoration: none;
  transition: filter 0.18s ease, transform 0.12s ease;
}

.btn-enter:active { transform: scale(0.98); }

.btn-share-card {
  height: 46px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  border: 1px solid var(--brass-line);
  background: var(--ink-850);
  color: var(--ivory-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.btn-share-card:active { transform: scale(0.97); }

/* 仅在支持悬停的设备上启用悬停效果，避免触屏点按后“粘住” */
@media (hover: hover) {
  .ghost-action:hover {
    border-color: var(--brass-line-strong);
    background: rgba(201, 166, 97, 0.12);
  }

  .cat-pill:hover {
    border-color: var(--brass);
    color: var(--brass-bright);
  }

  .game-card:hover {
    transform: translateY(-3px);
    border-color: var(--brass-line-strong);
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(201, 166, 97, 0.14);
  }

  .game-card:hover .cover-art {
    transform: scale(1.035);
  }

  .btn-enter:hover { filter: brightness(1.09); }

  .btn-share-card:hover {
    border-color: var(--brass-line-strong);
    color: var(--brass-bright);
  }
}

/* ==================== 页脚与提示 ==================== */
.portal-footer {
  padding-top: 16px;
  border-top: 1px solid rgba(201, 166, 97, 0.14);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-rule {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--ivory-muted);
}

.footer-note {
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--ivory-dim);
}

.toast {
  position: fixed;
  top: max(22px, calc(env(safe-area-inset-top) + 10px));
  left: 50%;
  transform: translate(-50%, -10px);
  max-width: calc(100vw - 32px);
  padding: 9px 18px;
  border-radius: 6px;
  background: rgba(27, 23, 20, 0.96);
  border: 1px solid var(--brass);
  color: var(--brass-bright);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  text-align: center;
}

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

/* ==================== 平板：两列，落单的最后一张卡片横向铺满 ==================== */
@media (min-width: 720px) {
  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    flex-direction: row;
  }

  .game-card:last-child:nth-child(odd) .card-cover {
    width: 46%;
    height: auto;
    min-height: 240px;
    border-bottom: 0;
    border-right: 1px solid var(--brass-line);
  }
}

/* ==================== 桌面：三列 ==================== */
@media (min-width: 1040px) {
  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-card:last-child:nth-child(odd) {
    grid-column: auto;
    flex-direction: column;
  }

  .game-card:last-child:nth-child(odd) .card-cover {
    width: auto;
    height: 190px;
    min-height: 0;
    border-bottom: 1px solid var(--brass-line);
    border-right: 0;
  }

  .game-card:last-child:nth-child(3n + 1):not(:first-child) {
    grid-column: 1 / -1;
    flex-direction: row;
  }

  .game-card:last-child:nth-child(3n + 1):not(:first-child) .card-cover {
    width: 46%;
    height: auto;
    min-height: 240px;
    border-bottom: 0;
    border-right: 1px solid var(--brass-line);
  }
}

/* ==================== 手机竖屏 ==================== */
@media (max-width: 719px) {
  .portal-shell {
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    gap: 18px;
  }

  .portal-header {
    padding-bottom: 14px;
  }

  .seal-mark {
    width: 40px;
    height: 40px;
  }

  .seal-mark span {
    font-size: 15px;
  }

  .portal-title {
    font-size: 21px;
    letter-spacing: 2px;
  }

  .brand-en {
    display: none;
  }

  .portal-sub {
    font-size: 11.5px;
  }

  .ghost-action {
    height: 34px;
    padding: 0 11px;
    font-size: 11px;
  }

  .feature-row {
    gap: 4px 16px;
    margin-top: -4px;
  }

  .feature-row li {
    font-size: 11px;
  }

  .game-grid {
    gap: 16px;
  }

  .card-cover {
    height: 170px;
  }

  .card-body {
    padding: 16px 16px 18px;
  }

  .card-title {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
