:root {
  color-scheme: dark;
  --bg: #0b0e10;
  --text: #e5e3db;
  --muted: #999c99;
  --quiet: #6c7474;
  --gold: #bba16f;
  --gold-bright: #d2bb8e;
  --border: #292d2d;
  --serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body::before { position: fixed; z-index: -1; inset: 0; content: ''; background: radial-gradient(ellipse at 35% 35%, #1d211e30, transparent 70%); pointer-events: none; }
button, input, summary { -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }
button, a, summary, input { outline-offset: 5px; }
:focus-visible { outline: 2px solid var(--gold-bright); }
button svg, summary svg, .identity svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.site-shell { max-width: 1640px; margin: auto; padding: 0 48px; }
.site-header { display: flex; align-items: center; min-height: 126px; gap: 34px; border-bottom: 1px solid var(--border); }
.identity { display: flex; gap: 18px; align-items: center; color: inherit; text-decoration: none; }
.identity-symbol { width: 46px; height: 57px; border: 1px solid #8d794858; display: grid; place-items: center; color: var(--gold); position: relative; }
.identity-symbol::before { content: ''; position: absolute; width: 8px; height: 8px; border-top: 1px solid var(--gold); border-right: 1px solid var(--gold); top: -5px; background: var(--bg); transform: rotate(-45deg); }
.identity-symbol svg { width: 29px; height: 33px; }
.identity-text { display: flex; flex-direction: column; gap: 7px; }
.identity strong { font-family: var(--serif); font-size: 35px; font-weight: 400; letter-spacing: .16em; line-height: 1; }
.identity-text > span { font-size: 9px; letter-spacing: .26em; color: var(--gold); }
.header-meta { margin-left: auto; display: flex; flex-direction: column; gap: 10px; text-align: right; }
.tiny-label { font: 9px/1.4 var(--mono); letter-spacing: .16em; color: var(--muted); }
.meta-detail { font-family: var(--serif); font-size: 15px; color: #959993; }
.icon-button { background: none; border: 1px solid var(--border); width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); transition: border-color .2s, color .2s; }
.icon-button:hover { color: var(--gold-bright); border-color: #6e6146; }
.icon-button svg { width: 17px; height: 17px; }
.main-layout { display: grid; grid-template-columns: minmax(0, 1fr) 292px; gap: 52px; padding: 40px 0 34px; min-height: 680px; align-items: start; }
.stage { min-width: 0; position: relative; height: clamp(560px, calc(100vh - 220px), 850px); isolation: isolate; overflow: hidden; background: var(--bg); border: 1px solid #23292a; }
.stage::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 100px 2px #0b0e105c; pointer-events: none; }
.stage-top { position: absolute; z-index: 2; top: 23px; left: 24px; right: 21px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.object-label { color: #a7aaa5; font: 9px/1 var(--mono); letter-spacing: .13em; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.small-dot { display: inline-block; width: 4px; height: 4px; background: var(--gold); transform: rotate(45deg); }
.dim { color: #60686b; }
.view-button { display: flex; align-items: center; gap: 8px; background: transparent; border: 0; color: #a0a7a5; font: 10px/1 var(--sans); padding: 7px 0 7px 8px; }
.view-button svg { width: 15px; height: 15px; }
.view-button:hover { color: var(--gold-bright); }
.viewport { position: absolute; inset: 23px 0 20px; }
.viewport canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.viewport canvas.dragging { cursor: grabbing; }
.stage-side { position: absolute; left: 20px; font: 8px/1 var(--mono); letter-spacing: .15em; color: #7b847e; writing-mode: vertical-rl; display: flex; align-items: center; gap: 9px; pointer-events: none; }
.stage-side span { writing-mode: horizontal-tb; font-size: 12px; }
.side-light { top: 28%; }
.side-dark { bottom: 26%; color: #647073; }
.stage-bottom { position: absolute; z-index: 2; bottom: 21px; left: 24px; right: 24px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; gap: 10px; }
.drag-hint { display: flex; align-items: center; gap: 10px; color: #959d9c; font-size: 10px; }
.drag-mark { font-size: 20px; color: var(--gold); font-family: var(--serif); }
.hint-separator { padding: 0 6px; color: #53605e; }
.geometry-note { color: #a9ac9e; font: 12px/1 var(--mono); letter-spacing: .06em; white-space: nowrap; }
.geometry-note span { color: #606c6b; font-size: 9px; margin: 0 4px; }
.stage-progress { height: 2px; position: absolute; bottom: 0; left: 0; right: 0; background: transparent; }
.stage-progress > span { display: block; width: 0; height: 100%; background: var(--gold); opacity: .75; }
.loader { position: absolute; z-index: 5; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 22px; background: var(--bg); color: var(--gold); font: 13px var(--serif); letter-spacing: .04em; transition: opacity .5s; }
.loader.loaded { opacity: 0; pointer-events: none; }
.loader-orbit { width: 30px; height: 30px; border: 1px solid #bba16f38; border-top-color: var(--gold); border-radius: 50%; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-panel { position: absolute; z-index: 8; inset: 0; padding: 60px 40px; background: var(--bg); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.error-panel[hidden] { display: none; }
.error-panel h2 { font: 32px var(--serif); font-weight: 400; }
.error-panel p { font-size: 14px; line-height: 1.6; max-width: 420px; color: var(--muted); }
.error-panel button { margin-top: 20px; padding: 15px 25px; }
.control-panel { padding-top: 10px; }
.accent { color: var(--gold); }
.panel-intro h1 { font-family: var(--serif); font-weight: 400; font-size: 60px; line-height: 1.02; letter-spacing: -.03em; margin: 22px 0 19px; }
.panel-intro h1 em { color: var(--gold-bright); font-weight: 400; }
.panel-intro p { color: #a9ada6; font-size: 12px; line-height: 1.8; margin: 0; }
.scoreboard { display: grid; grid-template-columns: 1fr 30px 1fr; align-items: center; padding-top: 32px; }
.score { display: flex; flex-direction: column; }
.score-dark { padding-left: 17px; }
.score-label { font: 9px/1 var(--mono); letter-spacing: .14em; display: flex; align-items: center; gap: 7px; color: #c7c8be; }
.bead-dot { display: block; width: 7px; height: 7px; border-radius: 50%; }
.white-dot { background: #dedfd1; box-shadow: 0 0 5px #dedfd125; }
.black-dot { background: #1c262c; border: 1px solid #7c878b; }
.score-value { font-family: var(--serif); font-size: 52px; line-height: 1.15; letter-spacing: -.055em; margin-top: 7px; font-variant-numeric: tabular-nums lining-nums; min-height: 60px; }
.score-light .score-value { color: #e5e5d9; }
.score-dark .score-value { color: #a1b0b5; }
.score-direction { font-size: 10px; color: #949d99; margin-top: 2px; }
.score-divider { align-self: center; text-align: center; font: 29px var(--serif); font-weight: 300; color: #3a4646; padding-top: 8px; }
.balance-line { height: 3px; margin-top: 24px; background: #445157; position: relative; }
.balance-line span { display: block; height: 100%; width: 50%; background: #d5cfb9; }
.balance-line i { position: absolute; width: 1px; height: 11px; left: 50%; top: -4px; background: var(--gold); opacity: .6; }
.verdict-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 12px; font: 8px/1.5 var(--mono); letter-spacing: .06em; min-height: 13px; }
#verdict { color: var(--gold-bright); }
#phase-label { color: #9aa5a3; white-space: nowrap; font-size: 8px; }
.primary-action { margin-top: 27px; }
.primary-button { position: relative; display: flex; width: 100%; align-items: center; justify-content: center; gap: 12px; min-height: 52px; border: 1px solid #c1a66f; background: #bfa779; color: #131815; font-size: 13px; font-weight: 600; letter-spacing: .015em; transition: background .2s, transform .15s; }
.primary-button:hover { background: #d1bc95; }
.primary-button:active { transform: translateY(1px); }
.primary-button svg { width: 19px; height: 21px; stroke-width: 1.5; }
.primary-button kbd { font: 13px var(--mono); opacity: .55; position: absolute; right: 15px; }
.primary-button[data-running="true"] { background: #26281f; color: #d0bc92; border-color: #716647; }
.primary-button[data-running="true"]:hover { background: #323328; }
.action-caption { font: 10px/1.5 var(--sans); text-align: center; color: #9b9f93; margin: 9px 0 18px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.secondary-button { min-height: 41px; background: transparent; border: 1px solid #39403e; color: #c3c7bc; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 11px; padding: 8px 5px; transition: background .2s, border-color .2s; }
.secondary-button svg { width: 16px; height: 16px; }
.secondary-button:hover:not(:disabled) { background: #1d2424; border-color: #8b7c5c; color: var(--gold-bright); }
.minor-actions { display: flex; justify-content: space-between; margin: 10px 0 19px; }
.text-button { display: flex; align-items: center; gap: 6px; color: #a7afa8; border: 0; background: transparent; padding: 7px 0; font-size: 10px; }
.text-button svg { width: 14px; height: 14px; }
.text-button:hover:not(:disabled) { color: var(--gold-bright); }
.settings { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.settings summary { list-style: none; display: flex; gap: 10px; padding: 15px 0; align-items: center; color: #b5bcb4; font-size: 11px; cursor: pointer; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary svg { width: 15px; height: 15px; color: #96a09a; }
.settings summary .chevron { margin-left: auto; width: 13px; height: 13px; transition: transform .2s; }
.settings[open] .chevron { transform: rotate(180deg); }
.settings-content { padding: 8px 0 14px; }
.speed-label { display: flex; align-items: center; justify-content: space-between; color: #bbc0b8; font-size: 11px; }
.speed-label output { font: 11px var(--mono); color: var(--gold); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; margin: 20px 0 19px; background: #3a423c; height: 2px; cursor: pointer; accent-color: var(--gold); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; border: 0; background: var(--gold); border-radius: 50%; }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 0; background: var(--gold); border-radius: 50%; }
.toggle-row { position: relative; display: flex; align-items: center; justify-content: space-between; color: #b1b9b2; font-size: 11px; padding: 9px 0; cursor: pointer; }
.toggle-row input { position: absolute; right: 0; width: 34px; height: 20px; margin: 0; opacity: 0; }
.switch { width: 29px; height: 16px; border: 1px solid #4c5851; border-radius: 20px; position: relative; background: #171d1c; pointer-events: none; }
.switch::after { content: ''; position: absolute; width: 8px; height: 8px; top: 3px; left: 3px; border-radius: 50%; background: #79877d; transition: transform .2s; }
.toggle-row input:checked + .switch { border-color: #a58d60; background: #403c2c; }
.toggle-row input:checked + .switch::after { background: var(--gold-bright); transform: translateX(13px); }
.toggle-row input:focus-visible + .switch { outline: 2px solid var(--gold-bright); outline-offset: 4px; }
.mechanism-note { display: flex; gap: 12px; align-items: center; font-size: 10px; line-height: 1.7; color: #98a19b; margin: 19px 0 0; }
.mechanism-symbol { font-size: 23px; color: #bba987; font-family: Georgia, serif; }
.site-footer { min-height: 66px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 20px; font: 8px/1.6 var(--mono); letter-spacing: .08em; color: #89938e; }
.footer-divider { color: #54625a; margin: 0 9px; }
.footer-tech { white-space: nowrap; display: flex; align-items: center; }
.status-dot { width: 4px; height: 4px; background: #9ea88a; border-radius: 50%; margin-right: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }
.noscript { position: fixed; z-index: 99; inset: auto 0 0; background: #bfa779; color: #0b0e10; padding: 20px; text-align: center; }
body.is-running .status-dot { background: var(--gold-bright); }
body.is-running .side-light { color: #b2b8a5; }
body.is-running .side-dark { color: #899699; }
@media (min-width: 1500px) {
  .main-layout { grid-template-columns: minmax(0, 1fr) 315px; gap: 64px; }
  .control-panel { padding-top: 28px; }
  .panel-intro h1 { font-size: 68px; }
}
@media (max-width: 1150px) {
  .site-shell { padding: 0 28px; }
  .main-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; padding-top: 28px; }
  .stage { height: 610px; }
  .panel-intro h1 { font-size: 54px; }
  .stage-top { left: 17px; right: 17px; }
  .stage-bottom { left: 17px; right: 17px; }
  .stage-side { left: 13px; }
  .view-button span { display: none; }
  .drag-hint { font-size: 9px; gap: 6px; }
  .hint-separator { padding: 0 2px; }
}
@media (max-width: 820px) {
  .site-shell { padding: 0 24px; max-width: 700px; }
  .site-header { min-height: 104px; gap: 15px; }
  .header-meta { display: none; }
  .fullscreen-button { margin-left: auto; }
  .identity strong { font-size: 30px; }
  .identity-symbol { height: 47px; width: 40px; }
  .identity-text > span { font-size: 8px; letter-spacing: .22em; }
  .main-layout { display: flex; flex-direction: column; gap: 0; padding: 24px 0 30px; min-height: 0; }
  .stage { width: 100%; height: auto; aspect-ratio: 1.20; min-height: 310px; }
  .viewport { inset: 18px 0 16px; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; width: 100%; padding-top: 32px; }
  .panel-intro { grid-column: 1; grid-row: 1 / 5; }
  .panel-intro h1 { font-size: 53px; margin-top: 15px; }
  .panel-intro p { font-size: 11px; }
  .scoreboard { grid-column: 2; padding-top: 0; }
  .balance-line, .verdict-row { grid-column: 2; }
  .balance-line { margin-top: 16px; }
  .verdict-row { font-size: 7px; flex-wrap: wrap; }
  .primary-action { grid-column: 1 / -1; margin-top: 27px; }
  .preset-grid, .minor-actions, .settings, .mechanism-note { grid-column: 1 / -1; }
  .secondary-button { min-height: 44px; }
  .mechanism-note { justify-content: center; }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 9px; padding: 18px 0; font-size: 7px; }
}
@media (max-width: 440px) {
  .site-shell { padding: 0 16px; }
  .site-header { min-height: 93px; }
  .identity { gap: 12px; }
  .identity strong { font-size: 28px; }
  .identity-text > span { font-size: 7px; }
  .stage { min-height: 305px; }
  .stage-top { top: 15px; left: 14px; right: 14px; }
  .stage-bottom { bottom: 13px; left: 14px; right: 14px; }
  .object-label { font-size: 8px; }
  .geometry-note { display: none; }
  .drag-hint { font-size: 8px; }
  .stage-side { font-size: 7px; left: 9px; }
  .control-panel { gap: 0 17px; padding-top: 27px; }
  .tiny-label { font-size: 7px; }
  .panel-intro h1 { font-size: 44px; margin-bottom: 13px; }
  .panel-intro p { font-size: 10px; }
  .desktop-break { display: none; }
  .scoreboard { grid-template-columns: 1fr 18px 1fr; padding-top: 18px; }
  .score-dark { padding-left: 6px; }
  .score-label { font-size: 7px; gap: 5px; letter-spacing: .04em; }
  .score-value { font-size: 43px; min-height: 50px; }
  .score-direction { font-size: 8px; }
  .verdict-row { font-size: 6px; margin-top: 9px; }
  #phase-label { font-size: 6px; }
  .balance-line { margin-top: 13px; }
  .primary-action { margin-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
[hidden] { display: none !important; }
