:root {
  color-scheme: light;
  background: #9ed6f4;
  color: #492d21;
  --display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  font: 16px/1.35 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.stage { grid-row: 2; position: relative; overflow: hidden; min-height: 0; }
.message {
  grid-row: 1;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 0;
  max-height: 52svh;
  overflow: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 4.5svh) max(20px, env(safe-area-inset-right, 0px)) 9px max(20px, env(safe-area-inset-left, 0px));
  color: #213644;
  text-align: center;
  overflow-wrap: anywhere;
}
.message h1, .message p { margin: 0; min-width: 0; max-width: 100%; }
.message h1 { font: italic 500 clamp(22px, 5.4vw, 32px)/1 var(--display); }
.message #note {
  max-width: min(100%, 30ch);
  font: 500 clamp(16px, 4.2vw, 21px)/1.35 var(--display);
  text-wrap: balance;
}
.message .signature {
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .28em;
  text-transform: uppercase;
  opacity: .65;
}
.message:not([hidden]) { animation: message-in 1.6s ease both; }
@keyframes message-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .message { gap: 4px; padding-top: 10px; padding-bottom: 4px; }
  .message h1 { font-size: clamp(20px, 3.2vw, 24px); }
  .message #note { max-width: min(100%, 58ch); font-size: 16px; }
  .message .signature { line-height: 1.3; }
}
@media (orientation: portrait) and (max-height: 650px) {
  .message { gap: 6px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-bottom: 6px; }
  .message #note { max-width: min(100%, 34ch); }
}
.preview .message { padding-top: 12px; }
.preview .message:not([hidden]) { animation: none; }
.preview canvas { pointer-events: none; }
@media (max-height: 360px) {
  .preview .message { gap: 4px; max-height: 70svh; padding: 9px 12px 5px; }
  .preview .message h1 { font-size: 19px; }
  .preview .message #note { max-width: 100%; font-size: 15px; line-height: 1.25; }
  .preview .message .signature { font-size: 9px; line-height: 1.25; letter-spacing: .22em; }
}

canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline: 2px solid #783e26; outline-offset: -5px; }
.hint {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(clamp(12px, 3.3svh, 30px) + env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px 12px;
  margin: 0;
  color: #263e4d;
  font: 500 .75rem/1.5 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  opacity: .82;
  transition: opacity .65s ease, transform .65s ease;
}
.hint-separator { opacity: .6; }
.hint.is-dismissed { opacity: 0; transform: translateY(5px); }
.sound-toggle {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #263e4d32;
  background: #eefaff55;
  color: #263e4d;
  opacity: .82;
  transition: opacity .25s ease, background-color .25s ease;
}
.sound-toggle:hover, .sound-toggle:focus-visible { background: #eefaffaa; opacity: 1; }
.sound-toggle:focus-visible { outline-color: #263e4d; }
.sound-toggle svg { display: block; width: 19px; height: 19px; }
.sound-toggle[data-state="on"] .slash,
.sound-toggle[data-state="muted"] .wave { display: none; }
@media (max-width: 480px) {
  .hint { flex-direction: column; }
  .hint-separator { display: none; }
}
@media (max-width: 360px) {
  .hint { bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .hint, .sound-toggle { transition: none; }
  .message:not([hidden]) { animation: none; }
}

button {
  border: 0; border-radius: 999px; background: #f2dcc4; color: #693b28;
  font: 600 .875rem/1.2 system-ui, sans-serif; min-height: 44px; padding: 8px 12px; cursor: pointer;
}
button:hover { background: #edcba8; }
button:focus-visible { outline: 2px solid #974528; outline-offset: 3px; }

/* Optional wind control kept for later. */
#wind { background: #9e3d25; color: #fff9eb; }
#wind:hover { background: #7e2d1d; }
