:root {
  color-scheme: light;
  --paper: #f5f3ed;
  --ink: #233d34;
  --muted: #7a8379;
  --line: #dfE2d8;
  --green: #234e41;
  --green-light: #e7eee5;
  --stage: #eaeae3;
  font-family: "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, output { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #558ec2; outline-offset: 4px; }
button, a { -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-shell { width: min(1320px, calc(100% - 88px)); margin: 0 auto; padding-bottom: 10px; }
.site-header { height: 50px; display: flex; align-items: center; border-bottom: 1px solid var(--line); gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 33px; height: 35px; stroke: none; }
.brand-name { font-size: 30px; letter-spacing: -1.6px; font-weight: 750; line-height: 1; }
.brand-period { font-size: 12px; color: #d88d60; }
.brand-tagline { margin: 4px 0 0; color: #889086; font-size: 9px; font-weight: 650; letter-spacing: 1.7px; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: transparent; border: 1px solid transparent; border-radius: 50%; }
.icon-button:hover { background: #e9eae2; }
.icon-button[aria-pressed="false"] { color: #8e968d; }
.settings-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid #d5dbcf; border-radius: 22px; background: transparent; padding: 0 17px; margin-left: 7px; font-size: 12px; font-weight: 650; }
.settings-button:hover { background: #e9ede3; border-color: #aebcaf; }
.settings-button svg { width: 17px; height: 17px; }
.game-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 0px; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: #7c897d; font-size: 10px; letter-spacing: 1.5px; font-weight: 650; line-height: 1.5; }
.status-dot { width: 5px; height: 5px; background: #69977b; border-radius: 50%; }
.heading-copy h1 { font-size: 20px; margin: 0px; line-height: 1.12; font-weight: 650; letter-spacing: -1.4px; }
.heading-copy p { color: #80877b; font-size: 12px; margin: 0; }
.mobile-break { display: none; }
.time-panel { min-width: 185px; text-align: right; padding-top: 5px; }
.time-caption { display: flex; justify-content: flex-end; align-items: center; gap: 6px; color: #7c887c; font-size: 9px; letter-spacing: 1.7px; font-weight: 650; }
.time-caption svg { width: 13px; height: 13px; }
.timer { margin: 2px 0 1px; font-size: 20px; font-weight: 500; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1.35; }
.best-time { font-size: 10px; color: #969c91; }
.best-time span { margin-left: 5px; color: #647565; font-variant-numeric: tabular-nums; }
.play-area { border: 1px solid #dee1d6; background: var(--stage); border-radius: 17px; overflow: hidden; position: relative; }
.board-topline { height: 20px; padding: 0 19px; display: flex; align-items: center; justify-content: space-between; background: #eeeee7; gap: 18px; }
.progress-copy { display: flex; align-items: center; gap: 5px; font-size: 10px; color: #8b9287; white-space: nowrap; }
.progress-copy strong { color: #445c4d; font-weight: 650; }
.progress-word { margin-left: 3px; }
.mini-cube { width: 10px; height: 10px; border: 1.3px solid #8d9b8a; border-radius: 2px; transform: rotate(-10deg); margin-right: 3px; }
#selectionInfo { color: #8c9487; font-size: 10px; letter-spacing: .1px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#selectionInfo.selected { color: #325944; font-weight: 600; }
.progress-track { height: 2px; background: #dfe4d8; }
#overallProgress { height: 100%; background: #739479; transition: width .25s ease; }
.stage { height: calc(100vh - 250px); position: relative; overflow: hidden; isolation: isolate; }
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#gameCanvas.selectable, #gameCanvas.can-grab, #gameCanvas.can-pick { cursor: grab; }
#gameCanvas.dragging, #gameCanvas.is-dragging { cursor: grabbing; }
#countdown { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); pointer-events: none; z-index: 4; text-align: center; color: #345940; background: rgb(249 249 240 / .91); border: 1px solid #dce5d1; border-radius: 18px; padding: 18px 25px; box-shadow: 0 6px 28px #253e2a0d; font-size: 18px; font-weight: 600; letter-spacing: -.4px; white-space: nowrap; }
#countdown:empty { display: none; }
#countdown small { display: block; margin-top: 5px; color: #899c7a; font-size: 10px; font-weight: 400; letter-spacing: .1px; }
#basketTargets { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.basket-label { position: absolute; left: 0; top: 0; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; padding: 3px; background: rgb(247 247 239 / .89);
  color: #52634f; border: 1px solid rgb(211 217 203 / .8); border-radius: 8px; font-size: 10px;
  font-weight: 600; line-height: 1.2; white-space: nowrap; box-shadow: 0 2px 8px #24372a06;
  transform: translate(-50%, -50%); pointer-events: none; transition: background .15s, box-shadow .15s; }
.basket-label small { color: #8a9485; font-size: 8px; font-weight: 400; }
.basket-label.target-valid { border-color: #679e77; background: #eff9e9; }
.basket-label.target-invalid { border-color: #deac91; }
.basket-label.target-hover { box-shadow: 0 0 0 3px #335d4026; background: #fffdf3; }
.camera-tools { position: absolute; display: flex; align-items: center; top: 13px; right: 13px; z-index: 3; border: 1px solid rgb(208 215 201 / .8); border-radius: 9px; background: rgb(250 249 242 / .88); box-shadow: 0 2px 7px #25382a03; padding: 3px; }
.camera-button { width: 29px; height: 29px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; color: #7d8c78; }
.camera-button:hover { color: #335543; background: #e5ebdd; }
.camera-button svg { width: 14px; height: 14px; }
.tool-separator { width: 1px; height: 14px; margin: 0 3px; background: #dce1d5; }
.loading-note { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; font-size: 12px; color: #62755f; background: #f5f3edee; padding: 13px 18px; border-radius: 30px; white-space: nowrap; }
.loading-spinner { width: 14px; height: 14px; border: 1.5px solid #becbb6; border-top-color: #4b7355; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 25px; background: #eeeee6f0; z-index: 10; }
.loading-error strong { font-size: 18px; }
.loading-error p { font-size: 13px; color: var(--muted); max-width: 340px; }
.loading-error button { width: auto; min-width: 150px; margin-top: 10px; }
.toast { position: absolute; left: 50%; top: 20px; transform: translate(-50%, 8px); max-width: calc(100% - 6px);
  padding: 11px 17px; background: #284a3def; color: #fffef5; border-radius: 11px;
  box-shadow: 0 4px 20px #20352920; font-size: 16px; line-height: 1.45; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 5; }
.toast.visible, .toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }
.baskets-section { padding-top: 20px; }
.baskets-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; color: #86917f; font-size: 9px; letter-spacing: 1.4px; font-weight: 650; }
.baskets-heading > span:last-child { font-size: 10px; letter-spacing: .1px; font-weight: 400; color: #929a8a; }
.baskets-heading > span:last-child span { margin-left: 4px; color: #708264; }
.basket-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; }
.basket-card { position: relative; text-align: left; padding: 5px; border: 1px solid #dce1d3; border-radius: 11px; background: #f9f8f1; transition: border-color .16s, transform .16s, background .16s, box-shadow .16s; min-width: 0; overflow: hidden; }
.basket-card:before { content: ''; width: 27px; height: 2px; background: var(--basket-color, #739479); position: absolute; left: 15px; top: 0; border-radius: 0 0 2px 2px; opacity: .75; }
.basket-card:hover { background: #fffef9; border-color: #a7b59c; transform: translateY(-1px); }
.basket-card.active { border-color: var(--basket-color, #739479); box-shadow: 0 0 0 2px color-mix(in srgb, var(--basket-color, #739479) 10%, transparent); background: #fffef9; }
.basket-card.wrong { opacity: .68; }
.basket-card.complete { background: #edf2e7; }
.basket-card-top { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.color-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--basket-color, #739479); flex-shrink: 0; }
.basket-name { font-size: 12px; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.basket-count { font-size: 9px; color: #696a69; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.basket-step { font-size: 10px; color: #696a69; margin: 0; min-height: 14px; }
.size-track { display: flex; gap: 5px; align-items: end; }
.size-step { display: flex; align-items: flex-end; justify-content: center; flex: 1; min-width: 0; height: 25px; padding-bottom: 4px; border-bottom: 2px solid #e6e9df; }
.size-step i { display: block; max-width: 100%; background: #e0e5d9; border-radius: 2px; }
.size-step span, .size-step b { display: none; }
.size-step.current { border-color: var(--basket-color, #739479); }
.size-step.current i { background: var(--basket-color, #739479); }
.size-step.done { border-color: var(--basket-color, #739479); opacity: .45; }
.size-step.done i { background: var(--basket-color, #739479); }
.game-footer { display: flex; justify-content: space-between; gap: 15px; align-items: center; padding: 17px 2px 8px; color: #696a69; font-size: 10px; letter-spacing: .05px; }
.footer-dot { color: #b0b8a5; margin: 0 5px; }
.footer-signature { color: #89957e; font-style: italic; }

/* Dialogues: a calm paper sheet above the live 3D scene. */
.dialog { width: min(444px, calc(100% - 32px)); max-height: calc(100dvh - 38px); padding: 0; border: 1px solid #ffffffe6; border-radius: 22px; background: #faf9f3; color: var(--ink); box-shadow: 0 22px 90px #23372a26, 0 2px 12px #23372a0d; overflow-y: auto; overscroll-behavior: contain; }
.dialog::backdrop { background: rgb(43 57 42 / .22); backdrop-filter: blur(5px); }
.dialog-content { padding: 30px 33px 24px; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; min-height: 25px; }
.dialog-top .eyebrow { font-size: 8px; letter-spacing: 1.65px; }
.close-button { width: 30px; height: 30px; margin: -5px -8px -5px 4px; color: #8c9984; }
.close-button svg { width: 17px; height: 17px; }
.dialog h2 { font-size: 34px; font-weight: 600; line-height: 1.08; letter-spacing: -1.2px; margin: 12px 0 12px; }
.dialog-intro { font-size: 12px; line-height: 1.65; color: #8a9480; margin: 0; max-width: 315px; }
.settings-fields { margin-top: 27px; }
.setting-field { margin-bottom: 20px; }
.field-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.field-heading label { font-size: 12px; font-weight: 600; }
.field-heading output { display: flex; align-items: center; justify-content: center; min-width: 28px; height: 25px; background: #edf0e5; border: 1px solid #e0e5d6; color: #5a7350; border-radius: 7px; font-size: 12px; font-weight: 650; }
input[type="range"] { display: block; width: 100%; height: 18px; margin: 0; accent-color: #4b7058; cursor: pointer; }
.range-row { display: flex; align-items: center; gap: 19px; min-height: 25px; }
.range-row input { flex: 1; min-width: 0; }
.preview-swatches, .preview-sizes { display: flex; gap: 5px; align-items: center; justify-content: flex-end; flex-shrink: 0; min-width: 77px; max-width: 125px; }
.preview-swatches span { width: 15px; height: 15px; border-radius: 4px; background: var(--swatch, #739479); display: block; }
.preview-sizes { align-items: flex-end; height: 25px; gap: 5px; }
.preview-sizes span { display: block; border-radius: 3px; background: #739073; opacity: .8; min-width: 5px; }
.setup-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px; border: 1px solid #dde3d2; background: #edf1e5; border-radius: 11px; margin-top: 24px; }
.setup-summary strong { display: block; font-size: 15px; font-weight: 650; letter-spacing: -.3px; }
#setupFormula { display: block; font-size: 9px; color: #8b977d; margin-top: 4px; }
.setup-record { color: #8c987e; display: flex; flex-direction: row; gap: 4px; align-items: flex-end; font-size: 16px; }
.setup-record svg { width: 20px; height: 20px; }
.rule-note { color: #9aa18e; font-size: 14px; line-height: 1.6; margin: 14px 1px 20px; }
.rule-note strong { color: #78886b; font-weight: 600; }
.primary-button { width: 100%; min-height: 48px; border: 1px solid var(--green); background: var(--green); color: #fffff3; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 19px; font-size: 13px; font-weight: 550; transition: background .15s, transform .15s; }
.primary-button:hover:not(:disabled) { background: #173e32; transform: translateY(-1px); }
.primary-button svg { width: 18px; height: 18px; }
.secondary-button { width: 100%; min-height: 41px; border: 1px solid #dce4d2; background: transparent; border-radius: 10px; padding: 10px; font-size: 12px; color: #6d8060; margin-top: 10px; }
.secondary-button:hover { background: #eff3e7; }
.setup-footnote { text-align: center; font-size: 12px; color: #9ea791; margin: 12px 0 0; }
.help-dialog { width: min(460px, calc(100% - 32px)); }
.help-dialog .dialog-content { padding-bottom: 30px; }
.help-steps { list-style: none; padding: 0; margin: 27px 0 23px; display: grid; gap: 23px; }
.help-steps li { display: flex; align-items: flex-start; gap: 14px; }
.step-number { color: #b2bfa4; font-size: 12px; font-weight: 550; padding-top: 2px; letter-spacing: -.3px; }
.help-steps h3 { margin: 0 0 5px; font-size: 13px; font-weight: 600; }
.help-steps p { margin: 0; font-size: 11px; color: #8e9980; line-height: 1.7; }
.help-timing { padding: 14px; border-radius: 10px; background: #eef2e6; display: flex; gap: 10px; align-items: center; }
.help-timing svg { width: 21px; height: 21px; color: #8aa075; }
.help-timing p { color: #869574; font-size: 10px; line-height: 1.6; margin: 0; }
.finish-dialog { text-align: center; }
.finish-dialog .dialog-content { padding: 38px 35px 29px; }
.finish-dialog .eyebrow { justify-content: center; font-size: 8px; letter-spacing: 1.7px; }
.finish-dialog h2 { font-size: 42px; margin: 14px 0 13px; }
.finish-dialog .dialog-intro { margin: 0 auto; }
.celebration-cubes { height: 75px; width: 105px; position: relative; margin: 0 auto 20px; }
.celebration-cubes i { position: absolute; display: block; width: 36px; height: 36px; border-radius: 8px; box-shadow: inset -5px -5px 0 #0000000c, inset 2px 2px 0 #ffffff25; }
.celebration-cubes i:nth-child(1) { left: 16px; bottom: 0; background: #3b79e9; transform: rotate(-9deg); }
.celebration-cubes i:nth-child(2) { left: 53px; bottom: 1px; background: #edbe4b; transform: rotate(8deg); }
.celebration-cubes i:nth-child(3) { left: 35px; bottom: 34px; background: #ee7b64; transform: rotate(7deg); }
.celebration-cubes span { position: absolute; right: -5px; top: 8px; color: #bac89f; font-size: 24px; }
.finish-clock-label { margin-top: 29px; color: #8d9c7b; font-size: 9px; letter-spacing: 1.8px; }
.finish-time { color: #2c503a; font-size: 46px; letter-spacing: -2px; font-weight: 500; margin: 3px 0; font-variant-numeric: tabular-nums; }
.finish-best { font-size: 20px; color: #8b9d78; margin-bottom: 27px; }
.noscript-notice { position: fixed; inset: auto 20px 20px; background: #214f40; color: white; padding: 20px; border-radius: 12px; text-align: center; }

@media (min-width: 1550px) {
  .app-shell { width: min(1480px, calc(100% - 120px)); }
}
@media (max-width: 900px) {
  .app-shell { width: calc(100% - 42px); }
  .brand-tagline { display: none; }
  .basket-cards { gap: 8px; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
  .basket-card:before { left: 11px; }
}
@media (max-width: 600px) {
  .app-shell { width: calc(100% - 28px); padding-bottom: env(safe-area-inset-bottom, 4px); }
  .site-header { gap: 12px; }
  .brand-mark { width: 27px; height: 29px; }
  .brand { gap: 7px; }
  .brand-name { font-size: 26px; letter-spacing: -1.5px; }
  .header-actions { gap: 3px; }
  .icon-button { width: 34px; height: 36px; }
  .icon-button svg { width: 18px; height: 18px; }
  .settings-button { width: 36px; min-height: 36px; padding: 0; margin-left: 0; border-radius: 50%; }
  .settings-button span { display: none; }
  .settings-button svg { width: 18px; height: 18px; }
  .game-heading { gap: 8px; align-items: center; }
  .eyebrow { font-size: 8px; letter-spacing: 1.15px; }
  .heading-copy h1 { font-size: 16px; line-height: 1.13; letter-spacing: -1.05px; margin: 9px 0 0; }
  .mobile-break { display: block; }
  .heading-copy p { display: none; }
  .time-panel { min-width: 122px; padding-top: 13px; }
  .time-caption { font-size: 7px; letter-spacing: 1.2px; gap: 4px; }
  .time-caption svg { width: 11px; height: 11px; }
  .timer { letter-spacing: -1px; margin: 4px 0 3px; }
  .best-time { font-size: 8px; }
  .best-time span { margin-left: 2px; }
  .play-area { border-radius: 12px; }
  .board-topline { padding: 0 11px; height: 20px; gap: 10px; }
  .progress-copy { font-size: 9px; gap: 3px; }
  .progress-word { display: none; }
  #selectionInfo { font-size: 9px; }
  .camera-tools { top: 5px; right: 5px; padding: 2px; }
  .camera-button { width: 26px; height: 27px; }
  .camera-button svg { width: 13px; height: 13px; }
  .tool-separator { margin: 0 2px; }
  .basket-label { font-size: 9px; border-radius: 6px; gap: 2px; }
  .basket-label small { font-size: 7px; }
  .baskets-section { padding-top: 15px; }
  .baskets-heading { font-size: 8px; letter-spacing: 1px; margin-bottom: 8px; }
  .baskets-heading > span:last-child { font-size: 8px; }
  .basket-cards { gap: 7px; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .basket-card { border-radius: 9px; }
  .basket-card:before { left: 10px; width: 22px; }
  .basket-card-top { gap: 5px; margin-bottom: 6px; }
  .basket-name { font-size: 10px; }
  .basket-count { font-size: 8px; }
  .color-dot { width: 6px; height: 6px; }
  .basket-step { font-size: 8px; min-height: 11px; }
  .size-track { gap: 3px; }
  .game-footer { justify-content: center; padding: 13px 0 10px; font-size: 8px; }
  .footer-dot { margin: 0 3px; }
  .footer-signature { display: none; }
  .toast { font-size: 12px; padding: 4px; }
  .dialog { width: calc(100% - 38px); max-height: calc(100dvh - 28px); border-radius: 19px; }
  .dialog-content { padding: 25px 25px 21px; }
  .dialog h2 { font-size: 32px; margin: 11px 0 11px; }
  .dialog-intro { font-size: 11px; }
  .settings-fields { margin-top: 23px; }
  .setting-field { margin-bottom: 17px; }
  .field-heading label { font-size: 11px; }
  .field-heading { margin-bottom: 7px; }
  .range-row { gap: 13px; }
  .preview-swatches, .preview-sizes { min-width: 67px; gap: 4px; }
  .preview-swatches span { width: 12px; height: 12px; border-radius: 3px; }
  .setup-summary { margin-top: 19px; padding: 13px; }
  .setup-summary strong { font-size: 14px; }
  #setupFormula { font-size: 8px; }
  .rule-note { font-size: 12px; margin: 12px 1px 17px; }
  .primary-button { min-height: 46px; font-size: 12px; }
  .setup-footnote { font-size: 10px; }
  .finish-dialog .dialog-content { padding: 29px 25px 24px; }
  .finish-dialog h2 { font-size: 39px; }
  .finish-time { font-size: 42px; }
}
@media (max-width: 370px) {
  .app-shell { width: calc(100% - 22px); }
  .time-panel { min-width: 112px; }
  .basket-cards { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
  .dialog-content { padding-left: 21px; padding-right: 21px; }
}
@media (max-height: 700px) and (min-width: 901px) {
  .baskets-section { padding-top: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
