:root {
  --bg: #0d1117;
  --panel: #151c24;
  --panel-hover: #1a232d;
  --line: #232d38;
  --text: #e8ecef;
  --text-dim: #8b97a3;
  --accent: #34c9a8;
  --accent-dim: rgba(52, 201, 168, 0.14);
  --serif: Georgia, "Songti SC", "SimSun", serif;
  --sans: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

/* ---------- header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  padding: 26px 0 22px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shop-entry {
  flex-shrink: 0;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.shop-entry:hover { background: var(--accent-dim); }

.brand-mark {
  width: 34px;
  height: 34px;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 4px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.search-box input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 14px;
  width: 240px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }

/* ---------- genre bar ---------- */
.genre-bar {
  padding: 18px 0 4px;
}

.genre-bar .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-tag {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  padding: 5px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.genre-tag:hover { color: var(--text); border-color: var(--text-dim); }

.genre-tag.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- game grid ---------- */
main { flex: 1; padding: 22px 0 48px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--panel-hover);
}

.card-cover {
  aspect-ratio: 4 / 3;
  position: relative;
  overflow: hidden;
  background: #10161d;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 56px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
}

.card-body { padding: 12px 14px 14px; }

.card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-name {
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-genre {
  font-size: 12px;
  color: var(--accent);
  flex-shrink: 0;
}

.card-tagline {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-plays {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.75;
  margin-top: 6px;
}

/* ---------- empty state ---------- */
.empty-state {
  text-align: center;
  padding: 90px 0;
}

.empty-title {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.empty-hint {
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.7;
  margin-top: 8px;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
}

/* ---------- play page ---------- */
.play-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.play-back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.play-back:hover { color: var(--accent); }

.play-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-fullscreen,
.play-mode {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.play-fullscreen:hover,
.play-mode:hover { color: var(--accent); border-color: var(--accent); }

/* 舞台：桌面横屏时给竖屏游戏一个 9:16 居中容器，避免手游画面被横向拉满 */
.play-stage {
  flex: 1;
  display: flex;
  justify-content: center;
  min-height: 0;
  background: #07090c;
}

.play-frame-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.play-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* 桌面横屏：竖屏容器（宽 = 视口高 × 9/16），wide 模式铺满 */
@media (min-aspect-ratio: 5/6) {
  .play-stage:not(.wide) .play-frame-wrap {
    width: min(100%, calc((100vh - 46px) * 0.5625));
    box-shadow: 0 0 0 1px var(--line);
  }
}

/* 手机/竖窗：铺满，切换按钮无意义则隐藏 */
@media (max-aspect-ratio: 5/6) {
  .play-mode { display: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
}

@media (max-width: 640px) {
  .site-header { padding: 18px 0 14px; }
  .header-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  .brand-text h1 { font-size: 22px; letter-spacing: 3px; }
  .search-box input { width: 100%; }

  /* 分类条：手机上单行横滑，不挤占屏幕 */
  .genre-bar .wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .genre-bar .wrap::-webkit-scrollbar { display: none; }
  .genre-tag { flex-shrink: 0; }

  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 10px 11px 12px; }
  .card-name { font-size: 14px; }
  .card-tagline { font-size: 12px; }
  .play-topbar { padding: 8px 12px; gap: 10px; }
}

@media (max-width: 360px) {
  .game-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
