跳到正文

剪贴板

剪贴板 4q086zlz

原文
剪贴板信息

剪贴板信息

收录
更新
C++
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>攻略竹飞 · 青竹之约</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "KaiTi", "STKaiti", serif; }
body {
  min-height: 100vh;
  background: linear-gradient(135deg, #2d4a3e 0%, #1a3a2e 50%, #0f2820 100%);
  overflow: hidden;
  color: #f5e6c8;
}

/* 飘落竹叶 */
.leaf {
  position: fixed;
  color: #8fb89a;
  font-size: 20px;
  animation: fall linear infinite;
  pointer-events: none;
  z-index: 1;
  opacity: 0.6;
}
@keyframes fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* 主容器 */
#game {
  position: relative;
  width: 100vw;
  height: 100vh;
  z-index: 10;
}

/* 开始界面 */
#startScreen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(45,74,62,0.9), rgba(15,40,32,0.95));
  z-index: 100;
}
#startScreen h1 {
  font-size: 72px;
  color: #d4af37;
  text-shadow: 0 0 20px rgba(212,175,55,0.5), 2px 2px 4px #000;
  margin-bottom: 20px;
  letter-spacing: 15px;
  animation: titleGlow 3s ease-in-out infinite;
}
@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 20px rgba(212,175,55,0.5), 2px 2px 4px #000; }
  50% { text-shadow: 0 0 40px rgba(212,175,55,0.8), 2px 2px 4px #000; }
}
#startScreen .subtitle {
  font-size: 24px;
  color: #c8b88a;
  margin-bottom: 60px;
  letter-spacing: 8px;
}
.startBtn {
  padding: 15px 50px;
  font-size: 22px;
  background: linear-gradient(135deg, #8b6f2e, #d4af37);
  color: #2d1810;
  border: 2px solid #d4af37;
  border-radius: 30px;
  cursor: pointer;
  letter-spacing: 5px;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(212,175,55,0.3);
}
.startBtn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(212,175,55,0.5);
}

/* 游戏主界面 */
#mainGame {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
}

/* 顶部状态栏 */
#topBar {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 15px 30px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
}
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}
.statBar {
  width: 180px;
  height: 16px;
  background: rgba(0,0,0,0.5);
  border: 1px solid #d4af37;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.statFill {
  height: 100%;
  background: linear-gradient(90deg, #8fb89a, #d4af37);
  transition: width 0.5s;
  border-radius: 8px;
}
.statValue {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
}

/* 场景背景 */
#scene {
  position: absolute;
  inset: 0;
  transition: background 1s;
}
.scene-bamboo {
  background: linear-gradient(180deg, #3a5a4a 0%, #2d4a3e 40%, #1a3a2e 100%);
}
.scene-temple {
  background: linear-gradient(180deg, #5a3a3a 0%, #3a2a2a 40%, #2a1a1a 100%);
}
.scene-lake {
  background: linear-gradient(180deg, #2a3a5a 0%, #1a2a4a 40%, #0a1a3a 100%);
}
.scene-night {
  background: linear-gradient(180deg, #1a1a3a 0%, #0a0a2a 50%, #000 100%);
}

/* 角色立绘 */
#character {
  position: absolute;
  bottom: 180px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 200px;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.7));
  transition: all 0.5s;
  animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-10px); }
}
#character.happy { animation: happy 0.5s ease; }
@keyframes happy {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.1); }
}
#character.angry { animation: angry 0.5s ease; }
@keyframes angry {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  25% { transform: translateX(-50%) rotate(-5deg); }
  75% { transform: translateX(-50%) rotate(5deg); }
}

/* 对话框 */
#dialogBox {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 900px;
  background: linear-gradient(180deg, rgba(45,74,62,0.95), rgba(15,40,32,0.95));
  border: 2px solid #d4af37;
  border-radius: 15px;
  padding: 25px 30px;
  box-shadow: 0 0 30px rgba(212,175,55,0.3);
  z-index: 15;
}
#speaker {
  color: #d4af37;
  font-size: 22px;
  margin-bottom: 10px;
  letter-spacing: 3px;
}
#dialogText {
  font-size: 18px;
  line-height: 1.8;
  color: #f5e6c8;
  min-height: 50px;
}

/* 选项按钮 */
#choices {
  position: absolute;
  bottom: 200px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 60%;
  max-width: 600px;
  z-index: 16;
}
.choiceBtn {
  padding: 12px 20px;
  background: rgba(45,74,62,0.9);
  border: 1px solid #8fb89a;
  border-radius: 8px;
  color: #f5e6c8;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
}
.choiceBtn:hover {
  background: rgba(143,184,154,0.3);
  border-color: #d4af37;
  transform: translateX(10px);
  color: #d4af37;
}

/* 主菜单按钮 */
#menuBar {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 16;
}
.menuBtn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #8b6f2e, #d4af37);
  color: #2d1810;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.3s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.menuBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(212,175,55,0.5);
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.show { display: flex; }
.modalContent {
  background: linear-gradient(135deg, #2d4a3e, #1a3a2e);
  border: 2px solid #d4af37;
  border-radius: 15px;
  padding: 30px;
  min-width: 500px;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
}
.modalTitle {
  color: #d4af37;
  font-size: 28px;
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 5px;
}

/* 礼物选择 */
.giftGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}
.giftItem {
  background: rgba(143,184,154,0.2);
  border: 1px solid #8fb89a;
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}
.giftItem:hover {
  background: rgba(212,175,55,0.3);
  border-color: #d4af37;
  transform: scale(1.05);
}
.giftEmoji { font-size: 40px; margin-bottom: 8px; }
.giftName { font-size: 14px; color: #f5e6c8; }
.giftEffect { font-size: 12px; color: #8fb89a; margin-top: 5px; }

/* 猜拳小游戏 */
.rpsArea {
  text-align: center;
}
.rpsOptions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 30px 0;
}
.rpsBtn {
  width: 100px;
  height: 100px;
  font-size: 50px;
  background: rgba(143,184,154,0.2);
  border: 2px solid #8fb89a;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s;
}
.rpsBtn:hover {
  background: rgba(212,175,55,0.3);
  border-color: #d4af37;
  transform: scale(1.1);
}
.rpsResult {
  font-size: 24px;
  color: #d4af37;
  margin: 20px 0;
  min-height: 40px;
}

/* 接竹叶小游戏 */
#catchGame {
  position: relative;
  width: 100%;
  height: 400px;
  background: linear-gradient(180deg, #3a5a4a, #2d4a3e);
  border: 2px solid #d4af37;
  border-radius: 10px;
  overflow: hidden;
}
#basket {
  position: absolute;
  bottom: 10px;
  width: 80px;
  height: 50px;
  font-size: 50px;
  text-align: center;
  transition: left 0.1s;
}
.fallingLeaf {
  position: absolute;
  font-size: 30px;
  animation: fallLeaf linear;
}
@keyframes fallLeaf {
  from { top: -50px; }
  to { top: 400px; }
}

/* 结局界面 */
#endingScreen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 200;
}
#endingScreen.show { display: flex; }
#endingTitle {
  font-size: 56px;
  color: #d4af37;
  margin-bottom: 30px;
  letter-spacing: 10px;
  text-shadow: 0 0 30px rgba(212,175,55,0.8);
}
#endingText {
  font-size: 22px;
  color: #f5e6c8;
  max-width: 700px;
  text-align: center;
  line-height: 2;
  margin-bottom: 40px;
}

/* 通知 */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: linear-gradient(135deg, #d4af37, #8b6f2e);
  color: #2d1810;
  padding: 15px 30px;
  border-radius: 25px;
  font-size: 18px;
  z-index: 100;
  transition: transform 0.5s;
  box-shadow: 0 5px 20px rgba(212,175,55,0.5);
}
.toast.show { transform: translateX(-50%) translateY(0); }

.closeBtn {
  margin-top: 20px;
  padding: 10px 30px;
  background: #d4af37;
  color: #2d1810;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 16px;
}
</style>
</head>
<body>

<!-- 飘落竹叶 -->
<div id="leaves"></div>

<div id="game">
  <!-- 开始界面 -->
  <div id="startScreen">
    <h1>攻略竹飞</h1>
    <div class="subtitle">青 竹 之 约</div>
    <button class="startBtn" onclick="startGame()">踏 入 竹 林</button>
    <p style="margin-top:30px;color:#8fb89a;font-size:14px;">—— 一段竹林深处的邂逅 ——</p>
  </div>

  <!-- 主游戏界面 -->
  <div id="mainGame">
    <div id="topBar">
      <div class="stat">
        <span>💚 好感度</span>
        <div class="statBar">
          <div class="statFill" id="affectionBar" style="width:0%"></div>
          <div class="statValue" id="affectionValue">0/100</div>
        </div>
      </div>
      <div class="stat">
        <span>📅 第 <span id="dayCount">1</span> 天</span>
        <span style="margin-left:20px;">💰 <span id="goldCount">100</span></span>
      </div>
    </div>

    <div id="scene" class="scene-bamboo"></div>
    <div id="character">🧑‍🦰</div>

    <div id="dialogBox">
      <div id="speaker">竹飞</div>
      <div id="dialogText">……</div>
    </div>

    <div id="choices"></div>

    <div id="menuBar">
      <button class="menuBtn" onclick="openGift()">🎁 送礼</button>
      <button class="menuBtn" onclick="openRPS()">✊ 猜拳</button>
      <button class="menuBtn" onclick="openCatch()">🍃 接竹叶</button>
      <button class="menuBtn" onclick="nextDay()">🌙 休息</button>
    </div>
  </div>
</div>

<!-- 送礼弹窗 -->
<div class="modal" id="giftModal">
  <div class="modalContent">
    <div class="modalTitle">🎁 赠送礼物</div>
    <div class="giftGrid" id="giftGrid"></div>
    <div style="text-align:center;">
      <button class="closeBtn" onclick="closeModal('giftModal')">返回</button>
    </div>
  </div>
</div>

<!-- 猜拳弹窗 -->
<div class="modal" id="rpsModal">
  <div class="modalContent">
    <div class="modalTitle">✊ 与竹飞猜拳</div>
    <div class="rpsArea">
      <p style="color:#8fb89a;">赢了 +10 好感,输了 -5 好感</p>
      <div class="rpsOptions">
        <button class="rpsBtn" onclick="playRPS('✊')">✊</button>
        <button class="rpsBtn" onclick="playRPS('✋')">✋</button>
        <button class="rpsBtn" onclick="playRPS('✌️')">✌️</button>
      </div>
      <div class="rpsResult" id="rpsResult"></div>
    </div>
    <div style="text-align:center;">
      <button class="closeBtn" onclick="closeModal('rpsModal')">返回</button>
    </div>
  </div>
</div>

<!-- 接竹叶弹窗 -->
<div class="modal" id="catchModal">
  <div class="modalContent">
    <div class="modalTitle">🍃 接竹叶</div>
    <p style="color:#8fb89a;text-align:center;margin-bottom:10px;">用 ← → 键移动竹篮,接住竹叶!每接1片 +2 好感</p>
    <div id="catchGame">
      <div id="basket">🧺</div>
    </div>
    <p style="text-align:center;margin-top:10px;color:#d4af37;">已接:<span id="catchScore">0</span> 片</p>
    <div style="text-align:center;">
      <button class="closeBtn" onclick="endCatch()">结束</button>
    </div>
  </div>
</div>

<!-- 结局 -->
<div id="endingScreen">
  <div id="endingTitle"></div>
  <div id="endingText"></div>
  <button class="startBtn" onclick="location.reload()">重新开始</button>
</div>

<div class="toast" id="toast"></div>

<script>
// 游戏数据
const state = {
  affection: 0,
  day: 1,
  gold: 100,
  stage: 0, // 0初遇 1熟悉 2暧昧 3心动 4结局
  giftsGiven: 0,
  rpsWins: 0
};

// 礼物数据
const gifts = [
  { emoji: '🍵', name: '明前龙井', effect: '+8', value: 8, cost: 20, like: true },
  { emoji: '🎋', name: '青竹玉笛', effect: '+15', value: 15, cost: 50, like: true },
  { emoji: '📜', name: '古籍残卷', effect: '+12', value: 12, cost: 40, like: true },
  { emoji: '🌸', name: '桃花酿', effect: '+10', value: 10, cost: 30, like: false },
  { emoji: '🗡️', name: '寒铁短剑', effect: '+5', value: 5, cost: 60, like: false },
  { emoji: '🎐', name: '风铃', effect: '+10', value: 10, cost: 25, like: true },
  { emoji: '🍡', name: '桂花糕', effect: '+6', value: 6, cost: 15, like: true },
  { emoji: '📿', name: '菩提手串', effect: '+8', value: 8, cost: 35, like: false },
  { emoji: '🏮', name: '青竹灯笼', effect: '+12', value: 12, cost: 30, like: true }
];

// 剧情对话
const dialogues = {
  0: [ // 初遇
    { speaker: '旁白', text: '竹林深处,薄雾缭绕。你偶然踏入这片幽静之地……' },
    { speaker: '竹飞', text: '(一位青衫男子正倚竹吹笛,闻声抬眸)……你是何人?怎会来此?' },
    { speaker: '旁白', text: '他的眼神清冷如竹,却又带着一丝好奇。' }
  ],
  1: [ // 熟悉
    { speaker: '竹飞', text: '你又来了。……这竹林,平日里少有人至。' },
    { speaker: '竹飞', text: '(嘴角微扬)不过,倒也不讨厌。' }
  ],
  2: [ // 暧昧
    { speaker: '竹飞', text: '(见你来,放下手中茶盏)今日的茶刚沏好,要尝尝么?' },
    { speaker: '竹飞', text: '……你总来,可是有什么心事?若愿意,可以说与我听。' }
  ],
  3: [ // 心动
    { speaker: '竹飞', text: '(眸光温柔)你来了。……我等你。' },
    { speaker: '竹飞', text: '这青竹见证过许多过客,但你是第一个……让我想留住的人。' }
  ]
};

// 选项
const choicesData = {
  0: [
    { text: '「在下迷路了,误入此地。」', aff: 5, reply: '竹飞微微颔首:「原来如此。既来之,则安之。这竹林清静,不妨多待片刻。」' },
    { text: '「你的笛声……真好听。」', aff: 10, reply: '竹飞眸光微动:「……难得有人这样夸。你倒是个会说话的人。」' },
    { text: '「这竹林是你家的?」', aff: 3, reply: '竹飞:「算是吧。我在此独居已久。」' }
  ],
  1: [
    { text: '「给你带了礼物。」', aff: 8, reply: '竹飞:「……有心了。」(接过时,指尖轻触)' },
    { text: '「今天想做什么?」', aff: 6, reply: '竹飞:「随你。……有你在,做什么都好。」' },
    { text: '「我来给你吹首曲子吧!」', aff: 12, reply: '竹飞轻笑:「好。我洗耳恭听。」' }
  ],
  2: [
    { text: '「我想一直陪着你。」', aff: 15, reply: '竹飞怔住,半晌才低声道:「……这话,莫要轻易说。」' },
    { text: '「竹飞,你笑起来真好看。」', aff: 12, reply: '(他别过脸,耳根微红)「……油嘴滑舌。」' },
    { text: '「我们一起去湖边走走吧。」', aff: 10, reply: '竹飞:「好。难得你有此兴致。」' }
  ],
  3: [
    { text: '「竹飞,我喜欢你。」', aff: 20, reply: '(他深深看你一眼,执起你的手)「……我等这句话,等了很久。」' },
    { text: '「我们永远在一起吧。」', aff: 25, reply: '竹飞:「好。青竹为证,此生不负。」' }
  ]
};

// 初始化竹叶
function createLeaves() {
  const container = document.getElementById('leaves');
  for (let i = 0; i < 15; i++) {
    const leaf = document.createElement('div');
    leaf.className = 'leaf';
    leaf.textContent = '🍃';
    leaf.style.left = Math.random() * 100 + '%';
    leaf.style.animationDuration = (8 + Math.random() * 7) + 's';
    leaf.style.animationDelay = Math.random() * 10 + 's';
    leaf.style.fontSize = (15 + Math.random() * 15) + 'px';
    container.appendChild(leaf);
  }
}

function startGame() {
  document.getElementById('startScreen').style.display = 'none';
  document.getElementById('mainGame').style.display = 'block';
  showDialogue(0);
}

function showDialogue(stage) {
  const d = dialogues[stage];
  if (!d) return;
  let i = 0;
  const speaker = document.getElementById('speaker');
  const text = document.getElementById('dialogText');
  const choices = document.getElementById('choices');
  choices.innerHTML = '';
  
  function showNext() {
    if (i >= d.length) {
      showChoices(stage);
      return;
    }
    speaker.textContent = d[i].speaker;
    typeWriter(text, d[i].text, () => {
      setTimeout(() => { i++; showNext(); }, 1500);
    });
  }
  showNext();
}

function typeWriter(el, txt, cb) {
  el.textContent = '';
  let i = 0;
  const timer = setInterval(() => {
    el.textContent += txt[i];
    i++;
    if (i >= txt.length) { clearInterval(timer); cb && cb(); }
  }, 40);
}

function showChoices(stage) {
  const choices = document.getElementById('choices');
  choices.innerHTML = '';
  const data = choicesData[stage] || [];
  data.forEach(c => {
    const btn = document.createElement('button');
    btn.className = 'choiceBtn';
    btn.textContent = c.text;
    btn.onclick = () => makeChoice(c);
    choices.appendChild(btn);
  });
}

function makeChoice(c) {
  document.getElementById('choices').innerHTML = '';
  addAffection(c.aff);
  const speaker = document.getElementById('speaker');
  const text = document.getElementById('dialogText');
  speaker.textContent = '竹飞';
  typeWriter(text, c.reply, () => {
    setTimeout(() => {
      checkStage();
    }, 2000);
  });
}

function addAffection(v) {
  state.affection = Math.max(0, Math.min(100, state.affection + v));
  document.getElementById('affectionBar').style.width = state.affection + '%';
  document.getElementById('affectionValue').textContent = state.affection + '/100';
  
  const char = document.getElementById('character');
  if (v > 0) {
    char.classList.remove('happy');
    void char.offsetWidth;
    char.classList.add('happy');
  } else if (v < 0) {
    char.classList.remove('angry');
    void char.offsetWidth;
    char.classList.add('angry');
  }
  
  if (v > 0) showToast(`💚 好感 +${v}`);
  else if (v < 0) showToast(`💔 好感 ${v}`);
  
  if (state.affection >= 100) {
    setTimeout(() => showEnding('perfect'), 1500);
  }
}

function checkStage() {
  let newStage = 0;
  if (state.affection >= 25) newStage = 1;
  if (state.affection >= 50) newStage = 2;
  if (state.affection >= 75) newStage = 3;
  
  if (newStage > state.stage) {
    state.stage = newStage;
    const scenes = ['scene-bamboo', 'scene-bamboo', 'scene-lake', 'scene-night'];
    const scene = document.getElementById('scene');
    scene.className = scenes[newStage];
    showToast(`✨ 关系提升!进入新阶段`);
    showDialogue(newStage);
  }
}

// 送礼
function openGift() {
  const grid = document.getElementById('giftGrid');
  grid.innerHTML = '';
  gifts.forEach((g, i) => {
    const item = document.createElement('div');
    item.className = 'giftItem';
    item.innerHTML = `
      <div class="giftEmoji">${g.emoji}</div>
      <div class="giftName">${g.name}</div>
      <div class="giftEffect">${g.effect} 好感 · 💰${g.cost}</div>
    `;
    item.onclick = () => giveGift(i);
    grid.appendChild(item);
  });
  document.getElementById('giftModal').classList.add('show');
}

function giveGift(i) {
  const g = gifts[i];
  if (state.gold < g.cost) {
    showToast('💰 金币不足!');
    return;
  }
  state.gold -= g.cost;
  document.getElementById('goldCount').textContent = state.gold;
  
  let effect = g.value;
  let reply = '';
  if (g.like) {
    reply = `竹飞眼睛一亮:「这是……我很喜欢,谢谢你。」`;
  } else {
    effect = Math.floor(effect / 2);
    reply = `竹飞礼貌地接过:「有心了。」(似乎不太感兴趣)`;
  }
  
  addAffection(effect);
  state.giftsGiven++;
  closeModal('giftModal');
  
  const speaker = document.getElementById('speaker');
  const text = document.getElementById('dialogText');
  speaker.textContent = '竹飞';
  typeWriter(text, reply);
}

// 猜拳
function playRPS(p) {
  const opts = ['✊', '✋', '✌️'];
  const cpu = opts[Math.floor(Math.random() * 3)];
  let result = '';
  let aff = 0;
  
  if (p === cpu) {
    result = `你出${p},竹飞出${cpu}——平局!`;
  } else if (
    (p === '✊' && cpu === '✌️') ||
    (p === '✋' && cpu === '✊') ||
    (p === '✌️' && cpu === '✋')
  ) {
    result = `你出${p},竹飞出${cpu}——你赢了!`;
    aff = 10;
    state.rpsWins++;
  } else {
    result = `你出${p},竹飞出${cpu}——你输了!`;
    aff = -5;
  }
  
  document.getElementById('rpsResult').textContent = result;
  addAffection(aff);
}

// 接竹叶小游戏
let catchTimer, catchInterval, catchScore = 0, basketX = 260;
function openCatch() {
  document.getElementById('catchModal').classList.add('show');
  catchScore = 0;
  document.getElementById('catchScore').textContent = 0;
  basketX = 260;
  updateBasket();
  
  catchInterval = setInterval(() => {
    spawnLeaf();
  }, 800);
  
  catchTimer = setTimeout(() => endCatch(), 20000);
}

function spawnLeaf() {
  const game = document.getElementById('catchGame');
  const leaf = document.createElement('div');
  leaf.className = 'fallingLeaf';
  leaf.textContent = Math.random() > 0.2 ? '🍃' : '🌸';
  leaf.style.left = Math.random() * 560 + 'px';
  leaf.dataset.type = leaf.textContent;
  const duration = 2 + Math.random() * 1.5;
  leaf.style.animationDuration = duration + 's';
  game.appendChild(leaf);
  
  const checkHit = setInterval(() => {
    const rect = leaf.getBoundingClientRect();
    const gameRect = game.getBoundingClientRect();
    const leafX = rect.left - gameRect.left + 15;
    const leafY = rect.top - gameRect.top + 15;
    
    if (leafY > 340 && leafY < 400 && Math.abs(leafX - basketX - 40) < 50) {
      catchScore++;
      document.getElementById('catchScore').textContent = catchScore;
      leaf.remove();
      clearInterval(checkHit);
    } else if (leafY > 400) {
      leaf.remove();
      clearInterval(checkHit);
    }
  }, 50);
}

function updateBasket() {
  document.getElementById('basket').style.left = basketX + 'px';
}

document.addEventListener('keydown', e => {
  if (!document.getElementById('catchModal').classList.contains('show')) return;
  if (e.key === 'ArrowLeft') basketX = Math.max(0, basketX - 30);
  if (e.key === 'ArrowRight') basketX = Math.min(540, basketX + 30);
  updateBasket();
});

function endCatch() {
  clearInterval(catchInterval);
  clearTimeout(catchTimer);
  document.querySelectorAll('.fallingLeaf').forEach(l => l.remove());
  
  const aff = catchScore * 2;
  addAffection(aff);
  showToast(`🍃 接了${catchScore}片竹叶!好感 +${aff}`);
  closeModal('catchModal');
}

function closeModal(id) {
  document.getElementById(id).classList.remove('show');
}

function nextDay() {
  state.day++;
  state.gold += 30;
  document.getElementById('dayCount').textContent = state.day;
  document.getElementById('goldCount').textContent = state.gold;
  showToast(`🌙 新的一天 · 金币 +30`);
  
  if (state.day >= 10 && state.affection < 50) {
    showEnding('bad');
  } else {
    showDialogue(state.stage);
  }
}

function showEnding(type) {
  const screen = document.getElementById('endingScreen');
  const title = document.getElementById('endingTitle');
  const text = document.getElementById('endingText');
  
  if (type === 'perfect') {
    title.textContent = '🎋 青竹之约';
    text.innerHTML = `竹飞执起你的手,十指相扣。<br><br>
      「从今往后,这竹林便是我们的家。」<br>
      「青竹为证,此生不负。」<br><br>
      <span style="color:#d4af37;">—— 完美结局 · 竹影成双 ——</span>`;
  } else if (type === 'bad') {
    title.textContent = '🍂 缘浅情深';
    text.innerHTML = `十日已过,竹飞的身影渐渐淡去。<br><br>
      「你我……终究是有缘无分。」<br>
      「愿你此后,一路平安。」<br><br>
      <span style="color:#8fb89a;">—— 普通结局 · 竹林过客 ——</span>`;
  }
  
  screen.classList.add('show');
}

function showToast(msg) {
  const t = document.getElementById('toast');
  t.textContent = msg;
  t.classList.add('show');
  setTimeout(() => t.classList.remove('show'), 2000);
}

createLeaves();
</script>
</body>
</html>