:root {
  --classroom: #2f6858;
  --classroom-deep: #21483e;
  --chalk: #f8fff8;
  --tile: #eef7f4;
  --paper: #fffdf2;
  --paper-line: #d8e7df;
  --sky: #c8edf4;
  --sky-strong: #5fbfd6;
  --aqua: #e7f8fb;
  --lemon: #fff2a9;
  --lemon-strong: #e6bc3d;
  --white: #fffefe;
  --ink: #203b36;
  --soft-ink: #58736d;
  --pink: #ffe0e8;
  --mint: #c7f4dd;
  --line: rgba(47, 104, 88, 0.25);
  --shadow: 0 20px 54px rgba(32, 59, 54, 0.12);
  --card-shadow: 0 10px 24px rgba(32, 59, 54, 0.1);
  font-family:
    "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: #f7fdff;
  accent-color: var(--classroom);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background:
    radial-gradient(circle at 16% 6%, rgba(255, 242, 169, 0.68), transparent 18rem),
    linear-gradient(180deg, #f5fbf8 0%, #edf6f2 52%, #fff9e6 100%);
  background-size: auto;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.background-lab {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.background-lab::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(1120px, calc(100% - 24px));
  height: 16vh;
  min-height: 108px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, var(--classroom), var(--classroom-deep));
  background-size: 26px 26px, 26px 26px, auto;
  box-shadow: 0 18px 46px rgba(32, 72, 62, 0.18);
  content: "";
  transform: translateX(-50%);
}

.bubble {
  position: absolute;
  display: block;
  width: 54px;
  height: 54px;
  border: 2px solid rgba(95, 191, 214, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  animation: bubbleRise 9s ease-in-out infinite;
  opacity: 0.14;
}

.bubble::after {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  content: "";
}

.bubble-1 {
  left: 8%;
  bottom: 12%;
}

.bubble-2 {
  right: 10%;
  top: 18%;
  width: 34px;
  height: 34px;
  animation-delay: -3s;
}

.bubble-3 {
  left: 74%;
  bottom: 6%;
  width: 72px;
  height: 72px;
  animation-delay: -5s;
}

.star {
  position: absolute;
  width: 26px;
  height: 26px;
  background: var(--lemon-strong);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 67% 55%, 79% 91%, 50% 68%, 21% 91%, 33% 55%, 2% 35%, 39% 35%);
  opacity: 0.58;
  animation: twinkle 3.4s ease-in-out infinite;
  opacity: 0.16;
}

.star-1 {
  top: 8%;
  left: 16%;
}

.star-2 {
  right: 18%;
  bottom: 18%;
  transform: scale(0.78);
  animation-delay: -1.6s;
}

.app-shell {
  width: min(100% - 24px, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 34px;
  display: grid;
  place-items: center;
}

.screen-card,
.loading-panel,
.error-panel {
  width: 100%;
  min-height: min(760px, calc(100vh - 56px));
  border: 1px solid rgba(47, 104, 88, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 252, 249, 0.96)),
    var(--white);
  box-shadow: var(--shadow);
}

.loading-panel,
.error-panel {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.loading-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0;
  border: 2px solid rgba(47, 104, 88, 0.28);
  border-radius: 50%;
  background: var(--paper);
  color: var(--classroom);
  font-size: 26px;
  font-weight: 900;
}

.loading-panel h1,
.error-panel h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 44px);
}

.screen-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 3vw, 30px);
}

.screen-card::before {
  position: absolute;
  inset: 12px;
  z-index: 0;
  border: 1px solid rgba(47, 104, 88, 0.08);
  border-radius: 10px;
  content: "";
  pointer-events: none;
}

.screen-card > * {
  position: relative;
  z-index: 1;
}

.app-kicker,
.mini-label,
.unit-badge,
.speaker,
.result-label {
  margin: 0;
  color: var(--classroom);
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0;
}

.school-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  margin: 0 0 16px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, var(--classroom), var(--classroom-deep));
  background-size: 24px 24px, auto;
  color: var(--chalk);
  font-size: 0.88rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(32, 72, 62, 0.18);
}

.school-topbar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(330px, 1.05fr);
  gap: clamp(18px, 4vw, 42px);
  align-items: center;
  min-height: 580px;
}

.start-copy h1,
.quiz-header h1,
.result-hero h1 {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: clamp(2.2rem, 7vw, 5.1rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.start-subtitle {
  margin: 18px 0 0;
  color: var(--soft-ink);
  font-size: clamp(1.18rem, 3.8vw, 1.6rem);
  font-weight: 800;
}

.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.unit-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(47, 104, 88, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--classroom);
  font-size: 0.86rem;
  font-weight: 900;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-top: 24px;
  padding: 10px 16px;
  border: 1px solid rgba(47, 104, 88, 0.22);
  border-radius: 999px;
  background: rgba(255, 253, 242, 0.9);
  box-shadow: var(--card-shadow);
}

.progress-pill span {
  color: var(--soft-ink);
  font-weight: 800;
}

.progress-pill strong {
  color: var(--classroom);
  font-size: 1.2rem;
}

.start-actions,
.result-actions,
.quiz-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.primary-button,
.secondary-button,
.ghost-button,
.sound-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  min-width: 148px;
  padding: 13px 20px;
  border: 0;
  border-radius: 12px;
  font-weight: 900;
  line-height: 1.25;
  cursor: pointer;
  transition:
    transform 170ms ease,
    box-shadow 170ms ease,
    border-color 170ms ease;
}

.primary-button {
  background: linear-gradient(180deg, #3b7c6a, var(--classroom-deep));
  color: #fff;
  box-shadow: 0 12px 24px rgba(47, 104, 88, 0.26);
}

.secondary-button,
.ghost-button,
.sound-button {
  border: 1px solid rgba(47, 104, 88, 0.24);
  background: rgba(255, 255, 255, 0.9);
  color: var(--classroom);
  box-shadow: var(--card-shadow);
}

.ghost-button {
  background: linear-gradient(180deg, #fffdf0, #fff4b8);
  color: #6c5617;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.sound-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(47, 104, 88, 0.18);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.sound-button:focus-visible,
.choice-button:focus-visible {
  outline: 4px solid rgba(255, 211, 78, 0.62);
  outline-offset: 3px;
}

.start-cast {
  display: grid;
  grid-template-columns: 1.1fr 0.78fr;
  gap: 14px;
  align-items: end;
}

.hydrogen-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-column: 1 / -1;
  gap: 12px;
}

.character {
  position: relative;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(47, 104, 88, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--card-shadow);
}

.character-crop {
  display: block;
  min-height: 360px;
  background-image: var(--character-image);
  background-repeat: no-repeat;
  filter: drop-shadow(0 12px 12px rgba(59, 137, 170, 0.14));
}

.character figcaption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  width: fit-content;
  max-width: calc(100% - 20px);
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--classroom);
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(59, 137, 170, 0.12);
}

.char-shirori .character-crop {
  background-size: 255% auto;
  background-position: 2% 50%;
}

.char-professor .character-crop {
  background-size: 230% auto;
  background-position: 0% 52%;
}

.char-hydrogen-1 .character-crop,
.char-hydrogen-2 .character-crop {
  background-size: 248% auto;
  background-position: 0% 51%;
}

.main-cast .character-crop {
  min-height: 520px;
}

.small-cast .character-crop {
  min-height: 250px;
}

.quiz-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.quiz-header h1 {
  font-size: clamp(1.4rem, 4vw, 2.35rem);
}

.sound-button,
.compact {
  min-height: 42px;
  min-width: auto;
  padding: 9px 12px;
  font-size: 0.86rem;
}

.progress-track {
  height: 14px;
  margin: 16px 0 18px;
  overflow: hidden;
  border: 1px solid rgba(47, 104, 88, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--classroom), #efd05b);
  transition: width 280ms ease;
}

.question-panel {
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid rgba(47, 104, 88, 0.16);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(32, 59, 54, 0.08);
}

.question-text {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: clamp(1.2rem, 4vw, 1.82rem);
  font-weight: 900;
  line-height: 1.45;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-button {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  padding: 12px 14px;
  border: 2px solid rgba(47, 104, 88, 0.16);
  border-radius: 14px;
  background: #fbfffd;
  color: var(--ink);
  text-align: left;
  font-size: clamp(1rem, 3.5vw, 1.18rem);
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.choice-button:hover:not(:disabled) {
  border-color: var(--classroom);
  background: #ffffff;
  transform: translateY(-1px);
}

.choice-key {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--aqua);
  color: var(--classroom);
}

.choice-button.is-correct {
  border-color: #35bf7d;
  background: #effff6;
}

.choice-button.is-correct .choice-key {
  background: #35bf7d;
  color: #fff;
}

.choice-button.is-wrong {
  border-color: #f0a4b9;
  background: #fff4f8;
}

.choice-button.is-wrong .choice-key {
  background: #f0a4b9;
  color: #fff;
}

.reaction-zone {
  display: grid;
  grid-template-columns: minmax(190px, 0.54fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 18px;
}

.reaction-cast {
  display: grid;
  gap: 10px;
  align-items: end;
}

.reaction-cast.is-single {
  grid-template-columns: 1fr;
}

.reaction-cast.is-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reaction-cast.is-single .character {
  width: min(230px, 68vw);
  justify-self: center;
}

.reaction-character .character-crop {
  min-height: 230px;
}

.face-crop .character-crop,
.result-face .character-crop {
  min-height: 225px;
  background-image: var(--expression-image);
  background-size: 400% auto;
  background-position: var(--expression-position) center;
}

.reaction-cast.is-single .char-shirori.face-crop .character-crop {
  min-height: 300px;
}

.reaction-character figcaption {
  font-size: 0.72rem;
}

.message-box {
  align-self: stretch;
  min-height: 170px;
  padding: 18px;
  border: 1px solid rgba(47, 104, 88, 0.16);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(32, 59, 54, 0.08);
}

.message-box p {
  margin: 8px 0 0;
  color: var(--soft-ink);
  font-size: clamp(1rem, 3vw, 1.1rem);
  font-weight: 800;
  line-height: 1.7;
}

.message-box .speaker,
.message-box .result-label {
  margin: 0;
}

.success-message {
  border-color: rgba(54, 191, 125, 0.36);
  background: linear-gradient(180deg, #f7fff9, #ffffff);
}

.retry-message {
  border-color: rgba(240, 164, 185, 0.46);
  background: linear-gradient(180deg, #fff8fb, #ffffff);
}

.message-extra {
  color: var(--classroom) !important;
}

.quiz-footer {
  justify-content: flex-end;
}

.pop-badge {
  display: inline-grid;
  place-items: center;
  min-width: 96px;
  min-height: 48px;
  margin-bottom: 10px;
  border: 2px solid #ffd34e;
  border-radius: 999px;
  background: #fff6be;
  color: #8c6712;
  font-size: 1.3rem;
  font-weight: 900;
  animation: popBadge 450ms cubic-bezier(0.2, 1.6, 0.35, 1) both;
}

.effect-sparkle::after,
.effect-bubble::after,
.effect-float::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
}

.effect-sparkle::after {
  background-image:
    radial-gradient(circle at 20% 28%, rgba(255, 218, 78, 0.82) 0 3px, transparent 4px),
    radial-gradient(circle at 78% 18%, rgba(255, 218, 78, 0.72) 0 4px, transparent 5px),
    radial-gradient(circle at 86% 78%, rgba(95, 191, 214, 0.62) 0 4px, transparent 5px),
    radial-gradient(circle at 30% 84%, rgba(95, 191, 214, 0.5) 0 3px, transparent 4px);
  animation: sparkleBurst 900ms ease both;
}

.effect-bubble::after {
  background-image:
    radial-gradient(circle at 18% 72%, transparent 0 12px, rgba(95, 191, 214, 0.32) 13px 14px, transparent 15px),
    radial-gradient(circle at 82% 70%, transparent 0 18px, rgba(95, 191, 214, 0.24) 19px 20px, transparent 21px);
  animation: sparkleBurst 900ms ease both;
}

.effect-float .char-hydrogen-1,
.effect-float .char-hydrogen-2,
.reward-float {
  animation: hydrogenFloat 1.4s ease-in-out infinite;
}

.effect-float .char-hydrogen-2,
.reward-float.delay {
  animation-delay: -0.55s;
}

.result-screen {
  display: grid;
  gap: 20px;
}

.result-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
}

.score-ring {
  display: grid;
  place-items: center;
  width: clamp(104px, 25vw, 142px);
  height: clamp(104px, 25vw, 142px);
  border: 10px solid #fff;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff49a, #8cc7b8);
  color: var(--ink);
  box-shadow: var(--card-shadow);
}

.score-ring span {
  font-size: clamp(2.7rem, 9vw, 4.5rem);
  font-weight: 900;
  line-height: 1;
}

.score-ring small {
  font-weight: 900;
}

.result-copy {
  margin: 12px 0 0;
  color: var(--soft-ink);
  font-size: clamp(1rem, 3vw, 1.18rem);
  font-weight: 800;
  line-height: 1.7;
}

.result-cast {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hydrogen-result-cast {
  width: min(100%, 620px);
  margin: 0 auto;
}

.result-cast .character-crop {
  min-height: 250px;
}

.summary-section,
.reward-card {
  padding: 18px;
  border: 1px solid rgba(47, 104, 88, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--card-shadow);
}

.summary-section h2,
.reward-card h2 {
  margin: 0 0 14px;
  font-size: clamp(1.25rem, 4vw, 1.7rem);
}

.point-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.point-grid span,
.feature-list li {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(47, 104, 88, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--classroom);
  font-weight: 900;
}

.reward-card {
  background:
    linear-gradient(135deg, rgba(255, 246, 190, 0.92), rgba(246, 252, 249, 0.96)),
    #fff;
}

.reward-header {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
}

.reward-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) 1fr;
  gap: 16px;
  align-items: stretch;
}

.reward-character {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.card-character .character-crop {
  min-height: 220px;
}

.profile-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.profile-list div {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(47, 104, 88, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.profile-list dt {
  color: var(--classroom);
  font-weight: 900;
}

.profile-list dd {
  margin: 0;
  font-weight: 900;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.as-link {
  text-align: center;
}

@keyframes bubbleRise {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-24px);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 0.86;
    transform: scale(1.04);
  }
}

@keyframes sparkleBurst {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popBadge {
  from {
    transform: scale(0.55) rotate(-8deg);
  }
  to {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes hydrogenFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100% - 16px, 680px);
    padding-top: 10px;
  }

  .screen-card,
  .loading-panel,
  .error-panel {
    min-height: calc(100vh - 20px);
  }

  .start-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .start-cast {
    grid-template-columns: 1fr 0.72fr;
  }

  .main-cast .character-crop {
    min-height: 390px;
  }

  .small-cast .character-crop {
    min-height: 210px;
  }

  .reaction-zone {
    grid-template-columns: 1fr;
  }

  .message-box {
    grid-column: auto;
  }

  .result-cast {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reward-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .screen-card {
    padding: 16px;
  }

  .screen-card::before {
    inset: 8px;
  }

  .start-copy h1 {
    font-size: clamp(2.15rem, 13vw, 3.5rem);
  }

  .start-actions,
  .result-actions,
  .quiz-footer {
    display: grid;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .start-cast {
    grid-template-columns: 1fr 1fr;
  }

  .main-cast {
    grid-column: 1 / -1;
  }

  .main-cast .character-crop {
    min-height: 340px;
  }

  .small-cast .character-crop {
    min-height: 170px;
  }

  .hydrogen-pair {
    gap: 8px;
  }

  .quiz-header {
    display: grid;
  }

  .choice-button {
    grid-template-columns: 34px 1fr;
    min-height: 60px;
    padding: 10px;
  }

  .choice-key {
    width: 34px;
    height: 34px;
  }

  .reaction-zone {
    gap: 8px;
  }

  .reaction-character .character-crop,
  .result-cast .character-crop,
  .card-character .character-crop {
    min-height: 158px;
  }

  .message-box {
    min-height: 0;
    padding: 14px;
  }

  .result-hero {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 112px;
    height: 112px;
  }

  .profile-list div {
    grid-template-columns: 1fr;
  }

  .point-grid span,
  .feature-list li {
    width: 100%;
  }
}

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

/* MVP v2: unit select + dream science lab polish */
:root {
  --lab-blue: #dff7ff;
  --lab-blue-strong: #85d7ec;
  --lab-mint: #dff9ed;
  --lab-lavender: #ece8ff;
  --lab-pink: #ffeaf3;
  --lab-yellow: #fff5bd;
  --lab-card: rgba(255, 255, 255, 0.76);
  --lab-card-strong: rgba(255, 255, 255, 0.92);
  --lab-line: rgba(95, 139, 166, 0.2);
  --lab-ink: #26384d;
  --lab-soft: #66758b;
  --lab-green: #4dbf8d;
  --lab-red: #e989a7;
  --shadow: 0 22px 60px rgba(76, 111, 148, 0.18);
  --card-shadow: 0 12px 28px rgba(76, 111, 148, 0.13);
  color: var(--lab-ink);
  background: #f7fcff;
}

html {
  background:
    linear-gradient(135deg, rgba(236, 232, 255, 0.74) 0%, rgba(223, 247, 255, 0.92) 38%, rgba(223, 249, 237, 0.82) 72%, rgba(255, 245, 189, 0.52) 100%),
    repeating-linear-gradient(0deg, rgba(95, 139, 166, 0.055) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(95, 139, 166, 0.04) 0 1px, transparent 1px 34px);
}

body {
  color: var(--lab-ink);
}

.background-lab::before {
  inset: 0;
  left: 0;
  width: auto;
  height: auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 54px 54px;
  box-shadow: none;
  opacity: 0.36;
  transform: none;
}

.background-lab::after {
  position: absolute;
  inset: 4% 3%;
  color: rgba(90, 116, 158, 0.16);
  content: "H₂    O₂    CO₂    N₂    ☆    試験管    原子    H₂    O₂    CO₂";
  font-size: clamp(1.1rem, 4vw, 2rem);
  font-weight: 900;
  line-height: 3.2;
  word-spacing: 1.4rem;
}

.bubble {
  border-color: rgba(133, 215, 236, 0.34);
  background: rgba(255, 255, 255, 0.18);
  opacity: 0.2;
}

.star {
  background: #f5d95d;
  opacity: 0.22;
}

.app-shell {
  width: min(100% - 20px, 1060px);
  padding: max(12px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
}

.screen-card,
.loading-panel,
.error-panel {
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 252, 255, 0.72)),
    var(--lab-card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.screen-card {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: min(860px, calc(100vh - 34px));
  overflow: hidden auto;
}

.screen-card::before {
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(133, 215, 236, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(151, 142, 218, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
}

.school-topbar {
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(93, 155, 186, 0.96), rgba(75, 111, 166, 0.94)),
    #5d9bba;
  box-shadow: 0 12px 28px rgba(75, 111, 166, 0.2);
}

.app-kicker,
.mini-label,
.unit-badge,
.speaker,
.result-label {
  color: #4f79b6;
}

.home-screen,
.start-screen,
.quiz-screen,
.result-screen {
  color: var(--lab-ink);
}

.navigator-panel {
  display: grid;
  grid-template-columns: minmax(104px, 148px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: clamp(12px, 2vw, 18px);
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(236, 232, 255, 0.66)),
    var(--lab-card);
  box-shadow: var(--card-shadow);
}

.navigator-copy h1,
.navigator-copy h2,
.unit-section-heading h2,
.start-copy h2 {
  margin: 4px 0 0;
  color: var(--lab-ink);
  font-size: clamp(1.35rem, 5vw, 2.35rem);
  line-height: 1.22;
  letter-spacing: 0;
}

.navigator-copy p,
.unit-section-heading p,
.start-subtitle,
.result-copy {
  color: var(--lab-soft);
}

.navigator-copy p:last-child {
  margin: 8px 0 0;
  font-weight: 800;
  line-height: 1.6;
}

.lab-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lab-status-row span,
.unit-course,
.unit-status,
.unit-meta span,
.progress-pill,
.point-grid span,
.feature-list li {
  border: 1px solid var(--lab-line);
  background: rgba(255, 255, 255, 0.72);
  color: #4f79b6;
}

.lab-status-row span {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 900;
}

.unit-section {
  display: grid;
  gap: 12px;
}

.unit-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.unit-section-heading p {
  max-width: 420px;
  margin: 0;
  font-weight: 800;
  line-height: 1.6;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.unit-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(96px, auto) auto auto 1fr auto auto;
  gap: 8px;
  min-height: 285px;
  padding: 13px;
  overflow: hidden;
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(236, 232, 255, 0.58)),
    var(--lab-card-strong);
  color: var(--lab-ink);
  text-align: left;
  box-shadow: var(--card-shadow);
  cursor: pointer;
}

.unit-card::before {
  position: absolute;
  top: 10px;
  right: 12px;
  color: rgba(79, 121, 182, 0.12);
  content: attr(data-symbol);
  font-size: 2rem;
  font-weight: 900;
}

.unit-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(76, 111, 148, 0.17);
}

.unit-card.is-coming-soon {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(242, 244, 252, 0.64)),
    rgba(255, 255, 255, 0.66);
  cursor: default;
  filter: saturate(0.78);
}

.unit-card.is-cleared {
  border-color: rgba(77, 191, 141, 0.46);
}

.unit-status {
  justify-self: start;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.is-coming-soon .unit-status {
  color: #8f789f;
  background: rgba(236, 232, 255, 0.72);
}

.unit-card-art {
  display: grid;
  place-items: center;
  min-height: 98px;
}

.unit-card-character {
  width: 100%;
}

.unit-card-character .character-crop {
  min-height: 118px;
}

.unit-symbol {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border: 1px solid rgba(133, 215, 236, 0.6);
  border-radius: 50%;
  background: rgba(223, 247, 255, 0.58);
  color: #4f79b6;
  font-size: 1.75rem;
  font-weight: 900;
}

.unit-course {
  justify-self: start;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

.unit-card h3 {
  margin: 0;
  color: var(--lab-ink);
  font-size: clamp(1.12rem, 4vw, 1.45rem);
  line-height: 1.2;
}

.unit-card p {
  display: -webkit-box;
  min-height: 3.9em;
  margin: 0;
  overflow: hidden;
  color: var(--lab-soft);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.unit-card-meta {
  display: grid;
  gap: 4px;
  color: #52657d;
  font-size: 0.78rem;
  font-weight: 900;
}

.mini-progress {
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(133, 215, 236, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lab-green), var(--lab-blue-strong));
}

.start-layout {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.72fr);
  min-height: auto;
}

.start-copy h2 {
  font-size: clamp(2rem, 7vw, 4rem);
}

.primary-button,
.secondary-button,
.ghost-button,
.sound-button,
.choice-button {
  border-radius: 8px;
}

.primary-button {
  background: linear-gradient(180deg, #5fa8d3, #4f79b6);
  box-shadow: 0 12px 24px rgba(79, 121, 182, 0.24);
}

.secondary-button,
.sound-button {
  border-color: rgba(95, 139, 166, 0.25);
  background: rgba(255, 255, 255, 0.78);
  color: #4f79b6;
}

.ghost-button {
  border-color: rgba(233, 188, 79, 0.36);
  background: linear-gradient(180deg, rgba(255, 245, 189, 0.95), rgba(255, 255, 255, 0.72));
  color: #81682d;
}

.question-panel,
.message-box,
.summary-section,
.reward-card {
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  background: var(--lab-card-strong);
  box-shadow: var(--card-shadow);
}

.question-text {
  color: var(--lab-ink);
}

.choice-button {
  border-color: rgba(95, 139, 166, 0.2);
  background: rgba(255, 255, 255, 0.82);
}

.choice-key {
  background: var(--lab-blue);
  color: #4f79b6;
}

.choice-button.is-correct {
  border-color: rgba(77, 191, 141, 0.72);
  background: rgba(232, 255, 244, 0.92);
}

.choice-button.is-correct .choice-key {
  background: var(--lab-green);
}

.choice-button.is-wrong {
  border-color: rgba(233, 137, 167, 0.66);
  background: rgba(255, 242, 248, 0.94);
}

.choice-button.is-wrong .choice-key {
  background: var(--lab-red);
}

.success-message {
  border-color: rgba(77, 191, 141, 0.34);
  background: linear-gradient(180deg, rgba(232, 255, 244, 0.94), rgba(255, 255, 255, 0.86));
}

.retry-message {
  border-color: rgba(233, 137, 167, 0.36);
  background: linear-gradient(180deg, rgba(255, 242, 248, 0.94), rgba(255, 255, 255, 0.86));
}

.navigator-note {
  display: inline-block;
  margin-top: 10px !important;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(236, 232, 255, 0.64);
  color: #58619b !important;
}

.character {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.character-crop {
  min-height: 220px;
  background-color: transparent;
  filter: drop-shadow(0 16px 18px rgba(76, 111, 148, 0.18));
}

.character figcaption {
  display: none;
}

.navigator-character .character-crop {
  min-height: 132px;
}

.teacher-preview .character-crop {
  min-height: 300px;
}

.small-cast .character-crop {
  min-height: 190px;
}

.face-crop .character-crop,
.result-face .character-crop {
  background-size: 400% auto;
}

.reaction-cast.is-single .char-shirori.teacher-question .character-crop {
  min-height: 318px;
  background-size: 390% auto;
}

.reaction-zone {
  grid-template-columns: minmax(160px, 0.42fr) minmax(0, 1fr);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.result-stats article {
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--card-shadow);
}

.result-stats span {
  color: var(--lab-soft);
  font-size: 0.78rem;
  font-weight: 900;
}

.result-stats strong {
  color: var(--lab-ink);
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  line-height: 1.1;
}

.result-navigator {
  grid-template-columns: minmax(86px, 120px) minmax(0, 1fr);
}

.error-hint {
  max-width: 520px;
  color: var(--lab-soft);
  font-weight: 800;
  line-height: 1.6;
}

@media (min-width: 760px) {
  .unit-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 12px, 560px);
    padding-top: 8px;
  }

  .screen-card {
    gap: 14px;
    min-height: calc(100svh - 16px);
    padding: 14px;
  }

  .screen-card::before {
    inset: 7px;
  }

  .school-topbar {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .navigator-panel {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .navigator-character .character-crop {
    min-height: 92px;
  }

  .navigator-copy h1,
  .navigator-copy h2 {
    font-size: clamp(1.08rem, 5vw, 1.45rem);
  }

  .navigator-copy p:last-child {
    font-size: 0.9rem;
  }

  .unit-section-heading {
    display: grid;
    gap: 6px;
  }

  .unit-grid {
    gap: 10px;
  }

  .unit-card {
    min-height: 254px;
    padding: 11px;
  }

  .unit-card-art {
    min-height: 78px;
  }

  .unit-card-character .character-crop {
    min-height: 86px;
  }

  .unit-symbol {
    width: 66px;
    height: 66px;
    font-size: 1.35rem;
  }

  .unit-card p {
    font-size: 0.78rem;
  }

  .start-layout {
    grid-template-columns: 1fr;
  }

  .start-copy h2 {
    font-size: clamp(1.9rem, 10vw, 3rem);
  }

  .teacher-preview .character-crop {
    min-height: 215px;
  }

  .small-cast .character-crop {
    min-height: 145px;
  }

  .quiz-header {
    display: grid;
    gap: 10px;
  }

  .reaction-zone {
    grid-template-columns: minmax(108px, 0.38fr) minmax(0, 1fr);
    align-items: center;
  }

  .reaction-cast.is-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reaction-character .character-crop {
    min-height: 138px;
  }

  .reaction-cast.is-single .char-shirori.teacher-question .character-crop {
    min-height: 194px;
  }

  .message-box {
    min-height: 0;
    padding: 12px;
  }

  .message-box p {
    font-size: 0.92rem;
    line-height: 1.55;
  }

  .result-stats {
    gap: 8px;
  }

  .result-stats article {
    min-height: 70px;
    padding: 9px 7px;
  }

  .result-actions,
  .start-actions,
  .quiz-footer {
    display: grid;
  }
}
