* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --plum: #695978;
  --plum-dark: #44384f;
  --lavender: #e9e3f2;
  --bubble: #a8d5d9;
  --rose: #c87995;
  --cream: #fffaf0;
  --ink: #54485e;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 18%, rgba(168, 213, 217, .28), transparent 30%),
    radial-gradient(circle at 84% 82%, rgba(223, 143, 165, .22), transparent 34%),
    linear-gradient(165deg, #695978 0%, #41364f 48%, #241f2d 100%);
  color: var(--ink);
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Segoe Print', 'Comic Neue', cursive;
}

.start-stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, .95fr) minmax(400px, 1.05fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(14px, 2vh, 26px) clamp(40px, 7vw, 130px);
  padding: clamp(30px, 6vh, 86px) clamp(32px, 7vw, 150px) clamp(18px, 3vh, 40px);
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 23%, rgba(255, 255, 255, .78) 0 4%, transparent 20%),
    linear-gradient(180deg, #e9e3f2 0%, #efe9f3 43%, #d8e8df 74%, #a8d5bd 100%);
}

.start-stage::before,
.start-stage::after {
  content: '';
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(1px);
}

.start-stage::before {
  width: 42vw;
  height: 28vh;
  left: -9vw;
  bottom: -11vh;
  background: #8fc4a8;
  box-shadow: 34vw 5vh 0 #b0d4bd, 68vw 1vh 0 #93c3aa;
}

.start-stage::after {
  width: 32vw;
  height: 20vh;
  right: -7vw;
  top: 9vh;
  background: rgba(255, 255, 255, .26);
}

.forest {
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  bottom: 6vh;
  height: 27vh;
  opacity: .36;
  background:
    radial-gradient(ellipse at 7% 100%, #5d9b79 0 20%, transparent 21%),
    radial-gradient(ellipse at 25% 100%, #6da989 0 29%, transparent 30%),
    radial-gradient(ellipse at 53% 100%, #679f82 0 25%, transparent 26%),
    radial-gradient(ellipse at 78% 100%, #72ad8d 0 29%, transparent 30%),
    radial-gradient(ellipse at 97% 100%, #5d9677 0 21%, transparent 22%);
}

.forest-front {
  bottom: 2vh;
  opacity: .28;
  transform: scaleX(1.12);
}

.start-hero,
.menu-panel {
  min-height: 0;
  align-self: center;
}

.start-hero {
  width: 100%;
  max-width: 720px;
  justify-self: end;
  text-align: center;
  animation: arrive-left .55s ease-out both;
}

.eyebrow,
.menu-kicker {
  margin: 0;
  color: var(--rose);
  font: 800 clamp(10px, 1.3vw, 16px)/1.2 system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.hero-art {
  position: relative;
  width: min(100%, 520px);
  height: clamp(220px, 35vh, 440px);
  margin: -2px auto -8px;
}

.hero-art img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 15px 18px rgba(80, 62, 91, .28));
  animation: wobble 3s ease-in-out infinite alternate;
}

.bubble {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, .72);
  border-radius: 50%;
  background: rgba(168, 213, 217, .18);
  box-shadow: inset 5px 6px 10px rgba(255, 255, 255, .35);
}

.bubble-one { width: 48px; height: 48px; top: 32px; left: 6px; }
.bubble-two { width: 25px; height: 25px; top: 2px; right: 18px; }
.bubble-three { width: 34px; height: 34px; right: 0; bottom: 30px; }

h1 {
  margin: 0;
  color: var(--plum);
  font-size: clamp(44px, 7vh, 84px);
  line-height: .92;
  letter-spacing: .045em;
  text-shadow: 0 3px 9px rgba(201, 182, 211, .65);
}

.game-subtitle {
  margin: 5px 0 9px;
  color: var(--rose);
  font-size: clamp(17px, 2.6vh, 30px);
  font-weight: 700;
  letter-spacing: .25em;
  text-transform: uppercase;
}

.intro {
  max-width: 560px;
  margin: 0 auto;
  color: var(--ink);
  font-size: clamp(13px, 1.45vw, 20px);
  line-height: 1.45;
}

.menu-panel {
  width: 100%;
  max-width: 680px;
  max-height: min(720px, 78vh);
  justify-self: start;
  padding: clamp(22px, 3vw, 44px);
  overflow: auto;
  border: 2px solid rgba(255, 255, 255, .74);
  border-radius: 24px;
  background: rgba(255, 250, 246, .76);
  box-shadow: 0 15px 35px rgba(82, 65, 94, .22), inset 0 1px 0 #fff;
  backdrop-filter: blur(8px);
  scrollbar-width: thin;
  scrollbar-color: var(--bubble) transparent;
  animation: arrive-right .55s .08s ease-out both;
}

.menu-panel h2 {
  margin: 3px 0 13px;
  color: var(--plum);
  font-size: clamp(26px, 3.2vw, 46px);
  line-height: 1;
}

.menu-button {
  display: flex;
  align-items: center;
  gap: clamp(13px, 1.2vw, 19px);
  margin-top: clamp(9px, 1.2vh, 14px);
  padding: clamp(10px, 1.4vh, 16px) clamp(14px, 1.4vw, 21px);
  border: 2px solid rgba(168, 213, 217, .88);
  border-radius: 15px;
  background: rgba(255, 255, 255, .7);
  color: var(--plum);
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(105, 89, 120, .1);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.menu-button:hover,
.menu-button:focus-visible {
  transform: translateY(-2px);
  border-color: var(--rose);
  box-shadow: 0 8px 15px rgba(105, 89, 120, .18);
  outline: none;
}

.menu-button.primary {
  border-color: transparent;
  background: linear-gradient(105deg, var(--plum), #798fa0 58%, var(--rose));
  color: #fff;
  box-shadow: 0 8px 18px rgba(105, 89, 120, .3);
}

.button-icon {
  display: grid;
  flex: 0 0 clamp(36px, 3.1vw, 48px);
  width: clamp(36px, 3.1vw, 48px);
  height: clamp(36px, 3.1vw, 48px);
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
  font: 800 14px/1 system-ui, sans-serif;
}

.menu-button:not(.primary) .button-icon {
  background: var(--lavender);
}

.menu-button strong,
.menu-button small {
  display: block;
}

.menu-button strong {
  font-size: clamp(14px, 1.45vw, 20px);
}

.menu-button small {
  margin-top: 1px;
  color: inherit;
  font: 500 clamp(10px, 1vw, 14px)/1.25 system-ui, sans-serif;
  opacity: .78;
}

.level-picker {
  margin-top: clamp(9px, 1.2vh, 14px);
  border-radius: 14px;
  background: rgba(233, 227, 242, .66);
}

.level-picker summary {
  display: flex;
  justify-content: space-between;
  padding: clamp(10px, 1.3vh, 15px) clamp(14px, 1.4vw, 21px);
  color: var(--plum);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.level-picker summary::-webkit-details-marker { display: none; }

.level-picker summary::after {
  content: '⌄';
  margin-left: 8px;
  transition: transform .16s ease;
}

.level-picker[open] summary::after { transform: rotate(180deg); }

.level-picker summary small {
  margin-left: auto;
  color: var(--rose);
  font: 800 11px/1.8 system-ui, sans-serif;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 9px 10px;
}

.level-grid a {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  padding: 7px;
  overflow: hidden;
  border-radius: 9px;
  background: rgba(255, 255, 255, .76);
  color: var(--plum);
  font: 800 13px/1 system-ui, sans-serif;
  text-decoration: none;
}

.level-grid a:hover,
.level-grid a:focus-visible {
  background: var(--bubble);
  color: var(--plum-dark);
  outline: 2px solid #fff;
}

.level-grid span {
  overflow: hidden;
  font-size: 8px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-link {
  display: block;
  margin: 10px 0 0;
  color: var(--plum);
  font: 700 clamp(11px, 1vw, 14px)/1.2 system-ui, sans-serif;
  text-align: center;
  text-decoration-color: rgba(105, 89, 120, .35);
  text-underline-offset: 3px;
}

.editor-link:hover,
.editor-link:focus-visible { color: var(--rose); }

.start-controls {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  align-self: end;
}

.start-controls span {
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 999px;
  background: rgba(255, 250, 246, .64);
  color: var(--ink);
  font: 600 clamp(9px, .85vw, 13px)/1.2 system-ui, sans-serif;
}

.start-controls b { color: var(--plum); }

@keyframes wobble {
  from { transform: rotate(-2deg) translateY(1px); }
  to { transform: rotate(2deg) translateY(-3px); }
}

@keyframes arrive-left {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes arrive-right {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 720px), (max-height: 500px) and (orientation: portrait) {
  body { display: block; overflow: auto; }

  .start-stage {
    width: 100%;
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 20px;
    padding: 28px 16px 20px;
    border-radius: 0;
  }

  .hero-art { height: 210px; }
  .intro { max-width: 480px; }
  .menu-panel { max-width: 520px; max-height: none; margin: 0 auto; }
  .start-controls { grid-column: 1; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .start-stage {
    grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr);
    gap: 12px 24px;
    padding: 12px 28px 10px;
  }

  .eyebrow, .menu-kicker { font-size: 9px; }
  .hero-art { width: min(100%, 290px); height: min(42vh, 210px); }
  h1 { font-size: clamp(34px, 9vh, 52px); }
  .game-subtitle { margin: 3px 0 5px; font-size: clamp(13px, 4vh, 20px); }
  .intro { max-width: 390px; font-size: 11px; line-height: 1.3; }
  .menu-panel { max-width: 560px; max-height: calc(100vh - 24px); padding: 14px 18px; }
  .menu-panel h2 { margin-bottom: 7px; font-size: clamp(22px, 7vh, 34px); }
  .menu-button { margin-top: 6px; padding: 7px 11px; }
  .button-icon { flex-basis: 31px; width: 31px; height: 31px; }
  .menu-button strong { font-size: 13px; }
  .menu-button small { font-size: 9px; }
  .level-picker { margin-top: 6px; }
  .level-picker summary { padding: 8px 11px; font-size: 12px; }
  .editor-link { margin-top: 7px; font-size: 9px; }
  .start-controls { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
