/* Scoped finale theme selection. The server still owns choices and the 20 s deadline. */
html:has(#game-stage .ft-finale),
body.in-match:has(#game-stage .ft-finale),
body.in-match:has(.ft-finale) #play#play {
  background: #f3ecd4 !important;
  color: #0a0a0a;
}
body:has(#game-stage .ft-finale)::before { display: none !important; }
body.in-match:has(.ft-finale) #play.view {
  padding: 0 !important;
  min-height: 100svh !important;
  overflow: visible;
}
body.in-match #game-stage#game-stage:has(.ft-finale) {
  width: 100%; max-width: 520px; min-width: 0; margin-inline: auto; padding: 0;
}
body.in-match #game-stage#game-stage#game-stage .panel.ft-finale {
  --ft-ink: #0a0a0a;
  --ft-paper: #f3ecd4;
  --ft-head: "KK Head", "Bangers", Impact, sans-serif;
  --ft-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  min-width: 0;
  min-height: 100svh;
  margin: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) max(12px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) max(12px, env(safe-area-inset-left, 0px));
  border: 0 !important;
  border-radius: 0;
  background: var(--ft-paper) !important;
  background-image: none !important;
  color: var(--ft-ink) !important;
  box-shadow: none;
  font-family: var(--ft-body);
  isolation: isolate;
  overflow: visible;
  animation: none !important;
}
.ft-finale, .ft-finale * { box-sizing: border-box; }
.ft-finale::before,.ft-finale::after {
  content: ""; position: absolute; z-index: -1; width: 92px; height: 100px; pointer-events: none;
  background: radial-gradient(circle, #0a0a0a .7px, transparent 1px) 0 0 / 7px 7px;
  opacity: .35; -webkit-mask-image: linear-gradient(135deg, transparent 35%, #000); mask-image: linear-gradient(135deg, transparent 35%, #000);
}
.ft-finale::before { top: 5px; right: 0; transform: rotate(-90deg); }
.ft-finale::after { bottom: 0; left: 0; transform: rotate(90deg); }
.ft-finale .ft-header { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; align-items: start; gap: 10px; padding-inline: 9px; }
.ft-finale .ft-close {
  display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; margin-top: 10px; padding: 10px;
  border: 1.6px solid var(--ft-ink); border-radius: 10px; color: var(--ft-ink); background: transparent; box-shadow: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 120ms ease;
}
.ft-finale .ft-close svg { width: 24px; height: 24px; }
.ft-finale .ft-close:active { background: #ffd833; transform: none !important; }
.ft-finale .ft-round { text-align: center; }
.ft-finale .ft-round p { margin: 0; font: 400 48px/1 var(--ft-head); color: var(--ft-ink); text-transform: uppercase; letter-spacing: .015em; }
.ft-finale .ft-round > span { display: block; margin-top: 3px; font: 700 15px/1.2 var(--ft-body); color: var(--ft-ink); }
.ft-finale .ft-round-steps { display: flex; gap: 6px; justify-content: center; margin-top: 9px; }
.ft-finale .ft-round-steps span { display: block; flex: 0 1 32px; height: 11px; border: 1.3px solid var(--ft-ink); border-radius: 99px; }
.ft-finale .ft-round-steps .is-filled { background: #ffd833; }
.ft-finale .ft-main { display: grid; gap: 26px; }
.ft-finale .ft-hero { position: relative; display: grid; grid-template-columns: minmax(0,1fr) 35%; row-gap: 10px; align-items: center; padding-inline: 7px; }
.ft-finale .ft-hero-copy { min-width: 0; z-index: 1; padding-top: 5px; }
.ft-finale .ft-eyebrow { margin: 0 0 9px; color: #706d5e; font: 400 22px/1.1 var(--ft-head); text-transform: uppercase; }
.ft-finale .ft-hero h2 { margin: 0; color: var(--ft-ink) !important; font: 400 clamp(39px, 11.9vw, 61px)/1.02 var(--ft-head) !important; text-align: left; letter-spacing: .015em; text-transform: uppercase; white-space: nowrap; text-shadow: none; }
.ft-finale .ft-trophy { display: block; width: 100%; height: auto; aspect-ratio: 1; overflow: visible; transform: scale(1.12); }
.ft-finale .ft-ribbon {
  grid-column: 1 / -1; justify-self: start; max-width: 100%; margin: 0; padding: 5px 10px;
  border: 1.5px solid var(--ft-ink); background: #ffe16a; color: var(--ft-ink); box-shadow: 1px 1px 0 var(--ft-ink);
  font: italic 700 17px/1.2 var(--ft-body); transform: rotate(-2deg) skewX(-8deg); overflow-wrap: anywhere;
}
.ft-finale .ft-explanation { grid-column: 1 / -1; margin: 3px 0 0; color: #514f44; font: 400 14px/1.4 var(--ft-body); }
.ft-finale .ft-cards { display: grid; gap: 19px; }
.ft-finale .ft-card {
  appearance: none; -webkit-appearance: none; display: grid; grid-template-columns: 40% minmax(0,1fr) 22px; gap: 6px; align-items: center;
  width: 100%; min-width: 0; min-height: 142px; margin: 0; padding: 9px 11px 9px 5px;
  border: 1.8px solid var(--ft-ink); border-radius: 17px; background: #fff8e5; color: var(--ft-ink); box-shadow: 2px 4px 0 var(--ft-ink);
  text-align: left; font-family: var(--ft-body); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: background 130ms ease;
}
.ft-finale .ft-card:active { background: #fff0a4; transform: none !important; }
.ft-finale .ft-card--watch { grid-template-columns: 40% minmax(0,1fr) 22px; cursor: default; }
.ft-finale .ft-art { display: block; width: 100%; height: auto; max-height: 130px; aspect-ratio: 1; overflow: visible; }
.ft-finale .ft-card-copy { display: grid; gap: 8px; min-width: 0; }
.ft-finale .ft-card-title { display: block; color: var(--ft-ink); font: 400 clamp(23px, 6.55vw, 34px)/1.08 var(--ft-head); letter-spacing: .005em; text-transform: uppercase; overflow-wrap: anywhere; }
.ft-finale .ft-card-description { color: #292820; font: 400 15px/1.35 var(--ft-body); overflow-wrap: anywhere; }
.ft-finale .ft-difficulty { display: inline-flex; justify-self: start; align-items: center; gap: 12px; max-width: 100%; padding: 3px 9px; border: 1px solid var(--ft-ink); border-radius: 99px; background: #ffe471; font: 700 13px/1.2 var(--ft-body); }
.ft-finale .ft-dots { display: flex; align-items: center; gap: 5px; }
.ft-finale .ft-dots i { width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 50%; }
.ft-finale .ft-dots .is-filled { background: currentColor; }
.ft-finale .ft-arrow { width: 22px; height: 22px; }
.ft-finale .ft-footer { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: auto; padding: 5px 10px 0; color: #57554a; font: 400 13px/1.45 var(--ft-body); }
.ft-finale .ft-footer > span { min-width: 0; overflow-wrap: anywhere; }
.ft-finale .ft-tap { flex: none; width: 32px; height: 39px; color: var(--ft-ink); }
.ft-finale .ft-wait-dot { flex: none; width: 9px; height: 9px; border: 1.2px solid var(--ft-ink); border-radius: 50%; background: #ffd833; }
.ft-finale :is(.ft-close,.ft-card):focus-visible { outline: 3px solid #1765c4; outline-offset: 5px; }
@media (max-width: 370px) {
  body.in-match #game-stage#game-stage#game-stage .panel.ft-finale { padding-inline: 10px; }
  .ft-finale .ft-header { padding-inline: 3px; }
  .ft-finale .ft-card { grid-template-columns: 35% minmax(0,1fr) 18px; padding-right: 8px; min-height: 129px; }
  .ft-finale .ft-arrow { width: 18px; }
  .ft-finale .ft-card-title { font-size: 23px; }
  .ft-finale .ft-card-description { font-size: 13px; }
  .ft-finale .ft-card-copy { gap: 7px; }
  .ft-finale .ft-difficulty { font-size: 12px; gap: 8px; }
  .ft-finale .ft-ribbon { font-size: 14px; }
  .ft-finale .ft-explanation { font-size: 13px; }
}
@media (max-height: 740px) {
  body.in-match #game-stage#game-stage#game-stage .panel.ft-finale { gap: 18px; }
  .ft-finale .ft-main { gap: 18px; }
  .ft-finale .ft-cards { gap: 14px; }
  .ft-finale .ft-round p { font-size: 40px; }
  .ft-finale .ft-hero h2 { font-size: clamp(36px, 10.5vw, 50px) !important; }
  .ft-finale .ft-trophy { max-height: 115px; }
  .ft-finale .ft-card { min-height: 120px; }
  .ft-finale .ft-art { max-height: 110px; }
}
@media (prefers-reduced-motion: reduce) { .ft-finale, .ft-finale * { animation: none !important; transition: none !important; } }
/* Keep the three choices together on ordinary iPhone viewport heights. */
@media (min-height: 741px) and (max-height: 900px) {
  body.in-match #game-stage#game-stage#game-stage .panel.ft-finale { gap: 18px; }
  .ft-finale .ft-main { gap: 20px; }
  .ft-finale .ft-round p { font-size: 44px; }
  .ft-finale .ft-hero { row-gap: 8px; }
  .ft-finale .ft-hero h2 { font-size: clamp(39px, 11.1vw, 55px) !important; }
  .ft-finale .ft-trophy { max-height: 130px; }
  .ft-finale .ft-cards { gap: 16px; }
  .ft-finale .ft-card { min-height: 126px; padding-block: 7px; }
  .ft-finale .ft-art { max-height: 108px; }
  .ft-finale .ft-card-copy { gap: 6px; }
}
