    :root {
      color-scheme: dark;
      --bg: #091522;
      --surface: #102338;
      --surface2: #172c42;
      --line: #2c4760;
      --fg: #edf5fc;
      --sub: #a7bed0;
      --accent: #66e2b5;
      --yellow: #ffc970;
      --bad: #ff828b
    }

    * {
      box-sizing: border-box
    }

    body {
      margin: 0;
      background: radial-gradient(ellipse at 50% -30%, #234a59 0, transparent 55%), var(--bg);
      font: 15px/1.55 system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
      color: var(--fg)
    }

    button,
    select {
      font: inherit
    }

    button {
      cursor: pointer
    }

    button:focus-visible,
    select:focus-visible {
      outline: 3px solid #a8f6d2;
      outline-offset: 2px
    }

    main {
      max-width: 1420px;
      margin: auto;
      padding: 18px 16px 40px
    }

    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
      margin-bottom: 15px
    }

    h1 {
      font-size: clamp(22px, 3vw, 32px);
      margin: 0;
      letter-spacing: .02em
    }

    h1 span {
      color: var(--accent)
    }

    .tag {
      font-size: 12px;
      letter-spacing: .08em;
      color: var(--accent);
      font-weight: 800
    }

    .pill {
      background: #203950;
      border: 1px solid #3c5970;
      border-radius: 100px;
      padding: 6px 11px;
      font-size: 13px;
      color: #cbdceb
    }

    nav {
      display: flex;
      flex-wrap: wrap;
      gap: 7px;
      margin-bottom: 14px
    }

    .stage {
      border: 1px solid #375269;
      color: #cbd9e5;
      background: #14293a;
      padding: 8px 13px;
      border-radius: 10px;
      font-weight: 700
    }

    .stage.current {
      background: #2c5a56;
      border-color: var(--accent);
      color: white
    }

    .stage.done:after {
      content: ' ✓';
      color: var(--accent)
    }

    .columns {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 320px;
      gap: 14px
    }

    .panel {
      border: 1px solid #2a455b;
      border-radius: 16px;
      background: linear-gradient(140deg, #13273c, #0d1d2d);
      box-shadow: 0 12px 28px #0003;
      overflow: hidden
    }

    .intro {
      padding: 15px 16px 10px;
      display: flex;
      gap: 12px;
      align-items: flex-start;
      justify-content: space-between
    }

    .intro h2 {
      margin: 0 0 3px;
      font-size: 19px
    }

    .desc {
      color: #c0d3e2;
      font-size: 13px
    }

    .clear-conditions {
      margin: 4px 16px 10px;
      padding: 13px 15px;
      border: 2px solid #eac16f;
      border-radius: 11px;
      background: #2b2d29;
      color: #fff
    }

    .clear-conditions h3 {
      margin: 0 0 5px;
      color: #ffe09b;
      font-size: 17px
    }

    .clear-conditions p {
      margin: 0 0 8px;
      font-size: 13px;
      color: #f3e6cb
    }

    .condition-row {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin: 6px 0 0
    }

    .condition-chip {
      background: #142e38;
      border: 1px solid #7f9ba2;
      border-radius: 8px;
      padding: 7px 10px;
      font-size: 14px
    }

    .condition-chip strong {
      color: #fff
    }

    .clear-conditions .requirement {
      margin: 10px 0 0;
      font-weight: 700;
      font-size: 13px;
      color: #ffe09b
    }

    .info {
      background: #16362e;
      border: 1px solid #3b7963;
      border-radius: 10px;
      padding: 9px 12px;
      margin: 8px 16px;
      color: #c6f4df;
      font-size: 13px;
      min-height: 42px
    }

    .info.error {
      background: #3a252e;
      border-color: #92535b;
      color: #ffd5d5
    }

    .tools {
      display: flex;
      flex-wrap: wrap;
      gap: 7px;
      padding: 12px 15px;
      border-bottom: 1px solid #29445b
    }

    .tool {
      min-width: 67px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 1px;
      background: #1b3449;
      border: 1px solid #416077;
      color: #e6f1f7;
      border-radius: 10px;
      padding: 6px 9px;
      line-height: 1.2
    }

    .tool b {
      font-size: 17px;
      font-weight: 600
    }

    .tool small {
      font-size: 11px
    }

    .tool-separator {
      width: 1px;
      min-height: 42px;
      background: #466479;
      margin: 0 3px
    }

    .tool-action {
      background: #263d52;
      border-color: #688399
    }

    .tool-action b {
      font-size: 22px
    }

    .tool.active {
      background: #296a57;
      border-color: #88efc2;
      box-shadow: inset 0 0 0 1px #88efc2
    }

    .settings {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      padding: 9px 15px;
      color: var(--sub);
      font-size: 13px;
      min-height: 54px
    }

    .settings select {
      padding: 7px 9px;
      border-radius: 8px;
      color: #fff;
      border: 1px solid #4a677f;
      background: #1e3a51
    }

    .board {
      position: relative;
      margin: 0 10px 7px;
      background: radial-gradient(circle at 40% 20%, #1b3850, #0a1929 75%);
      border: 1px solid #35526b;
      border-radius: 12px;
      touch-action: none;
      overflow: hidden
    }

    .board canvas {
      display: block;
      width: 100%;
      height: auto;
      aspect-ratio: 900/600;
      cursor: crosshair
    }

    .underboard {
      padding: 10px 15px 14px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px
    }

    .btn {
      background: #28475a;
      border: 1px solid #517189;
      border-radius: 9px;
      color: white;
      padding: 9px 12px;
      font-weight: 700
    }

    .btn.primary {
      background: #2e8b6f;
      border-color: #78e0bb;
      color: #fff
    }

    .btn:hover,
    .stage:hover {
      filter: brightness(1.14)
    }

    .muted {
      font-size: 12px;
      color: var(--sub)
    }

    .side {
      padding: 16px
    }

    .side-ad {
      min-height: 300px;
      margin-top: 16px;
      grid-column: 1 / -1
    }

    .side h3 {
      font-size: 15px;
      margin: 0 0 9px
    }

    .side h3:not(:first-child) {
      margin-top: 20px
    }

    .meter {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px
    }

    .metric {
      background: #0d2133;
      border: 1px solid #2c4b62;
      padding: 11px;
      border-radius: 11px
    }

    .metric label {
      font-size: 12px;
      color: #acc5d6;
      display: block
    }

    .metric strong {
      font: 700 21px/1.5 ui-monospace, Consolas, monospace;
      letter-spacing: -1px
    }

    .metric strong.good {
      color: var(--accent)
    }

    .goal {
      font-size: 13px;
      color: #cedee9;
      background: #1b3041;
      border-left: 3px solid var(--yellow);
      padding: 11px;
      border-radius: 6px
    }

    .component-list {
      max-height: 268px;
      overflow: auto
    }

    .component {
      font: 12px/1.45 ui-monospace, monospace;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 7px 3px;
      border-bottom: 1px solid #294157;
      gap: 7px
    }

    .component button {
      border: 1px solid #4d697e;
      background: #203b50;
      color: #fff;
      border-radius: 6px;
      padding: 3px 7px;
      font-size: 11px
    }

    .status {
      font-size: 13px;
      color: #c0d3e2;
      white-space: pre-line
    }

    .learn {
      margin-top: 14px;
      padding: 18px 20px
    }

    .learn h2 {
      font-size: 19px;
      margin: 0 0 9px
    }

    .learn p {
      font-size: 13px;
      color: #c1d3e1;
      margin: 8px 0
    }

    .learn details {
      border-top: 1px solid #29455a;
      padding: 10px 0
    }

    .learn summary {
      cursor: pointer;
      font-weight: 700;
      color: #dfecf4
    }

    .footer {
      margin-top: 20px;
      color: #8cabbf;
      font-size: 12px;
      text-align: center
    }

    @media(max-width:1000px) {
      .columns {
        grid-template-columns: minmax(0, 1fr)
      }

      .side {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px
      }

      .side h3:not(:first-child) {
        margin: 0 0 9px
      }

      .component-list {
        max-height: none
      }

      .side>div {
        min-width: 0
      }
    }

    @media(max-width:630px) {
      main {
        padding: 12px 8px 30px
      }

      .intro {
        padding: 11px
      }

      .tools {
        padding: 8px;
        gap: 5px
      }

      .tool {
        min-width: 57px;
        padding: 6px 7px
      }

      .tool small {
        font-size: 10px
      }

      .side {
        display: block
      }

      .side>div {
        margin: 10px 0
      }

      .board {
        margin: 0 4px
      }

      .board canvas {
        aspect-ratio: 900/600
      }

      .pill {
        display: none
      }

      .learn {
        padding: 15px
      }

      .metric strong {
        font-size: 19px
      }
    }

    .stage-index {
      margin-top: 16px;
      padding: 16px 18px
    }

    .stage-index h2 {
      font-size: 20px;
      margin: 0 0 4px
    }

    .stage-index h2 span {
      font-size: 13px;
      color: var(--sub);
      font-weight: 500
    }

    .stage-index p {
      font-size: 12px;
      color: var(--sub);
      margin: 0 0 12px
    }

    .stage-index nav {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
      gap: 7px;
      margin: 0
    }

    .stage-index .stage {
      text-align: left;
      font-size: 12px;
      padding: 9px 10px;
      line-height: 1.5;
      min-height: 42px
    }

    @media(max-width:630px) {
      .stage-index {
        padding: 12px
      }

      .stage-index nav {
        grid-template-columns: repeat(2, minmax(0, 1fr))
      }

      .stage-index .stage {
        padding: 8px;
        font-size: 11px
      }
    }

    /* Clear state, progress and completion overlay */

    .clear-conditions.achieved {
      border-color: #78ecb3;
      background: #163e31
    }

    .clear-conditions.achieved h3 {
      color: #baffd9
    }

    .clear-modal[hidden] {
      display: none !important
    }

    .clear-modal {
      position: fixed;
      inset: 0;
      z-index: 1000;
      background: #020a13dd;
      display: grid;
      place-items: center;
      padding: 18px;
      backdrop-filter: blur(7px)
    }

    .clear-box {
      width: min(100%, 520px);
      padding: 32px 24px 24px;
      text-align: center;
      border: 3px solid #76edb2;
      border-radius: 22px;
      background: linear-gradient(145deg, #184c3d, #11283a);
      box-shadow: 0 0 0 6px #64ffb122, 0 30px 90px #000b;
      animation: popClear .25s ease-out
    }

    @keyframes popClear {
      from {
        transform: scale(.85);
        opacity: 0
      }

      to {
        transform: scale(1);
        opacity: 1
      }
    }

    .clear-mark {
      font-size: 54px;
      line-height: 1.1;
      color: #baffda
    }

    .clear-box h2 {
      font-size: clamp(30px, 7vw, 46px);
      letter-spacing: .04em;
      color: #baffda;
      margin: 9px 0 4px
    }

    .clear-box .clear-stage {
      font-size: 18px;
      font-weight: 800;
      color: #fff;
      margin: 0 0 15px
    }

    .clear-box .clear-lesson {
      font-size: 14px;
      line-height: 1.7;
      color: #e0f7e9;
      margin: 12px 0 18px
    }

    .clear-measures {
      background: #0a2630;
      border: 1px solid #54897b;
      border-radius: 12px;
      padding: 12px;
      text-align: left;
      font-size: 14px
    }

    .clear-measures>div {
      padding: 6px 0;
      border-bottom: 1px solid #345e57
    }

    .clear-measures>div:last-child {
      border-bottom: 0
    }

    .clear-actions {
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 10px;
      margin-top: 20px
    }

    .clear-actions button {
      font-weight: 800;
      font-size: 16px;
      padding: 11px 20px;
      min-height: 48px
    }

    @media(prefers-reduced-motion:reduce) {
      .clear-box {
        animation: none
      }
    }

    footer {
      text-align: center;
      margin-top: 16px;
      padding: 14px 0 6px;
      color: #8cabbf;
      font-size: 13px
    }

    /* Individual live condition indicators */
    .condition-chip {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      transition: background .15s, border-color .15s
    }

    .condition-chip .condition-mark {
      flex: none;
      display: inline-grid;
      place-items: center;
      width: 21px;
      height: 21px;
      border: 1px solid #75909c;
      border-radius: 50%;
      color: #b8cad1;
      font-weight: 900;
      font-size: 15px;
      line-height: 1
    }

    .condition-chip.met {
      background: #174a39;
      border-color: #69d9a5;
      color: #e3fff0
    }

    .condition-chip.met .condition-mark {
      background: #43b884;
      color: #082c1b;
      border-color: #43b884
    }

    .clear-conditions .requirement {
      display: flex;
      align-items: center;
      gap: 7px
    }

    .clear-conditions .requirement .condition-mark {
      flex: none;
      display: inline-grid;
      place-items: center;
      width: 21px;
      height: 21px;
      border: 1px solid #75909c;
      border-radius: 50%;
      font-weight: 900;
      color: #b8cad1
    }

    .clear-conditions .requirement.met {
      color: #b4f9d4
    }

    .clear-conditions .requirement.met .condition-mark {
      background: #43b884;
      color: #082c1b;
      border-color: #43b884
    }
