/* Menu layout */
.menu {
  --cell: 2.25rem;
  --rule: color-mix(in srgb, var(--text) 16%, transparent);
  --edge: color-mix(in srgb, var(--text) 26%, transparent);
  --play-edge: color-mix(in srgb, var(--head) 55%, #000);
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding:
    calc(1.5rem + env(safe-area-inset-top, 0px))
    calc(1.5rem + env(safe-area-inset-right, 0px))
    calc(1.25rem + env(safe-area-inset-bottom, 0px))
    calc(1.5rem + env(safe-area-inset-left, 0px));
  background: var(--bg);
  animation: menu-in 0.5s ease backwards;
}
.menu[hidden] { display: none; }
.menu::before {
  content: "";
  position: fixed;
  inset: calc(var(--cell) * -1);
  background:
    linear-gradient(color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px) 0 0 / var(--cell) var(--cell),
    linear-gradient(90deg, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px) 0 0 / var(--cell) var(--cell);
  pointer-events: none;
  animation: menu-drift 9s linear infinite;
}
.menu-content {
  position: relative;
  z-index: 1;
  width: min(100%, 28rem);
  margin-block: auto;
}

/* Title and entrance */
.menu h1 {
  display: flex;
  margin: 0;
  font-size: clamp(4rem, 21vw, 6.5rem);
  font-weight: 780;
  line-height: 0.9;
  letter-spacing: -0.06em;
}
.menu h1 span {
  display: inline-block;
  animation:
    menu-drop 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) backwards,
    menu-wave 7s ease-in-out infinite;
  animation-delay: calc(var(--i) * 80ms), calc(1.6s + var(--i) * 110ms);
}
.menu-tagline {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}
.menu-rise {
  animation: menu-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(var(--d, 0) * 1ms);
}
.menu-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Player statistics */
.menu-stats {
  display: flex;
  margin: 1.75rem 0 0;
  padding: 1rem 0;
  border-block: 1px solid var(--rule);
}
.menu-stat { flex: 1; margin: 0; }
.menu-stat + .menu-stat { padding-left: 1.25rem; border-left: 1px solid var(--rule); }
.menu-stat dt {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.8125rem;
}
.menu-stat dd { margin: 0.25rem 0 0; }
.menu-count {
  display: block;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.menu-blob-dot {
  width: 0.65em;
  height: 0.65em;
  margin-right: 0.45em;
  border-radius: 50%;
  background: var(--food);
  animation: menu-pulse 2.2s ease-in-out infinite;
}

/* Play button */
.menu-play.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 5rem;
  margin-top: 1.5rem;
  padding: 0 1.5rem;
  border: 2px solid var(--play-edge);
  border-radius: 1rem;
  background: var(--head);
  color: var(--on-accent);
  box-shadow: 0 6px 0 var(--play-edge);
  text-align: left;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.15s;
  animation: menu-pop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 650ms backwards;
}
@media (hover: hover) {
  .menu-play.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 0 var(--play-edge); }
}
.menu-play.btn.is-pressed:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--play-edge);
  filter: none;
}
.menu-play.btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--text) 65%, transparent); outline-offset: 5px; }
.menu-play-copy { display: flex; flex-direction: column; gap: 0.125rem; }
.menu-play-copy > :first-child { font-size: 1.5rem; font-weight: 750; line-height: 1.1; }
.menu-play-subtitle { font-size: 0.8125rem; opacity: 0.8; }
.menu-play-arrow {
  width: 1.75rem;
  height: 1.75rem;
  animation: menu-nudge 2.4s ease-in-out 1.6s infinite;
}
.menu-run { display: none; position: absolute; inset: 0; pointer-events: none; }
@supports (offset-path: inset(0 round 1px)) {
  .menu-run { display: block; }
}
.menu-run i {
  --n: 7;
  position: absolute;
  top: 0;
  left: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 0.15rem;
  background: var(--on-accent);
  opacity: calc(1 - var(--i) * 0.11);
  offset-path: inset(0.55rem round 0.6rem);
  offset-anchor: center;
  offset-rotate: 0deg;
  animation: menu-run 8s linear infinite;
  animation-delay: calc((var(--n) - var(--i)) * -0.11s);
}
.menu-run i:first-child { width: 0.7rem; height: 0.7rem; background: var(--food); opacity: 1; }

/* Navigation tiles and account links */
.menu-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  margin-top: 1.5rem;
}
.menu-tile.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 5.25rem;
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--edge);
  border-radius: 0.875rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 0 var(--edge);
  font-size: 0.9375rem;
  font-weight: 640;
  transition: transform 0.12s, box-shadow 0.12s, background-color 0.15s;
}
.menu-tile svg {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--head);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (hover: hover) {
  .menu-tile.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--edge); }
  .menu-tile.btn:hover svg { transform: rotate(-10deg) scale(1.15); }
}
.menu-tile.btn.is-pressed:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--edge);
  filter: none;
}
.menu-tile.btn:focus-visible { outline: 3px solid var(--head); outline-offset: 3px; }
.menu-links { display: grid; gap: 0.625rem; margin-top: 1rem; }
.menu-wide.btn {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.875rem;
  width: 100%;
  min-height: 4.25rem;
  padding: 0.625rem 1rem;
  border: 2px solid var(--edge);
  border-radius: 0.875rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 0 var(--edge);
  text-align: left;
  transition: transform 0.12s, box-shadow 0.12s, background-color 0.15s;
}
.menu-wide[hidden] { display: none; }
.menu-wide-owner.btn { border-style: dashed; }
.menu-wide svg {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--head);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.menu-wide-copy { display: flex; flex-direction: column; min-width: 0; font-size: 1rem; font-weight: 640; }
.menu-wide-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (hover: hover) {
  .menu-wide.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--edge); }
  .menu-wide.btn:hover svg { transform: rotate(-10deg) scale(1.15); }
}
.menu-wide.btn.is-pressed:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--edge);
  filter: none;
}
.menu-wide.btn:focus-visible { outline: 3px solid var(--head); outline-offset: 3px; }

/* Footer and changelog button */
.menu-footer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  width: min(100%, 28rem);
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.menu-version { font-variant-numeric: tabular-nums; }
.menu-changelog.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 0.625rem;
  border: 2px solid var(--edge);
  border-radius: 0.625rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 3px 0 var(--edge);
  font-size: 0.8125rem;
  font-weight: 640;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.12s, background-color 0.15s;
}
.menu-changelog svg { width: 1rem; height: 1rem; color: var(--head); }
@media (hover: hover) {
  .menu-changelog.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 0 var(--edge); }
}
.menu-changelog.btn.is-pressed:not(:disabled) { transform: translateY(3px); box-shadow: none; filter: none; }
@media (prefers-reduced-motion: reduce) {
  .menu-changelog.btn { transition: none; }
}

/* Compact screens and menu animation */
@media (max-height: 700px) {
  .menu h1 { font-size: 4rem; }
  .menu-stats { margin-top: 1rem; padding: 0.75rem 0; }
  .menu-play.btn { margin-top: 1rem; min-height: 4.25rem; }
  .menu-tiles { margin-top: 1rem; }
}
@keyframes menu-drift { to { transform: translate(var(--cell), var(--cell)); } }
@keyframes menu-drop { from { opacity: 0; transform: translateY(-0.7em) rotate(-8deg) scale(0.9); } }
@keyframes menu-wave {
  0%, 30%, 100% { transform: translateY(0); }
  10% { transform: translateY(-0.11em); }
  20% { transform: translateY(0.04em); }
}
@keyframes menu-rise { from { opacity: 0; transform: translateY(1rem); } }
@keyframes menu-pop { from { opacity: 0; transform: scale(0.9) translateY(0.75rem); } }
@keyframes menu-pulse { 50% { transform: scale(1.3); } }
@keyframes menu-nudge { 0%, 55%, 100% { transform: translateX(0); } 25% { transform: translateX(0.4rem); } }
@keyframes menu-run { to { offset-distance: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .menu::before, .menu *, .menu *::before { animation: none !important; }
  .menu-run { display: none; }
}

/* Credits and menu entrance animation */
.credit {
  position: absolute;
  right: calc(1.5rem + env(safe-area-inset-right, 0px));
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.version {
  position: absolute;
  left: calc(1.5rem + env(safe-area-inset-left, 0px));
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(0.75rem); } }
@media (prefers-reduced-motion: reduce) { .menu { animation: none; } }
