* { box-sizing: border-box; }
:root { color-scheme: light; --ink: #4b5d4d; --green: #557154; --paper: #fffaf0; --line: #d3d4b8; }
body { margin: 0; color: var(--ink); background: linear-gradient(135deg, #eee3c9, #f7f1e3 52%, #e4ecda); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; line-height: 1.75; }
button, input { font: inherit; }
button { min-width: 44px; min-height: 44px; padding: 9px 12px; border: 1px solid #b2c1a2; border-radius: 10px; color: #4e6a48; background: #fffdf4; font-size: 12px; font-weight: 650; cursor: pointer; touch-action: manipulation; }
button:hover:not(:disabled) { background: #e8edd8; border-color: #819b68; }
button:disabled { opacity: .48; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 3px solid #a46732; outline-offset: 4px; }
[hidden] { display: none !important; }
.page { max-width: 1120px; margin: auto; padding: 22px 30px 0; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid #c9d1b5; padding-bottom: 12px; }
.back-home { min-height: 44px; display: inline-flex; align-items: center; color: #56714b; font-size: 13px; text-underline-offset: 4px; }
.header-note { color: #829174; font-size: 11px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 25px; padding: 30px 0; }
.eyebrow { font-size: 10px; font-weight: 750; letter-spacing: 1.5px; color: #8a9678; margin: 0 0 8px; }
h1 { margin: 0 0 12px; color: #4c6a43; font-size: clamp(36px, 5vw, 52px); letter-spacing: 1px; line-height: 1.25; }
h1 > span { color: #bd8748; }
.lead { margin: 0; font-size: 15px; line-height: 1.9; color: #79886b; }
.hero-vessel { position: relative; flex: 0 0 200px; width: 200px; height: 125px; border: 2px solid #acb799; border-top: 0; border-radius: 0 0 24px 24px; transform: rotate(4deg); background: #fff6df66; }
.vessel-sand { position: absolute; bottom: 0; left: 6%; width: 88%; height: 45%; border-radius: 60% 55% 20px 20px; background: #d9b26d; box-shadow: inset 0 -9px 0 #c49d59; }
.vessel-rock { position: absolute; width: 44px; height: 28px; left: 28px; bottom: 17px; background: #789789; border: 2px solid #5f7f70; border-radius: 6px; transform: rotate(-8deg); }
.vessel-dot { position: absolute; width: 9px; height: 9px; border-radius: 30%; background: #cc9b48; }
.vessel-dot.one { top: 10px; left: 92px; }
.vessel-dot.two { top: 32px; left: 114px; }
.vessel-dot.three { top: 50px; left: 98px; }
.hero-vessel p { position: absolute; bottom: -35px; width: 100%; text-align: center; font-size: 10px; color: #8d987b; margin: 0; }
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.presets button { min-height: 46px; background: #58754f; border-color: #738e63; color: #fff8e7; }
.presets button:hover:not(:disabled) { background: #46653f; }
.notice { font-size: 12px; color: #7b5c28; background: #fff0c9; border: 1px solid #d7ae65; border-radius: 10px; padding: 12px 15px; margin: 0 0 12px; }
.sand-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .85fr); gap: 22px; align-items: start; }
.panel { min-width: 0; padding: 23px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 5px 0 #b3bfa144; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; }
h2 { margin: 0; color: #56724b; font-size: 21px; line-height: 1.45; }
.state-label { border: 1px solid #c2cbab; border-radius: 20px; padding: 3px 10px; font-size: 11px; color: #768a64; white-space: nowrap; }
body[data-running="true"] .state-label { color: #8b682c; border-color: #cdb16c; background: #f6e9bc; }
.scoreboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 17px; }
.scoreboard > div { min-width: 0; display: flex; align-items: center; gap: 7px; padding: 8px 12px; background: #f0f1df; border: 1px solid #d8ddc1; border-radius: 9px; }
.scoreboard span { font-size: 11px; color: #829371; }
.scoreboard strong { margin-left: auto; color: #5c7c4d; font-size: 22px; line-height: 1.3; }
.scoreboard .grain-symbol { color: #b68b40; letter-spacing: -1px; }
.scoreboard .stone-symbol { color: #68867a; }
.canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; border: 2px solid #bbba95; border-radius: 13px; background: #fbf4df; box-shadow: 0 5px 0 #bab69266; touch-action: manipulation; user-select: none; cursor: crosshair; overflow: hidden; }
.canvas[aria-disabled="true"] { cursor: default; }
.cell-base { stroke: #e7ddc7; stroke-width: .45; }
.sand-dot { fill: #a97429; }
.sand-highlight { fill: #f2cf89; }
.rock-mark { fill: none; stroke: #42675a; stroke-width: 1.4; stroke-linecap: round; }
.cursor-marker { pointer-events: none; fill: none; stroke: #a05c2e; stroke-width: 2.2; }
.canvas-caption { display: flex; justify-content: space-between; gap: 10px; color: #8a9878; font-size: 10px; margin: 14px 0 15px; }
.materials { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.materials button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; }
.materials button[aria-pressed="true"] { background: #ece8c8; border: 2px solid #a9975a; color: #76612c; }
.materials i { display: inline-block; width: 14px; height: 14px; flex: 0 0 14px; }
.brush-sand { border-radius: 25%; background: #d9a64e; border: 1px dotted #936725; }
.brush-rock { border-radius: 2px; background: #68867a; border: 1px solid #42675a; box-shadow: inset 0 -5px 0 #547367; }
.brush-empty { border: 1px dashed #adb698; background: #fbf4df; }
.playback-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.playback-controls button { min-height: 46px; }
.primary { background: #607d50; border-color: #607d50; color: #fff8e7; }
.primary:hover:not(:disabled) { background: #496b3d; border-color: #496b3d; }
.live-status { font-size: 12px; color: #6c8757; min-height: 44px; margin: 17px 0 10px; }
.save-state { padding: 10px 12px; background: #eef0db; border: 1px solid #d3ddba; border-radius: 9px; font-size: 11px; color: #789063; margin: 0; }
.save-note { font-size: 10px; color: #94a180; margin: 11px 0 0; }
.side-stack { display: grid; gap: 22px; min-width: 0; }
.rules { color: #7e936b; font-size: 12px; padding-left: 20px; margin: 18px 0; }
.rules li { padding-left: 2px; margin-bottom: 13px; }
.rules b { color: #617f4f; }
.note-card { background: #f0efd7; border-left: 3px solid #c6cc9d; padding: 11px 13px; color: #87936b; font-size: 12px; margin: 17px 0; }
.small-note { color: #8a9b77; font-size: 10px; line-height: 1.9; margin: 14px 0; }
.little-palette { display: flex; justify-content: center; gap: 12px; padding: 17px 0 2px; }
.little-palette span { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid #cbd2b5; border-radius: 11px; color: #9d7b40; background: #f2e8bf; font-size: 21px; }
.little-palette span:nth-child(2) { background: #dce7d8; color: #68867a; transform: rotate(6deg); }
.little-palette span:nth-child(3) { background: #fbf4df; color: #a0ab8b; transform: rotate(-5deg); }
.share-panel { background: #e9edd8; border: 1px solid #afbf97; border-radius: 11px; color: #7a9366; font-size: 11px; padding: 15px 18px; margin-top: 25px; }
.share-panel p { margin: 0; }
.share-panel label { display: block; margin: 10px 0 5px; }
#share-fallback { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid #b1c09a; border-radius: 7px; background: #fffdf4; color: #6e845b; font-size: 12px; }
footer { text-align: center; padding: 28px 0; color: #9ca987; font-size: 10px; letter-spacing: 1px; }
footer span { color: #b59255; padding-inline: 5px; }
dialog { width: min(460px, calc(100% - 32px)); border: 1px solid #c5d0ad; border-radius: 17px; background: #fffaf0; color: var(--ink); padding: 25px; box-shadow: 0 20px 70px #39452d44; }
dialog::backdrop { background: #3b4c3299; backdrop-filter: blur(3px); }
dialog > p:not(.eyebrow) { font-size: 13px; color: #82916c; margin: 15px 0 20px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions button { min-width: 0; padding: 10px 6px; }
@media (max-width: 900px) {
  .page { padding-inline: 22px; }
  .sand-layout { gap: 16px; }
  .panel { padding: 17px; }
  .studio { padding: 15px; }
  .side-stack { gap: 16px; }
  h2 { font-size: 19px; }
  .scoreboard > div { padding: 8px; gap: 5px; }
}
@media (max-width: 700px) {
  .page { padding: 14px 16px 0; }
  .site-header { gap: 8px; }
  .back-home { font-size: 12px; }
  .header-note { font-size: 10px; }
  .hero { padding: 25px 0; }
  .hero-vessel { display: none; }
  .lead { font-size: 14px; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .sand-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .panel { padding: 22px 18px; }
  .studio { padding: 16px 13px; }
  .section-heading { gap: 7px; }
  h2 { font-size: 20px; }
  .studio h2 { font-size: 19px; }
  .state-label { font-size: 10px; padding: 3px 8px; }
  .scoreboard { gap: 6px; }
  .scoreboard > div { padding: 8px; gap: 4px; }
  .scoreboard strong { font-size: 21px; }
  .canvas-caption { flex-direction: column; gap: 3px; }
  dialog { padding: 22px 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
