/* ===== 成语接龙 · 中国风样式 ===== */
:root {
  --red: #b23b2e;
  --red-dark: #8e2a1f;
  --red-light: #c94a3c;
  --gold: #d9a441;
  --gold-light: #f0d48a;
  --paper: #f7efe0;
  --paper-dark: #f1e3c8;
  --ink: #3d2b1f;
  --line: rgba(61,43,31,.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "STKaiti", "KaiTi", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.6), transparent 55%),
    radial-gradient(circle at 85% 75%, rgba(217,164,65,.12), transparent 50%),
    linear-gradient(180deg, #faf3e2, #f2e4c9);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
}

/* ===== 顶部栏 ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; }
.logo {
  margin: 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  letter-spacing: 3px;
  color: var(--red-dark);
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
}
.round-info, .best-info { font-size: 13px; color: var(--ink); background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; }
.round-info b, .best-info b { color: var(--red); font-size: 15px; }

/* ===== 主区域 ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.score-row { display: flex; gap: 10px; margin-bottom: 10px; }
.score-box, .chain-box {
  flex: 1;
  text-align: center;
  background: #fffdf6;
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 8px 6px;
  font-size: 13px;
  color: #7a6a55;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.score-box b, .chain-box b { display: block; font-size: 20px; color: var(--red); margin-top: 2px; }

/* 接龙卡片 */
.play-card {
  position: relative;
  background: #fffdf6;
  border: 2.5px solid var(--red);
  border-radius: 18px;
  padding: 16px 12px 14px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(142,42,31,.12);
  overflow: hidden;
}
.play-card::before {
  content: "接龙";
  position: absolute;
  top: -4px; right: -12px;
  width: 64px; height: 64px;
  background: var(--red);
  color: #fff;
  font-size: 13px;
  letter-spacing: 2px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  transform: rotate(45deg);
  opacity: .92;
}
.card-label { font-size: 15px; color: #6b5a45; margin-bottom: 12px; }
.need-char {
  display: inline-block;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background: var(--red);
  border-radius: 8px;
  padding: 0 8px;
  margin: 0 3px;
  vertical-align: middle;
}
.need-pinyin { font-style: normal; color: var(--gold); font-weight: 600; margin-left: 2px; }

.current-idiom {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 10px;
}
.current-idiom span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 58px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 38px;
  font-weight: 700;
  color: var(--red-dark);
  background: linear-gradient(180deg, #fdf6e8, #f7e7c8);
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  box-shadow: inset 0 -2px 0 rgba(217,164,65,.4);
  animation: charIn .4s ease both;
}
.current-owner { font-size: 12px; color: #9a8b74; }

/* 接龙历史 */
.history {
  flex: 1;
  overflow-y: auto;
  margin-top: 12px;
  padding: 4px 2px;
  -webkit-overflow-scrolling: touch;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: rgba(255,255,255,.75);
  border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  animation: slideIn .3s ease both;
}
.history-item .idiom {
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
}
.history-item .py { font-size: 12px; color: #a08d72; margin-left: auto; }
.badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 12px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 1px;
}
.badge.player { background: var(--red); }
.badge.ai { background: var(--gold); }
.badge.start { background: #8a7a64; }

/* ===== 底部操作区 ===== */
.input-area { margin-top: 12px; }
.input-row { display: flex; gap: 8px; }
#wordInput {
  flex: 1;
  font-size: 18px;
  font-family: inherit;
  padding: 13px 14px;
  border: 2px solid #d8c9a8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
#wordInput:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(178,59,46,.15); }
#wordInput.shake { animation: shake .4s ease; border-color: var(--red); }

.btn-primary {
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--red-light), var(--red-dark));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 13px 24px;
  box-shadow: 0 4px 10px rgba(142,42,31,.35);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn-primary:active { transform: scale(.95); box-shadow: 0 2px 6px rgba(142,42,31,.3); }
.btn-primary.big { width: 100%; padding: 14px; font-size: 20px; margin-top: 14px; }

.hint-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; min-height: 0; }
.hint-row:empty { display: none; }
.hint-chip {
  border: 1.5px solid var(--gold);
  background: #fffdf6;
  color: var(--ink);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 16px;
  font-family: "STKaiti", "KaiTi", serif;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,.08);
  transition: transform .1s ease;
}
.hint-chip:active { transform: scale(.93); background: var(--gold-light); }

.tool-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-ghost {
  flex: 1;
  border: 1.5px solid var(--line);
  background: rgba(255,255,255,.8);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.btn-ghost:active { transform: scale(.95); background: #f5ead2; }

.share-tip { text-align: center; font-size: 12px; color: #a08d72; margin-top: 10px; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(61,43,31,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal.hidden { display: none; }
.modal-box {
  background: linear-gradient(180deg, #fdf6e6, #f4e6ca);
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 26px 22px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  animation: popIn .35s ease;
}
.modal-title {
  margin: 0 0 10px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 30px;
  color: var(--red-dark);
  letter-spacing: 4px;
}
.rule { font-size: 14px; line-height: 1.8; color: #6b5a45; margin: 8px 0 16px; }
.rule em { color: var(--red); font-style: normal; font-weight: 700; }

.difficulty { display: flex; gap: 8px; justify-content: center; margin-bottom: 6px; }
.diff-btn {
  border: 1.5px solid var(--gold);
  background: transparent;
  color: var(--ink);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
}
.diff-btn.active { background: var(--red); border-color: var(--red); color: #fff; }

.end-sub { font-size: 14px; color: #6b5a45; margin: 0 0 14px; }
.end-score { display: flex; gap: 8px; margin-top: 6px; }
.end-item {
  flex: 1;
  background: #fffdf6;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 4px;
  font-size: 12px;
  color: #8a7a64;
}
.end-item b { display: block; font-size: 22px; color: var(--red); margin-top: 3px; }

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  top: 14%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(61,43,31,.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 动画 ===== */
@keyframes charIn {
  from { transform: translateY(14px) scale(.8); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes slideIn {
  from { transform: translateX(-16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes popIn {
  from { transform: scale(.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); color: var(--gold); }
  100% { transform: scale(1); }
}
.num-pop.pop { animation: pop .4s ease; }

/* 滚动条美化 */
.history::-webkit-scrollbar { width: 4px; }
.history::-webkit-scrollbar-thumb { background: rgba(178,59,46,.3); border-radius: 4px; }