* { box-sizing: border-box; }
:root {
  color: #211b3d;
  background: #211b3d;
  font-family: system-ui, sans-serif;
  --side: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --top: max(16px, env(safe-area-inset-top));
  --bottom: max(16px, env(safe-area-inset-bottom));
}
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display: grid; place-items: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; }
[hidden] { display: none !important; }
#app { position: relative; width: min(100%, 390px); height: min(100vh, 844px); height: min(100dvh, 844px); overflow: hidden; background: #fff8e7; container-type: size; }
section, #transition, #board { position: absolute; inset: 0; width: 100%; height: 100%; }
#home, #waiting { background-size: 100% 100%; background-position: center; }
button { min-width: 44px; min-height: 44px; cursor: pointer; touch-action: manipulation; font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid #211b3d; outline-offset: 4px; }
.image-button { border: 0; background: transparent; padding: 0; }
.image-button img { display: block; width: 100%; pointer-events: none; }
#settings { position: absolute; top: var(--top); right: var(--side); width: max(44px, 14.87cqw); }
#logo { position: absolute; top: 17.54%; left: 50%; width: min(90%, calc(100% - 2 * var(--side))); transform: translateX(-50%); }
.start-area { position: absolute; top: 69.43%; inset-inline: var(--side); text-align: center; }
#art-loading {
  position: absolute;
  top: 62%;
  inset-inline: var(--side);
  text-align: center;
  font-weight: 900;
}
#art-progress { display: block; width: min(230px, 100%); margin: 8px auto; accent-color: #237d6c; }
#tap-to-start {
  position: absolute;
  top: 61.97%;
  left: 50%;
  width: min(230px, calc(100% - 2 * var(--side)));
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid #10182d;
  border-radius: 24px;
  box-shadow: 0 4px #10182d;
  background: #fffdf5ed;
  font-size: 22px;
  font-weight: 900;
  animation: tap-prompt 1.4s ease-in-out infinite;
}
#tap-to-start span { display: block; font-size: 14px; }
@keyframes tap-prompt { 50% { opacity: .42; } }
@media (prefers-reduced-motion: reduce) {
  #tap-to-start { animation: none; }
}
#start { width: min(60.51cqw, 100%); }
#selected-mode, #wait-mode { padding: 3px 11px; border: 2px solid #10182d; border-radius: 999px; font-weight: 900; }
#selected-mode { width: fit-content; margin: 4px auto 0; background: #fff8e7; }
#wait-mode { position: absolute; top: var(--top); left: var(--side); background: #dbfbf2; font-size: 14px; }
.score { position: absolute; top: 6.99%; width: 100%; text-align: center; font-size: 4.3cqw; font-weight: 900; }
.score strong { display: block; color: #176982; font-size: min(20cqw, 9.25cqh); line-height: 1; text-shadow: 0 3px #fffdf5; }
#hearts { position: absolute; top: 92.06%; inset-inline: 0; display: flex; justify-content: center; gap: 4.36cqw; }
#hearts img { width: min(11.03cqw, 5.1cqh); align-self: flex-start; }
.deco { position: absolute; width: var(--size); translate: -50% -50%;
  animation: drift var(--period) ease-in-out var(--delay) infinite; }
@media (prefers-reduced-motion: reduce) { .deco { animation: none; } }
.paused .deco, .ready .deco { animation-play-state: paused; }
#waiting:has(#result:not([hidden])) #decorations { opacity: .18; }
.paused > section, .paused #options { pointer-events: none; }
@keyframes drift { 50% { transform: translate(var(--dx), var(--dy)) rotate(var(--angle)); } }
#result { position: absolute; inset: 0; text-align: center; }
.result-summary { position: absolute; top: 38.03%; inset-inline: var(--side); font-weight: 900; }
#result-banner { width: min(100%, 330px); }
#result-text { margin: 6px 0 0; line-height: 1.4; background: #fff8e7; border-radius: 12px; padding: 4px; }
#back { position: absolute; top: 80.8%; left: 50%; transform: translateX(-50%); width: min(56.41cqw, 26.07cqh); }
#back { border-radius: 16px; }
#back:not(:focus-visible) { outline: none; }
#board { display: block; touch-action: none; }
.game-header { position: absolute; top: max(10%, var(--top)); inset-inline: var(--side); text-align: center; pointer-events: none; }
#objective { height: 1.22em; margin: 0 0 8px; font-size: min(11cqw, 5.15cqh, 44px); line-height: 1.22;
  font-weight: 1000; letter-spacing: -.06em; white-space: nowrap; color: #fffdf6; paint-order: stroke fill;
  -webkit-text-stroke: .16em #171225;
  filter: drop-shadow(0 0 .035em #fff8e7) drop-shadow(0 .06em #725544) drop-shadow(0 .08em .03em #211b3dbd); }
#timer { height: 16px; padding: 2px; border: 2px solid; border-radius: 12px; background: #fff8e7; }
#timer div { height: 100%; background: #38dfc2; border-radius: 8px; transform-origin: left; }
#timer.urgent div { background: #ff477e; }
#transition { z-index: 2; pointer-events: none; overflow: hidden; background: #7959f5; }
#transition-art, #speed-surface svg { display: block; width: 100%; height: 100%; }
#transition-art { object-fit: fill; }
#speed-surface { display: none; position: absolute; inset: -7px; }
.speed #transition-art { display: none; }
.speed #speed-surface { display: block; }
#ready { position: absolute; top: 24%; inset-inline: 0; z-index: 3; pointer-events: none; text-align: center; font-size: 34px; font-weight: 900; text-shadow: 0 0 6px #fff8e7, 0 0 6px #fff8e7; }
#pause[open] { position: fixed; inset: 0; display: grid; place-items: center; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #211b3dcc; color: inherit; text-align: center; font-weight: 900; }
.pause-panel { width: min(330px, calc(100% - 32px)); border: 3px solid; border-radius: 16px; background: #fff8e7; }
#pause p { margin: 0; padding: 18px; }
#resume { width: 100%; padding: 18px; border: 0; background: transparent; font-weight: inherit; }
#options { width: min(330px, calc(100% - 32px)); max-height: calc(100vh - var(--top) - var(--bottom)); max-height: calc(100dvh - var(--top) - var(--bottom)); padding: 20px; border: 3px solid #10182d; border-radius: 20px; background: linear-gradient(#f9ffed, #bee8df); color: inherit; }
#options::backdrop { background: #211b3da6; }
dialog:not([open]) { display: none; }
.dialog-fallback { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 3; box-shadow: 0 0 0 150vmax #211b3dcc; }
#pause.dialog-fallback { z-index: 4; transform: none; box-shadow: none; }
#options h2 { margin: 0 0 12px; }
#options fieldset { min-inline-size: 0; margin: 0 0 12px; padding: 0; border: 0; }
#options legend { margin-bottom: 6px; padding: 0; font-weight: 800; }
.mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mode-options label { position: relative; cursor: pointer; }
.mode-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-options span { display: grid; place-items: center; min-height: 44px; padding: 4px; border: 3px solid #10182d; border-radius: 10px; background: #fff8e7; font-weight: 800; }
.mode-options input:checked + span { background: #91e4db; border-width: 4px; }
.mode-options input:focus-visible + span { border-color: #6352c2; }
.volume { display: block; margin-top: 8px; font-weight: 700; }
.volume output { float: right; }
.volume input { appearance: none; display: block; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-x; }
.volume input::-webkit-slider-runnable-track { height: 12px; border: 2px solid #10182d; border-radius: 999px; background: linear-gradient(to right,#7959f5 var(--volume),#fff8e7 var(--volume)); }
.volume input::-webkit-slider-thumb { appearance: none; width: 24px; height: 24px; margin-top: -8px; border: 3px solid #10182d; border-radius: 50%; background: #fff8e7; }
.volume input::-moz-range-track { height: 8px; border: 2px solid #10182d; border-radius: 999px; background: linear-gradient(to right,#7959f5 var(--volume),#fff8e7 var(--volume)); }
.volume input::-moz-range-thumb { width: 18px; height: 18px; border: 3px solid #10182d; border-radius: 50%; background: #fff8e7; }
#close-options { display: block; width: min(100%, 164px); margin: 4px auto 5px; border: 3px solid #10182d; border-radius: 12px;
  background: linear-gradient(#fff1a0,#ffae4a); box-shadow: inset 0 3px #fff8e7, 0 5px #10182d; font-weight: 900; }

.shot .deco, .shot #tap-to-start { animation-play-state: paused; }

#debug-error {
  position: fixed;
  inset: auto auto var(--bottom) var(--side);
  z-index: 10;
  margin: 0;
  max-width: calc(100% - 2 * var(--side));
  max-height: 35vh;
  overflow: auto;
  padding: 8px;
  border: 0;
  background: #fffdf5;
  color: #b00020;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
