:root {
  color-scheme: light;
  --island-sky: #88b6d9;
  --paper: #fff7df;
  --cream: #fffdf7;
  --ink: #573b22;
  --muted: #725d42;
  --line: #9a8057;
  --mint: #66d5bf;
  --mint-ink: #194b40;
  --error: #9e3d27;
  --focus: #88610a;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font: 500 100% / 1.5 Nunito, "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--island-sky);
}

button, input {
  font: inherit;
}

.island {
  --viewport-height: 100vh;
  position: relative;
  isolation: isolate;
  block-size: var(--viewport-height);
  overflow: hidden;
  overflow: clip;
}

@supports (height: 100dvh) {
  .island { --viewport-height: 100dvh; }
}

.island-frame {
  --cloud-x: 47.8%;
  --cloud-y: 32.1%;
  /* The illustration and its button share the same cover-fitted rectangle. */
  position: absolute;
  top: 44%;
  left: 46%;
  inline-size: max(100%, calc(var(--viewport-height) * 1.5));
  aspect-ratio: 3 / 2;
  transform: translate(-46%, -44%);
}

.island-art {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  pointer-events: none;
  user-select: none;
}

.cloud,
.cloud-ripple {
  position: absolute;
  top: var(--cloud-y);
  left: var(--cloud-x);
  inline-size: max(44px, 4%);
  block-size: max(44px, 4.5%);
  border-radius: 50%;
  translate: -50% -50%;
}

.cloud {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cloud:focus-visible {
  outline: 3px solid #fff5d1;
  outline-offset: 4px;
  box-shadow: 0 0 0 3px #3c5c62;
}

.cloud-ripple {
  pointer-events: none;
}

.cloud-ripple::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  border: 1.5px solid #fff6d9;
  box-shadow: 0 0 0 5px #fff4d640;
}

.entry {
  --entry-time: 330ms;
  --exit-time: 190ms;
  --from-x: 0px;
  --from-y: -1.8rem;
  position: fixed;
  inset: 0;
  margin: auto;
  inline-size: min(calc(100% - 2rem), 24rem);
  max-block-size: calc(100% - 2rem);
  overflow: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 2rem 2.65rem 2.2rem 2.6rem / 2.4rem 2.15rem 2.5rem 2.05rem;
  padding: clamp(1.25rem, 5vw, 1.8rem);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 5px 10px #3a302924, 0 24px 60px #392d284d;
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: var(--exit-time);
  transition-timing-function: ease-in;
  transition-behavior: allow-discrete;
}

.entry::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: transparent;
  transition-property: background-color, display, overlay;
  transition-duration: var(--exit-time);
  transition-behavior: allow-discrete;
}

.entry[open]:where(:not([data-closing])) {
  opacity: 1;
  transition-duration: var(--entry-time);
  transition-timing-function: var(--ease-out);
}

.entry[open]:where(:not([data-closing]))::backdrop {
  background-color: rgb(31 43 37 / 33%);
  transition-duration: var(--entry-time);
  transition-timing-function: var(--ease-out);
}

@starting-style {
  .entry[open]:where(:not([data-closing])) { opacity: 0; }
  .entry[open]:where(:not([data-closing]))::backdrop { background-color: transparent; }
}

.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1rem;
}

.entry-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.entry-close,
.entry-submit {
  border-radius: 3.125rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.entry-close {
  min-inline-size: 3.25rem;
  min-block-size: 2.75rem;
  padding: 0 0.5rem;
  border: 1px solid transparent;
  background: #80614012;
  color: var(--muted);
  font-size: 0.875rem;
}

.entry-form label {
  display: block;
  margin-block-end: 0.35rem;
  font-weight: 700;
}

.entry-form input,
.entry-submit {
  inline-size: 100%;
  min-block-size: 3.125rem;
}

.entry-form input {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 3.125rem;
  background: var(--cream);
  color: var(--ink);
  caret-color: var(--mint-ink);
  font-size: 1rem;
}

.entry-form input[aria-invalid="true"] {
  border-color: var(--error);
}

.entry-form input::selection {
  background: #c6ead7;
  color: var(--mint-ink);
}

.entry :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.entry-status {
  min-block-size: 1.35rem;
  margin: 0.4rem 0 0.45rem;
  color: var(--error);
  font-size: 0.875rem;
}

.entry[data-entering] .entry-status {
  color: var(--mint-ink);
}

.entry-submit {
  padding: 0.6rem 1rem;
  border: 1px solid #228875;
  background: var(--mint);
  color: var(--mint-ink);
  box-shadow: 0 3px 0 #278b76;
  transition: background-color 150ms ease, transform 150ms var(--ease-out), box-shadow 150ms ease;
}

.entry-submit:disabled {
  cursor: progress;
  background: #dbecdf;
  box-shadow: none;
}

@media (hover: hover) {
  .entry-close:hover { background: #80614025; }
  .entry-submit:enabled:hover { background: #83e0cd; }
}

@media (prefers-reduced-motion: no-preference) {
  .island-frame[data-ripple] .cloud-ripple::before {
    animation: cloud-ripple 580ms var(--ease-out) both;
  }

  @keyframes cloud-ripple {
    0% { scale: 0.65; opacity: 0; }
    15% { opacity: 0.75; }
    100% { scale: 2.5; opacity: 0; }
  }

  .entry { transform: translateY(-0.4rem) scale(0.97); }
  .entry[open]:where(:not([data-closing])) { transform: none; }

  @starting-style {
    .entry[open]:where(:not([data-closing])) {
      transform: translate(var(--from-x), var(--from-y)) scale(0.86);
    }
  }

  .entry-submit:enabled:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #278b76;
  }

  .entry-form input[aria-invalid="true"] {
    animation: entry-nudge 240ms ease-out;
  }

  @keyframes entry-nudge {
    25% { transform: translateX(-4px); }
    55% { transform: translateX(3px); }
    80% { transform: translateX(-1px); }
  }

  @view-transition { navigation: auto; }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 330ms;
    animation-timing-function: var(--ease-out);
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry { --entry-time: 110ms; --exit-time: 90ms; }
}
