:root {
  --ink: #284e4b;
  --muted: #708581;
  --paper: #fffdf7;
  --line: #ddd3b3;
  --red: #eb6c63;
  --red-dark: #ba4a45;
  --blue: #5ba9cf;
  --blue-dark: #347c9d;
  --green: #59aa82;
  --green-dark: #31795e;
  --yellow: #f2bb49;
  --shadow: 0 18px 38px rgba(64,85,71,.14), 0 8px 0 rgba(151,136,87,.17);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: #f2f4e4;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
}
button { color: inherit; font: inherit; }
button:focus-visible { outline: 4px solid rgba(242,187,73,.58); outline-offset: 3px; }
.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 17%, rgba(255,255,255,.88) 0 3px, transparent 4px) 0 0 / 46px 46px,
    radial-gradient(circle at 93% 10%, rgba(91,169,207,.16), transparent 34%),
    linear-gradient(135deg,#fff6d8,#eef5e9 55%,#e0efec);
}
.app {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 52px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand,.top-button {
  min-height: 52px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: rgba(255,253,247,.96);
  box-shadow: 0 5px 0 rgba(145,130,83,.18);
  cursor: pointer;
}
.brand { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 5px 15px 5px 7px; text-align: left; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center;
  border-radius: 14px; color: white; background: linear-gradient(145deg,var(--red),#d45851);
  font-size: 23px; font-weight: 900;
}
.brand b,.brand small { display: block; }
.brand b { font-size: 17px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.top-actions { display: flex; gap: 9px; }
.top-button { padding: 0 16px; font-weight: 900; }
.brand:hover,.top-button:hover { transform: translateY(-1px); }
.brand:active,.top-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(145,130,83,.18); }
.paper { border: 2px solid var(--line); border-radius: 40px; background: var(--paper); box-shadow: var(--shadow); }
.hero { min-height: 535px; display: grid; grid-template-columns: minmax(0,1.05fr) minmax(400px,.95fr); overflow: hidden; }
.hero-copy { min-width: 0; padding: 48px 34px 38px 52px; }
.eyebrow { margin: 0 0 13px; color: #a1681d; font-size: 13px; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
h1,h2,h3,p { overflow-wrap: anywhere; }
h1,h2,h3 { margin: 0; }
.hero h1,.page-head h2,.result-page h1,.notebook-page h1 { font-family: Georgia,"Times New Roman",serif; }
.hero h1 { max-width: 620px; font-size: clamp(49px,5.6vw,72px); line-height: 1; letter-spacing: -.045em; }
.lead { max-width: 600px; margin: 23px 0 25px; color: var(--muted); font-size: 18px; line-height: 1.5; }
.hero-actions,.game-actions,.result-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.primary,.secondary,.hint-button {
  min-height: 55px; padding: 0 23px; border-radius: 17px; font-weight: 900; cursor: pointer;
}
.primary { border: 0; color: white; background: var(--green); box-shadow: 0 7px 0 var(--green-dark); }
.primary:hover:not(:disabled) { background: #67b88f; transform: translateY(-1px); }
.primary:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 var(--green-dark); }
.primary:disabled { opacity: .55; cursor: default; }
.secondary,.hint-button { border: 2px solid var(--line); background: #fffaf0; box-shadow: 0 5px 0 rgba(145,130,83,.16); }
.secondary:hover,.hint-button:hover { background: #fff2cb; transform: translateY(-1px); }
.secondary:active,.hint-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(145,130,83,.16); }
.hero-facts { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin-top: 32px; }
.hero-fact {
  min-width: 0; display: grid; grid-template-columns: 34px 1fr; align-items: center;
  gap: 0 8px; padding: 9px; border: 2px solid #d9d6ba; border-radius: 17px; background: #f4f8ea;
}
.hero-fact span {
  grid-row: 1/3; width: 31px; height: 31px; display: grid; place-items: center;
  border-radius: 50%; color: white; background: var(--red); font-weight: 900;
}
.hero-fact b { font-size: 12px; }
.hero-fact small { color: var(--muted); font-size: 10px; }
.hero-visual {
  position: relative; min-width: 0; min-height: 535px; overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.45) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.45) 1px,transparent 1px),
    linear-gradient(145deg,#d8ebea,#bddbdf);
  background-size: 31px 31px,31px 31px,auto;
}
.hero-visual::before {
  content: ""; position: absolute; width: 420px; height: 420px; left: 49%; top: 48%;
  border: 48px solid rgba(255,255,255,.25); border-radius: 50%; transform: translate(-50%,-50%);
}
.hero-student { position: absolute; z-index: 5; right: -23px; bottom: -18px; width: 180px; height: 300px; object-fit: contain; }
.hero-magnet { position: absolute; z-index: 3; left: 47%; top: 47%; width: 300px; transform: translate(-50%,-50%) rotate(-8deg); filter: drop-shadow(0 14px 12px rgba(46,72,72,.18)); }
.hero-clips { position: absolute; z-index: 4; left: 48%; top: 46%; width: 310px; height: 300px; transform: translate(-50%,-50%); }
.clip {
  position: absolute; width: 30px; height: 58px; border: 7px solid #75888c; border-radius: 18px;
  box-shadow: inset 0 0 0 4px #dce5e3; transform-origin: center;
}
.clip:nth-child(1) { left: 6%; top: 22%; transform: rotate(-32deg); }
.clip:nth-child(2) { right: 4%; top: 17%; transform: rotate(27deg); }
.clip:nth-child(3) { left: 13%; bottom: 4%; transform: rotate(38deg); }
.clip:nth-child(4) { right: 10%; bottom: 0; transform: rotate(-22deg); }
.hero-badge {
  position: absolute; z-index: 6; left: 21px; top: 22px; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 19px; background: rgba(255,255,255,.94);
  box-shadow: 0 7px 18px rgba(38,76,76,.15); font-weight: 900;
}
.safety {
  width: min(930px,calc(100% - 28px)); display: flex; align-items: center; gap: 14px;
  margin: 18px auto 0; padding: 16px 21px; border: 2px solid #e0c77f; border-radius: 24px;
  background: #fff1bf; box-shadow: 0 7px 0 rgba(155,129,59,.14);
}
.safety span { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--yellow); font-size: 23px; font-weight: 900; }
.safety p { margin: 0; line-height: 1.42; }
.home-labs,.notebook-page,.result-page { margin-top: 24px; padding: 38px; scroll-margin-top: 18px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head h2,.notebook-page h1,.result-page h1 { font-size: clamp(38px,5vw,58px); line-height: 1.03; }
.page-head p { max-width: 650px; margin: 9px 0 0; color: var(--muted); line-height: 1.45; }
.lab-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.lab-card { min-width: 0; padding: 25px 23px 22px; border: 2px solid var(--line); border-radius: 27px; background: #fff8ed; box-shadow: 0 7px 0 rgba(144,130,83,.17); }
.lab-card:nth-child(2) { background: #edf7f3; }
.lab-card:nth-child(3) { background: #edf4fa; }
.lab-number { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 18px; color: white; background: var(--red); font-family: Georgia,serif; font-size: 28px; font-weight: 900; transform: rotate(-3deg); }
.lab-card:nth-child(2) .lab-number { background: var(--blue); }
.lab-card:nth-child(3) .lab-number { background: #806fba; }
.lab-card h3 { font-size: 25px; line-height: 1.08; }
.lab-card p { min-height: 82px; color: var(--muted); line-height: 1.45; }
.lab-card .primary { width: 100%; }
.lab-status { display: block; margin: 0 0 14px; color: var(--green-dark); font-size: 12px; font-weight: 900; }
.game-shell { padding: 28px; }
.game-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; margin-bottom: 20px; }
.progress-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 13px; font-weight: 900; }
.progress-track { height: 13px; overflow: hidden; border: 2px solid #cfd1b3; border-radius: 999px; background: #edf0df; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--red),var(--blue)); transition: width .35s ease; }
.score-chip { padding: 10px 14px; border-radius: 15px; background: #fff2c5; font-weight: 900; }
.experiment { display: grid; grid-template-columns: minmax(360px,.96fr) minmax(0,1.04fr); gap: 24px; }
.stage {
  position: relative; min-height: 470px; overflow: hidden; border: 2px solid #c7d5ca; border-radius: 31px;
  background:
    linear-gradient(rgba(255,255,255,.5) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.5) 1px,transparent 1px),
    #e2f1ee;
  background-size: 30px 30px;
}
.stage-label { position: absolute; z-index: 7; left: 18px; top: 17px; right: 18px; padding: 9px 13px; border-radius: 16px; background: rgba(255,255,255,.93); text-align: center; font-weight: 900; }
.table { position: absolute; z-index: 1; left: 6%; right: 6%; bottom: 25px; height: 128px; border: 6px solid #8a6847; border-radius: 24px 24px 12px 12px; background: linear-gradient(#dfb879,#bf8c58); box-shadow: 0 14px 0 rgba(100,74,47,.18); }
.stage-magnet { position: absolute; z-index: 4; left: 15%; bottom: 111px; width: 170px; transition: transform .5s ease; }
.stage-object { position: absolute; z-index: 5; right: 16%; bottom: 123px; width: 135px; height: 135px; transition: transform .65s ease; filter: drop-shadow(0 8px 7px rgba(37,70,69,.17)); }
.stage-object.is-attracted { transform: translateX(-145px) rotate(-12deg); }
.stage-object.is-still { transform: translateY(7px); }
.pole-stage { position: absolute; inset: 83px 25px 25px; display: flex; align-items: center; justify-content: center; gap: 20px; }
.bar-magnet { width: 145px; height: 72px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 6px solid #365b58; border-radius: 16px; box-shadow: 0 10px 0 rgba(60,83,76,.14); transition: transform .7s ease; }
.bar-magnet span { display: grid; place-items: center; color: white; font-family: Georgia,serif; font-size: 28px; font-weight: 900; }
.north { background: var(--red); }
.south { background: var(--blue); }
.pole-stage.attract .bar-magnet:first-child { transform: translateX(25px); }
.pole-stage.attract .bar-magnet:last-child { transform: translateX(-25px); }
.pole-stage.repel .bar-magnet:first-child { transform: translateX(-24px); }
.pole-stage.repel .bar-magnet:last-child { transform: translateX(24px); }
.force-lines { position: absolute; width: 70px; height: 95px; border-top: 5px dashed #a88939; border-bottom: 5px dashed #a88939; border-radius: 50%; opacity: .58; }
.question-panel { min-width: 0; display: flex; flex-direction: column; padding: 16px 3px 4px; }
.question-panel .eyebrow { margin-bottom: 8px; }
.question-panel h1 { font-family: Georgia,"Times New Roman",serif; font-size: clamp(36px,4.2vw,52px); line-height: 1.03; }
.question-panel > p { margin: 13px 0 19px; color: var(--muted); font-size: 17px; line-height: 1.45; }
.answer-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.answer-grid.three { grid-template-columns: repeat(3,1fr); }
.answer {
  min-height: 116px; padding: 14px 10px; border: 3px solid #d2d5bc; border-radius: 23px;
  background: #fffaf0; box-shadow: 0 7px 0 rgba(145,130,83,.16); cursor: pointer;
}
.answer .answer-icon { width: 76px; height: 62px; display: block; margin: 0 auto 4px; }
.answer .answer-icon svg { width: 100%; height: 100%; }
.answer > span:not(.answer-icon) { display: block; margin-bottom: 7px; font-size: 29px; }
.answer b { display: block; font-size: 17px; line-height: 1.15; }
.answer:hover:not(:disabled) { border-color: #86bcb5; transform: translateY(-2px); }
.answer:disabled { cursor: default; }
.answer.wrong { border-color: var(--red); background: #fff0ed; animation: shake .32s ease; }
.answer.correct,.answer.hinted { border-color: var(--green); background: #e8f5ed; }
.answer.hinted { animation: pulse 1s ease 2; }
.feedback { min-height: 91px; margin-top: 15px; padding: 15px 17px; border: 2px solid #d8d7bd; border-radius: 20px; background: #f8f6e8; line-height: 1.42; }
.feedback b { display: block; margin-bottom: 4px; }
.feedback.error { border-color: #efafa7; background: #fff0ed; }
.feedback.success { border-color: #a9d6bd; background: #e9f6ee; }
.feedback.hint { border-color: #e5c674; background: #fff4c9; }
.game-actions { margin-top: 15px; align-items: center; }
.game-actions .primary { margin-left: auto; }
.result-page { text-align: center; }
.result-student { width: 126px; height: 164px; object-fit: contain; }
.stars { margin: 13px 0; color: var(--yellow); font-size: 58px; letter-spacing: 8px; text-shadow: 0 4px 0 rgba(159,118,34,.15); }
.result-page > p { max-width: 680px; margin: 14px auto 24px; color: var(--muted); font-size: 18px; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(3,minmax(0,190px)); justify-content: center; gap: 12px; margin: 23px auto 28px; }
.stat { padding: 17px 12px; border: 2px solid var(--line); border-radius: 20px; background: #fffaf0; }
.stat b { display: block; font-size: 31px; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 900; }
.result-actions { justify-content: center; }
.notebook-page { margin-top: 0; }
.notebook-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; }
.note-card { min-width: 0; min-height: 187px; padding: 12px 8px; border: 2px solid var(--line); border-radius: 21px; background: #fffaf0; text-align: center; }
.note-card.locked { opacity: .5; filter: grayscale(.38); }
.note-icon { width: 88px; height: 86px; margin: 0 auto 5px; }
.note-icon svg { width: 100%; height: 100%; }
.note-card b { display: block; min-height: 34px; font-size: 14px; line-height: 1.16; }
.note-card span { display: block; margin-top: 6px; color: var(--blue-dark); font-size: 12px; font-weight: 900; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 50% { transform: scale(1.025); } }
@media (max-width: 930px) {
  .hero { grid-template-columns: minmax(0,1fr) 365px; }
  .hero-copy { padding-left: 36px; }
  .experiment { grid-template-columns: 365px minmax(0,1fr); }
  .answer-grid.three { grid-template-columns: 1fr; }
  .answer-grid.three .answer { min-height: 82px; display: grid; grid-template-columns: 78px 1fr; align-items: center; }
  .notebook-grid { grid-template-columns: repeat(4,1fr); }
}
@media (max-width: 760px) {
  .app { width: min(1120px,calc(100% - 20px)); padding-top: 10px; }
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding: 37px 27px 31px; }
  .hero-visual { min-height: 420px; }
  .hero-magnet { width: 260px; }
  .hero-student { width: 152px; height: 248px; }
  .lab-grid { grid-template-columns: 1fr; }
  .lab-card p { min-height: 0; }
  .experiment { grid-template-columns: 1fr; }
  .stage { min-height: 420px; }
  .question-panel { padding-top: 4px; }
  .game-head { grid-template-columns: 1fr; }
  .score-chip { justify-self: start; }
  .notebook-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 520px) {
  .app { width: calc(100% - 16px); }
  .topbar { align-items: flex-start; gap: 7px; }
  .brand { padding-right: 8px; }
  .brand small { display: none; }
  .top-actions { gap: 6px; }
  .top-button { width: 49px; padding: 0; font-size: 0; }
  .top-button::first-letter { font-size: 20px; }
  .paper { border-radius: 29px; }
  .hero-copy { padding: 31px 20px 25px; }
  .hero h1 { font-size: 47px; }
  .lead { font-size: 16px; }
  .hero-actions > * { width: 100%; }
  .hero-facts { grid-template-columns: 1fr; }
  .hero-visual { min-height: 360px; }
  .hero-badge { left: 12px; top: 13px; font-size: 13px; }
  .hero-magnet { left: 44%; width: 230px; }
  .hero-student { right: -35px; width: 137px; height: 215px; }
  .safety { width: calc(100% - 12px); align-items: flex-start; padding: 14px; border-radius: 20px; font-size: 14px; }
  .home-labs,.notebook-page,.result-page,.game-shell { padding: 20px 14px; }
  .page-head { display: block; }
  .stage { min-height: 360px; border-radius: 23px; }
  .stage-magnet { left: 9%; bottom: 103px; width: 135px; }
  .stage-object { right: 9%; bottom: 112px; width: 110px; height: 110px; }
  .stage-object.is-attracted { transform: translateX(-110px) rotate(-12deg); }
  .pole-stage { inset: 78px 10px 20px; gap: 8px; }
  .bar-magnet { width: 127px; height: 65px; }
  .question-panel h1 { font-size: 37px; }
  .answer-grid { gap: 8px; }
  .answer { min-height: 104px; padding: 12px 6px; }
  .answer b { font-size: 15px; }
  .answer-grid.three { grid-template-columns: 1fr; }
  .answer-grid.three .answer { min-height: 82px; }
  .game-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .game-actions .primary { width: 100%; margin: 0; grid-column: 1/-1; }
  .stats { grid-template-columns: 1fr; }
  .notebook-grid { grid-template-columns: repeat(2,1fr); gap: 8px; }
  .note-card { min-height: 170px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
