:root {
  --bg: #f6f3ed;
  --card: #ffffff;
  --ink: #2c2a26;
  --muted: #8a857c;
  --green: #3f9d6b;
  --yellow: #e0a92e;
  --gray: #c2bcb0;
  --accent: #7a5638;
  --accent-2: #a9774a;
  --border: #e7e0d4;
  --shadow: 0 6px 24px rgba(60, 45, 30, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 480px at 50% -120px, #efe6d8 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 34px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.15)); }
.brand h1 { margin: 0; font-size: 21px; letter-spacing: .5px; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s ease;
}
.tab:hover { border-color: var(--accent-2); color: var(--accent); }
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
  box-shadow: 0 4px 12px rgba(122, 86, 56, .35);
}

.view { display: none; padding: 22px; max-width: 1000px; margin: 0 auto; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.mode-row, .meta-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mode-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s ease;
}
.mode-btn:hover { border-color: var(--accent-2); color: var(--accent); }
.mode-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
  box-shadow: 0 3px 10px rgba(122, 86, 56, .3);
}
.pool-sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.mode-hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; line-height: 1.6; }

.guess-box { position: relative; margin: 14px 0 4px; }
#guessInput {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fcfaf6;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#guessInput:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(169, 119, 74, .15);
  background: #fff;
}
.suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  max-height: 300px;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  z-index: 5;
  display: none;
  box-shadow: var(--shadow);
}
.suggestions li {
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  transition: background .12s ease;
}
.suggestions li:hover, .suggestions li.hl { background: #f3ecdf; }
.suggestions .flag { color: var(--muted); font-size: 13px; }
.suggestions .flag-en { color: var(--accent); font-size: 12px; opacity: .8; }

/* 首页随机匹配状态区 */
#homeMatchHint {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #8a5cb8;
  background: rgba(138, 92, 184, .1);
  border: 1px solid rgba(138, 92, 184, .3);
  border-radius: 999px;
  padding: 9px 20px;
  margin: 22px auto 0;
  max-width: 460px;
}
.home-match-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

/* 随机匹配按钮：突出显示 */
.match-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(122, 86, 56, .3);
}
.match-btn:hover { opacity: .92; color: #fff; }

.badge {
  background: #f0e9da;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.ghost-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s ease;
}
.ghost-btn:hover:not(:disabled) { border-color: var(--accent-2); color: var(--accent); }
.ghost-btn:disabled { opacity: .45; cursor: not-allowed; }

.board { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.row {
  display: grid;
  grid-template-columns: minmax(64px, 1.3fr) repeat(9, minmax(0, 1fr));
  gap: 5px;
}
.row.head { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
.cell {
  padding: 8px 4px;
  border-radius: 9px;
  text-align: center;
  font-size: 12px;
  background: #f3efe7;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.02);
}
.cell.name { justify-content: flex-start; font-weight: 600; font-size: 12px; }
.cell.green { background: var(--green); color: #fff; }
.cell.yellow { background: var(--yellow); color: #fff; }
.cell.gray { background: var(--gray); color: #fff; }
.cell small { font-size: 11px; opacity: .85; }

.result { text-align: center; font-size: 16px; font-weight: 600; margin-top: 14px; min-height: 22px; }
.result.win { color: var(--green); }
.result.lose { color: #c0392b; }

/* 历史库 */
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input, .filters select {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  font-size: 14px;
  background: #fcfaf6;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(169, 119, 74, .15);
  background: #fff;
}
.filters input { flex: 1; min-width: 200px; }

.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f7f1e6; position: sticky; top: 0; color: var(--accent); font-weight: 700; }
td .lg { color: var(--muted); font-size: 11px; }

.help h2 { margin-top: 0; }
.help ol { line-height: 1.8; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.legend .cell { color: #fff; }
.note { color: #c0392b; font-size: 13px; }

.lib-row { cursor: pointer; transition: background .12s ease; }
.lib-row:hover { background: #faf4e8; }
.lib-country { white-space: nowrap; }
.lib-country .flag-svg { margin-right: 4px; }
.flag-svg { vertical-align: middle; }
.lib-empty { text-align: center; color: var(--muted); padding: 28px 0; font-size: 14px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.pager .pager-info { font-size: 13px; color: var(--muted); }
.bio-card {
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background: #fbf8f1;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 4px 0 10px;
}

.answer-bio {
  text-align: center;
  font-size: 14px;
  color: var(--ink);
  background: #fbf8f1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px auto 0;
  max-width: 640px;
  line-height: 1.6;
}
.foot {
  padding: 18px 20px 30px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.foot .ver { font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.foot .log div { opacity: .85; }
.foot .credit { margin-top: 12px; font-size: 12px; }
.foot .credit a { color: #fb7299; text-decoration: none; }
.foot .credit a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .row { grid-template-columns: 1.2fr repeat(9, 1fr); font-size: 11px; }
  .cell { min-height: 32px; padding: 6px 3px; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* ============ 实时对战 ============ */
.pvp-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.pvp-code-input {
  padding: 10px 14px;
  font-size: 15px;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: #fcfaf6;
  width: 180px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pvp-code-input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(169, 119, 74, .15);
  background: #fff;
}
.pvp-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.pvp-code {
  font-size: 26px;
  letter-spacing: 6px;
  color: var(--accent);
  background: #f5edde;
  border: 1.5px dashed var(--accent-2);
  border-radius: 10px;
  padding: 4px 14px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.pvp-countdown {
  font-size: 14px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 20px;
  background: var(--gray);
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.pvp-countdown.urgent { background: #e07a5f; animation: pvpPulse .9s ease-in-out infinite; }
@keyframes pvpPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.badge { font-size: 12px; color: var(--accent); background: #f0e6d8; padding: 2px 10px; border-radius: 20px; font-weight: 600; }

.pvp-boards { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.pvp-board-title { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 0 4px; }
.pvp-boards .board-wrap {
  background: #fbf8f1;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* 对手棋盘：单元格只显示颜色，文字留空，更紧凑 */
.pvp-board.opp .row.head .cell:not(.name) { color: var(--muted); }
.pvp-board.opp .cell:not(.name) { font-size: 0; }   /* 隐藏对手列文字，仅留颜色 */
.pvp-board.opp .cell.hit { font-size: 15px; }        /* 命中保留对勾 */
@media (max-width: 860px) {
  .pvp-code { font-size: 22px; letter-spacing: 4px; }
  .cell { font-size: 11px; padding: 7px 2px; min-height: 34px; }
}

/* ============ 首页 / 启动选择 ============ */
.hero { text-align: center; padding: 26px 16px 6px; }
.hero-logo {
  font-size: 56px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.18));
  animation: float 3.4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-title {
  margin: 8px 0 4px;
  font-size: 40px;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 0; color: var(--muted); font-size: 14px; }
.hero-pick {
  margin: 22px 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
}

/* 首页玩法卡片：四张等宽平均排列 */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  max-width: 1120px;
  margin: 26px auto 0;
}
.mode-card {
  /* 每张卡一个主题色，下面按 data-go 覆写 */
  --mc: #a9774a;
  --mc-soft: rgba(169, 119, 74, .12);
  --mc-border: rgba(169, 119, 74, .32);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  padding: 24px 22px 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  position: relative;
  overflow: hidden;
  min-height: 248px;      /* 等高，视觉整齐 */
}

/* 顶部主题色细条 */
.mode-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--mc);
  opacity: .85;
}
.mode-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, var(--mc-soft), transparent 70%);
  opacity: 0;
  transition: opacity .2s ease;
}
.mode-card:hover {
  transform: translateY(-6px);
  border-color: var(--mc);
  box-shadow: 0 16px 36px rgba(60, 45, 30, .16);
}
.mode-card:hover::after { opacity: 1; }
.mode-card > * { position: relative; z-index: 1; }

/* emoji 图标：统一放在主题色圆角方块里 */
.mc-emoji {
  font-size: 30px;
  line-height: 1;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--mc-soft);
  transition: transform .2s ease;
}
.mode-card:hover .mc-emoji { transform: scale(1.06) rotate(-4deg); }

.mc-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .5px;
}
.mc-desc {
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  flex: 1;
}
.mc-tag {
  align-self: flex-start;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--mc);
  background: var(--mc-soft);
  border: 1px solid var(--mc-border);
  padding: 4px 12px;
  border-radius: 999px;
}

/* 四种玩法各自的主题色 */
.mode-card[data-go="daily"]  { --mc: #4a7fb5; --mc-soft: rgba(74, 127, 181, .13);  --mc-border: rgba(74, 127, 181, .32); }
.mode-card[data-go="random"] { --mc: #3f9d76; --mc-soft: rgba(63, 157, 118, .13);  --mc-border: rgba(63, 157, 118, .32); }
.mode-card[data-go="match"]  { --mc: #8a5cb8; --mc-soft: rgba(138, 92, 184, .13);  --mc-border: rgba(138, 92, 184, .32); }
.mode-card[data-go="pvp"]    { --mc: #c2703d; --mc-soft: rgba(194, 112, 61, .13);  --mc-border: rgba(194, 112, 61, .32); }

/* 响应式：宽屏四列 → 平板两列 → 手机单列 */
@media (max-width: 1040px) {
  .mode-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 620px; }
  .mode-card { min-height: 210px; }
}
@media (max-width: 760px) {
  .mode-cards { grid-template-columns: 1fr; max-width: 420px; }
  .mode-card { min-height: 0; }
  .hero-title { font-size: 32px; }
}
