/* Cocos 小游戏测试平台 —— 样式表 */

:root {
  --bg: #f2f5fa;
  --panel: #ffffff;
  --panel-2: #f5f7fc;
  --text: #1a2233;
  --muted: #6b7688;
  --border: #e4e9f2;
  --primary: #3b6cf6;
  --primary-dark: #2b55d0;
  --primary-soft: #eaf0ff;
  --danger: #e5484d;
  --danger-dark: #c9373c;
  --danger-soft: #fdecec;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(18, 28, 56, .06);
  --shadow: 0 6px 24px rgba(18, 28, 56, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131f;
    --panel: #161d2c;
    --panel-2: #1d2537;
    --text: #e7ecf6;
    --muted: #93a0b8;
    --border: #26304a;
    --primary: #5b83f8;
    --primary-dark: #6f93ff;
    --primary-soft: #1d2a4d;
    --danger-soft: #3a1d20;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 8px 28px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.no-scroll { overflow: hidden; }

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

code {
  font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  font-size: .92em;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.muted { color: var(--muted); }
.flex-1 { flex: 1; }

/* --------------------------------------------------------------- 顶部导航 */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.brand-logo {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #6a8dff, #3b5bdb);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text em { font-style: normal; font-size: 11px; color: var(--muted); }

.nav { display: flex; gap: 4px; margin-left: 10px; }

.nav a {
  position: relative;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--muted);
  transition: .16s;
  display: flex; align-items: center; gap: 6px;
}

.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

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

.addr-chip {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.addr-chip:hover { color: var(--primary); border-color: var(--primary); }

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: .16s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { background: var(--panel-2); border-color: #c8d3e8; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }

.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }

.icon-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer;
  padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ------------------------------------------------------------------ 主体 */

main.wrap { flex: 1; padding-top: 26px; padding-bottom: 40px; }

.loading { text-align: center; color: var(--muted); padding: 80px 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-title h1 { margin: 0 0 4px; font-size: 22px; }
.page-title p { margin: 0; font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search input {
  width: 240px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.empty h2 { margin: 0 0 8px; font-size: 17px; color: var(--text); }

/* -------------------------------------------------------------- 游戏卡片 */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 18px;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: .18s;
  cursor: pointer;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #cfd9ee; }

.game-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.cover-letter {
  font-size: 44px;
  font-weight: 700;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}

.cover-version {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0, 0, 0, .38);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* 卡片右上角「⋯」更多菜单（编辑 / 删除） */
.game-menu { position: absolute; top: 10px; right: 10px; z-index: 5; }

.menu-btn {
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .38);
  color: #fff;
  font-family: inherit; font-size: 16px; font-weight: 700; line-height: 1;
  letter-spacing: 1px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: .16s;
}
.menu-btn:hover { background: rgba(0, 0, 0, .6); }
.game-menu.open .menu-btn { background: rgba(0, 0, 0, .68); }

.menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 124px;
  padding: 5px;
  display: none;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.game-menu.open .menu-pop { display: flex; }

.menu-item {
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  white-space: nowrap;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: .14s;
}
.menu-item:hover { background: var(--primary-soft); color: var(--primary); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: var(--danger-soft); color: var(--danger); }

.game-body { padding: 14px 15px 8px; flex: 1; }
.game-name { margin: 0 0 6px; font-size: 16px; }
.game-desc {
  margin: 0;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11.5px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 2px 8px;
}

.game-stats { margin-top: 10px; }
.stat-link {
  border: none; background: transparent; padding: 0;
  color: var(--muted); font-size: 12.5px; cursor: pointer; font-family: inherit;
  text-decoration: underline dashed;
  text-underline-offset: 3px;
}
.stat-link:hover { color: var(--primary); }

.game-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 15px 14px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
/* 主按钮占满剩余宽度，次按钮按需换行，任何宽度下都不溢出、不裁切 */
.foot-play { flex: 1 1 auto; min-width: 0; }
.foot-open { flex: 0 0 auto; }

/* ------------------------------------------------------------------ 弹窗 */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(14, 20, 36, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .14s ease-out;
  overflow: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--panel);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px rgba(10, 18, 40, .32);
  animation: popIn .16s ease-out;
}
.modal-lg { max-width: 1080px; }

@keyframes popIn { from { transform: translateY(8px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h3 { margin: 0; font-size: 16px; }

.modal-body { padding: 18px; overflow: auto; flex: 1; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.confirm-msg { margin: 0; white-space: pre-wrap; }

/* --------------------------------------------------------------- 表单 */

.form-row { margin-bottom: 14px; }
.form-row > label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.form-row textarea { resize: vertical; line-height: 1.6; }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.inline { display: flex; gap: 8px; align-items: center; }
.inline select { flex: 1; }

.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* --------------------------------------------------------------- 试玩弹窗 */

.play-hint {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.play-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.play-bar .play-hint { margin-bottom: 0; flex: 1 1 260px; }

.play-switch { display: flex; gap: 8px; flex: 0 0 auto; }
.play-switch .btn.is-on {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.play-frame {
  /* --play-h：画框高度上限。取「视口 78vh」与「视口高度减去弹窗头/脚/提示条等固定占用（约 240px）」的较小值，
     再由高度上限按比例反推宽度，保证 16:9 / 9:20 都不变形、也不超出视口。 */
  --play-h: min(78vh, calc(100vh - 240px));
  position: relative;
  margin: 0 auto;
  width: min(100%, calc(var(--play-h) * 16 / 9));
  max-width: 100%;
  aspect-ratio: 16 / 9;
  max-height: var(--play-h);
  background: #0b1020;
  border-radius: 12px;
  overflow: hidden;
}
/* 竖屏游戏：高瘦矩形，宽 : 高 = 9 : 20（即 高 : 宽 = 20 : 9） */
.play-frame.is-portrait {
  width: min(100%, calc(var(--play-h) * 9 / 20));
  aspect-ratio: 9 / 20;
}
.play-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.play-url {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.play-url code { flex: 1; min-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 提示条 */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: #1a2233;
  color: #fff;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(10, 18, 40, .3);
  animation: toastIn .18s ease-out;
  max-width: 80vw;
}
.toast-error { background: var(--danger); }
.toast-out { opacity: 0; transform: translateY(6px); transition: .2s; }

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ 响应式 */

@media (max-width: 760px) {
  .header-inner { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; gap: 10px 12px; }
  .brand-text em { display: none; }
  .nav { margin-left: 0; order: 3; width: 100%; }
  .nav a { flex: 1; justify-content: center; }
  .header-actions { margin-left: auto; }
  .addr-chip { max-width: 140px; }

  main.wrap { padding-top: 18px; }
  .page-title h1 { font-size: 19px; }
  .page-actions { width: 100%; }
  .page-actions .search { flex: 1; }
  .search input { width: 100%; }

  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .cover-letter { font-size: 32px; }
  .game-body { padding: 12px 12px 6px; }
  .game-foot { padding: 10px 12px 12px; }

  .form-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
  /* 手机上画框高度上限收紧，横竖屏都按各自比例自适应宽度 */
  .play-frame { --play-h: min(62vh, calc(100vh - 240px)); }
}
