/* One vivid, finite rehearsal. It contains no interactive imitation of a grid. */
dialog:has(.tool-lesson) { width: min(420px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); }
.dialog-wrap:has(.tool-lesson) { padding: 18px 16px 12px; }
.dialog-wrap:has(.tool-lesson) .dialog-character-heading { gap: 10px; align-items: center; margin-bottom: 8px; }
.dialog-wrap:has(.tool-lesson) .dialog-character-heading h2 { font: 600 25px/1.12 var(--heading); color: #15535b; }
.tool-lesson { color: #28575c; }
.tool-lesson-demo {
  --tool-demo-duration: 2.8s;
  position: relative; display: block; overflow: hidden; height: 115px;
  margin: 0 0 9px; border: 1px solid #dab775; border-radius: 20px;
  background: radial-gradient(ellipse at 50% 0, #fffdf1, #ffedbc 72%, #f3d790);
  box-shadow: inset 0 2px #fffdf0, 0 3px #b9924c40;
  pointer-events: none; user-select: none;
}
.tool-lesson-surface { position: absolute; display: flex; align-items: center; justify-content: center; gap: 9px; width: 178px; height: 38px; left: calc(50% - 89px); bottom: 10px; border-radius: 12px; background: #efcd8999; box-shadow: inset 0 2px #c5975140; }
.tool-lesson-surface i { width: 13px; height: 13px; border: 1px solid #c6a363; border-radius: 5px; background: linear-gradient(145deg, #fffce7, #d9bd7b); box-shadow: 0 2px #aa7b3633; }
.tool-lesson-object { display: block; position: absolute; top: 7px; left: calc(50% - 44px); width: 88px; height: 83px; object-fit: contain; filter: drop-shadow(0 3px 2px #92632930); }
.tool-lesson-object--window { overflow: hidden; top: 0; width: 98px; height: 94px; left: calc(50% - 49px); border-radius: 19px; }
.tool-lesson-object--window > img { position: absolute; max-width: none; max-height: none; width: 348.1633%; height: 784.6809%; left: calc(var(--tool-crop-x) / -245 * 100%); top: calc(var(--tool-crop-y) / -235 * 100%); object-fit: fill; }
.tool-lesson-finger { position: absolute; top: 60px; left: calc(50% - 40px); width: 39px; height: 48px; object-fit: contain; transform-origin: 7px 3px; filter: drop-shadow(0 3px 2px #75502d40); }
.tool-lesson-contact { position: absolute; left: calc(50% - 43px); top: 54px; width: 25px; height: 25px; border: 3px solid #fffbd7; border-radius: 50%; background: #09c4c044; box-shadow: 0 0 0 4px #0bd4cf55; opacity: .7; }
.tool-lesson-wave { position: absolute; width: 60px; height: 60px; left: calc(50% - 30px); top: 36px; border: 3px solid #14b6ba; border-radius: 50%; box-shadow: 0 0 0 10px #26d8d728, 0 0 0 21px #26d8d715; opacity: 0; }
.tool-lesson-effect { position: absolute; bottom: 25px; left: calc(50% - 80px); width: 160px; height: 8px; border-radius: 8px; background: #ffd061; box-shadow: 0 0 9px #ffe68a; opacity: 0; }
.tool-lesson-instruction { margin: 9px 2px 10px; text-align: center; color: #24555a; font: 800 16px/1.4 var(--body); }
.tool-lesson-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; list-style: none; margin: 0; padding: 0; }
.tool-lesson-steps li { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: #366c6f; font: 600 16px/1.15 var(--heading); }
.tool-lesson-steps li > span { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid #d4ac55; border-radius: 50%; color: #7b571b; background: linear-gradient(140deg, #fff1b0, #f1c467); box-shadow: inset 0 1px #fff9dd; font: 600 16px/1 var(--heading); }
.tool-lesson-limit { margin: 10px 0 0; text-align: center; color: #5a7469; font: 700 16px/1.3 var(--body); }
.tool-lesson-assurance { margin: 10px 0 0; text-align: center; color: #617164; font: 700 16px/1.3 var(--body); }
.tool-lesson :is(.tool-lesson-instruction, .tool-lesson-limit, .tool-lesson-assurance) { font-size: 16px; }
.dialog-wrap:has(.tool-lesson) > .dialog-actions { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; }
.dialog-wrap:has(.tool-lesson) > .dialog-actions > .primary { width: 100%; min-height: 54px; font: 650 21px/1.15 var(--heading); }
.dialog-wrap:has(.tool-lesson) > .dialog-actions > .secondary { min-height: 44px; padding: 6px 12px; border: 0; background: none; box-shadow: none; color: #55716c; font: 800 16px/1.3 var(--body); text-decoration: underline; text-underline-offset: 3px; }
.dialog-wrap:has(.tool-lesson) > .dialog-actions button:focus-visible { outline: 3px solid #129aa9; outline-offset: 3px; }

/* The real board gets its full input surface back after the explanation. */
.tool-use-coach { flex: none; display: flex; align-items: center; justify-content: center; gap: 7px; margin: 3px 8px; padding: 6px 10px; border: 1px solid #d1b369; border-radius: 14px; background: linear-gradient(140deg, #fff7d9, #ffedb1); box-shadow: inset 0 1px #fffef0; pointer-events: none; }
.tool-use-coach > img { flex: none; width: 27px; height: 29px; object-fit: contain; }
.tool-use-coach p { margin: 0; color: #235b63; font: 800 16px/1.25 var(--body); }
body.playing .tool-lesson-armed .tool-hint { display: none; }

@media (max-height: 650px) {
  .dialog-wrap:has(.tool-lesson) { padding: 12px 12px 8px; }
  .dialog-wrap:has(.tool-lesson) .dialog-character-heading { margin-bottom: 5px; }
  .dialog-wrap:has(.tool-lesson) .dialog-character-heading h2 { font-size: 22px; }
  .tool-lesson-demo { height: 88px; margin-bottom: 6px; }
  .tool-lesson-object { top: 0; width: 69px; height: 65px; left: calc(50% - 34.5px); }
  .tool-lesson-object--window { top: -2px; width: 77px; height: 74px; left: calc(50% - 38.5px); }
  .tool-lesson-surface { height: 30px; bottom: 6px; }
  .tool-lesson-finger { width: 33px; height: 40px; top: 43px; }
  .tool-lesson-contact { top: 38px; width: 23px; height: 23px; }
  .tool-lesson-wave { top: 20px; }
  .tool-lesson-instruction { margin-block: 6px; line-height: 1.3; }
  .tool-lesson-steps { gap: 4px; }
  .tool-lesson-steps li { gap: 2px; }
  .tool-lesson-limit, .tool-lesson-assurance { margin-top: 6px; line-height: 1.25; }
  .dialog-wrap:has(.tool-lesson) > .dialog-actions { margin-top: 8px; gap: 1px; }
  .dialog-wrap:has(.tool-lesson) > .dialog-actions > .primary { min-height: 50px; }
}
@media (prefers-reduced-motion: no-preference) {
  .tool-lesson-finger { animation: tool-demo-touch var(--tool-demo-duration) ease-in-out 2 both; }
  .tool-lesson-contact { animation: tool-demo-contact var(--tool-demo-duration) ease-in-out 2 both; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-finger { animation-name: tool-demo-sweep; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-contact { animation-name: tool-demo-sweep-contact; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-object { animation: tool-demo-brush var(--tool-demo-duration) ease-in-out 2 both; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-surface i { animation: tool-demo-dust var(--tool-demo-duration) ease-out 2 both; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-surface i:nth-child(2) { animation-delay: 75ms; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-surface i:nth-child(3) { animation-delay: 150ms; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-surface i:nth-child(4) { animation-delay: 225ms; }
  .tool-lesson[data-tool-lesson="eraser"] .tool-lesson-surface i:nth-child(5) { animation-delay: 300ms; }
  .tool-lesson[data-tool-lesson="pickaxe"] .tool-lesson-object { animation: tool-demo-impact var(--tool-demo-duration) ease-out 2 both; }
  .tool-lesson:is([data-tool-lesson="water"],[data-tool-lesson="radar"]) .tool-lesson-wave { animation: tool-demo-wave var(--tool-demo-duration) ease-out 2 both; }
  .tool-lesson:is([data-tool-lesson="pickaxe"],[data-tool-lesson="blower"],[data-tool-lesson="bubble"]) .tool-lesson-effect { animation: tool-demo-flash var(--tool-demo-duration) ease-out 2 both; }
  .tool-lesson[data-tool-lesson="blower"] .tool-lesson-surface i { animation: tool-demo-leaf var(--tool-demo-duration) ease-out 2 both; }
  .tool-lesson[data-tool-lesson="bubble"] .tool-lesson-surface i { border-radius: 50%; animation: tool-demo-pop var(--tool-demo-duration) ease-out 2 both; }
}
@keyframes tool-demo-touch { 0%, 13% { opacity: 0; transform: translateY(-12px); } 22% { opacity: 1; transform: translateY(0); } 31%, 47% { opacity: 1; transform: translateY(4px) scale(.9); } 65%, 100% { opacity: 0; transform: translateY(-12px); } }
@keyframes tool-demo-contact { 0%, 23%, 65%, 100% { opacity: 0; transform: scale(.6); } 32%, 48% { opacity: .9; transform: scale(1); } }
@keyframes tool-demo-sweep { 0%, 13% { opacity: 0; transform: translate(-30px, -12px); } 22% { opacity: 1; transform: translate(-30px, 0); } 32% { opacity: 1; transform: translate(-30px, 4px) scale(.9); } 65% { opacity: 1; transform: translate(60px, 4px) scale(.9); } 77%, 100% { opacity: 0; transform: translate(60px, -12px); } }
@keyframes tool-demo-sweep-contact { 0%, 23% { opacity: 0; transform: translateX(-30px) scale(.6); } 32% { opacity: .9; transform: translateX(-30px) scale(1); } 65% { opacity: .9; transform: translateX(60px) scale(1); } 77%, 100% { opacity: 0; transform: translateX(60px) scale(.6); } }
@keyframes tool-demo-brush { 0%, 20% { transform: translateX(-25px) rotate(-8deg); } 34% { transform: translateX(-25px) rotate(-15deg); } 65%, 100% { transform: translateX(35px) rotate(6deg); } }
@keyframes tool-demo-impact { 0%, 25% { transform: rotate(-20deg) translateY(-5px); } 35% { transform: rotate(13deg) translateY(8px); } 47%, 100% { transform: none; } }
@keyframes tool-demo-dust { 0%, 35% { opacity: 1; transform: none; } 60%, 100% { opacity: 0; transform: translateY(7px) scale(.4); } }
@keyframes tool-demo-wave { 0%, 31% { opacity: 0; transform: scale(.25); } 43% { opacity: .8; } 77%, 100% { opacity: 0; transform: scale(2.5); } }
@keyframes tool-demo-flash { 0%, 31% { opacity: 0; transform: scaleX(.2); } 42% { opacity: .8; transform: scaleX(1); } 70%, 100% { opacity: 0; transform: scaleX(1.2); } }
@keyframes tool-demo-leaf { 0%, 35% { opacity: 1; transform: none; } 70%, 100% { opacity: 0; transform: translate(35px, -12px) rotate(70deg); } }
@keyframes tool-demo-pop { 0%, 35% { transform: scale(1); opacity: 1; } 43% { transform: scale(1.3); } 58%, 100% { transform: scale(.1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tool-lesson-finger { transform: translateY(3px); }
  .tool-lesson-contact { opacity: .8; }
  .tool-lesson-wave, .tool-lesson-effect { opacity: .25; }
}
