  :root { color-scheme: dark; }
  * { box-sizing: border-box; }
  body {
    margin: 0; min-height: 100vh;
    font-family: system-ui, sans-serif;
    background: #0b0e13; color: #e6e6e6;
    line-height: 1.6;
  }
  main { width: min(1000px, 96vw); margin: 0 auto; padding: 40px 0 60px; }
  a { color: #7a94f8; text-decoration: none; }
  a:hover { text-decoration: underline; }
  h1 { font-size: 1.9rem; margin: 0 0 2px; }
  h1 .mark { color: #c89a3c; }
  .tagline { color: #8b93a1; margin: 0 0 22px; }
  .toolbar {
    display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
    background: #12161d; border: 1px solid #23283a; border-radius: 10px;
    padding: 10px 14px; margin-bottom: 12px;
  }
  .toolbar .lbl { color: #8b93a1; font-size: .85rem; margin-right: 4px; }
  .palette button, .toolbar button {
    background: #171a21; color: #e6e6e6; border: 1px solid #2a3145;
    border-radius: 8px; padding: 7px 13px; font-size: .95rem; cursor: pointer;
    font-family: inherit;
  }
  .palette button:hover, .toolbar button:hover { border-color: #4c6ef5; }
  .palette button.armed { border-color: #c89a3c; color: #c89a3c; background: #1d1a12; }
  .esc-len { font-family: ui-monospace, monospace; font-size: .88rem; color: #caa64a; white-space: nowrap; }
  .toolbar .grow { flex: 1; }
  .toolbar input[type=range] { width: 130px; accent-color: #c89a3c; vertical-align: middle; }
  .rpmval { font-family: ui-monospace, monospace; font-size: .9rem; color: #c89a3c; min-width: 70px; display: inline-block; }
  .canvaswrap {
    position: relative; background: #0f1218;
    border: 1px solid #23283a; border-radius: 10px; overflow: hidden;
  }
  canvas { display: block; width: 100%; aspect-ratio: 960 / 600; touch-action: none; }
  .banner {
    position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
    background: #3a1215; color: #ff8a8f; border: 1px solid #7a2a2e;
    padding: 6px 14px; border-radius: 8px; font-size: .9rem;
    display: none; pointer-events: none; white-space: nowrap;
  }
  .banner.on { display: block; }
  .banner.hold { background: #3a2e12; color: #e0c07a; border-color: #7a5f26; }
  .infobar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    min-height: 48px; background: #12161d; border: 1px solid #23283a;
    border-radius: 10px; padding: 8px 14px; margin-top: 12px;
    color: #aab3c5; font-size: .95rem;
  }
  .infobar button {
    background: #171a21; color: #e6e6e6; border: 1px solid #2a3145;
    border-radius: 8px; padding: 5px 11px; font-size: .85rem; cursor: pointer;
    font-family: inherit;
  }
  .infobar button:hover { border-color: #4c6ef5; }
  .infobar button.danger:hover { border-color: #e5484d; color: #ff8a8f; }
  .ratio { font-family: ui-monospace, monospace; color: #c89a3c; }
  .toolbar label.pin { color: #8b93a1; font-size: .85rem; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
  .toolbar label.pin input { accent-color: #c89a3c; }
  .shelf {
    display: none; flex-wrap: wrap; gap: 10px;
    background: #12161d; border: 1px solid #23283a; border-radius: 10px;
    padding: 12px 14px; margin-bottom: 12px;
  }
  .shelf.on { display: flex; }
  .shelf .card {
    background: #0f1218; border: 1px solid #2a3145; border-radius: 8px;
    padding: 10px 12px; width: 215px;
  }
  .shelf .card h3 { margin: 0 0 4px; font-size: .95rem; color: #c89a3c; }
  .shelf .card p { margin: 0 0 8px; font-size: .82rem; color: #8b93a1; line-height: 1.45; }
  .shelf .card button {
    background: #171a21; color: #e6e6e6; border: 1px solid #2a3145;
    border-radius: 7px; padding: 4px 10px; font-size: .82rem; cursor: pointer;
    font-family: inherit; margin-right: 6px;
  }
  .shelf .card button:hover { border-color: #c89a3c; color: #c89a3c; }
  .shelf .card button.chal { border-style: dashed; color: #8b93a1; margin-right: 0; }
  .shelf .card button.chal:hover { border-color: #4c6ef5; color: #9db1ff; }
  .thumb {
    margin: 0 0 8px; background: #0b0e13; border: 1px solid #1c2230;
    border-radius: 6px; overflow: hidden;
  }
  .thumb-svg { display: block; width: 100%; height: auto; }
  .t-gear { fill: #171a21; fill-opacity: .6; stroke: #3b4560; stroke-width: 1.2; }
  .t-gear.drv { fill: #241d0e; fill-opacity: .7; stroke: #c89a3c; stroke-width: 1.6; }
  .t-gear.esc { stroke: #6fc7b6; stroke-dasharray: 3 2; }
  .t-gear.rat { stroke: #b07ad0; stroke-dasharray: 1.5 2; }
  .t-gear.gva { stroke: #7fa6d8; stroke-dasharray: 4 2; }
  .t-pin { fill: none; stroke: #55617e; stroke-width: 1; stroke-dasharray: 2 2; }
  .t-belt { stroke: #6b7896; stroke-width: 1.6; }
  .t-belt.cross { stroke-dasharray: 4 3; }
  .t-x { stroke: #c89a3c; stroke-width: 1.4; }
  .shelf .more { color: #5c6575; font-size: .82rem; align-self: center; }
  .shelf .more.ready { flex-basis: 100%; color: #8b93a1; }
  .shelf .mine { flex-basis: 100%; border-bottom: 1px solid #1c2230; padding-bottom: 10px; }
  .shelf .mine h3 { margin: 0 0 8px; font-size: .95rem; color: #c89a3c; }
  .shelf .mine-save { display: flex; gap: 8px; flex-wrap: wrap; }
  .shelf .mine-name {
    background: #0f1218; color: #e6e6e6; border: 1px solid #2a3145;
    border-radius: 7px; padding: 4px 10px; font-size: .85rem; font-family: inherit;
    min-width: 180px; flex: 0 1 260px;
  }
  .shelf .mine-name:focus { outline: none; border-color: #c89a3c; }
  .shelf .mine-save button {
    background: #171a21; color: #e6e6e6; border: 1px solid #2a3145;
    border-radius: 7px; padding: 4px 12px; font-size: .85rem; cursor: pointer; font-family: inherit;
  }
  .shelf .mine-save button:hover { border-color: #c89a3c; color: #c89a3c; }
  .shelf .mine-empty { margin: 8px 0 0; color: #5c6575; font-size: .82rem; }
  .shelf .card.mine-card h3 { color: #8fd49a; }
  .story {
    display: none; position: relative;
    background: #12161d; border: 1px solid #23283a; border-radius: 10px;
    padding: 14px 18px; margin-top: 12px; max-width: 760px;
  }
  .story.on { display: block; }
  .story h3 { margin: 0 0 8px; font-size: 1.02rem; color: #c89a3c; }
  .story p { margin: 0 0 10px; color: #aab3c5; font-size: .95rem; }
  .story p:last-child { margin-bottom: 0; }
  .story .notice { color: #8b93a1; font-size: .9rem; border-top: 1px solid #1c2230; padding-top: 10px; }
  .story .hintline { margin: 12px 0 0; border-top: 1px solid #1c2230; padding-top: 10px; }
  .story .hintline button { background: #171a21; color: #8b93a1; border: 1px dashed #2a3145; border-radius: 7px; padding: 4px 10px; font-size: .85rem; cursor: pointer; font-family: inherit; }
  .story .hintline button:hover { border-color: #c89a3c; color: #c89a3c; }
  .story > button { position: absolute; top: 8px; right: 10px; background: none; border: none; color: #5c6575; font-size: 1.1rem; cursor: pointer; }
  .story > button:hover { color: #e6e6e6; }
  .story .goal { color: #c89a3c; }
  .story .goal strong { color: #c89a3c; }
  .story .solved { color: #8fd49a; }
  .story .solved button { background: #171a21; color: #e6e6e6; border: 1px solid #2a3145; border-radius: 7px; padding: 4px 10px; font-size: .85rem; cursor: pointer; font-family: inherit; margin-left: 6px; }
  .story .solved button:hover { border-color: #c89a3c; color: #c89a3c; }
  .shelf .card.locked { opacity: .55; }
  section.how { margin-top: 34px; max-width: 760px; }
  section.how h2 { font-size: 1.05rem; color: #8b93a1; text-transform: uppercase; letter-spacing: .08em; }
  section.how .limits { color: #8b93a1; font-size: .92rem; border-top: 1px solid #1c2230; padding-top: 14px; margin-top: 18px; }
  footer { margin-top: 40px; color: #8b93a1; font-size: .9rem; }
  .expand {
    position: absolute; top: 8px; right: 8px; z-index: 6;
    background: rgba(23,26,33,.85); color: #c9cfdd; border: 1px solid #2a3145;
    border-radius: 8px; padding: 5px 9px; font-size: 1rem; line-height: 1;
    cursor: pointer; font-family: inherit;
  }
  .expand:hover { border-color: #c89a3c; color: #c89a3c; }
  .canvaswrap.fs {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    height: 100dvh; z-index: 1000; border: none; border-radius: 0;
    display: flex; align-items: center; justify-content: center;
    background: #07080b;
  }
  .canvaswrap.fs canvas { width: min(100vw, calc(100vh * 1.6)); height: auto; }
  .canvaswrap.fs canvas { width: min(100vw, calc(100dvh * 1.6)); }
  @media (orientation: portrait) {
    .canvaswrap.fs.rot canvas { width: min(100vh, calc(100vw * 1.6)); height: auto; transform: rotate(90deg); }
    .canvaswrap.fs.rot canvas { width: min(100dvh, calc(100vw * 1.6)); }
  }
  body.fs-open { overflow: hidden; }
  @media (max-width: 720px) {
    main { width: 100%; padding: 10px 10px 40px; }
    h1 { font-size: 1.45rem; }
    .tagline { font-size: .88rem; margin-bottom: 10px; }
    .toolbar { flex-wrap: nowrap; overflow-x: auto; gap: 8px 12px; padding: 8px 10px; -webkit-overflow-scrolling: touch; }
    .toolbar .grow { display: none; }
    .toolbar .lbl { white-space: nowrap; }
    .palette { display: inline-flex; gap: 6px; align-items: center; flex: 0 0 auto; }
    .palette button, .toolbar button { flex: 0 0 auto; }
    .canvaswrap { border-radius: 8px; }
    .shelf .card { width: 100%; }
    .infobar { font-size: .86rem; padding: 8px 10px; }
    section.how { margin-top: 26px; }
  }
