#front {
  --front-text: #c8c7d4;
  --front-paper: #92929e;
  --front-ink: #141522;
  --front-serif: Trattatello, var(--f-text), serif;
  background: #0d0f1d;
  color: var(--front-text);
  isolation: isolate;
}

#front .front-art {
  background: #0d0f1d url('/ui/lobby-loading-3c8594b836c9.jpg') center / cover no-repeat;
}

#front .front-art::after {
  background: linear-gradient(90deg, #0d0f1d50, transparent 45%);
}

#front .front-col,
#front.loading .front-col:has(#front-menu:empty) {
  left: max(5vw, env(safe-area-inset-left));
  top: 50%;
  width: clamp(180px, 22vw, 440px);
  max-height: calc(100dvh - 24px);
  display: flex;
  align-items: stretch;
  gap: clamp(14px, 4.8dvh, 56px);
  text-align: center;
}

#front .artist-logo {
  width: 100%;
  margin: 0 auto;
  opacity: .67;
}

#front .front-title {
  width: auto;
  color: var(--front-text);
  filter: none;
  font: 400 clamp(16px, 1.55vw, 32px)/1.05 var(--front-serif);
  text-transform: uppercase;
}

#front-menu {
  width: 94%;
  margin-inline: auto;
}

#front-menu .menu-list {
  gap: clamp(8px, 2.4dvh, 27px);
}

#front-menu .menu-button,
#front .front-load .menu-button {
  min-height: max(44px, 6.4dvh);
  padding: 6px 12px;
  border: 0;
  background: var(--grain), var(--front-paper);
  background-blend-mode: multiply;
  clip-path: var(--torn);
  color: var(--front-ink);
  font: 400 clamp(17px, 1.5vw, 29px)/1.08 var(--front-serif);
  text-align: center;
  cursor: pointer;
}

#front :is(#front-menu .menu-button, .front-load .menu-button):is(:hover, :focus-visible) {
  background: var(--grain), #c8c9d6;
  color: var(--front-ink);
  box-shadow: inset 0 0 0 3px #666b89;
  outline: none;
}

#front .front-load,
#front.loading .front-load {
  position: absolute;
  left: 50%;
  bottom: max(4dvh, env(safe-area-inset-bottom));
  width: clamp(216px, 24vw, 480px);
  min-height: 0;
  transform: translateX(-50%);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#front .front-col:has(#front-menu:not(:empty)) ~ .front-load,
#front.entry-advice .front-load {
  display: none;
}

#front-status, #front-detail, #front-percent {
  color: var(--front-text);
  font: 400 clamp(15px, 1.4vw, 27px)/1.15 var(--front-serif);
  text-shadow: 0 1px 4px #080914;
}

#front-status { text-transform: uppercase; }
#front-detail { margin: 0 0 8px; font-size: clamp(13px, 1vw, 19px); }
#front-detail:empty { display: none; }
#front-percent { display: block; margin-top: 8px; font-size: clamp(17px, 1.55vw, 30px); }

#front .front-track {
  height: clamp(3px, .55dvh, 6px);
  overflow: hidden;
  border-radius: 999px;
  background: #92929e40;
}

#front #front-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--front-paper);
}

#front.initial-loading .front-col:has(#front-menu:empty) {
  left: 50%;
  top: auto;
  bottom: max(25dvh, 108px);
  transform: translateX(-50%);
  width: clamp(190px, 25vw, 420px);
  overflow: visible;
}

#front.initial-loading .front-load {
  bottom: max(7dvh, env(safe-area-inset-bottom));
}

#front .front-entry:not([hidden]) {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(8px, 2dvh, 18px);
  padding: 20px;
  background: #000;
  color: #ebe8ee;
  text-align: center;
}

#front .front-entry svg { width: clamp(52px, 12dvh, 96px); }
#front .front-entry strong { font: 400 clamp(25px, 5dvh, 46px)/1.05 var(--front-serif); }
#front .front-entry p { margin: 0; font: 400 clamp(15px, 2.6dvh, 21px)/1.35 var(--f-text); }

#game:focus { outline: none; }

@media (max-width: 850px) and (orientation: landscape) {
  #front .front-col,
  #front.loading .front-col:has(#front-menu:empty) {
    gap: 12px;
  }
  #front-menu .menu-list { gap: 4px; }
  #front-menu .menu-button { min-height: 40px; }
}

#pocket {
  background: url('/ui/pocket-cover-b04ea8359da2.webp') center / 100% 100% no-repeat;
}

.pk-save {
  position: relative;
  flex: 0 0 auto;
}

.pk-save button[aria-busy="true"] { opacity: .55; cursor: wait; }

.pk-save-status:not(:empty) {
  position: absolute;
  z-index: 1;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 45vw;
  padding: 5px 11px;
  color: var(--paper-3);
  background: var(--ink);
  font-size: clamp(12px, 1.1vw, 17px);
  text-align: center;
}

.player-dialog {
  background: var(--grain), var(--paper);
  background-blend-mode: multiply;
  border: 0;
  border-radius: 0;
  clip-path: polygon(0.8% 0.7%, 9% 0%, 19% 0.8%, 32% 0.3%, 46% 1%,
    62% 0.2%, 77% 0.8%, 88% 0.2%, 99.1% 0.7%, 100% 13%, 99.4% 25%,
    100% 41%, 99.5% 57%, 100% 71%, 99.4% 86%, 99.8% 99.3%, 88% 100%,
    75% 99.3%, 63% 99.8%, 48% 99%, 33% 99.7%, 23% 99.2%, 12% 100%,
    0.5% 99.3%, 0% 86%, 0.6% 73%, 0% 57%, 0.6% 41%, 0.2% 25%, 0.6% 12%);
  color: var(--ink);
  box-shadow: 0 14px 45px #100b1c96;
}

.player-dialog h2 {
  width: max-content;
  max-width: calc(100% - 6rem);
  padding: 4px 14px;
  background: url('/ui/masking.png') center / 100% 100% no-repeat;
}

.player-dialog button:not(.pk-close) {
  color: var(--ink);
  border: 0;
  border-radius: 0;
  background: var(--grain), var(--paper-3);
  background-blend-mode: multiply;
  clip-path: var(--torn);
}

.player-dialog button:not(.pk-close):hover,
.player-dialog button:not(.pk-close):focus-visible {
  background: var(--ink);
  color: var(--paper-3);
}

.player-dialog [data-result]:empty,
.player-dialog [hidden] { display: none; }

.player-qr-paper {
  width: fit-content;
  max-width: 100%;
  padding: 7px;
  background: #fff;
  clip-path: polygon(0.8% 2%, 11% 0.4%, 22% 1.6%, 39% 0%, 52% 1.4%,
    66% 0.5%, 80% 1.6%, 98.5% 0.8%, 99.8% 15%, 98.5% 29%, 100% 49%,
    99.1% 65%, 100% 82%, 98.7% 99%, 84% 100%, 69% 98.8%, 53% 100%,
    38% 99.2%, 20% 99.7%, 1% 98.9%, 0% 83%, 1.3% 64%, 0.4% 49%, 1.5% 29%);
}

.player-qr-paper canvas { display: block; }

#front .front-restore-code {
  display: none;
  position: absolute;
  z-index: 1;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  background: transparent;
}

#front:has(.player-form) .front-restore-code { display: block; }
#front .front-restore-code:focus-visible { outline: 1px dashed var(--front-text); }
#front .front-restore-code:focus-visible::after { content: '↵'; color: var(--front-text); }

.save-indicator {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(320px, 75vw);
  padding: 6px 13px 7px 9px;
  clip-path: var(--torn);
  background: var(--grain), #28222d;
  background-blend-mode: multiply;
  color: var(--paper-3);
  font: 400 15px/1.15 var(--f-text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
}

.save-indicator[data-state] { opacity: 1; transform: none; }
.save-indicator svg { flex: 0 0 23px; width: 23px; height: 23px; }
.save-indicator[data-state="saving"] svg { animation: save-indicator-pulse 1.2s ease-in-out infinite alternate; }

@keyframes save-indicator-pulse {
  from { opacity: .58; }
  to { opacity: 1; }
}

html.touch .save-indicator { bottom: max(64px, env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  .save-indicator { transform: none; transition: none; }
  .save-indicator[data-state="saving"] svg { animation: none; }
}

.pk-pic .pk-object-image,
.pk-big .pk-object-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The cassette list has three visible columns. */
.ts {
  grid-template-columns: 22px minmax(0, 1fr) 18px;
}
@media (max-width: 700px), (max-height: 520px) {
  .ts {
    grid-template-columns: 18px minmax(0, 1fr) 12px;
  }
}

#ending.finale {
  z-index: 35;
  gap: 0;
  padding: 0;
  opacity: 1;
  pointer-events: auto;
  background: transparent;
  color: #f3ebd9;
  transition: none;
}
.finale [hidden] { display: none !important; }
.finale-noise, .finale-scan, .finale-power {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.finale-noise {
  image-rendering: pixelated;
  opacity: .28;
  mix-blend-mode: screen;
}
.finale-scan {
  background: repeating-linear-gradient(0deg, #0005 0 1px, transparent 2px 4px),
    radial-gradient(ellipse at center, transparent 42%, #080611bc 100%);
}
.finale-end, .finale-credits { position: relative; z-index: 1; }
.finale-end {
  margin: 0;
  font: 500 clamp(48px, 10vmin, 108px)/1 var(--f-big);
  text-shadow: 0 2px 22px #080411;
}
.finale-end span {
  margin-inline-start: .14em;
  animation: finale-question 1.15s steps(1, end) infinite;
}
@keyframes finale-question { 53% { opacity: .14; } }
.finale-credits {
  width: min(88vw, 620px);
  padding: clamp(14px, 5vmin, 40px);
  background: radial-gradient(ellipse at center, #080610e8 28%, #08061000 76%);
  animation: finale-credits-in 300ms ease-out both;
}
@keyframes finale-credits-in { from { opacity: 0; } }
.finale-credits img { display: block; width: min(85%, 465px); height: auto; margin: 0 auto clamp(12px, 3vmin, 26px); }
.finale-credits dl { margin: 0; display: grid; gap: clamp(6px, 2vmin, 16px); }
.finale-credits dt { font: 500 clamp(12px, 2.4vmin, 17px)/1.3 var(--f-big); }
.finale-credits dd { margin: 3px 0 0; font: 600 clamp(18px, 4.2vmin, 32px)/1.08 var(--f-hand); }
.finale-power { z-index: 2; visibility: hidden; }
.finale-off .finale-credits,
.finale-off .finale-noise,
.finale-off .finale-scan { visibility: hidden; }
.finale-off .finale-power {
  visibility: visible;
  background: #000;
  animation: finale-power-out 520ms ease-in both;
}
.finale-power::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #b6b5bf;
  box-shadow: 0 0 14px #b6b5bf55;
  opacity: 0;
}
.finale-off .finale-power::after { animation: finale-power-line 450ms ease-in both; }
@keyframes finale-power-out { from { opacity: .7; } }
@keyframes finale-power-line {
  0% { opacity: .2; transform: scale(1, .56); }
  42% { opacity: .55; transform: scale(1, .003); }
  80%, 100% { opacity: 0; transform: scale(.04, .003); }
}
#ending.finale-tickets {
  justify-content: center;
  background: #000;
  overflow: auto;
  padding: max(52px, env(safe-area-inset-top)) 5vw max(20px, env(safe-area-inset-bottom));
}
.finale-tickets h1 {
  margin: 0 0 clamp(14px, 5vmin, 52px);
  font: 600 clamp(35px, 7vmin, 72px)/1.05 var(--f-big);
}
.finale-tickets h1:focus { outline: none; }
.finale-events {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 880px);
  gap: clamp(14px, 10vw, 138px);
}
.finale-event { display: grid; grid-template-rows: auto auto auto; justify-items: center; gap: clamp(4px, 2.5vmin, 16px); }
.finale-event img { display: block; height: auto; width: 100%; }
.finale-event .finale-venue { width: 83%; }
.finale-event .finale-date { width: 80%; }
.finale-event a { width: min(100%, 320px); outline-offset: 5px; }
.finale-event a:hover img { filter: brightness(.86); }
.finale-event a:focus-visible,
.finale-profile:focus-visible { outline: 2px solid #f3ebd9; outline-offset: 4px; }
.finale-profile {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
}
@media (max-height: 420px) and (orientation: landscape) {
  #ending.finale-tickets { padding-top: 18px; }
  .finale-events { width: min(72vw, 480px); }
}
@media (prefers-reduced-motion: reduce) {
  .finale-end span, .finale-off .finale-power, .finale-off .finale-power::after, .finale-credits { animation: none; }
}

body.in-finale :is(#hud, #objective, #hint, #prompt, #title, #subtitle, #touch, #banners) { visibility: hidden; }

body.finale-ticket-menu .rotate-gate { display: none; }
html.touch:has(.finale-ticket-menu), html.touch body.finale-ticket-menu { touch-action: pan-y; }
