@font-face {
  font-family: "Smiley Sans";
  src: url("assets/SmileySans.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #123b53;
  --paper: #fffaf0;
  --gold: #f2b642;
  --coral: #e96552;
  --blue: #3190a9;
  --line: #d2c294;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Smiley Sans", "Microsoft YaHei", sans-serif;
  background: #f2e8ce url("assets/因果实验室背景.jpg") center / cover fixed no-repeat;
}

body::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 251, 237, .28), rgba(247, 234, 194, .42));
}

button { font: inherit; cursor: pointer; }

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(28px, 5vh, 64px) 0 40px;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 24px;
  align-items: start;
  width: 100%;
  margin-left: 0;
}
.brand-lockup { display: flex; width: fit-content; grid-column: 1; grid-row: 1; align-items: center; gap: 14px; padding: 12px 22px; border-radius: 24px; background: rgba(255, 250, 240, .76); box-shadow: 0 8px 22px rgba(18, 59, 83, .1); backdrop-filter: blur(7px); }
.title-copy { display: flex; flex-direction: column; }
h1 { margin: 0; font-family: "Smiley Sans", "Microsoft YaHei", sans-serif; font-size: clamp(38px, 5vw, 72px); font-weight: 400; letter-spacing: .06em; line-height: .95; text-shadow: none; }
.magnifier { width: 46px; height: 46px; border: 8px solid var(--coral); border-radius: 50%; position: relative; flex: none; }
.magnifier::after { content: ""; position: absolute; width: 24px; height: 8px; border-radius: 99px; background: var(--coral); right: -19px; bottom: -11px; transform: rotate(45deg); }
.brief { margin: 6px 0 0; color: #355e70; font-family: "Smiley Sans", "Microsoft YaHei", sans-serif; font-size: clamp(17px, 2vw, 24px); font-weight: 400; }
.header-actions { display: flex; grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-end; justify-content: flex-start; gap: 12px; }
.brand-logo { display: block; width: clamp(122px, 10vw, 158px); height: auto; padding: 5px 6px; border-radius: 12px; background: rgba(18, 59, 83, .62); opacity: .98; filter: drop-shadow(0 2px 4px rgba(18, 59, 83, .32)); }
.text-button { padding: 10px 18px; border: 0; border-radius: 999px; color: #fff; background: rgba(18, 59, 83, .94); box-shadow: 0 4px 0 #0a2839; }
.text-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #0a2839; }

.level-switch { display: flex; justify-content: center; gap: 10px; margin: -6px 0 clamp(24px, 4vh, 48px); }
.level-button { min-width: 118px; padding: 11px 18px; border: 2px solid rgba(18, 59, 83, .38); border-radius: 999px; color: #527284; background: rgba(255,255,255,.82); font-size: 18px; box-shadow: 0 3px 8px rgba(18, 59, 83, .08); }
.level-button span { color: var(--coral); font-size: 22px; }
.level-button.active { color: var(--ink); border-color: var(--ink); background: var(--paper); box-shadow: 0 4px 0 var(--ink); }

.case-board { display: grid; grid-template-columns: minmax(0, 1fr) 110px minmax(0, 1fr); align-items: center; gap: 18px; }
.clue-card { height: min(34vw, 370px); padding: clamp(24px, 3.2vw, 46px); display: flex; flex-direction: column; justify-content: flex-start; border: 3px solid var(--ink); border-radius: 30px; box-shadow: 12px 12px 0 rgba(18, 59, 83, .16); backdrop-filter: blur(3px); }
.cause-card { background: rgba(214, 239, 240, .93); }
.result-card { background: rgba(255, 232, 177, .94); }
.card-label { width: fit-content; margin: 0; padding: 7px 14px; border-radius: 999px; font-size: 20px; color: #fff; background: var(--ink); }
.result-card .card-label { background: var(--coral); }
.card-text { margin: clamp(28px, 3.6vw, 48px) 0 0; font-size: clamp(30px, 3.2vw, 50px); line-height: 1.2; letter-spacing: .025em; text-shadow: 0 1px 0 rgba(255,255,255,.38); }
.case-link { display: flex; align-items: center; gap: 7px; color: var(--coral); filter: drop-shadow(0 2px 0 rgba(255,255,255,.48)); }
.case-link span { height: 3px; flex: 1; background: currentColor; }
.case-link b { display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%; font-family: Georgia, serif; font-size: 47px; line-height: 1; color: #fff; background: var(--coral); }

.case-footer { width: min(760px, 100%); margin: clamp(28px, 5vh, 54px) auto 0; padding: 20px 30px 27px; text-align: center; border: 2px solid rgba(210, 194, 148, .9); border-radius: 26px; background: rgba(255, 252, 243, .88); box-shadow: 0 10px 26px rgba(18, 59, 83, .13); }
.prompt { margin: 0 0 21px; font-size: clamp(20px, 2.3vw, 28px); }
.draw-controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.control-button, .draw-button { border: 0; border-radius: 14px; transition: transform .14s ease, box-shadow .14s ease; }
.control-button { justify-self: stretch; min-width: 114px; padding: 14px 18px; color: #fff; background: var(--blue); box-shadow: 0 5px 0 #216878; font-size: 20px; }
.draw-button { min-width: 220px; padding: 15px 28px; color: var(--ink); background: var(--gold); box-shadow: 0 6px 0 #c68120; font-size: 24px; }
.control-button:not(:disabled):active, .draw-button:not(:disabled):active { transform: translateY(4px); box-shadow: 0 1px 0 currentColor; }
.control-button:disabled { color: #899aa2; background: #dce4e3; box-shadow: 0 5px 0 #bdc9c8; cursor: default; }

@media (min-width: 1400px) {
  /* On large teaching displays, open the top rail without widening the cards. */
  .topbar { width: calc(100% + 280px); margin-left: -140px; }
  .case-board { width: calc(100% + 120px); margin-left: -60px; }
}

@media (max-width: 700px) {
  .game-shell { width: min(100% - 28px, 560px); padding-top: 28px; }
  .topbar { width: 100%; margin-left: 0; grid-template-columns: 1fr auto; }
  .brief { margin-top: 2px; }
  .brand-logo { width: 122px; }
  .header-actions { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-end; gap: 8px; }
  .text-button { padding: 8px 13px; font-size: 14px; }
  .brand-lockup { padding: 7px 14px 9px 10px; border-radius: 18px; }
  .magnifier { transform: scale(.7); transform-origin: left center; margin-right: -12px; }
  .case-board { grid-template-columns: 1fr; gap: 16px; }
  .clue-card { height: 190px; }
  .case-link { transform: rotate(90deg); width: 84px; justify-self: center; margin: 9px 0; }
  .case-link b { transform: rotate(-90deg); }
  .level-button { min-width: auto; padding: 9px 13px; font-size: 15px; }
  .draw-controls { grid-template-columns: minmax(0, 1fr) minmax(138px, 1.45fr) minmax(0, 1fr); gap: 8px; }
  .draw-button { min-width: 0; padding: 13px 8px; font-size: 18px; }
  .control-button { min-width: 0; padding: 13px 6px; font-size: 16px; }
}
