:root {
  --paper: #f7e8b8;
  --ink: #402a4a;
  --accent: #e06687;
  --accent-dark: #8a4f8a;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  display: grid;
  place-items: start center;
  padding: 20px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", sans-serif;
}
.experiment { position: relative; container-type: inline-size; width: min(100%, 640px); margin: auto 0; }
.title-card {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 14px;
  display: grid;
  color: #fff8d7;
  text-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-2deg);
  pointer-events: none;
}
.title-card span { font-size: clamp(10px, 2cqw, 14px); }
.title-card strong { color: #ffd65c; font-size: clamp(17px, 4cqw, 27px); line-height: 1; }
.scene {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 6px;
  background: #8ecfe8;
  box-shadow: 0 6px 0 rgb(64 42 74 / 25%);
  cursor: pointer;
  touch-action: manipulation;
}
.scene:focus-visible { outline: 4px solid #fff36f; outline-offset: 5px; }
.scene:disabled { cursor: wait; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 640 / 420; image-rendering: pixelated; image-rendering: crisp-edges; }
.click-cue {
  position: absolute;
  right: 7%;
  bottom: 8%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 2px solid var(--ink);
  background: #fff8d7;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: clamp(8px, 2cqw, 12px);
}
.click-cue i { width: 9px; height: 9px; border: 2px solid var(--accent-dark); background: var(--accent); transform: rotate(45deg); }
.scene:disabled .click-cue { opacity: 0; }
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 8px 10px;
  border: 4px solid var(--ink);
  border-top: 0;
  background: #fff8d7;
}
.controls p { margin: 0; font-size: clamp(10px, 2cqw, 13px); line-height: 1.35; }
.controls button { flex: none; min-height: 44px; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 6px; color: #fff; background: var(--accent-dark); font: inherit; font-weight: 700; cursor: pointer; }
.controls button:hover:not(:disabled) { background: var(--accent); }
.controls button:focus-visible { outline: 3px dashed var(--accent-dark); outline-offset: 3px; }
.controls button:disabled { opacity: .55; cursor: wait; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
html.embedded body { display: flex; min-height: 100svh; padding: 8px; }
html.embedded .experiment { width: min(100%, 800px, calc((100svh - 100px) * 1.5238)); margin: auto; flex: none; }
@media (max-width: 480px) {
  body { padding: 10px; }
  .controls { align-items: flex-start; }
  .controls p { max-width: 68%; }
  .click-cue span { display: none; }
}
