:root {
  --ink: #294f4c;
  --muted: #6f8581;
  --paper: #fffdf7;
  --cream: #fff4d4;
  --line: #ddd4b5;
  --water: #67b8d4;
  --water-dark: #3a91b4;
  --green: #58a982;
  --green-dark: #2f795d;
  --yellow: #f2ba46;
  --coral: #ec7266;
  --shadow: 0 18px 38px rgba(72, 91, 75, .15), 0 8px 0 rgba(152, 139, 91, .17);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: #f3f4df;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
}

button { color: inherit; font: inherit; }
button:focus-visible { outline: 4px solid rgba(242, 186, 70, .55); outline-offset: 3px; }

.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.8) 0 3px, transparent 4px) 0 0 / 44px 44px,
    radial-gradient(circle at 90% 12%, rgba(103,184,212,.16), transparent 35%),
    linear-gradient(135deg, #fff7da 0%, #eef6e5 52%, #dff1ed 100%);
}

.app {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 50px;
}

.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,.95);
  box-shadow: 0 5px 0 rgba(145, 132, 88, .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, #6fc8de, #408fac);
  font-size: 25px;
}

.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; }
.top-button:hover,
.brand:hover { transform: translateY(-1px); }
.top-button:active,
.brand:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(145,132,88,.18); }

.paper {
  border: 2px solid var(--line);
  border-radius: 40px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero {
  min-height: 540px;
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(400px, .97fr);
  overflow: hidden;
}

.hero-copy {
  min-width: 0;
  padding: 50px 34px 39px 52px;
}

.eyebrow {
  margin: 0 0 14px;
  color: #a16b20;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; }

h1 {
  max-width: 610px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(50px, 6vw, 76px);
  line-height: .98;
  letter-spacing: -.045em;
}

.lead {
  max-width: 590px;
  margin: 25px 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.5;
}

.hero-actions,
.result-actions,
.game-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: #67b78f; transform: translateY(-1px); }
.primary:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 var(--green-dark); }
.primary:disabled { opacity: .52; cursor: default; }

.secondary,
.hint-button {
  border: 2px solid var(--line);
  background: #fffaf0;
  box-shadow: 0 5px 0 rgba(145,132,88,.16);
}
.secondary:hover,
.hint-button:hover { background: #fff3cf; transform: translateY(-1px); }
.secondary:active,
.hint-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(145,132,88,.16); }

.hero-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 34px;
}

.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(--green);
  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: 540px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.44) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.44) 1px, transparent 1px),
    linear-gradient(145deg, #d9eef0, #b9dee1);
  background-size: 31px 31px, 31px 31px, auto;
}

.hero-visual::before {
  content: "";
  position: absolute;
  width: 430px;
  height: 430px;
  left: 48%;
  top: 48%;
  border: 48px solid rgba(255,255,255,.25);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.scientist {
  position: absolute;
  z-index: 4;
  right: -24px;
  bottom: -18px;
  width: 188px;
  height: 310px;
  object-fit: contain;
}

.hero-tub {
  position: absolute;
  z-index: 2;
  left: 47%;
  top: 53%;
  width: 330px;
  height: 310px;
  transform: translate(-50%, -50%);
}

.hero-object {
  position: absolute;
  z-index: 4;
  left: 49%;
  top: 29%;
  width: 112px;
  transform: translate(-50%, -50%) rotate(-8deg);
  filter: drop-shadow(0 10px 8px rgba(35,72,72,.18));
  animation: bob 2.5s ease-in-out infinite;
}

.hero-badge {
  position: absolute;
  z-index: 5;
  left: 22px;
  top: 23px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 19px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 7px 18px rgba(38,81,82,.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; }

.laboratories,
.journal-page,
.result-page {
  padding: 38px;
}

.home-labs { margin-top: 24px; scroll-margin-top: 18px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-head h1,
.page-head h2,
.result-page h1 { font-size: clamp(37px, 5vw, 58px); }
.page-head p { max-width: 630px; 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: #fffaf0;
  box-shadow: 0 7px 0 rgba(144,132,88,.17);
}
.lab-card:nth-child(2) { background: #edf7f3; }
.lab-card:nth-child(3) { background: #eef5fb; }
.lab-number {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 18px;
  color: white;
  background: var(--water-dark);
  font-family: Georgia, serif;
  font-size: 28px;
  font-weight: 900;
  transform: rotate(-3deg);
}
.lab-card h2,
.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, #64b78e, #68bad4); transition: width .35s ease; }
.score-chip { padding: 10px 14px; border-radius: 15px; background: #fff2c5; font-weight: 900; }

.experiment {
  display: grid;
  grid-template-columns: minmax(330px, .93fr) minmax(0, 1.07fr);
  gap: 24px;
}

.tank-panel {
  position: relative;
  min-height: 480px;
  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),
    #e2f2ed;
  background-size: 30px 30px;
}

.task-label {
  position: absolute;
  z-index: 4;
  left: 18px;
  top: 17px;
  right: 18px;
  padding: 9px 13px;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  text-align: center;
  font-weight: 900;
}

.tank {
  position: absolute;
  left: 50%;
  bottom: 29px;
  width: min(360px, calc(100% - 34px));
  height: 315px;
  overflow: hidden;
  border: 7px solid #365d5a;
  border-top-width: 4px;
  border-radius: 16px 16px 55px 55px;
  background: rgba(255,255,255,.48);
  transform: translateX(-50%);
  box-shadow: inset 17px 0 0 rgba(255,255,255,.25), 0 17px 25px rgba(46,80,78,.16);
}

.tank::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  height: 61%;
  background: linear-gradient(#85d2e5, #4da6c7);
}

.tank::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: -4%;
  right: -4%;
  top: 37%;
  height: 17px;
  border-radius: 50%;
  background: rgba(214,247,250,.82);
  box-shadow: 0 6px 0 rgba(43,141,177,.36);
}

.water-lines {
  position: absolute;
  z-index: 2;
  left: 10%;
  right: 10%;
  bottom: 13%;
  height: 27%;
  opacity: .45;
  background: repeating-linear-gradient(0deg, transparent 0 25px, rgba(255,255,255,.45) 26px 28px);
}

.object-stage {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 18px;
  width: 142px;
  height: 142px;
  transform: translateX(-50%);
  transition: top .85s cubic-bezier(.25,.8,.25,1), transform .85s ease;
  filter: drop-shadow(0 9px 7px rgba(35,71,69,.18));
}
.object-stage.is-floating { top: 101px; transform: translateX(-50%) rotate(-4deg); }
.object-stage.is-sinking { top: 218px; transform: translateX(-50%) rotate(7deg); }
.object-stage svg { width: 100%; height: 100%; }

.bubbles {
  position: absolute;
  z-index: 4;
  inset: 42% 0 0;
  opacity: 0;
  background:
    radial-gradient(circle at 35% 80%, rgba(255,255,255,.75) 0 5px, transparent 6px),
    radial-gradient(circle at 61% 62%, rgba(255,255,255,.7) 0 7px, transparent 8px),
    radial-gradient(circle at 48% 37%, rgba(255,255,255,.68) 0 4px, transparent 5px);
}
.tank.has-result .bubbles { opacity: 1; animation: bubble 1.2s ease-out; }

.question-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 19px 3px 4px;
}
.question-panel .eyebrow { margin-bottom: 8px; }
.question-panel h1 { font-size: clamp(37px, 4.2vw, 54px); line-height: 1.03; }
.question-panel > p { margin: 13px 0 20px; color: var(--muted); font-size: 17px; line-height: 1.45; }

.answer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.answer {
  min-height: 119px;
  padding: 17px 13px;
  border: 3px solid #d2d5bc;
  border-radius: 23px;
  background: #fffaf0;
  box-shadow: 0 7px 0 rgba(145,132,88,.16);
  cursor: pointer;
}
.answer span { display: block; margin-bottom: 7px; font-size: 32px; }
.answer b { font-size: 19px; }
.answer:hover:not(:disabled) { border-color: #88bdb7; transform: translateY(-2px); }
.answer:disabled { cursor: default; }
.answer.wrong { border-color: var(--coral); 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: 93px;
  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 { position: relative; overflow: hidden; text-align: center; }
.result-scientist { width: 125px; height: 165px; 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: 670px; 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; }

.journal-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.journal-card {
  min-width: 0;
  min-height: 188px;
  padding: 12px 8px;
  border: 2px solid var(--line);
  border-radius: 21px;
  background: #fffaf0;
  text-align: center;
}
.journal-card.locked { opacity: .53; filter: grayscale(.35); }
.journal-icon { width: 92px; height: 92px; margin: 0 auto 5px; }
.journal-icon svg { width: 100%; height: 100%; }
.journal-card b { display: block; min-height: 34px; font-size: 14px; line-height: 1.16; }
.journal-card span { display: block; margin-top: 6px; color: var(--water-dark); font-size: 12px; font-weight: 900; }

@keyframes bob { 50% { transform: translate(-50%, -50%) rotate(7deg) translateY(-8px); } }
@keyframes bubble { from { transform: translateY(25px); opacity: 0; } to { transform: translateY(-20px); opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 50% { transform: scale(1.025); } }

@media (max-width: 920px) {
  .hero { grid-template-columns: minmax(0, 1fr) 365px; }
  .hero-copy { padding-left: 36px; }
  .experiment { grid-template-columns: 360px minmax(0,1fr); }
  .journal-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: 430px; }
  .hero-tub { width: 300px; height: 285px; }
  .scientist { width: 155px; height: 250px; }
  .lab-grid { grid-template-columns: 1fr; }
  .lab-card p { min-height: 0; }
  .experiment { grid-template-columns: 1fr; }
  .tank-panel { min-height: 445px; }
  .question-panel { padding: 5px 0 0; }
  .game-head { grid-template-columns: 1fr; }
  .score-chip { justify-self: start; }
  .journal-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; }
  h1 { font-size: 49px; }
  .lead { font-size: 16px; }
  .hero-actions > * { width: 100%; }
  .hero-facts { grid-template-columns: 1fr; }
  .hero-visual { min-height: 370px; }
  .hero-badge { left: 12px; top: 13px; font-size: 13px; }
  .hero-tub { left: 45%; width: 258px; height: 245px; }
  .scientist { right: -34px; width: 142px; height: 220px; }
  .safety { width: calc(100% - 12px); align-items: flex-start; padding: 14px; border-radius: 20px; font-size: 14px; }
  .laboratories,
  .journal-page,
  .result-page,
  .game-shell { padding: 20px 14px; }
  .page-head { display: block; }
  .page-head .secondary { margin-top: 14px; }
  .tank-panel { min-height: 386px; border-radius: 23px; }
  .tank { height: 270px; bottom: 21px; }
  .object-stage { width: 118px; height: 118px; top: 18px; }
  .object-stage.is-floating { top: 87px; }
  .object-stage.is-sinking { top: 182px; }
  .question-panel h1 { font-size: 38px; }
  .answer-grid { gap: 8px; }
  .answer { min-height: 104px; padding: 13px 7px; }
  .answer span { font-size: 27px; }
  .answer b { font-size: 16px; }
  .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; }
  .journal-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .journal-card { min-height: 171px; }
  .journal-icon { width: 78px; height: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
