:root {
  color-scheme: dark;
  --background: #090b13;
  --panel: rgba(17, 20, 31, 0.78);
  --panel-border: rgba(184, 194, 221, 0.09);
  --text: #eef0f8;
  --muted: #777d91;
  --accent: #ff7756;
  --accent-soft: rgba(255, 119, 86, 0.14);
  --green: #7ee2a4;
  --cubie: 82px;
  --half-cubie: 41px;
  --face-white: #f4f2ea;
  --face-yellow: #ffd34e;
  --face-red: #ff5d60;
  --face-orange: #ff9955;
  --face-blue: #668aff;
  --face-green: #62d999;
  --plastic-color: #121420;
  --sticker-inset: 3px;
  --sticker-radius: 7px;
  --plastic-radius: 10px;
  --sticker-brightness: 1;
  --gloss-strength: 0.35;
  --ambient-opacity: 0.19;
  font-family: "Manrope", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; overflow-x: hidden; background: var(--background); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, .viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.ambient { position: fixed; pointer-events: none; filter: blur(95px); opacity: var(--ambient-opacity); }
.ambient-one { top: -140px; left: -150px; width: 460px; height: 460px; background: #443178; }
.ambient-two { right: -200px; bottom: -170px; width: 500px; height: 500px; background: #184a60; }
.studio { position: relative; width: min(100% - 48px, 1060px); min-height: 100dvh; margin: 0 auto; padding: 36px 0 18px; }
.masthead, .dashboard, .history-bar, .footer, .section-label { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 15px; letter-spacing: 0.18em; }
.brand-subtitle, .eyebrow, .footer, .section-label, .drag-hint { font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: 0.12em; color: var(--muted); }
.brand-subtitle { font-size: 9px; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 9px); gap: 3px; transform: rotate(-7deg); }
.brand-mark span { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(6) { background: var(--face-yellow); }
.brand-mark span:nth-child(4), .brand-mark span:nth-child(9) { background: var(--face-blue); }
.brand-mark span:nth-child(7) { background: var(--face-green); }
.header-actions, .history-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--panel-border); border-radius: 11px; background: var(--panel); font-size: 20px; transition: border-color 160ms, background 160ms, opacity 160ms; }
.icon-button:hover:not(:disabled) { border-color: rgba(255, 119, 86, 0.45); background: rgba(31, 30, 39, 0.9); }
.icon-button:disabled { cursor: not-allowed; opacity: 0.36; }
.icon-button svg, .action-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.compact { width: 34px; height: 34px; border-radius: 9px; }
.dashboard { width: min(100%, 685px); margin: 43px auto 0; gap: 30px; }
.stat-block { display: grid; gap: 7px; min-width: 84px; }
.stat-block output { font-family: "DM Mono", monospace; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.timer-block { min-width: 125px; }
.size-picker { display: flex; align-items: center; gap: 3px; padding: 4px; border: 1px solid var(--panel-border); border-radius: 11px; background: var(--panel); }
.size-picker button { min-width: 48px; padding: 8px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-family: "DM Mono", monospace; font-size: 11px; }
.size-picker button.active { background: #242633; color: var(--text); }
.size-picker button span { padding: 0 1px; color: var(--muted); }
.puzzle-section { position: relative; height: clamp(380px, 49vw, 470px); margin: 8px auto 0; }
.puzzle-backdrop { position: absolute; inset: 11% 23%; border-radius: 50%; background: radial-gradient(ellipse, rgba(120, 133, 199, 0.1), transparent 68%); }
.cube-shadow { position: absolute; top: 77%; left: 50%; width: 260px; height: 52px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); filter: blur(20px); transform: translateX(-50%); pointer-events: none; }
.viewport { position: absolute; inset: 0; overflow: hidden; perspective: 1100px; touch-action: none; cursor: grab; }
.viewport:active { cursor: grabbing; }
.scene { position: absolute; top: 47%; left: 50%; width: 0; height: 0; transform-style: preserve-3d; transition: transform 120ms ease-out; }
.scene.dragging { transition: none; }
.cube { position: absolute; width: 0; height: 0; transform-style: preserve-3d; }
.cubie { position: absolute; top: calc(var(--half-cubie) * -1); left: calc(var(--half-cubie) * -1); width: var(--cubie); height: var(--cubie); transform-style: preserve-3d; will-change: transform; }
.cubie-face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: var(--plastic-radius); background: var(--plastic-color); backface-visibility: hidden; }
.cubie-face::after { position: absolute; inset: var(--sticker-inset); border-radius: var(--sticker-radius); background: var(--sticker-color, #181a24); content: ""; }
.cubie-face.sticker::after { filter: brightness(var(--sticker-brightness)); box-shadow: inset 0 1px 2px rgba(255, 255, 255, var(--gloss-strength)), inset 0 -3px 6px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.3); }
.cubie-face.sticker:hover::after { filter: brightness(1.13); }
.cube.labels-visible .cubie-face.sticker::before { position: relative; z-index: 1; color: rgba(10, 12, 20, 0.55); font-family: "DM Mono", monospace; font-size: clamp(11px, calc(var(--cubie) * 0.23), 20px); font-weight: 600; content: attr(data-face); pointer-events: none; }
.cube.sticker-glow .cubie-face.sticker::after { box-shadow: inset 0 1px 2px rgba(255, 255, 255, var(--gloss-strength)), inset 0 -3px 6px rgba(0, 0, 0, 0.12), 0 0 15px var(--sticker-color); }
.cubie-face[data-face="F"] { transform: translateZ(var(--half-cubie)); }
.cubie-face[data-face="B"] { transform: rotateY(180deg) translateZ(var(--half-cubie)); }
.cubie-face[data-face="R"] { transform: rotateY(90deg) translateZ(var(--half-cubie)); }
.cubie-face[data-face="L"] { transform: rotateY(-90deg) translateZ(var(--half-cubie)); }
.cubie-face[data-face="U"] { transform: rotateX(90deg) translateZ(var(--half-cubie)); }
.cubie-face[data-face="D"] { transform: rotateX(-90deg) translateZ(var(--half-cubie)); }
.status-pill { position: absolute; top: 25px; left: 0; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid var(--panel-border); border-radius: 999px; background: var(--panel); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: 0.09em; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(126, 226, 164, 0.6); }
.status-pill.scrambled .status-dot { background: var(--accent); box-shadow: 0 0 12px rgba(255, 119, 86, 0.6); }
.status-pill.animating .status-dot { background: var(--face-yellow); }
.view-tools { position: absolute; top: 24px; right: 0; display: grid; gap: 7px; }
.drag-hint { position: absolute; bottom: 0; left: 0; width: 100%; text-align: center; transition: opacity 300ms; }
.drag-hint span { color: #abb0c0; }
.control-deck { width: min(100%, 690px); margin: 22px auto 0; }
.primary-actions { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 11px; }
.action-button { display: flex; align-items: center; justify-content: center; gap: 9px; height: 48px; border: 1px solid var(--panel-border); border-radius: 11px; background: var(--panel); font-family: "DM Mono", monospace; font-size: 11px; letter-spacing: 0.08em; transition: background 160ms, border-color 160ms, transform 160ms; }
.action-button:hover:not(:disabled) { border-color: rgba(255, 119, 86, 0.5); transform: translateY(-1px); }
.action-button:disabled { opacity: 0.58; cursor: wait; }
.scramble-button { border-color: rgba(255, 119, 86, 0.38); background: var(--accent-soft); color: #ffa38c; }
.move-grid-wrap { margin-top: 26px; }
.section-label { margin-bottom: 10px; font-size: 9px; }
.move-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.move-button { height: 43px; border: 1px solid var(--panel-border); border-radius: 9px; background: var(--panel); font-family: "DM Mono", monospace; font-size: 14px; transition: color 150ms, border-color 150ms, transform 150ms; }
.move-button:hover { border-color: rgba(255, 119, 86, 0.45); color: var(--accent); }
.move-button:active, .move-button.pressed { transform: translateY(2px); color: var(--accent); }
.history-bar { min-height: 64px; margin-top: 15px; border-top: 1px solid var(--panel-border); border-bottom: 1px solid var(--panel-border); }
.history-copy { display: grid; gap: 5px; min-width: 0; }
.history-copy output { max-width: min(500px, 65vw); overflow: hidden; color: #c9cbd8; font-family: "DM Mono", monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.algorithm-form { display: grid; gap: 8px; margin-top: 19px; }
.algorithm-field { display: flex; height: 43px; border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel); }
.algorithm-field:focus-within { border-color: rgba(255, 119, 86, 0.52); }
.algorithm-field input { width: 100%; padding: 0 12px; border: 0; outline: none; background: transparent; color: var(--text); font-family: "DM Mono", monospace; font-size: 12px; }
.algorithm-field button { padding: 0 14px; border: 0; border-radius: 0 9px 9px 0; background: transparent; color: #ffa38c; font-family: "DM Mono", monospace; font-size: 10px; white-space: nowrap; }
.algorithm-feedback { min-height: 14px; color: var(--face-red); font-family: "DM Mono", monospace; font-size: 10px; }
.settings-studio { width: min(100%, 940px); margin: 55px auto 0; padding: 31px 0 5px; border-top: 1px solid var(--panel-border); outline: none; }
.settings-heading, .settings-heading-actions, .settings-card-heading, .slider-setting > span, .material-colors { display: flex; align-items: center; }
.settings-heading { justify-content: space-between; margin-bottom: 22px; }
.settings-heading .eyebrow { margin: 0 0 7px; color: var(--accent); }
.settings-heading h2 { margin: 0; font-size: 26px; letter-spacing: -0.05em; }
.settings-intro { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.settings-heading-actions { gap: 10px; }
.settings-reset { height: 34px; padding: 0 12px; border: 1px solid var(--panel-border); border-radius: 9px; background: var(--panel); color: var(--muted); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: 0.08em; }
.settings-reset:hover { border-color: rgba(255, 119, 86, 0.5); color: var(--accent); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.settings-grid[hidden] { display: none; }
.settings-card { min-width: 0; padding: 21px 20px 16px; border: 1px solid var(--panel-border); border-radius: 14px; background: linear-gradient(155deg, rgba(20, 22, 35, 0.91), rgba(13, 15, 25, 0.86)); }
.settings-card-heading { gap: 12px; margin-bottom: 19px; }
.settings-icon { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid rgba(255, 119, 86, 0.19); border-radius: 10px; background: rgba(255, 119, 86, 0.07); color: var(--accent); font-size: 21px; }
.settings-card-heading h3 { margin: 0; font-size: 13px; font-weight: 700; }
.settings-card-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.dial-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 0 -3px 20px; padding-bottom: 15px; border-bottom: 1px solid var(--panel-border); }
.dial { position: relative; display: grid; justify-items: center; gap: 5px; cursor: pointer; }
.dial-disc { position: relative; display: grid; place-items: center; width: 61px; height: 61px; border: 1px solid rgba(194, 200, 219, 0.16); border-radius: 50%; background: radial-gradient(circle at 36% 32%, #303443, #151823 72%); box-shadow: 0 5px 12px rgba(0, 0, 0, 0.34), inset 0 1px 1px rgba(255, 255, 255, 0.13); }
.dial-disc::before { position: absolute; inset: -5px; border: 1px dashed rgba(194, 200, 219, 0.12); border-radius: 50%; content: ""; }
.dial-needle { position: absolute; top: 8px; left: calc(50% - 1px); width: 2px; height: 11px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); transform: rotate(var(--dial-angle, 0deg)); transform-origin: 1px 22px; }
.dial input { position: absolute; z-index: 2; top: 0; left: 50%; width: 65px; height: 65px; margin: 0; transform: translateX(-50%); opacity: 0; cursor: ew-resize; }
.dial-label { margin-top: 3px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: 0.1em; }
.dial output { color: var(--text); font-family: "DM Mono", monospace; font-size: 10px; }
.slider-setting { display: grid; grid-template-columns: 1fr auto; gap: 9px 8px; margin: 14px 0 16px; color: #d2d4df; font-size: 11px; }
.slider-setting output { color: var(--accent); font-family: "DM Mono", monospace; font-size: 10px; white-space: nowrap; }
.slider-setting input[type="range"] { grid-column: 1 / -1; width: 100%; height: 15px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
.slider-setting input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--slider-progress, 50%), #292d3a var(--slider-progress, 50%), #292d3a 100%); }
.slider-setting input[type="range"]::-webkit-slider-thumb { width: 13px; height: 13px; margin-top: -4.5px; appearance: none; border: 2px solid #0f111b; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px rgba(255, 119, 86, 0.48); }
.slider-setting input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: #292d3a; }
.slider-setting input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.slider-setting input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 2px solid #0f111b; border-radius: 50%; background: var(--accent); }
.switch-setting { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 45px; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(184, 194, 221, 0.06); cursor: pointer; }
.switch-setting > span:first-child { display: grid; gap: 3px; }
.switch-setting strong { font-size: 11px; font-weight: 600; }
.switch-setting small { color: var(--muted); font-size: 9px; }
.switch-setting input { position: absolute; right: 0; width: 36px; height: 20px; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { position: relative; flex: 0 0 36px; width: 36px; height: 20px; border: 1px solid #353847; border-radius: 999px; background: #1b1e29; transition: border-color 140ms, background 140ms; pointer-events: none; }
.switch-track::after { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #858a9c; content: ""; transition: transform 140ms, background 140ms; }
.switch-setting input:checked + .switch-track { border-color: rgba(255, 119, 86, 0.7); background: rgba(255, 119, 86, 0.24); }
.switch-setting input:checked + .switch-track::after { background: var(--accent); transform: translateX(16px); }
.switch-setting input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.palette-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 0 0 20px; }
.palette-preset { height: 29px; padding: 0 4px; border: 1px solid var(--panel-border); border-radius: 7px; background: #151723; color: var(--muted); font-family: "DM Mono", monospace; font-size: 8px; }
.palette-preset.active { border-color: rgba(255, 119, 86, 0.46); background: rgba(255, 119, 86, 0.11); color: #ffa38c; }
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 8px; }
.color-setting { display: grid; justify-items: center; gap: 5px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 8px; letter-spacing: 0.07em; cursor: pointer; }
.color-setting input { width: 48px; height: 33px; padding: 2px; overflow: hidden; border: 1px solid rgba(184, 194, 221, 0.18); border-radius: 8px; background: #1b1e29; cursor: pointer; }
.color-setting input::-webkit-color-swatch-wrapper { padding: 0; }
.color-setting input::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-setting input::-moz-color-swatch { border: 0; border-radius: 5px; }
.material-colors { justify-content: space-evenly; gap: 8px; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--panel-border); }
.inline-color { grid-template-columns: 35px 1fr; align-items: center; gap: 6px; }
.inline-color input { width: 35px; height: 26px; }
.timer-block.timer-disabled output { color: var(--muted); }
.footer { margin-top: 22px; padding-bottom: 10px; font-size: 9px; }
.help-dialog { position: fixed; width: min(calc(100% - 32px), 540px); padding: 30px; overflow: visible; border: 1px solid rgba(191, 191, 213, 0.15); border-radius: 18px; background: #11131e; color: var(--text); box-shadow: 0 24px 100px rgba(0, 0, 0, 0.5); }
.help-dialog::backdrop { background: rgba(5, 6, 12, 0.76); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 18px; right: 18px; }
.help-dialog h2 { margin: 9px 0 24px; font-size: 28px; }
.shortcut-list { display: grid; gap: 11px; }
.shortcut-list > div { display: flex; align-items: center; gap: 6px; min-height: 30px; }
kbd { min-width: 27px; padding: 5px 7px; border: 1px solid var(--panel-border); border-radius: 6px; background: #1b1e2a; font-family: "DM Mono", monospace; font-size: 10px; text-align: center; }
.shortcut-list > div > span { margin-left: auto; color: #b2b5c4; font-size: 12px; }
.help-note { margin: 23px 0 0; color: #a3a7b8; font-size: 12px; line-height: 1.7; }
.help-note code { color: var(--accent); }
.celebration { position: fixed; z-index: 5; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px; animation: confetti-fall var(--duration, 2s) ease-in forwards; }
@keyframes confetti-fall { to { transform: translate3d(var(--drift), 110vh, 0) rotate(800deg); opacity: 0; } }

@media (max-width: 680px) {
  :root { --cubie: 65px; --half-cubie: 32.5px; }
  .studio { width: calc(100% - 30px); padding-top: 22px; }
  .dashboard { margin-top: 35px; gap: 9px; }
  .stat-block { min-width: 56px; }
  .timer-block { min-width: 103px; }
  .stat-block output { font-size: 16px; }
  .size-picker button { min-width: 37px; padding: 7px 5px; font-size: 10px; }
  .puzzle-section { height: 370px; }
  .status-pill { top: 21px; font-size: 9px; }
  .view-tools { top: 20px; }
  .drag-hint { font-size: 8px; letter-spacing: 0.06em; }
  .control-deck { margin-top: 17px; }
  .primary-actions { gap: 7px; }
  .action-button { gap: 6px; height: 44px; font-size: 9px; }
  .action-button svg { width: 15px; height: 15px; }
  .section-label { font-size: 8px; }
  .move-grid { gap: 6px; }
  .settings-studio { margin-top: 37px; padding-top: 24px; }
  .settings-heading h2 { font-size: 22px; }
  .settings-intro { max-width: 190px; font-size: 10px; }
  .settings-heading-actions { gap: 6px; }
  .settings-reset { padding: 0 8px; font-size: 8px; }
  .settings-grid { grid-template-columns: 1fr; gap: 10px; }
  .settings-card { padding: 18px 15px 14px; }
  .dial-disc { width: 58px; height: 58px; }
  .dial-needle { transform-origin: 1px 20.5px; }
  .help-dialog { padding: 26px 18px; }
  .shortcut-list > div > span { font-size: 10px; }
}

@media (max-width: 370px) {
  .best-block { display: none; }
  .action-button { font-size: 8px; }
  .section-label span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
