/* The main menu (Components/MainMenu.razor), drawn over a film of the studio (index.html, js/menu.js): the gold logo on
   top (js/menu3d.js puts it in 3D), a dark glass panel with a neon edge holding pill buttons, and the show's line under
   it. While the film is up the live stage sleeps, hidden behind it; a show or a lesson fades the stage in over the film
   at the same frame (stage.js wake) and the menu dissolves. */
:root {
  --logo-top: max(10px, calc(env(safe-area-inset-top, 0px) + 1.4vh));
  --logo-h: clamp(84px, 19vh, 196px);
  --menu-w: min(580px, calc(100vw - 28px));
  --menu-gap: 1.4vh;
}

/* ---- the film -------------------------------------------------------------------------------------------------- */
.backdrop { position: fixed; inset: 0; overflow: hidden; background: #05050c; pointer-events: none; }
html:not(.film) .backdrop { display: none; }
.backdrop picture, .backdrop-still, .backdrop-film { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.backdrop-film { opacity: 0; transition: opacity 0.6s ease; }
.backdrop-film.moving { opacity: 1; }
/* A little darker at the edges and the foot, where the show's line sits. */
.backdrop::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 46%, transparent 55%, rgba(4, 2, 18, 0.55) 100%), linear-gradient(180deg, transparent 72%, rgba(4, 2, 18, 0.5)); }
/* Once the live stage has faded in over it, the film is out of the way. */
html.stage-live .backdrop { visibility: hidden; transition: visibility 0s 0.5s; }

/* The live stage, behind the film till a show or a lesson wakes it, then fading in over it. */
html.film .stage-host { opacity: 0; visibility: hidden; transition: opacity 0.45s ease, visibility 0s 0.45s; }
html.film.stage-live .stage-host { opacity: 1; visibility: visible; transition: opacity 0.45s ease, visibility 0s; }

/* ---- the logo ------------------------------------------------------------------------------------------------- */
.menu-logo { position: fixed; z-index: 3; left: 50%; top: var(--logo-top); height: var(--logo-h); aspect-ratio: 480 / 324;
  transform: translateX(-50%); display: none; place-items: center; pointer-events: none; }
html.booting .menu-logo, html.menu-on .menu-logo { display: grid; }
.go-mode .menu-logo { display: none !important; }
.menu-logo-flat { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.65)) drop-shadow(0 0 20px rgba(255, 198, 41, 0.28)); }
/* Drawn in 3D over its box (js/menu3d.js, on its own see-through canvas over the page): the flat one steps back, still
   there for screen readers. */
html.logo3d .menu-logo-flat { opacity: 0; }
.menu3d { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }
html.menu-leaving .menu3d { opacity: 0; transition: opacity 0.4s ease; }
html.menu-leaving .menu-logo { animation: menu-logo-out 0.5s ease-in forwards; }
@keyframes menu-logo-out { to { opacity: 0; transform: translate(-50%, -24%) scale(1.12); } }
/* A show's program page loads without the film: the logo over the bar, as the loading screen always had it. */
html:not(.film) .menu-logo { z-index: 101; top: 50%; transform: translate(-50%, calc(-100% - 34px)); height: clamp(120px, 26vh, 220px); }

/* ---- the loading screen, over the film ------------------------------------------------------------------------- */
html.film .loading { z-index: 2; background: radial-gradient(ellipse 46% 30% at 50% 62%, rgba(5, 4, 20, 0.62), transparent 100%);
  padding-top: calc(var(--logo-top) + var(--logo-h)); gap: 16px; }
html.film .loading-tip { text-shadow: 0 1px 2px #000, 0 0 12px rgba(0, 0, 0, 0.9); }

/* ---- the menu ------------------------------------------------------------------------------------------------- */
.mm { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--logo-top) + var(--logo-h) + var(--menu-gap)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
  overflow: auto; pointer-events: none; scrollbar-width: none; }
.mm > * { pointer-events: auto; }
.mm.leaving, .mm.leaving * { pointer-events: none !important; }

/* The glass panel with its neon edge: the edge is a masked ring, so the glass stays glass. */
.mm-panel { position: relative; flex: none; width: var(--menu-w); padding: 20px 22px 16px; border-radius: 28px;
  background: linear-gradient(180deg, rgba(34, 22, 84, 0.6), rgba(12, 7, 38, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), -10px -10px 34px rgba(46, 232, 255, 0.28), 10px 12px 38px rgba(255, 46, 170, 0.28), 0 26px 60px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(9px) saturate(1.3); backdrop-filter: blur(9px) saturate(1.3);
  animation: mm-panel-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }
.mm-panel::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 2.5px; pointer-events: none;
  background: linear-gradient(150deg, #48f6ff 0%, #4f7bff 30%, #b84dff 62%, #ff3fa4 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.mm-panel::after { content: ""; position: absolute; inset: 7px; border-radius: 22px; pointer-events: none; border: 1px solid rgba(255, 255, 255, 0.08); }
@keyframes mm-panel-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
.mm.leaving .mm-panel { animation: mm-panel-out 0.45s ease-in forwards; }
@keyframes mm-panel-out { to { opacity: 0; transform: scale(1.08); filter: blur(10px); } }
html.low-gpu .mm-panel { -webkit-backdrop-filter: none; backdrop-filter: none; background: linear-gradient(180deg, rgba(34, 22, 84, 0.92), rgba(12, 7, 38, 0.95)); }

/* One column, never wider than the panel: a label that can't fit wraps or overflows its own pill, not the panel. */
.mm-buttons { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.mbtn { --c: #3ff0ff; position: relative; display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 8px; width: 100%;
  min-height: 54px; padding: 6px 16px; border-radius: 999px; border: 2px solid var(--c); color: #fff; text-decoration: none; cursor: pointer;
  font: 800 clamp(15px, 2.3vh, 19px)/1.1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 34%, #160e40) 0%, #120a32 52%, color-mix(in srgb, var(--c) 20%, #0b0624) 100%);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent), inset 0 0 16px color-mix(in srgb, var(--c) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  text-shadow: 0 0 10px color-mix(in srgb, var(--c) 75%, transparent), 0 2px 0 rgba(0, 0, 0, 0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease; -webkit-tap-highlight-color: transparent; }
.mbtn:hover:not(:disabled) { transform: translateY(-1px) scale(1.012); filter: brightness(1.14);
  box-shadow: 0 0 24px color-mix(in srgb, var(--c) 80%, transparent), inset 0 0 18px color-mix(in srgb, var(--c) 40%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.mbtn:active:not(:disabled) { transform: scale(0.985); }
.mbtn:focus-visible, .mcorner:focus-visible, .mm-back:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.mbtn:disabled { cursor: default; filter: saturate(0.4) brightness(0.75); }
.mbtn .icon { justify-self: center; width: 28px; height: 28px; color: var(--c); filter: drop-shadow(0 0 6px var(--c)); }
.mbtn small { display: block; margin-top: 3px; font: 700 10px/1 var(--display); letter-spacing: 0.2em; color: color-mix(in srgb, var(--c) 55%, #fff); text-shadow: none; }
.mbtn.blue { --c: #2f9bff; }
.mbtn.purple { --c: #a65cff; }
.mbtn.pink { --c: #ff3b9a; }
.mbtn.gold { --c: #ffc629; }
/* "New": the lesson, offered on someone's first visit. */
.mbtn .new { position: absolute; top: -9px; right: 18px; padding: 3px 8px; border-radius: 999px; font: 800 10px/1 var(--display); letter-spacing: 0.14em;
  color: #2a1400; background: #ffd400; box-shadow: 0 0 12px rgba(255, 212, 0, 0.7); text-shadow: none; animation: mm-new 1.2s ease-in-out infinite alternate; }
@keyframes mm-new { to { transform: scale(1.08); } }

/* Play now: the big gold one, the king turning in it (js/menu3d.js; the flat glyph until then). */
.mbtn.play { --c: #ffc629; grid-template-columns: 70px 1fr 70px; min-height: 86px; padding: 4px 16px; border: 3px solid transparent;
  background: radial-gradient(120% 140% at 50% 0%, #4a2c86 0%, #24124f 46%, #140a33 100%) padding-box,
    linear-gradient(180deg, #fff6c4 0%, #ffd34d 28%, #c0840e 52%, #ffe07a 76%, #a8690a 100%) border-box;
  box-shadow: 0 0 22px rgba(255, 198, 41, 0.55), 0 0 46px rgba(255, 150, 20, 0.25), inset 0 0 20px rgba(255, 198, 41, 0.35); }
.mbtn.play b { display: block; font: 900 clamp(24px, 4.2vh, 36px)/1 var(--display); letter-spacing: 0.05em; color: #fff4c9;
  text-shadow: 0 0 14px rgba(255, 198, 41, 0.85), 0 2px 0 #7a4a00, 0 0 2px #3d2200; }
.mbtn.play small { margin-top: 6px; font-size: 12px; letter-spacing: 0.24em; color: #ffd75e; }
.play-king { justify-self: center; display: grid; place-items: center; width: 64px; height: 76px; }
.play-king-flat { font: 400 54px/1 var(--glyph); color: #ffd34d; filter: drop-shadow(0 2px 0 #7a4a00) drop-shadow(0 0 10px rgba(255, 198, 41, 0.7)); }
html.king3d .play-king-flat { opacity: 0; }
/* Waiting for the studio before the show: its download across the foot of the button. */
.mbtn.play.pending::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: 9px; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, #ffd34d calc(var(--studio-load, 0) * 100%), rgba(255, 255, 255, 0.18) 0); }
.mbtn.play.pending { animation: mm-pulse 0.9s ease-in-out infinite alternate; }
@keyframes mm-pulse { to { filter: brightness(1.2); } }

.mm-corners { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.mcorner { --c: #2f9bff; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 6px 16px 6px 12px; border-radius: 999px;
  border: 2px solid var(--c); color: #fff; text-decoration: none; cursor: pointer; font: 800 13px/1 var(--display); letter-spacing: 0.07em; text-transform: uppercase;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, #160e40), #0f0829);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c) 50%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.22); transition: filter 0.12s ease, transform 0.12s ease; }
.mcorner:hover { filter: brightness(1.15); transform: translateY(-1px); }
.mcorner .icon { width: 20px; height: 20px; color: var(--c); filter: drop-shadow(0 0 5px var(--c)); }
.mcorner.gold { --c: #ffc629; }

.mm-note { margin-top: 12px; text-align: center; font: 600 13px/1.35 var(--body); color: var(--lav); }
.mm-note b { color: var(--text); }
.mm-panel .notice { margin-bottom: 12px; }

/* The show's line under the panel. */
/* Over the busy board: a dark haze behind it, and the letters outlined. */
.mm-lines { position: relative; flex: none; display: grid; justify-items: center; gap: 0.5vh; margin-top: 2vh; padding: 0.6vh 4vw 1vh; text-align: center;
  animation: mm-panel-in 0.6s 0.1s ease both; }
.mm-lines::before { content: ""; position: absolute; inset: -10% -6%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(4, 2, 18, 0.72), rgba(4, 2, 18, 0.45) 60%, transparent); }
.mm-tag { margin: 0; font: 800 clamp(13px, 2.3vh, 21px)/1.15 var(--display); letter-spacing: 0.14em; color: #43f3ff; text-transform: uppercase;
  -webkit-text-stroke: 0.6px #001a33; paint-order: stroke fill; text-shadow: 0 0 12px rgba(5, 217, 232, 0.85), 0 2px 0 #001a33, 0 0 3px #000, 0 0 8px #000; }
.mm-slogan { margin: 0; font: 900 clamp(24px, min(5.6vh, 5.2vw), 54px)/1.02 var(--display); letter-spacing: 0.035em; color: #ffd400; text-transform: uppercase;
  -webkit-text-stroke: 2px #3a1d00; paint-order: stroke fill; text-shadow: 0 0 20px rgba(255, 212, 0, 0.45), 0 4px 0 #6b3d00, 0 0 6px #000, 0 0 14px rgba(0, 0, 0, 0.8); }
.mm.leaving .mm-lines { animation: mm-fade-out 0.35s ease-in forwards; }
/* Who the show is partnered with for payments, under the line: the partners' own logos, unaltered, each on a white
   badge (their colours need a light ground), quiet beside the show's own neon. */
.mm-partners { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin-top: 1.2vh; }
.mm-partners-label { margin: 0; font: 700 clamp(10px, 1.5vh, 13px)/1 var(--display); letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(232, 241, 255, 0.8); text-shadow: 0 1px 2px #000, 0 0 6px #000; }
.mm-partners ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
.mm-partner { display: flex; align-items: center; padding: 6px 12px; border-radius: 7px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
.mm-partner img { display: block; height: clamp(16px, 2.3vh, 22px); width: auto; }
@keyframes mm-fade-out { to { opacity: 0; } }

/* ---- the panel's other views: the lobby, sign-in, settings, profile, tournaments ------------------------------- */
.mm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.mm-head h2 { font: 900 clamp(18px, 2.8vh, 24px)/1.05 var(--display); color: #fff; text-shadow: 0 0 12px rgba(72, 246, 255, 0.6); }
/* The heading takes the focus as its view opens (for keyboards and screen readers); it's no control, so no ring. */
.mm-head h2:focus { outline: none; }
.mm-back { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 14px 6px 10px; border-radius: 999px;
  border: 2px solid rgba(72, 246, 255, 0.8); background: rgba(10, 8, 34, 0.85); color: #fff; cursor: pointer;
  font: 800 12px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; }
.mm-back:hover { filter: brightness(1.2); }
.mm-back .icon { width: 18px; height: 18px; }
.mm-view { display: grid; gap: 14px; max-height: calc(100dvh - var(--logo-top) - var(--logo-h) - var(--menu-gap) - 190px); overflow: auto;
  overscroll-behavior: contain; padding-right: 2px; scrollbar-width: thin; }
.mm-view h3 { margin: 0; font: 800 14px/1.2 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--cyan); }
/* The lobby (Components/Lobby.razor) inside the panel rather than a card of its own. */
.mm .lobby { position: static; width: auto; max-height: none; overflow: visible; padding: 0; gap: 14px; }
.mm-profile { display: flex; align-items: center; gap: 14px; }
.mm-profile .lobby-avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; }
.mm-profile h3 { color: #fff; font-size: 18px; letter-spacing: 0.04em; }
.mm .row .btn { flex: 1 1 auto; }
.mm .toggles { grid-template-columns: 1fr; gap: 12px; }
.mm .toggle { font-size: 15px; }

/* ---- a show starting: the HUD fades in as the camera lands (stage.js wake) ------------------------------------- */
html.cm-arriving #app > :not(.stage-host):not(.mm):not(.stage-error) { opacity: 0; }
html.cm-landed #app > :not(.stage-host):not(.mm):not(.stage-error) { transition: opacity 0.6s ease; }

/* ---- short windows (a small laptop's): the buttons closer together, so the show's line stays on screen ---------- */
@media (max-height: 760px) and (min-width: 561px) {
  .mm-panel { padding: 14px 18px 12px; }
  .mm-buttons { gap: 9px; }
  .mbtn { min-height: 46px; }
  .mbtn.play { min-height: 70px; }
  .play-king { height: 64px; }
  .mm-corners { margin-top: 12px; }
  .mcorner { min-height: 36px; }
  .mm-lines { margin-top: 1.2vh; }
}

/* ---- phones: a plainer panel for their graphics chips ---------------------------------------------------------- */
/* On a Samsung phone in Chrome (2026-12-04) patches of the panel came out wrong: the masked ring's whole gradient over
   the bottom row, the edge missing down one side, smeared film in the glass. So on phones, upright or on their side (a
   touch screen under 560px tall; tablets and laptops keep their glass), no mask and no frosted blur: the neon edge is the
   panel's own border with the gradient showing only there, over glass dark enough not to need the blur. Each layout's
   padding below gives back the border's 2px, so the buttons stay where they were. */
@media (max-width: 560px), (max-height: 560px) and (min-aspect-ratio: 5/4) and (pointer: coarse) {
  .mm-panel, html.low-gpu .mm-panel { border: 2px solid transparent; -webkit-backdrop-filter: none; backdrop-filter: none;
    background: linear-gradient(180deg, rgba(34, 22, 84, 0.94), rgba(12, 7, 38, 0.96)) padding-box,
      linear-gradient(150deg, #48f6ff 0%, #4f7bff 30%, #b84dff 62%, #ff3fa4 100%) border-box; }
  .mm-panel::before { content: none; }
  .mm-panel::after { inset: 5px; }
}

/* ---- phones held upright --------------------------------------------------------------------------------------- */
/* Sized to the screen. The pills are 100vw - 56px wide here, so each label's room is known: the longest ones (Play now,
   Multiplayer lobby, and Settings beside Tournaments) stay on one line from 334px up; narrower, Multiplayer lobby wraps
   inside its pill. On a 360px Samsung the pills were wider than the panel, and Tournaments ran into its edge (2026-12-04). */
@media (max-width: 560px) {
  :root { --logo-h: clamp(72px, 15vh, 130px); --menu-gap: 1vh; }
  .mm { padding-left: 12px; padding-right: 12px; }
  .mm-panel { padding: 14px 12px 12px; border-radius: 24px; }
  .mm-panel::after { border-radius: 18px; }
  .mm-buttons { gap: 10px; }
  .mbtn { min-height: 50px; padding: 4px 12px; grid-template-columns: 30px minmax(0, 1fr) 30px; gap: 6px;
    font-size: clamp(13px, calc((100vw - 156px) / 14.2), 15px); }
  .mbtn .icon { width: 24px; height: 24px; }
  .mbtn.play { min-height: 76px; padding: 4px 12px; grid-template-columns: 50px minmax(0, 1fr) 50px; }
  .play-king { width: 48px; height: 66px; }
  .play-king-flat { font-size: 44px; }
  .mbtn.play b { font-size: clamp(17px, calc((100vw - 198px) / 7), 27px); white-space: nowrap; }
  .mbtn.play small { font-size: clamp(10px, calc((100vw - 198px) / 13.5), 12px); }
  /* Side by side, sharing the row; one under the other if they still can't fit (big system text). */
  .mm-corners { flex-wrap: wrap; gap: 8px; }
  .mcorner { flex: 1 1 auto; justify-content: center; min-height: 40px; padding: 6px 10px 6px 8px; gap: 6px; white-space: nowrap;
    font-size: clamp(10px, calc((100vw - 156px) / 16.5), 12px); }
  .mcorner .icon { width: 18px; height: 18px; }
  .mm-slogan { font-size: clamp(21px, 7.2vw, 34px); }
  .mm-tag { font-size: clamp(11px, 3.3vw, 15px); }
}

/* ---- screens on their side but short (phones turned round): logo and line on the left, panel on the right ------ */
@media (max-height: 560px) and (min-aspect-ratio: 5/4) {
  :root { --logo-h: clamp(64px, 30vh, 150px); --menu-w: min(560px, 58vw); }
  .menu-logo, html.film .menu-logo { left: calc(14px + env(safe-area-inset-left, 0px)); transform: none; top: max(10px, env(safe-area-inset-top, 0px)); height: var(--logo-h); max-width: 36vw; }
  @keyframes menu-logo-out { to { opacity: 0; transform: translateY(-24%) scale(1.12); } }
  .mm { align-items: flex-end; justify-content: center; padding: 10px calc(12px + env(safe-area-inset-right, 0px)) 10px 12px; }
  .mm-panel { padding: 12px 14px 10px; border-radius: 22px; }
  /* A phone's plainer panel (above): the padding gives back its border's 2px. */
  @media (max-width: 560px), (pointer: coarse) {
    .mm-panel { padding: 10px 12px 8px; }
  }
  .mm-buttons { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mbtn { min-height: 42px; padding: 4px 10px; grid-template-columns: 26px 1fr 8px; font-size: 13px; gap: 4px; }
  .mbtn .icon { width: 20px; height: 20px; }
  .mbtn small { display: none; }
  .mbtn.play { grid-column: 1 / -1; min-height: 56px; grid-template-columns: 50px 1fr 50px; }
  .mbtn.play small { display: block; font-size: 10px; margin-top: 3px; }
  .mbtn.play b { font-size: 24px; }
  .play-king { width: 44px; height: 52px; }
  .play-king-flat { font-size: 36px; }
  .mm-corners { margin-top: 8px; }
  .mcorner { min-height: 34px; font-size: 11px; }
  .mm-lines { position: fixed; left: calc(14px + env(safe-area-inset-left, 0px)); bottom: max(12px, env(safe-area-inset-bottom, 0px)); width: 36vw;
    justify-items: start; text-align: left; margin: 0; }
  .mm-tag { font-size: clamp(10px, 2.6vh, 14px); }
  .mm-slogan { font-size: clamp(17px, 5.6vh, 30px); }
  .mm-partners { justify-content: flex-start; margin-top: 6px; }
  .mm-partner { padding: 5px 9px; }
  .mm-partner img { height: 16px; }
  .mm-view { max-height: calc(100dvh - 110px); }
  html.film .loading { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .mm-panel, .mm-lines { animation: none; }
  .mm.leaving .mm-panel, .mm.leaving .mm-lines, html.menu-leaving .menu-logo { animation: mm-fade-out 0.2s ease forwards; }
  .mbtn .new, .mbtn.play.pending { animation: none; }
  .mbtn, .mcorner { transition: none; }
}
