:root {
  --green: #1f5f46;
  --deep: #12382d;
  --mint: #7fc7af;
  --paper: #fbf7ec;
  --card: #fffdf5;
  --line: #d7d0bc;
  --soil: #8b6848;
  --blue: #4d9aa8;
  --gold: #d5a84f;
  --danger: #b34a38;
  --shadow: 0 18px 50px rgba(26, 44, 35, .18);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #21352d;
  background: #ece7d8;
}
button, input, select { font: inherit; }
button, .file-btn {
  border: 1px solid #b9c8bc;
  background: #fffaf0;
  color: #183b31;
  padding: 11px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
button:hover, .file-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(22, 69, 48, .14); }
button:active { transform: translateY(1px); }
button.primary { background: var(--green); color: white; border-color: var(--green); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.home-screen {
  position: relative;
  padding: min(5vw, 54px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(251,247,236,.95), rgba(236,247,239,.9)),
    radial-gradient(circle at 82% 20%, rgba(213,168,79,.22), transparent 30%);
}
.home-screen.active { display: grid; grid-template-columns: minmax(320px, 560px) 1fr; gap: 34px; align-items: center; }
.eyebrow { color: var(--green); font-weight: 700; letter-spacing: 0; }
h1 { font-size: clamp(40px, 6vw, 86px); margin: 0; color: var(--deep); letter-spacing: 0; }
h2 { margin: 8px 0 20px; color: #4d6259; }
.tagline { font-size: 20px; line-height: 1.7; max-width: 620px; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 12px; max-width: 430px; margin: 28px 0 18px; }
.community {
  display: inline-block;
  padding: 12px 16px;
  background: #fff4ce;
  border: 1px solid #e7cb75;
  border-radius: 8px;
  font-weight: 700;
}
footer { position: absolute; left: min(5vw, 54px); right: min(5vw, 54px); bottom: 18px; color: #5b655d; }

.lab-hero {
  position: relative;
  min-height: 620px;
  border-left: 6px solid rgba(31,95,70,.12);
}
.shelf, .bench, .advisor, .student { position: absolute; }
.shelf {
  top: 32px; right: 60px; width: 380px; height: 142px;
  background: #d8e7da; border: 8px solid #9b8064; border-radius: 8px;
  box-shadow: var(--shadow);
}
.shelf:after { content: ""; position: absolute; left: 0; right: 0; top: 64px; border-top: 7px solid #9b8064; }
.tube, .bottle {
  position: absolute; bottom: 82px; width: 26px; height: 54px; left: 42px;
  background: linear-gradient(#e8fffa 45%, #8fcabf 46%); border: 2px solid #699;
}
.tube.teal { left: 82px; background: linear-gradient(#e8fffa 45%, #5db5c3 46%); }
.bottle { left: 130px; width: 38px; border-radius: 12px 12px 6px 6px; }
.seedlings { position: absolute; bottom: 16px; left: 210px; display: flex; gap: 22px; }
.seedlings i, .potato-plant i { display: block; width: 28px; height: 42px; border-radius: 70% 20%; background: #4b9d58; transform: rotate(-18deg); }
.seedlings i:nth-child(2), .potato-plant i:nth-child(3) { transform: rotate(18deg); background: #65b86a; }
.advisor { right: 30px; top: 205px; width: 210px; text-align: center; animation: floaty 3s ease-in-out infinite; }
.bubble { background: white; border: 2px solid var(--deep); padding: 12px; border-radius: 8px; font-weight: 700; margin-bottom: 8px; }
.avatar { font-size: 74px; line-height: 1; }
.folder { margin: -8px auto 0; width: 98px; padding: 8px; background: #e4c36f; border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); }
.student { left: 70px; bottom: 138px; width: 180px; text-align: center; animation: breathe 2.8s ease-in-out infinite; }
.coat { font-size: 96px; }
.clipboard { position: absolute; right: -28px; top: 52px; background: #f4e2b6; border: 2px solid #8b6848; padding: 8px; border-radius: 5px; transform: rotate(5deg); }
.pipette { position: absolute; left: 10px; top: 85px; width: 76px; height: 8px; background: #397684; transform: rotate(-28deg); border-radius: 9px; }
.bench {
  left: 28px; right: 30px; bottom: 44px; height: 150px;
  background: linear-gradient(#b78b5d 0 28px, #8b6848 29px);
  border-radius: 10px; box-shadow: var(--shadow);
}
.potato-plant { position: absolute; left: 58px; top: -66px; width: 110px; height: 90px; text-align: center; }
.potato-plant span { position: absolute; bottom: 0; left: 34px; font-size: 42px; }
.potato-plant i { position: absolute; bottom: 38px; left: 50px; }
.potato-plant i:nth-child(2) { left: 30px; }
.potato-plant i:nth-child(4) { left: 70px; }
.chart, .laptop, .notebook, .incubator {
  position: absolute; background: var(--card); border: 2px solid #8fa89a; border-radius: 6px; padding: 10px;
}
.chart { left: 220px; top: 26px; width: 105px; height: 74px; display: flex; align-items: end; gap: 8px; }
.chart b { width: 18px; background: var(--blue); height: 30px; }
.chart b:nth-child(2) { height: 48px; background: var(--green); }
.chart b:nth-child(3) { height: 20px; background: var(--gold); }
.laptop { left: 360px; top: 35px; width: 150px; height: 64px; background: #dbe9eb; }
.notebook { right: 210px; top: 30px; transform: rotate(-5deg); background: #f5e5bd; }
.incubator { right: 36px; top: -32px; width: 130px; height: 106px; background: #dce9e7; text-align: center; }
@keyframes floaty { 50% { transform: translateY(-8px); } }
@keyframes breathe { 50% { transform: scale(1.025); } }

.setup-screen, .game-screen { padding: 28px; background: linear-gradient(#f7f3e8, #e8efe9); }
.back-home { margin-bottom: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 28px; }
.choice-card {
  text-align: left; min-height: 150px; background: var(--card); border-color: var(--line);
  box-shadow: 0 10px 28px rgba(35, 66, 50, .08);
}
.choice-card strong { display: block; font-size: 18px; margin-bottom: 8px; color: var(--deep); }
.choice-card small { display: block; line-height: 1.6; color: #5d6a61; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--deep); color: white; padding: 14px 18px; border-radius: 8px; margin-bottom: 16px;
}
.topbar button { background: #f8efd7; }
.game-layout { display: grid; grid-template-columns: 280px 1fr 320px; gap: 16px; }
.panel { background: rgba(255,253,245,.94); border: 1px solid var(--line); border-radius: 8px; padding: 16px; box-shadow: 0 8px 26px rgba(20, 50, 38, .08); }
.stat { margin: 10px 0; }
.stat-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar { height: 10px; background: #e2decd; border-radius: 99px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--green); width: 50%; }
.bar.money i { background: var(--gold); }
.save-tools { display: grid; gap: 8px; margin-top: 18px; }
.file-btn input { display: none; }
.stage-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stage-row div { background: #eef5ef; border: 1px solid #cbd8cd; border-radius: 8px; padding: 12px; }
.stage-row span { display: block; color: #5d6a61; font-size: 13px; }
.advisor-line, .event-box {
  margin: 14px 0; padding: 14px; border-radius: 8px; background: #fff4ce; border: 1px solid #e7cb75; font-weight: 700;
}
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.action-btn { text-align: left; min-height: 82px; }
.action-btn small { display: block; color: #657269; margin-top: 5px; }
.office-event { background: #f6e7df; border: 1px solid #dfaa96; border-radius: 8px; padding: 12px; margin: 14px 0; }
.hidden { display: none; }
.log-list { max-height: 510px; overflow: auto; padding-left: 20px; }
.log-list li { margin: 0 0 10px; line-height: 1.45; }
dialog { width: min(760px, calc(100vw - 28px)); border: 0; border-radius: 10px; padding: 0; box-shadow: var(--shadow); background: var(--card); }
dialog::backdrop { background: rgba(15, 33, 26, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--deep); color: white; }
.modal-head h2 { margin: 0; color: white; }
#closeModal { background: transparent; color: white; border: 0; font-size: 28px; padding: 2px 8px; }
#modalContent { padding: 18px; line-height: 1.7; }
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 20; background: var(--deep); color: white; padding: 10px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.toast.show { opacity: 1; }

@media (max-width: 980px) {
  .home-screen.active { grid-template-columns: 1fr; padding-bottom: 80px; }
  .lab-hero { min-height: 520px; }
  footer { position: static; margin-top: 20px; }
  .game-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 620px) {
  .menu-grid, .stage-row { grid-template-columns: 1fr; }
  .lab-hero { transform: scale(.82); transform-origin: top left; width: 122%; min-height: 430px; }
  .setup-screen, .game-screen { padding: 14px; }
  button, .file-btn { min-height: 44px; }
}
