/* ============================================================
   《piupiupiu小猫海龟汤》样式
   第 7 课 M1：恐怖风首页（暗黑色调、红色点缀，计划第 7 课任务 4）
   第 8 课 M2：对话气泡、剩余次数、猜汤底面板、胜负画面（见下方 M2 段）
   全部样式本地实现，无任何外部字体/图片/CDN（机房断网可玩）
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  /* 近黑的底色 + 四角压暗，营造"从阴影里看东西"的感觉 */
  background:
    radial-gradient(ellipse at center, #16161c 0%, #0a0a0d 62%, #050507 100%);
  color: #c9c2b8;                 /* 旧纸般的灰白 */
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  display: flex;
  /* M2 改动：从垂直居中改为顶端对齐——对话变长后页面会超出屏幕，
     居中对齐会把顶上的标题挤出可视区，顶端对齐则一直完整可见 */
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
}

.stage {
  width: 100%;
  max-width: 640px;
  text-align: center;
}

/* ---------- 标题区 ---------- */

.candle {
  font-size: 34px;
  /* 烛光的红色微光晕 */
  text-shadow: 0 0 18px rgba(255, 120, 60, 0.55), 0 0 42px rgba(200, 60, 20, 0.3);
  animation: candleSway 3.2s ease-in-out infinite;
}

@keyframes candleSway {
  0%, 100% { opacity: 1;   transform: translateY(0); }
  50%      { opacity: 0.82; transform: translateY(-1px); }
}

.title {
  margin-top: 10px;
  font-size: 42px;
  letter-spacing: 4px;
  color: #b3121f;                 /* 血红点缀 */
  /* 标题像被血光映着，加轻微忽明忽暗的闪烁动画 */
  text-shadow: 0 0 12px rgba(179, 18, 31, 0.65), 0 0 34px rgba(120, 0, 10, 0.45);
  animation: titleFlicker 4.6s linear infinite;
}

@keyframes titleFlicker {
  0%, 100% { opacity: 1; }
  41%      { opacity: 1; }
  42%      { opacity: 0.55; }   /* 突然暗一下，像灯闪 */
  43%      { opacity: 1; }
  76%      { opacity: 1; }
  77%      { opacity: 0.4; }
  78%      { opacity: 0.92; }
  79%      { opacity: 1; }
}

.subtitle {
  margin-top: 12px;
  font-size: 14px;
  color: #6f6a61;
  letter-spacing: 2px;
}

/* ---------- 案件卡片 ---------- */

.case-card {
  margin: 36px auto 0;
  padding: 26px 28px 22px;
  text-align: left;
  background: #101014;
  border: 1px solid #3a1216;      /* 暗红描边 */
  border-left: 3px solid #8e0e18; /* 左侧一条血线 */
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  position: relative;
}

.case-tag {
  position: absolute;
  top: -11px;
  left: 18px;
  padding: 2px 10px;
  background: #8e0e18;
  color: #f2e9e4;
  font-size: 12px;
  letter-spacing: 2px;
}

.case-title {
  font-size: 15px;
  color: #b3121f;
  letter-spacing: 6px;
  margin-bottom: 12px;
}

.puzzle {
  font-family: "KaiTi", "STKaiti", "SimSun", serif;  /* 楷体讲故事的味道 */
  font-size: 19px;
  line-height: 2;
  color: #d8d1c6;
}

.sealed {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px dashed #33262a;
  font-size: 13px;
  color: #7a5a5e;
  text-align: right;
}

/* ---------- 页脚 ---------- */

.site-footer {
  margin-top: 34px;
  font-size: 12px;
  color: #4a463f;
  letter-spacing: 1px;
}

/* ============================================================
   第 8 课 M2 新增：剩余次数、对话气泡、猜汤底面板、胜负画面
   延续 M1 的暗黑血红配色，不引入任何新资源
   ============================================================ */

/* ---------- 剩余次数条 ---------- */

.count-bar {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #33262a;
  text-align: right;
}

#count {
  font-size: 14px;
  letter-spacing: 1px;
  color: #d8b56a;                 /* 烛火般的暖黄，醒目但不刺眼 */
}

/* ---------- 对话区 ---------- */

.chat-card {
  margin: 20px auto 0;
  padding: 16px;
  text-align: left;
  background: #101014;
  border: 1px solid #3a1216;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.chat-log {
  max-height: 300px;              /* 对话太长就在框内滚动，输入框始终可见 */
  overflow-y: auto;
  padding: 4px 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 82%;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.7;
  border-radius: 10px;
  word-break: break-word;
}

/* 玩家（右侧）：暗血红底，像把话递进黑暗里 */
.bubble.player {
  align-self: flex-end;
  background: #2a1013;
  border: 1px solid #571720;
  color: #e0c9c4;
}

/* 小猫裁判（左侧）：近黑底 + 猫耳朵符号开头 */
.bubble.kitty {
  align-self: flex-start;
  background: #14141a;
  border: 1px solid #2c2c34;
  color: #cfc8bd;
}

.bubble.kitty::before {
  content: "🐈‍⬛ ";
}

.bubble.kitty b {
  color: #ff5b62;                 /* "是 / 否 / 无关"三个判决词加粗提亮 */
  font-size: 16px;
}

/* ---------- 输入行与按钮 ---------- */

.input-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.input-row input,
.guess-panel input {
  flex: 1;
  padding: 9px 12px;
  font-size: 14px;
  color: #e6dcd2;
  background: #0b0b0f;
  border: 1px solid #3a3036;
  outline: none;
  font-family: inherit;
}

.input-row input:focus,
.guess-panel input:focus {
  border-color: #8e0e18;          /* 聚焦时描边变成血色 */
}

.btn {
  padding: 9px 18px;
  font-size: 14px;
  letter-spacing: 2px;
  color: #f2e9e4;
  background: #8e0e18;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover {
  background: #b3121f;
}

/* 幽灵按钮：次要操作（"我猜汤底"入口） */
.btn.ghost {
  background: transparent;
  border: 1px solid #571720;
  color: #b98f93;
}

.btn.ghost:hover {
  color: #f2e9e4;
  border-color: #8e0e18;
  background: transparent;
}

/* 危险按钮：猜汤底（一步定胜负的操作用更重的提示色） */
.btn.danger {
  background: #6e0a12;
  border: 1px solid #b3121f;
}

.btn.danger:hover {
  background: #8e0e18;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- 猜汤底面板（默认收起，加 .open 才展开） ---------- */

.guess-entry {
  margin-top: 10px;
  text-align: right;
}

.guess-panel {
  display: none;
  gap: 8px;
  margin-top: 10px;
}

.guess-panel.open {
  display: flex;
}

/* ---------- 失败公布区（默认隐藏，加 .show 才出现） ---------- */

.reveal-panel {
  display: none;
  margin: 20px auto 0;
  padding: 22px 24px;
  text-align: left;
  background: #140b0d;
  border: 1px solid #8e0e18;
  border-left: 4px solid #b3121f;
  box-shadow: 0 0 34px rgba(120, 0, 10, 0.35);
}

.reveal-panel.show {
  display: block;
}

.reveal-panel h2 {
  font-size: 20px;
  letter-spacing: 4px;
  color: #b3121f;
  margin-bottom: 12px;
}

.reveal-answer {
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
  font-size: 17px;
  line-height: 2;
  color: #d8d1c6;
}

/* ---------- 胜利弹窗（猜中汤底时"弹出"的提示） ---------- */

.modal {
  display: none;
  position: fixed;
  inset: 0;                       /* 铺满全屏的暗幕 */
  background: rgba(0, 0, 0, 0.82);
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.show {
  display: flex;
}

.modal-box {
  max-width: 480px;
  width: 88%;
  padding: 30px 28px;
  text-align: center;
  background: #101014;
  border: 1px solid #b3121f;
  box-shadow: 0 0 60px rgba(179, 18, 31, 0.4);
  animation: popIn 0.35s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: scale(1); }
}

.win-icon {
  font-size: 34px;
  margin-bottom: 8px;
}

.modal-box h2 {
  font-size: 24px;
  letter-spacing: 6px;
  color: #d8b56a;                 /* 揭底成功用暖金色，和失败的血红区分开 */
  margin-bottom: 14px;
}

/* ============================================================
   第 9 课 M3 新增：案件选择页卡片、对局页插图、静音按钮
   延续 M1/M2 的暗黑血红配色，不引入任何外部资源
   ============================================================ */

/* ---------- 声音开关（对局页右上角，一键静音） ---------- */

.sound-btn {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 20;
  width: 40px;
  height: 40px;
  font-size: 18px;
  line-height: 1;
  color: #b98f93;
  background: #101014;
  border: 1px solid #3a1216;
  cursor: pointer;
}

.sound-btn:hover {
  color: #f2e9e4;
  border-color: #8e0e18;
}

/* ---------- 案件选择页：卡片网格 ---------- */

.case-grid {
  margin: 36px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.case-tile {
  display: block;
  background: #101014;
  border: 1px solid #3a1216;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.case-tile:hover {
  border-color: #b3121f;
  transform: translateY(-2px);
}

/* 缩略图：统一裁成一样高，保持卡片整齐 */
.tile-img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-bottom: 1px solid #3a1216;
  background: #0a0a0d;
}

.tile-title {
  padding: 12px 14px 0;
  font-size: 17px;
  letter-spacing: 3px;
  color: #d8d1c6;
}

.tile-lead {
  padding: 7px 14px 0;
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
  font-size: 13px;
  line-height: 1.8;
  color: #7d756b;
}

.tile-badge {
  display: inline-block;
  margin: 10px 14px 14px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #d8b56a;                 /* 次数上限标识：烛火暖黄 */
}

/* ---------- 对局页：案件插图与返回链接 ---------- */

.case-img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  margin-bottom: 14px;
  border: 1px solid #3a1216;
  background: #0a0a0d;
}

.back-link {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 12px;
  letter-spacing: 1px;
  color: #b98f93;
  text-decoration: none;
}

.back-link:hover {
  color: #f2e9e4;
}

/* ============================================================
   第 10 课 M4 新增：剩余次数 ≤3 红色警告、再来一局按钮、结算页打磨
   延续 M1/M2/M3 的暗黑血红配色，不引入任何外部资源
   ============================================================ */

/* ---------- 剩余次数 ≤3：数字变红 + 心跳式闪烁 ---------- */

#count.low {
  color: #ff2a35;
  text-shadow: 0 0 10px rgba(255, 42, 53, 0.55);
  animation: countPulse 1.1s ease-in-out infinite;
}

@keyframes countPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ---------- 结束后的操作按钮（失败公布区 / 胜利弹窗共用） ---------- */

.end-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.end-actions .btn {
  text-decoration: none;
  display: inline-block;
}

.end-actions .btn.ghost {
  line-height: 1;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ---------- 结算页打磨：失败面板加重血红、胜利弹窗加一圈金晕 ---------- */

.reveal-panel.show {
  animation: failIn 0.4s ease-out;
}

@keyframes failIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal.show .modal-box {
  box-shadow: 0 0 60px rgba(179, 18, 31, 0.4), 0 0 110px rgba(216, 181, 106, 0.18);
}
