:root {
  color-scheme: light;
  --background: #f6f6f2; --board: #f6f6f2; --paper: #fff; --ink: #25272d; --muted: #6b6c77;
  --line: #d9d9df; --accent: #ded8fa; --accent-ink: #382d57; --piece-a: #f2d071; --piece-b: #b6a9ef;
  --piece-ink: #35303e; --button-fill: #292b33; --button-ink: #fff; --button-edge: #25252e; --success: #65519d;
  --dot: #6c6b8018; --shadow: #35314520; --ease: cubic-bezier(0.2, 0, 0, 1); --shape-line: .9;
  --ex-bg: var(--background); --ex-surface: var(--paper); --ex-ink: var(--ink); --ex-muted: var(--muted); --ex-line: var(--line); --ex-violet: var(--piece-b); --ex-yellow: var(--piece-a); --ex-shadow: var(--shadow); --ex-accent-ink: var(--success);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--background); font-synthesis: none; -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; min-width: 280px; height: 100dvh; display: grid; grid-template-rows: 76px minmax(0, 1fr) 28px; overscroll-behavior: none; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; }
button:not(:disabled), a { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--success); outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 23px; height: 23px; padding: 0 5px; border: 1px solid color-mix(in srgb, currentColor 25%, transparent); border-radius: 5px; font: 10px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; opacity: .7; flex-shrink: 0; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; min-width: 0; }
.brand-group { display: flex; align-items: center; gap: 21px; min-width: 0; }
.logo { width: 48px; height: 48px; display: grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 13px; background: transparent; }
.logo svg { width: 46px; height: 46px; overflow: visible; }
.logo .logo-left { fill: var(--piece-a); }
.logo .logo-right { fill: var(--piece-b); }
.site-header .logo.tx-mark { width: 48px; height: 48px; }
.personal-best { display: grid; gap: 3px; padding-left: 21px; border-left: 1px solid var(--line); }
.personal-best > span { color: var(--muted); font-size: 10px; }
.personal-best strong { font-size: 18px; font-weight: 600; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.header-actions { display: flex; align-items: center; gap: 3px; padding: 4px; border: 1px solid transparent; border-radius: 14px; background: color-mix(in srgb, var(--paper) 60%, transparent); box-shadow: 0 1px 2px var(--shadow); }
.header-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; min-width: 42px; padding: 8px 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-size: 12px; }
.header-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.header-button kbd { min-width: 17px; height: 18px; padding: 0 3px; font-size: 9px; border: 0; opacity: .55; }
.help-button > span { font-size: 20px; line-height: 1; }
.sound-button[aria-pressed="true"] .sound-mute { opacity: 0; }
[data-theme="dark"] { color-scheme: dark; }
.app-content { min-height: 0; }
.game { height: 100%; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 30px; min-height: 0; min-width: 0; padding: 0 30px 6px 22px; }
.stage { position: relative; min-width: 0; min-height: 0; }
.board { width: 100%; height: 100%; overflow: hidden; position: relative; border-radius: 16px; background: linear-gradient(var(--dot) .5px, transparent .5px), linear-gradient(90deg, var(--dot) .5px, transparent .5px); background-size: 40px 40px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; isolation: isolate; }
.board:focus-visible { outline: 2px solid var(--success); outline-offset: 2px; }
#scene { display: block; width: 100%; height: 100%; pointer-events: none; }
.paper { stroke: var(--piece-ink); stroke-width: var(--shape-line); stroke-linejoin: round; }
#whole-face, #aim-a, #path-a, .help-face-a { fill: var(--piece-a); }
#aim-b, #path-b, .help-face-b { fill: var(--piece-b); }
.solid-side { stroke: color-mix(in srgb, var(--piece-ink) 40%, transparent); stroke-width: .5; stroke-linejoin: round; }
.side-a, .help-side-a { fill: color-mix(in srgb, var(--piece-a) 72%, #000); }
.side-b, .help-side-b { fill: color-mix(in srgb, var(--piece-b) 72%, #000); }
.solid-light { fill: url(#paper-light); pointer-events: none; }
#paper-shadow feDropShadow { flood-color: var(--shadow); }
[data-depth="2d"] .solid-side, [data-depth="2d"] .solid-light { display: none; }
[data-depth="2d"] #whole, [data-depth="2d"] #pieces, [data-depth="2d"] #aim-pieces { filter: none; }
.piece { transform: translate(0, 0); }
.area-label { fill: var(--piece-ink); font: 600 21px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.6px; font-variant-numeric: tabular-nums; opacity: 0; }
.board.revealed[data-reveal="settled"] .area-label { opacity: 1; }
.line-under { stroke: var(--background); stroke-width: 5; stroke-linecap: round; }
.cut-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 5; stroke-linecap: round; opacity: .3; }
.line-core { stroke: var(--piece-ink); stroke-width: 1.4; stroke-linecap: round; }
.cut-dot { fill: var(--ink); stroke: var(--paper); stroke-width: 2; }
.cut-flash { stroke: var(--paper); stroke-width: 4; stroke-linecap: round; opacity: 0; }
.cut-sparkle { fill: none; stroke: var(--success); stroke-width: 2.5; stroke-linecap: round; opacity: 0; }
.cut-badge { position: absolute; top: 16px; left: 50%; translate: -50% 0; display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 30px; background: var(--piece-a); color: var(--piece-ink); box-shadow: 0 2px 8px var(--shadow); font-size: 10px; font-weight: 600; letter-spacing: .6px; white-space: nowrap; pointer-events: none; }
.cut-badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.control-panel { display: flex; flex-direction: column; justify-content: center; gap: clamp(12px, 3vh, 26px); min-height: 0; min-width: 0; padding: 12px 0; }
.result { min-width: 0; }
.result-kicker { display: flex; align-items: center; gap: 6px; margin: 0 0 9px; color: var(--muted); font-size: 10px; font-weight: 600; line-height: 16px; letter-spacing: 1.4px; white-space: nowrap; }
.challenge-target { padding: 1px 5px; color: var(--success); background: color-mix(in srgb, var(--success) 9%, transparent); border-radius: 5px; font-size: 9px; line-height: 14px; font-weight: 500; letter-spacing: 0; }
.score-frame { position: relative; container-type: inline-size; }
.score { font-size: min(9.3vh, 29cqi, 82px); line-height: 1.1; font-weight: 650; letter-spacing: -4.5px; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; transform-origin: left center; }
.score-slash { font-size: .65em; font-weight: 400; margin: 0 5px; opacity: .4; }
.score .percent { font-size: .3em; font-weight: 400; letter-spacing: -1px; margin-left: 3px; color: var(--muted); }
.score-digits { display: inline-grid; }
.score-digits > span { grid-area: 1 / 1; }
.score-reserve { visibility: hidden; }
.result[data-reveal="counting"] .score { color: var(--muted); }
.result.is-great .score { color: var(--success); }
.result[data-quality="perfect"] .score { color: var(--ink); }
.result[data-challenge="beat"] .score { color: var(--success); }
.result-label { margin: 13px 0 5px; font-size: clamp(17px, 2.7vh, 23px); line-height: 1.2; letter-spacing: -.65px; font-weight: 550; }
.result-detail { min-height: 26px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
#cut-comparison { margin: 12px 0 0; font-size: 10px; color: var(--success); line-height: 1.5; }
#cut-comparison:empty { display: none; }
.result[data-reveal="counting"] #cut-comparison { visibility: hidden; }
.actions { display: flex; flex-direction: column; gap: 12px; padding-bottom: 4px; }
.secondary-actions { display: contents; }
.button { min-width: 0; min-height: 50px; display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border: 1.25px solid var(--button-edge); border-radius: 10px; text-decoration: none; font: 500 13px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; white-space: nowrap; box-shadow: 0 4px 0 var(--button-edge), 0 5px 8px var(--shadow); }
.button-primary { color: var(--button-ink); background: var(--button-fill); }
.button-secondary { color: var(--ink); background: var(--paper); }
.button-accent { color: var(--accent-ink); background: var(--accent); }
.actions .button-primary, [data-theme="dark"] .actions .button {
  background: var(--action-face); border-color: var(--action-rim);
  box-shadow: inset 0 1px 0 var(--action-highlight), 0 4px 0 var(--action-base), 0 5px 2px var(--shadow), 0 7px 8px var(--shadow);
}
.actions .button-primary { --action-face: color-mix(in srgb, var(--button-fill) 88%, white); --action-base: color-mix(in srgb, var(--button-fill) 65%, black); --action-rim: var(--action-base); --action-highlight: #ffffff24; }
[data-theme="dark"] .actions .button { --action-face: var(--paper); --action-base: color-mix(in srgb, var(--paper) 78%, var(--ink)); --action-rim: color-mix(in srgb, var(--paper) 70%, var(--line)); --action-highlight: #ffffff1c; }
[data-theme="dark"] .actions .button-primary { --action-face: var(--button-fill); --action-base: color-mix(in srgb, var(--button-fill) 68%, var(--paper)); --action-rim: color-mix(in srgb, var(--button-fill) 78%, var(--paper)); --action-highlight: #ffffffcc; }
[data-theme="dark"] .actions .button-accent { --action-face: var(--accent); --action-base: color-mix(in srgb, var(--piece-b) 72%, var(--paper)); --action-rim: color-mix(in srgb, var(--piece-b) 85%, var(--paper)); --action-highlight: #ffffff55; }
.button kbd { height: 21px; min-width: 21px; }
.actions .button > span { display: inline-flex; align-items: center; gap: 10px; }
.actions .button svg { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.app-footer { display: flex; align-items: center; justify-content: flex-end; padding: 0 28px; font-size: 10px; color: var(--muted); }
.app-footer a { color: inherit; text-decoration: none; }
dialog { width: min(100% - 32px, 510px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 25px; border: 1px solid transparent; border-radius: 25px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 100px #00000040; }
dialog::backdrop { background: #17191d85; backdrop-filter: blur(5px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.dialog-header h2 { font-size: 27px; line-height: 1.15; letter-spacing: -1px; margin: 0; font-weight: 550; }
.close-button { min-width: 48px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 7px; border: 0; background: transparent; font-size: 24px; border-radius: 10px; }
.close-button kbd { font-size: 9px; height: 20px; min-width: 22px; border: 0; }
#share-dialog { width: min(100% - 32px, 590px); }
#share-preview { display: block; width: 100%; height: auto; border-radius: 14px; outline: 1px solid oklch(0 0 0 / .1); outline-offset: -1px; }
[data-theme="dark"] #share-preview { outline-color: oklch(1 0 0 / .1); }
.share-actions { display: flex; gap: 12px; padding-bottom: 4px; }
.share-actions > * { flex: 1; }
.share-label-short { display: none; }
#challenge-link { color: var(--ink); text-underline-offset: 3px; white-space: nowrap; }
.native-share, #start-playing { width: 100%; }
.native-share { margin-bottom: 14px; }
.share-status { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.share-status:empty { display: none; }
.help-picture { background: var(--background); border-radius: 15px; }
.help-picture svg { width: 100%; display: block; max-height: 180px; }
.help-picture text { fill: var(--piece-ink); font: 600 16px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; text-anchor: middle; }
.help-picture .help-perfect { fill: var(--ink); font-size: 31px; letter-spacing: -1px; }
.help-gesture { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 3 5; }
#help-description { margin: 18px 0 10px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.help-goal { margin: 0; font-size: 14px; }
.help-goal strong { font-weight: 600; }
.help-keyboard { display: flex; justify-content: space-between; gap: 8px; margin: 22px 0; font-size: 11px; color: var(--muted); }
.help-keyboard > span { display: inline-flex; align-items: center; gap: 6px; }
.help-keyboard kbd { min-width: 30px; font-size: 9px; }
.theme-changing *, .theme-changing *::before, .theme-changing *::after { transition: none !important; }
@media (hover: hover) {
  .header-button:hover, .close-button:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
  .button:not(:disabled):hover { filter: brightness(.97); }
  .app-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
}
@media (prefers-reduced-motion: no-preference) {
  .piece { transition: transform 280ms var(--ease); }
  .area-label { transition: opacity 120ms ease-out; }
  .button, .header-button, .logo { transition: transform 150ms ease-out; }
  .actions .button-primary, [data-theme="dark"] .actions .button { transition: transform 150ms ease-out, box-shadow 150ms ease-out; }
  .logo-left, .logo-right { transition: fill 150ms ease-out; }
  .button:not(:disabled):active { transform: translateY(3px) scale(.96); box-shadow: 0 1px 0 var(--button-edge); }
  .actions .button-primary:not(:disabled):active, [data-theme="dark"] .actions .button:not(:disabled):active {
    transform: translateY(2px) scale(.96);
    box-shadow: inset 0 1px 0 var(--action-highlight), 0 2px 0 var(--action-base), 0 3px 2px var(--shadow);
  }
  .header-button:not(:disabled):active, .logo:active { transform: scale(.96); }
  .result, .actions { transition: opacity 120ms ease-out; }
}
@media (prefers-reduced-motion: reduce) { .area-label { transition: opacity 100ms ease-out; } .button:not(:disabled):active { filter: brightness(.92); } }
.board.keyboard-cut .piece, .board.keyboard-cut .area-label { transition: none; }
.game:has(.board.is-drawing) .control-panel { opacity: .25; }
@media (max-width: 1080px) {
  .game { grid-template-columns: minmax(0, 1fr) 212px; gap: 18px; padding-right: 20px; padding-left: 14px; }
}
@media (max-height: 650px) {
  body { grid-template-rows: 60px minmax(0, 1fr) 24px; }
  .game { padding-top: 3px; padding-bottom: 3px; gap: 20px; }
  .control-panel { gap: 13px; padding: 4px 0; }
  .result-kicker { margin-bottom: 5px; }
  .result-label { margin-top: 9px; }
  .result-detail { min-height: 0; font-size: 11px; line-height: 1.5; }
  #cut-comparison { display: none; }
  .actions { gap: 10px; }
  .actions .button { min-height: 42px; padding: 9px 12px; }
  .header-actions { padding: 0; }
  #share-preview { width: auto; max-width: 100%; max-height: calc(100dvh - 270px); margin: 0 auto; object-fit: contain; background: var(--background); }
}
@media (max-height: 500px) and (min-width: 801px) {
  body { grid-template-rows: 56px minmax(0, 1fr) 24px; }
  .actions { gap: 8px; }
  .actions .button { min-height: 34px; padding: 6px 10px; font-size: 11px; }
  .actions .button svg { width: 14px; height: 14px; }
  .score { font-size: min(42px, 29cqi); }
  .actions .button kbd { min-width: 19px; height: 19px; }
}
@media (max-height: 500px) { .help-picture { display: none; } }
@media (max-height: 650px) and (min-width: 801px) {
  #share-dialog[open] { display: grid; width: min(100% - 32px, 820px); grid-template-columns: minmax(0, 1fr) 240px; grid-template-areas: "heading heading" "image instruction" "image native" "image actions" "image status"; column-gap: 20px; }
  #share-dialog .dialog-header { grid-area: heading; }
  #share-preview { grid-area: image; max-height: calc(100dvh - 150px); align-self: start; }
  .native-share { grid-area: native; align-self: start; min-height: 40px; margin: 0 0 12px; padding: 8px 12px; font-size: 12px; }
  .share-actions { grid-area: actions; align-self: start; }
  #share-dialog .share-actions .button { min-height: 40px; padding: 8px 5px; font-size: 11px; gap: 4px; }
  #share-dialog .share-actions { gap: 7px; }
  #share-dialog .share-actions kbd { min-width: 18px; height: 18px; padding: 0 3px; font-size: 9px; }
  .share-label-full { display: none; }
  .share-label-short { display: inline; }
  #share-status { grid-area: status; align-self: start; font-size: 11px; }
}
@media (max-width: 800px) {
  body { grid-template-rows: 60px minmax(0, 1fr) 24px; }
  .site-header { padding: 0 14px; gap: 8px; }
  .brand-group { gap: 10px; }
  .logo { width: 40px; height: 44px; }
  .logo svg { width: 39px; height: 39px; }
  .personal-best { border: 0; padding: 0; gap: 2px; }
  .personal-best > span { font-size: 9px; }
  .personal-best strong { font-size: 13px; letter-spacing: -.2px; }
  .header-actions { gap: 1px; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .header-button { width: 38px; min-width: 38px; min-height: 42px; padding: 8px; }
  .header-button kbd, .view-button svg { display: none; }
  .view-button { padding: 8px; margin: 0; border-right: 0; border-radius: 10px; }
  .game { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 5px 14px 7px; }
  .board { border-radius: 16px; }
  .cut-badge { top: 14px; font-size: 9px; padding: 5px 9px; }
  .control-panel { display: grid; grid-template-columns: minmax(0, 1fr) 136px; gap: 16px; height: 174px; padding: 0 5px; }
  .result { min-width: 0; }
  .score { font-size: min(29cqi, 58px); letter-spacing: -3px; }
  .result-kicker { margin-bottom: 5px; font-size: 9px; letter-spacing: .7px; }
  .result-label { font-size: 17px; margin-top: 8px; letter-spacing: -.4px; }
  .result-detail { font-size: 11px; min-height: 0; line-height: 1.5; }
  #cut-comparison { display: none; }
  .actions { gap: 11px; }
  .actions .button { min-height: 42px; padding: 10px; font-size: 11px; gap: 5px; border-radius: 9px; }
  .actions .button > span { gap: 6px; }
  .actions .button svg { width: 14px; height: 14px; }
  .actions .button kbd { min-width: 20px; height: 20px; font-size: 9px; }
  .app-footer { padding: 0 19px; font-size: 9px; }
  .share-actions .button { padding: 10px; font-size: 12px; gap: 8px; }
  .share-label-full { display: none; }
  .share-label-short { display: inline; }
}
@media (max-width: 370px) {
  .site-header { padding: 0 10px; }
  .brand-group { gap: 7px; }
  .control-panel { grid-template-columns: minmax(0, 1fr) 125px; gap: 10px; }
  .game { padding-left: 10px; padding-right: 10px; gap: 9px; }
  .score { font-size: min(29cqi, 43px); letter-spacing: -2.8px; }
  .result-label { font-size: 15px; }
  .result-detail { font-size: 10px; }
  .actions .button { padding-left: 9px; padding-right: 8px; }
  .dialog-header h2 { font-size: 23px; }
  dialog { padding: 19px; }
  .help-keyboard { gap: 5px; font-size: 10px; }
  .help-keyboard > span { gap: 4px; }
  .share-actions { gap: 7px; }
  .share-actions .button { padding: 9px 6px; font-size: 11px; gap: 4px; }
  .share-actions kbd { min-width: 18px; height: 18px; padding: 0 3px; font-size: 9px; }
}
