:root { color: #1b2434; background: #f7f9fd; font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; line-height: 1.6; }
* { box-sizing: border-box; }
body { margin: 0; }
.lab { max-width: 1180px; margin: 0 auto; padding: 22px 20px 28px; }
header { margin-bottom: 14px; }
.eyebrow { margin: 0; color: #d15a3a; font-size: 11px; font-weight: 800; letter-spacing: .13em; }
h1 { margin: 4px 0 6px; font-size: 24px; }
header > p:last-child { margin: 0; color: #56627a; }
h3 { margin: 0 0 8px; font-size: 15px; color: #b34a26; }
button { min-height: 44px; padding: 9px 13px; border: 1px solid #c3cddd; border-radius: 10px; background: #fff; color: #1b2434; font: inherit; font-weight: 650; cursor: pointer; }
button:hover { border-color: #d15a3a; }
button.primary, button.active { border-color: #d15a3a; background: #d15a3a; color: #fff; }
button:disabled { cursor: default; opacity: .85; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.scene { position: relative; height: 500px; min-height: 500px; overflow: hidden; border: 1px solid #d6dded; border-radius: 14px; background: #f2f5fb; touch-action: none; }
.scene canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.scene canvas:active { cursor: grabbing; }
.scene-message { position: absolute; inset: 0; display: grid; margin: 0; padding: 20px; place-content: center; color: #56627a; font-size: 14px; text-align: center; }
.scene-footer { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 8px; }
.scene-hint { margin: 0; color: #56627a; font-size: 12px; }
.scene-footer button { min-height: 38px; padding: 6px 12px; font-size: 13px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; line-height: 1.3; }
.legend { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; white-space: nowrap; color: #56627a; font-size: 12px; }
.legend::before { flex: 0 0 auto; width: 13px; height: 13px; border-radius: 50%; content: ""; }
.legend-current::before { background: #d15a3a; }
.legend-field::before { background: #3f7fd6; }
.legend-force::before { background: #2f8a63; }
.legend-north::before { background: #d0324b; }
.legend-south::before { background: #4a5a7a; }

.panel-body { display: grid; gap: 13px; }
.controls-row { display: flex; flex-wrap: wrap; gap: 8px; }
.selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field { display: grid; gap: 5px; font-size: 14px; font-weight: 650; }
.field select { min-height: 44px; padding: 9px 11px; border: 1px solid #c3cddd; border-radius: 10px; background: #fff; color: #1b2434; font: inherit; font-weight: 650; }
.field output { color: #d15a3a; font-weight: 800; }
input[type="range"] { width: 100%; height: 30px; accent-color: #d15a3a; }

.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
.readout > div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 11px; background: #fdeee8; }
.readout small { color: #56627a; font-size: 12px; }
.readout b { font-size: 17px; color: #b34a26; }
.pole-N { color: #d0324b !important; }
.pole-S { color: #4a5a7a !important; }

.answer-box { display: grid; gap: 3px; padding: 14px 16px; border-radius: 12px; background: #e8f3ec; border-left: 4px solid #2f8a63; }
.answer-box small { color: #56627a; font-size: 12px; }
.answer-box b { font-size: 23px; color: #1f7a55; }
.answer-box.none { background: #f1f4fa; border-left-color: #8090aa; }
.answer-box.none b { color: #56627a; font-size: 18px; }

.rule-card { padding: 14px 16px; border-radius: 12px; background: #f1f4fa; }
.rule-card p { margin: 0 0 8px; font-size: 14px; }
.finger-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.finger-list li { display: flex; gap: 9px; align-items: center; font-size: 14px; }
.chip { display: inline-grid; min-width: 62px; padding: 3px 9px; place-items: center; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 700; }
.chip.current { background: #d15a3a; }
.chip.field { background: #3f7fd6; }
.mnemonic { margin: 9px 0 0 !important; padding: 8px 11px; border-radius: 9px; background: #fff; font-size: 14px; }

.hint { padding: 13px 15px; border-left: 4px solid #3f7fd6; border-radius: 0 10px 10px 0; background: #eef3fb; }
.hint b { display: block; margin-bottom: 4px; color: #2c62ad; }
.hint p { margin: 0; font-size: 14px; }
.hint.warn { border-left-color: #e0a33a; background: #fdf5e6; }
.hint.warn b { color: #a8741a; }
.note { margin: 6px 0 0; color: #56627a; font-size: 13px; }

.strength-meter { padding: 13px 15px; border-radius: 12px; background: #f1f4fa; }
.strength-meter small { color: #56627a; font-size: 12px; }
.bar { height: 16px; margin: 7px 0; overflow: hidden; border-radius: 999px; background: #dde4f0; }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #e0a33a, #d15a3a); transition: width .25s ease; }

.ways { display: grid; gap: 8px; padding: 14px 16px; border-radius: 12px; background: #f1f4fa; }
.way { padding: 9px 11px; border-radius: 9px; background: #fff; }
.way b { font-size: 14px; }
.way p { margin: 3px 0 0; color: #56627a; font-size: 13px; }

.applications { display: grid; gap: 9px; padding: 14px 16px; border-radius: 12px; background: #fdeee8; }
.application { padding: 11px 13px; border-radius: 10px; background: #fff; }
.app-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.app-head b { font-size: 15px; }
.app-head span { color: #b34a26; font-size: 12px; font-weight: 650; }
.application p { margin: 5px 0 0; color: #56627a; font-size: 13px; }

.level { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 0; color: #b34a26; font-weight: 700; }
.topic { padding: 2px 9px; border-radius: 999px; background: #fdeee8; font-size: 12px; }
.question { margin: 0; font-size: 17px; font-weight: 700; }
.choices { display: grid; gap: 9px; }
.choice { min-height: 50px; font-size: 14px; text-align: left; }
.choice.correct { border-color: #138a62; background: #e6f7ef; }
.choice.incorrect { border-color: #c64141; background: #fff0f0; }
.result { padding: 13px; border-left: 5px solid #8090aa; border-radius: 8px; background: #edf1f8; }
.result.correct { border-color: #138a62; background: #e6f7ef; }
.result.incorrect { border-color: #c64141; background: #fff0f0; }
.result b { display: block; margin-bottom: 3px; }
.result p { margin: 0; font-size: 14px; }
.steps { display: grid; gap: 11px; padding: 14px 16px; border-radius: 12px; background: #f1f4fa; }
.steps ol { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: 6px; font-size: 14px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .scene { height: 400px; min-height: 400px; }
}
@media (max-width: 600px) {
  .lab { padding: 17px 13px; }
  .tabs button { flex: 1 1 44%; }
  .scene { height: 330px; min-height: 330px; }
  .selectors { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .bar span { transition: none; } }

@media (prefers-color-scheme: dark) {
  :root { color: #edf2ff; background: #101522; }
  header > p:last-child, .note, .scene-hint, .scene-message, .readout small, .answer-box small, .legend, .way p, .application p, .strength-meter small { color: #b4bfd4; }
  button, .field select { color: #edf2ff; background: #1a2232; border-color: #46536b; }
  .scene { background: #141b2b; border-color: #46536b; }
  .readout > div, .applications { background: #2a1c16; }
  .readout b, .app-head span, h3, .level { color: #e8a882; }
  .rule-card, .hint, .ways, .strength-meter, .steps, .result { background: #1a2232; }
  .hint.warn { background: #2b2415; }
  .way, .application, .mnemonic { background: #212a3d; }
  .answer-box { background: #14281f; }
  .answer-box b { color: #7fd3a8; }
  .answer-box.none { background: #1a2232; }
  .bar { background: #2a3348; }
  .topic { background: #2a1c16; }
  .result.correct, .choice.correct { background: #12392f; }
  .result.incorrect, .choice.incorrect { background: #431f25; }
}
