:root {
  --ink: #183044;
  --muted: #52697a;
  --paper: #f7fbfc;
  --white: #fff;
  --blue: #1677a7;
  --cyan: #28b8c7;
  --yellow: #f4c542;
  --coral: #ef6a5b;
  --green: #3b9d6d;
  --navy: #15384c;
  --line: #cfe0e7;
  --shadow: 0 12px 32px rgba(24, 48, 68, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.8;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 4px solid rgba(244, 197, 66, .75);
  outline-offset: 3px;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
  color: var(--white);
  background: rgba(18, 47, 65, .94);
  border-bottom: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--navy); background: var(--yellow); border-radius: 50%; font-family: Georgia, serif; }
.top-actions { display: flex; gap: 8px; }
.mode-button, .menu-button {
  min-height: 38px;
  padding: 6px 13px;
  color: white;
  background: transparent;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 6px;
  cursor: pointer;
}
.mode-button[aria-pressed="true"] { color: var(--navy); background: var(--yellow); border-color: var(--yellow); }
.menu-button { display: none; }

.lesson-nav {
  position: fixed;
  z-index: 18;
  top: 64px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}
.lesson-nav a { display: flex; align-items: center; gap: 6px; padding: 10px 17px; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 700; }
.lesson-nav a:hover { color: var(--blue); background: #edf7fa; }
.lesson-nav span { display: grid; place-items: center; width: 23px; height: 23px; color: white; background: var(--blue); border-radius: 50%; font-size: .72rem; }

.hero { position: relative; min-height: min(760px, 86vh); display: flex; align-items: center; overflow: hidden; color: white; }
.hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(10,41,59,.88) 0%, rgba(10,41,59,.58) 43%, rgba(10,41,59,.06) 77%); }
.hero-content { position: relative; width: min(1180px, calc(100% - 40px)); margin: 105px auto 0; }
.eyebrow, .section-kicker, .stage-label, .question-label, .result-label { margin: 0 0 8px; color: var(--coral); font-size: .78rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.hero .eyebrow { color: #ffe27d; }
.hero h1 { max-width: 720px; margin: 0; font-size: clamp(2.8rem, 7vw, 6rem); line-height: 1.06; letter-spacing: 0; }
.hero-content > p:not(.eyebrow) { max-width: 600px; margin: 22px 0 30px; font-size: clamp(1rem, 2vw, 1.25rem); font-weight: 700; }
.start-button { display: inline-flex; gap: 12px; align-items: center; padding: 13px 20px; color: var(--navy); background: var(--yellow); border-radius: 6px; text-decoration: none; font-weight: 900; box-shadow: var(--shadow); }
.scroll-hint { position: absolute; right: 24px; bottom: 18px; padding: 6px 12px; background: rgba(10,41,59,.7); border-radius: 4px; font-size: .8rem; }

.intro-band { display: grid; grid-template-columns: 1.15fr 1fr; gap: 70px; align-items: center; padding: 56px max(24px, calc((100vw - 1180px) / 2)); background: white; }
.intro-band h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.55rem); line-height: 1.35; }
.goal-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
.goal-list li { padding: 16px 10px; border-top: 4px solid var(--cyan); background: #eff9fa; text-align: center; }
.goal-list strong, .goal-list span { display: block; }
.goal-list span { color: var(--muted); font-size: .78rem; }

.lesson-section { scroll-margin-top: 105px; padding: 88px max(24px, calc((100vw - 1180px) / 2)); }
.section-heading { max-width: 800px; margin-bottom: 34px; }
.section-heading h2 { margin: 0 0 12px; font-size: clamp(2rem, 4.5vw, 3.4rem); line-height: 1.25; letter-spacing: 0; }
.section-heading > p:last-child { margin: 0; color: var(--muted); font-size: 1.05rem; }
.stage-label { color: var(--blue); }
.teacher-note { display: none; margin: -8px 0 30px; padding: 18px 22px; background: #fff8d8; border-left: 5px solid var(--yellow); }
.teacher-mode .teacher-note { display: block; }
.teacher-note strong { color: #7a5d00; }
.teacher-note p { margin: 4px 0 0; }
.teacher-note p:empty::after { content: "メモを読み込んでいます…"; color: var(--muted); }
.teacher-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: white;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(10, 35, 50, .35);
}
.teacher-dialog::backdrop { background: rgba(10, 35, 50, .72); backdrop-filter: blur(3px); }
.teacher-dialog form { position: relative; display: grid; gap: 12px; padding: 32px; }
.teacher-dialog h2 { margin: 0; font-size: 1.65rem; }
.teacher-dialog p { margin: 0; }
.teacher-dialog label { margin-top: 5px; font-weight: 800; }
.teacher-dialog input {
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 5px;
}
.teacher-dialog input:focus { border-color: var(--blue); }
.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  cursor: pointer;
}
.dialog-submit {
  min-height: 48px;
  color: white;
  background: var(--blue);
  border: 0;
  border-radius: 5px;
  font-weight: 900;
  cursor: pointer;
}
.dialog-submit:disabled { opacity: .55; cursor: wait; }
.login-error { min-height: 27px; color: #b8342a; font-weight: 800; }

.two-column { display: grid; grid-template-columns: 1.1fr .9fr; gap: 24px; }
.concept-panel, .question-panel, .quick-check { padding: 28px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.field-demo { position: relative; height: 230px; overflow: hidden; background: #eaf8fb; border-radius: 5px; }
.electric-wave, .magnetic-wave { position: absolute; left: 10%; top: 50%; width: 76%; height: 80px; border-top: 7px solid var(--coral); border-radius: 50%; transform: translateY(-50%); }
.electric-wave::after { content: ""; position: absolute; inset: -87px 0 auto; height: 80px; border-bottom: 7px solid var(--coral); border-radius: 50%; }
.magnetic-wave { border-color: var(--blue); transform: translateY(-50%) rotateX(65deg); }
.magnetic-wave::after { content: ""; position: absolute; inset: -87px 0 auto; height: 80px; border-bottom: 7px solid var(--blue); border-radius: 50%; }
.travel-arrow { position: absolute; right: 14px; bottom: 12px; font-weight: 800; }
.term-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.term-row > div { display: grid; grid-template-columns: 18px 1fr; column-gap: 7px; }
.term-row small { grid-column: 2; color: var(--muted); }
.term-dot { width: 13px; height: 13px; margin-top: 8px; border-radius: 50%; }
.term-dot.electric { background: var(--coral); }
.term-dot.magnetic { background: var(--blue); }
.question-panel h3, .experiment h3, .antenna-control h3, .mini-calc h3, .quick-check h3 { margin: 0 0 18px; font-size: 1.45rem; line-height: 1.45; }
.choice-list { display: grid; gap: 10px; }
.choice-list button, .quiz-choices button, .sequence-options button {
  width: 100%;
  min-height: 52px;
  padding: 11px 15px;
  color: var(--ink);
  background: white;
  border: 2px solid var(--line);
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}
.choice-list button:hover, .quiz-choices button:hover, .sequence-options button:hover { border-color: var(--blue); background: #f0f9fb; }
button.correct { border-color: var(--green) !important; background: #e9f8ef !important; }
button.wrong { border-color: var(--coral) !important; background: #fff0ee !important; }
.feedback { min-height: 29px; margin: 14px 0 0; font-weight: 800; }

.experiment { display: grid; grid-template-columns: .8fr 1.2fr; gap: 28px; margin-top: 28px; padding: 34px; background: var(--navy); color: white; border-radius: 8px; }
.experiment-copy > p { color: #c4dce7; }
.experiment label, .antenna-control label { display: block; margin: 18px 0 8px; font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--yellow); cursor: pointer; }
.formula { margin-top: 20px; padding: 10px 12px; color: var(--navy); background: #dff6f8; border-radius: 4px; font-weight: 800; text-align: center; }
.result-line { color: white !important; font-size: 1.1rem; }
.result-line strong { color: #ffe27d; font-size: 1.5rem; }
.wave-lab { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 24px; color: var(--ink); background: white; border-radius: 5px; }
.wave-track { height: 140px; background-color: #eaf8fb; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='140' viewBox='0 0 120 140'%3E%3Cpath d='M0 70 C30 0 90 140 120 70' fill='none' stroke='%231677a7' stroke-width='6'/%3E%3C/svg%3E"); background-repeat: repeat-x; border-bottom: 2px solid var(--line); }
.ruler { width: 120px; padding-top: 8px; border-left: 2px solid var(--coral); border-right: 2px solid var(--coral); text-align: center; font-weight: 800; transition: width .2s; }
.wave-lab p { margin: 16px 0 0; color: var(--muted); }

.color-band { background: #eaf5f7; }
.band-scale { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid #abcbd6; border-radius: 6px; overflow: hidden; }
.band-scale button { min-height: 92px; padding: 12px 7px; color: var(--ink); background: white; border: 0; border-right: 1px solid #abcbd6; cursor: pointer; }
.band-scale button:last-child { border-right: 0; }
.band-scale button.active { color: white; background: var(--blue); }
.band-scale strong, .band-scale span { display: block; }
.band-scale span { margin-top: 4px; font-size: .75rem; }
.band-detail { display: grid; grid-template-columns: 150px 1fr; gap: 26px; align-items: center; min-height: 230px; padding: 30px; background: white; border: 1px solid var(--line); border-top: 0; }
.band-icon { display: grid; place-items: center; aspect-ratio: 1; color: white; background: var(--coral); border-radius: 50%; font-size: 2rem; font-weight: 900; }
.band-detail h3 { margin: 3px 0; font-size: 1.5rem; }
.band-detail p { margin: 5px 0; }
.band-range { color: var(--blue); font-weight: 900; }
.think-strip { margin-top: 28px; padding: 24px 28px; background: #fff8d8; border-left: 5px solid var(--yellow); }
.think-strip p { margin: 5px 0 10px; }
.reveal-button, .next-button, .quiz-result button, .play-button {
  padding: 10px 16px;
  color: white;
  background: var(--blue);
  border: 0;
  border-radius: 5px;
  font-weight: 800;
  cursor: pointer;
}
.hidden-answer { display: none; color: #5c4b0b; font-weight: 700; }
.hidden-answer.open { display: block; }

.antenna-lab { display: grid; grid-template-columns: 1.15fr .85fr; min-height: 410px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.antenna-scene { position: relative; overflow: hidden; background: #dff3f7; }
.antenna-scene::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 28%; background: #8ac58e; }
.signal-source { position: absolute; z-index: 2; right: 10%; top: 12%; width: 72px; height: 92px; padding-top: 50px; color: var(--navy); font-size: .75rem; font-weight: 900; text-align: center; background: linear-gradient(80deg, transparent 46%, var(--coral) 47%, var(--coral) 53%, transparent 54%); }
.signal-source::before, .signal-source::after { content: ""; position: absolute; left: 24px; width: 24px; border: 3px solid var(--coral); border-left: 0; border-bottom: 0; transform: rotate(45deg); }
.signal-source::before { top: 12px; height: 24px; }
.signal-source::after { top: 2px; left: 14px; width: 44px; height: 44px; }
.antenna-needle { position: absolute; z-index: 3; left: 25%; bottom: 24%; width: 130px; height: 7px; background: var(--navy); transform-origin: 15px 50%; transition: transform .1s; }
.antenna-needle::before { content: ""; position: absolute; left: 10px; top: -25px; width: 7px; height: 80px; background: var(--navy); }
.signal-meter { position: absolute; z-index: 5; left: 16px; top: 16px; width: 160px; padding: 12px; background: rgba(255,255,255,.92); border-radius: 5px; }
.signal-meter span, .signal-meter strong { display: block; font-size: .75rem; }
.signal-meter > div { height: 12px; margin: 5px 0; overflow: hidden; background: #dce8ed; border-radius: 6px; }
.signal-meter i { display: block; width: 10%; height: 100%; background: var(--coral); transition: width .15s, background .15s; }
.antenna-control { align-self: center; padding: 36px; }
.antenna-control p { color: var(--muted); }
.mini-calc { display: grid; grid-template-columns: 1fr 1fr; gap: 35px; align-items: center; margin-top: 28px; padding: 28px; background: white; border-top: 4px solid var(--cyan); }
.length-visual > div { display: flex; align-items: center; justify-content: flex-end; height: 44px; padding-right: 12px; color: white; font-weight: 900; }
.full-length { width: 100%; background: var(--blue); }
.half-length { width: 50%; margin-top: 10px; background: var(--coral); }

.dark-band { color: white; background: var(--navy); }
.dark-band .section-heading > p:last-child { color: #bfd5df; }
.dark-band .stage-label { color: #ffe27d; }
.dark-band .teacher-note { color: var(--ink); }
.route-switch { display: flex; gap: 8px; }
.route-switch button, .mod-tabs button {
  min-height: 44px;
  padding: 9px 18px;
  color: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 5px;
  cursor: pointer;
}
.route-switch button.active { color: var(--navy); background: var(--yellow); border-color: var(--yellow); }
.route-scene { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; min-height: 270px; margin-top: 14px; padding: 35px 18px; background: #0d2b3c; border: 1px solid #537082; border-radius: 6px; overflow: hidden; }
.route-node { position: relative; z-index: 2; display: grid; place-items: center; justify-self: center; width: 105px; aspect-ratio: 1; padding: 8px; color: var(--ink); background: white; border-radius: 50%; text-align: center; font-size: .8rem; font-weight: 900; }
.route-line { height: 4px; background: #577686; }
.route-line.active { background: var(--yellow); box-shadow: 0 0 18px var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.play-button { display: block; margin: 16px auto 0; color: var(--navy); background: var(--yellow); }
.route-question { margin-top: 34px; padding: 25px; color: var(--ink); background: white; border-radius: 6px; }
.sequence-options { display: grid; gap: 9px; }

.modulation-lab { background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.mod-tabs { display: flex; padding: 10px; background: #eaf5f7; }
.mod-tabs button { color: var(--ink); border-color: #8eb8c7; }
.mod-tabs button.active { color: white; background: var(--blue); border-color: var(--blue); }
.mod-display { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 24px; }
.mod-display span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .82rem; font-weight: 800; }
canvas { display: block; width: 100%; height: auto; background: #f6fbfc; border: 1px solid var(--line); }
#modExplanation { margin: 0; padding: 16px 24px 22px; }
.flow-line, .big-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 28px; }
.flow-line div { flex: 1; min-height: 95px; display: grid; place-items: center; align-content: center; padding: 12px; background: #eaf5f7; border-top: 4px solid var(--cyan); text-align: center; }
.flow-line strong { display: grid; place-items: center; width: 27px; height: 27px; color: white; background: var(--blue); border-radius: 50%; }
.flow-line span { font-weight: 800; }
.flow-line i, .big-summary i { color: var(--coral); font-style: normal; font-size: 1.4rem; }
.quick-check { max-width: 650px; margin: 28px auto 0; text-align: center; }
.choice-list.horizontal { grid-template-columns: 1fr 1fr; }
.choice-list.horizontal button { text-align: center; }

.receiver-board { display: grid; grid-template-columns: .8fr 1.2fr; background: white; border: 1px solid var(--line); }
.radio-visual { display: grid; place-items: center; min-height: 420px; background: #ccebf0; }
.radio-body { position: relative; width: 260px; height: 180px; padding: 25px; background: var(--coral); border: 8px solid var(--navy); border-radius: 8px; box-shadow: 12px 14px 0 rgba(21,56,76,.16); }
.radio-antenna { position: absolute; width: 7px; height: 150px; margin: -225px 0 0 -150px; background: var(--navy); transform: rotate(-22deg); transform-origin: bottom; }
#radioDisplay { width: 105px; height: 40px; display: grid; place-items: center; color: #253b21; background: #d8e7aa; border: 4px solid var(--navy); font-family: Consolas, monospace; font-weight: 900; }
.speaker-grid { position: absolute; right: 24px; top: 25px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, var(--navy) 2px, transparent 3px); background-size: 13px 13px; }
.radio-knob { position: absolute; left: 35px; bottom: 22px; width: 35px; height: 35px; border: 6px solid var(--navy); border-radius: 50%; }
.receiver-steps { padding: 34px; }
.receiver-steps h3 { margin: 0 0 16px; font-size: 1.5rem; }
#receiverButtons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#receiverButtons button { min-height: 52px; padding: 9px; color: var(--ink); background: #f6fbfc; border: 2px solid var(--line); border-radius: 5px; cursor: pointer; }
#receiverButtons button:disabled { opacity: .45; cursor: not-allowed; }
#receiverButtons button.done { color: white; background: var(--green); border-color: var(--green); }
.performance-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 28px; }
.performance-grid article { padding: 20px; background: white; border-bottom: 4px solid var(--blue); }
.performance-grid strong { font-size: 1.2rem; }
.performance-grid p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }

.final-section { background: white; }
.final-section .section-heading { margin-inline: auto; text-align: center; }
.final-quiz, .quiz-result { width: min(720px, 100%); margin: 0 auto; padding: 32px; background: #f2f8fa; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.quiz-progress { height: 8px; overflow: hidden; background: #d9e7eb; border-radius: 4px; }
.quiz-progress i { display: block; width: 20%; height: 100%; background: var(--cyan); transition: width .2s; }
#quizCount { color: var(--muted); font-size: .85rem; font-weight: 800; }
#quizQuestion { min-height: 62px; margin: 18px 0; font-size: 1.4rem; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.next-button:disabled { opacity: .45; cursor: not-allowed; }
.quiz-result { text-align: center; }
.quiz-result > strong { color: var(--blue); font-size: 4rem; line-height: 1; }
.big-summary { flex-wrap: wrap; margin-top: 58px; padding: 24px; color: white; background: var(--navy); border-radius: 6px; }
.big-summary span { font-weight: 900; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px max(24px, calc((100vw - 1180px) / 2)); color: #bcd0da; background: #0d2838; font-size: .8rem; }
footer p { margin: 0; }
footer a { color: white; }

@media (max-width: 820px) {
  .menu-button { display: block; }
  .mode-button { font-size: .78rem; }
  .lesson-nav { display: none; top: 64px; padding: 8px; flex-wrap: wrap; box-shadow: var(--shadow); }
  .lesson-nav.open { display: flex; }
  .lesson-nav a { padding: 8px 10px; }
  .hero { min-height: 720px; }
  .hero > img { object-position: 43% center; }
  .hero-shade { background: linear-gradient(0deg, rgba(10,41,59,.9) 0%, rgba(10,41,59,.5) 62%, rgba(10,41,59,.05) 100%); }
  .hero-content { align-self: flex-end; margin-bottom: 70px; }
  .intro-band, .two-column, .experiment, .antenna-lab, .mini-calc, .receiver-board { grid-template-columns: 1fr; }
  .goal-list { grid-template-columns: 1fr 1fr 1fr; }
  .band-scale { grid-template-columns: 1fr; }
  .band-scale button { min-height: 58px; border-right: 0; border-bottom: 1px solid #abcbd6; }
  .band-scale button:last-child { border-bottom: 0; }
  .band-detail { grid-template-columns: 90px 1fr; }
  .route-scene { grid-template-columns: 1fr; gap: 8px; }
  .route-node { width: 86px; }
  .route-line { width: 4px; height: 34px; justify-self: center; }
  .mod-display { grid-template-columns: 1fr; }
  .flow-line { display: grid; grid-template-columns: 1fr; }
  .flow-line i { transform: rotate(90deg); text-align: center; }
  .performance-grid { grid-template-columns: 1fr 1fr; }
  .big-summary { justify-content: center; }
  footer { flex-direction: column; }
}

@media (max-width: 520px) {
  .brand span:last-child { display: none; }
  .hero h1 { font-size: 2.7rem; }
  .lesson-section { padding-block: 66px; }
  .goal-list, .term-row, .quiz-choices, #receiverButtons { grid-template-columns: 1fr; }
  .band-detail { grid-template-columns: 1fr; }
  .band-icon { width: 90px; }
  .route-switch, .mod-tabs { display: grid; grid-template-columns: 1fr; }
  .performance-grid { grid-template-columns: 1fr; }
  .final-quiz { padding: 22px 16px; }
}

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