/* =====================================================================
   FEST — the games all over the building: Play tabs, tickets, the play
   surface laid over an element, permit stamps and the Permit Book.
   Each game's own styles are injected by its module.
   ===================================================================== */

/* the little brass diamond everything here wears */
.fest-dia { display: inline-block; width: 6px; height: 6px; transform: rotate(45deg); border: 1px solid currentColor; flex-shrink: 0; }

/* -------------------------------------------------------------- Play tab */
.fest-rel { position: relative; }   /* only on hosts that had no position of their own */
.fest-tab {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px 0 9px; border-radius: 999px;
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; line-height: 1;
  color: var(--gold-hi); background: rgba(2, 10, 17, .78); border: 1px solid var(--line-2); cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .25s, color .25s, background .25s, transform .3s var(--ease-out), opacity .25s;
  opacity: .82; white-space: nowrap; vertical-align: middle;
}
.fest-tab:hover, .fest-tab:focus-visible, .fest-host:hover .fest-tab { opacity: 1; border-color: var(--gold); background: rgba(14, 30, 40, .92); }
.fest-tab:hover { transform: translateY(-1px); }
.fest-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.fest-tab .fest-dia { color: var(--gold); }
.fest-tab.is-stamped { color: var(--bio); border-color: rgba(70, 227, 203, .45); }
.fest-tab.is-stamped .fest-dia { background: var(--bio); color: var(--bio); }
.fest-tab.is-corner { position: absolute; z-index: 6; }
.fest-tab.is-tr { top: 10px; right: 10px; }
.fest-tab.is-tl { top: 10px; left: 10px; }
.fest-tab.is-br { bottom: 10px; right: 10px; }
.fest-tab.is-bl { bottom: 10px; left: 10px; }
.fest-tab.is-flow { display: flex; width: fit-content; margin: 10px 0 0 auto; }
.chart-tools .fest-tab, .chart-head > .fest-tab, .card-label .fest-tab { margin-left: 8px; }
.footer-grid .row > .fest-tab { height: 34px; }
.chart-head > .fest-tab { align-self: flex-start; flex-shrink: 0; }
/* chart headers: the Play tab sits with Table; on narrow cards they stack */
.chart-tools.fest-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chart-tools.fest-stack .fest-tab { margin-left: 0; }
@media (pointer: coarse) { .fest-tab { height: 30px; opacity: 1; } }

/* a slim Play line over a whole section or grid */
.fest-ribbon {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; padding: 8px 14px 8px 8px;
  border: 1px dashed var(--line); border-radius: 999px; background: rgba(2, 10, 17, .35); width: fit-content; max-width: 100%;
  position: relative; z-index: 3;
}
.fest-ribbon .fr-title { font-family: var(--f-display); font-size: 1.15rem; color: var(--ink); }
.fest-ribbon .fr-goal { font-size: .82rem; color: var(--ink-3); }
@media (max-width: 560px) { .fest-ribbon { border-radius: 16px; } .fest-ribbon .fr-goal { flex-basis: 100%; padding-left: 4px; } }

/* hosts that are themselves the button (ticker, depth pill) */
.fest-self { cursor: pointer; }
.fest-dot {
  position: absolute; width: 6px; height: 6px; transform: rotate(45deg); background: var(--gold); box-shadow: 0 0 8px var(--gold);
  pointer-events: none; animation: fest-glint 3.4s ease-in-out infinite;
}
.ticker > .fest-dot { left: 8px; top: calc(50% - 3px); }
.depth-pill > .fest-dot { right: -2px; top: -2px; }
.fest-dot.is-stamped { background: var(--bio); box-shadow: 0 0 8px var(--bio); }
@keyframes fest-glint { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.fest-flash { animation: fest-flash 2.2s var(--ease-out); }
@keyframes fest-flash { 0%, 60% { box-shadow: 0 0 0 3px rgba(230, 192, 105, .9), 0 0 40px rgba(230, 192, 105, .5); } 100% { box-shadow: 0 0 0 0 rgba(230, 192, 105, 0); } }

/* ---------------------------------------------------------------- ticket */
.fest-ticket {
  position: fixed; z-index: 1060; width: min(330px, calc(100vw - 24px)); padding: 16px 18px 16px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(10, 26, 36, .97), rgba(3, 12, 19, .97)); border: 1px solid var(--line-2);
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(247, 227, 164, .08);
  opacity: 0; transform: translateY(6px) scale(.98); transition: opacity .2s, transform .25s var(--ease-out);
}
.fest-ticket.in { opacity: 1; transform: none; }
.fest-ticket::before, .fest-ticket::after { content: ''; position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--bg, #01060b); border: 1px solid var(--line-2); }
.fest-ticket::before { left: -7px; clip-path: inset(0 0 0 50%); }
.fest-ticket::after { right: -7px; clip-path: inset(0 50% 0 0); }
.ft-k { display: flex; justify-content: space-between; gap: 10px; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.ft-k .ft-ok { color: var(--bio); }
.ft-title { font-family: var(--f-display); font-weight: 400; font-size: 1.7rem; line-height: 1.05; margin: 8px 0 10px; color: var(--ink); }
.ft-goal { font-size: .88rem; color: var(--ink); line-height: 1.45; }
.ft-goal b { display: block; font-family: var(--f-mono); font-weight: 400; font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); margin-bottom: 2px; }
.ft-how { font-size: .84rem; color: var(--ink-2); line-height: 1.45; margin-top: 8px; }
.ft-best { font-size: .78rem; color: var(--ink-3); margin-top: 8px; }
.ft-best b { color: var(--gold-hi); font-weight: 500; }
.ft-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ------------------------------------------------- play surface (stage) */
.fest-over { isolation: isolate; }
.fest-stage {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; min-height: 0;
  border-radius: inherit; overflow: hidden; color: var(--ink);
  background: radial-gradient(120% 90% at 50% 0%, #0d2533, #02090f 75%);
  border: 1px solid var(--line-2); box-shadow: inset 0 0 40px rgba(0, 0, 0, .5);
  opacity: 0; transform: scale(.985); transition: opacity .22s, transform .3s var(--ease-out);
  user-select: none; -webkit-user-select: none;
}
.fest-stage.in { opacity: 1; transform: none; }
.fs-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--hair); font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
}
.fs-title { display: inline-flex; align-items: center; gap: 8px; color: var(--gold-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fs-title .fest-dia { color: var(--gold); }
.fs-score { margin-left: auto; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fs-score b { color: var(--gold-hi); font-weight: 500; }
.fs-x {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--hair-2); background: transparent;
  color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.fs-x:hover { color: var(--gold-hi); border-color: var(--line-2); }
.fs-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* shared bits games can use inside a stage */
.fs-center { flex: 1; display: grid; place-items: center; text-align: center; padding: 14px; gap: 10px; align-content: center; }
.fs-big { font-family: var(--f-display); font-size: clamp(1.6rem, 4vw, 2.6rem); line-height: 1; color: var(--ink); }
.fs-big em { color: var(--gold-hi); }
.fs-note { font-size: .84rem; color: var(--ink-2); max-width: 36ch; line-height: 1.45; }
.fs-k { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }
.fs-btn { margin-top: 4px; }
.fs-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.fs-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.fest-stage .btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.6); transform: none; box-shadow: none; }

/* floating words and bubbles */
.fest-say {
  position: fixed; z-index: 1070; pointer-events: none; transform: translate(-50%, -50%);
  font-family: var(--f-display); font-style: italic; font-size: 1.35rem; white-space: nowrap; color: var(--gold-hi);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .9); animation: fest-say var(--ms, 1600ms) var(--ease-out) forwards;
}
.fest-say.is-bio { color: var(--bio); }
.fest-say.is-coral { color: var(--coral); }
.fest-say.is-ink { color: var(--ink); }
@keyframes fest-say { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.9); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -140%); } }
.fest-bub {
  position: fixed; z-index: 1065; pointer-events: none; border-radius: 50%; border: 1px solid; transform: translate(-50%, -50%);
  animation: fest-bub .85s var(--ease-out) forwards;
}
@keyframes fest-bub { to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.4); } }

/* ------------------------------------------------------------- the stamp */
.fest-stamp {
  position: fixed; z-index: 1080; width: 170px; height: 170px; margin: -85px 0 0 -85px; pointer-events: none;
  color: #e0574a; mix-blend-mode: screen; filter: drop-shadow(0 0 1px rgba(224, 87, 74, .6));
  animation: fest-slam .38s cubic-bezier(.3, 1.6, .5, 1) both;
}
.fest-stamp svg { width: 100%; height: 100%; }
.fest-stamp text { fill: currentColor; font-family: var(--f-mono); }
.fest-stamp.out { transition: opacity .6s, transform .6s; opacity: 0; transform: rotate(-14deg) scale(1.05); }
@keyframes fest-slam { 0% { opacity: 0; transform: rotate(-4deg) scale(2.2); } 70% { opacity: 1; } 100% { opacity: .92; transform: rotate(-14deg) scale(1); } }

/* --------------------------------------------------------- Permit Book */
/* the counter lives in the nav, beside the sound button */
.fest-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; flex-shrink: 0;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(2, 10, 17, .5); color: var(--ink-2); cursor: pointer;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  transition: border-color .25s, color .25s, background .25s;
}
.fest-pill .fest-dia { color: var(--gold); }
.fest-pill b { color: var(--gold-hi); font-weight: 500; letter-spacing: .04em; }
.fest-pill:hover { border-color: var(--gold); color: var(--ink); background: rgba(14, 30, 40, .8); }
.fest-pill.has .fest-dia { background: var(--gold); }
.fest-pill.is-float { position: fixed; left: 18px; bottom: 18px; z-index: 1000; background: rgba(2, 10, 17, .85); }
@media (max-width: 1240px) { .fest-pill span { display: none; } .fest-pill { padding: 0 11px; } }
.fest-menu-item { display: none; }
@media (max-width: 560px) {
  .nav-tools .fest-pill { display: none; }
  .fest-menu-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 0; background: none; border: 0; border-top: 1px solid var(--hair);
    color: var(--ink); font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer;
  }
  .fest-menu-item .fest-dia { color: var(--gold); }
  .fest-menu-item b { margin-left: auto; font-family: var(--f-mono); font-size: 12px; font-weight: 500; color: var(--gold-hi); }
}

.fest-book {
  position: fixed; z-index: 1055; right: 12px; top: calc(var(--nav-h) + 10px); width: min(460px, calc(100vw - 24px)); height: min(82vh, 780px);
  display: flex; flex-direction: column; border-radius: 18px; overflow: hidden;
  background: linear-gradient(180deg, rgba(10, 26, 36, .98), rgba(2, 9, 15, .98)); border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .9);
  opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .3s var(--ease-out);
}
.fest-book.in { opacity: 1; transform: none; }
.fb-head { display: flex; gap: 12px; align-items: flex-start; padding: 18px 16px 14px 20px; border-bottom: 1px solid var(--hair); }
.fb-head > div { flex: 1; }
.fb-k { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.fb-head h4 { font-family: var(--f-display); font-weight: 400; font-size: 2rem; line-height: 1; margin: 6px 0 8px; }
.fb-head p { font-size: .84rem; color: var(--ink-2); line-height: 1.45; }
.fb-head p b { color: var(--gold-hi); font-weight: 500; }
.fb-body { overflow: auto; padding: 12px 20px 14px; overscroll-behavior: contain; flex: 1; min-height: 0; }
.fb-foot { display: flex; flex-direction: column; gap: 8px; padding: 10px 20px 14px; border-top: 1px solid var(--hair); font-size: .82rem; }
.fb-foot a { color: var(--bio); }
.fb-group { padding: 12px 0 4px; }
.fb-gh { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.fb-gh h5 { font-family: var(--f-mono); font-weight: 400; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.fb-gh h5 a:hover { color: var(--gold-hi); }
.fb-gh span { font-family: var(--f-mono); font-size: 10px; color: var(--ink-3); }
.fb-note { font-size: .78rem; color: var(--ink-3); margin-top: 2px; }
.fb-group ol { list-style: none; margin-top: 6px; }
.fb-group li { display: grid; grid-template-columns: 22px 18px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--hair); }
.fb-group li:first-child { border-top: 0; }
.fb-no { font-family: var(--f-mono); font-size: 10px; color: var(--ink-4); }
.fb-mark { width: 16px; height: 16px; border-radius: 50%; border: 1px dashed var(--ink-4); display: grid; place-items: center; font-size: 10px; color: var(--bg, #01060b); }
.is-stamped .fb-mark { border: 0; background: var(--bio); }
.fb-name { display: flex; flex-direction: column; min-width: 0; }
.fb-name b { font-weight: 500; font-size: .9rem; color: var(--ink); }
.fb-name span { font-size: .76rem; color: var(--ink-3); line-height: 1.35; }
.fb-name:hover b { color: var(--gold-hi); }
.fb-best { font-family: var(--f-mono); font-size: 10px; color: var(--gold-hi); white-space: nowrap; }
@media (max-width: 560px) { .fest-book { left: 8px; right: 8px; width: auto; max-height: calc(100svh - var(--nav-h) - 24px); } }

/* rank, prize counter and quiet mode in the Permit Book */
.fb-rank { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: baseline; margin-top: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(2, 10, 17, .45); }
.fb-rank b { font-family: var(--f-display); font-weight: 400; font-size: 1.25rem; color: var(--gold-hi); }
.fb-rank em { grid-column: 1 / -1; font-style: normal; font-size: .78rem; color: var(--ink-2); line-height: 1.4; }
.fb-rank .fb-next { grid-column: 1 / -1; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.fb-rank .fb-next i { font-style: normal; color: var(--bio); }
.fb-prizes { padding-top: 14px; }
.fb-prize-list { margin-top: 6px; }
.fb-quiet { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .78rem; color: var(--ink-3); line-height: 1.4; }
.fb-quiet input { margin-top: 3px; accent-color: var(--bio); }
.fb-quiet b { display: block; font-weight: 500; color: var(--ink); font-size: .88rem; }

/* the index (Permit Book + Lower): area tabs, a filter, rows or cards */
.fx-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 10px; margin: 0 -2px; scroll-snap-type: x proximity; }
.fx-tabs::-webkit-scrollbar { display: none; }
.fx-tab {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; scroll-snap-align: start;
  border: 1px solid var(--hair-2); background: rgba(2, 10, 17, .45); color: var(--ink-2); font-size: 12.5px; white-space: nowrap; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.fx-tab i { font-style: normal; font-family: var(--f-mono); font-size: 10px; color: var(--ink-4); letter-spacing: .04em; }
.fx-tab:hover { border-color: var(--line-2); color: var(--ink); }
.fx-tab.on { border-color: var(--gold); background: rgba(230, 192, 105, .12); color: var(--gold-hi); }
.fx-tab.on i { color: var(--gold); }
.fx-tab-extra { border-style: dashed; }
.fx-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 4px 0 10px; border-bottom: 1px solid var(--hair); }
.fx-note { font-size: .78rem; color: var(--ink-3); line-height: 1.4; }
.fx-note a { color: var(--bio); }
.fx-filters { display: inline-flex; border: 1px solid var(--hair-2); border-radius: 999px; padding: 2px; }
.fx-filt { height: 24px; padding: 0 10px; border-radius: 999px; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; }
.fx-filt.on { background: rgba(230, 192, 105, .14); color: var(--gold-hi); }
.fx-empty { padding: 26px 4px; text-align: center; font-family: var(--f-display); font-style: italic; font-size: 1.1rem; color: var(--ink-3); }
/* rows (the book) */
.fx-list { list-style: none; }
.fx-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--hair); color: inherit; transition: background .2s; border-radius: 8px; }
.fx-row:hover { background: rgba(230, 192, 105, .05); }
.fx-mark { width: 20px; height: 20px; border-radius: 50%; border: 1px dashed var(--ink-4); display: grid; place-items: center; font-size: 11px; color: var(--bg, #01060b); }
.is-stamped .fx-mark { border: 0; background: var(--bio); }
.fx-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fx-name b { font-weight: 500; font-size: .92rem; color: var(--ink); }
.fx-goal { font-size: .78rem; color: var(--ink-3); line-height: 1.35; }
.fx-best { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .1em; color: var(--gold); margin-top: 2px; }
.fx-go { color: var(--ink-4); transition: transform .25s var(--ease-out), color .2s; }
.fx-row:hover .fx-go { color: var(--gold-hi); transform: translateX(3px); }
.fx-extra { padding-top: 4px; }
/* cards (the Lower page) */
.fest-index { margin-top: clamp(28px, 4vw, 48px); }
.fest-index .fx-tab { height: 38px; padding: 0 16px; font-size: 14px; }
.fest-index .fx-bar { margin-bottom: 18px; }
.fx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 14px; }
.fx-card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 14px; border-radius: 14px; color: inherit;
  border: 1px solid var(--hair-2); background: linear-gradient(180deg, rgba(14, 36, 50, .55), rgba(3, 12, 20, .55));
  transition: border-color .25s, transform .3s var(--ease-out), background .25s;
}
.fx-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.fx-card.is-stamped { border-color: rgba(70, 227, 203, .35); }
.fx-top { display: flex; justify-content: space-between; gap: 8px; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-4); }
.fx-state { color: var(--gold); }
.is-stamped .fx-state { color: var(--bio); }
.fx-card b { font-family: var(--f-display); font-weight: 400; font-size: 1.4rem; line-height: 1.05; color: var(--ink); margin-top: 4px; }
.fx-card .fx-goal { font-size: .84rem; }

@media (prefers-reduced-motion: reduce) {
  .fest-dot, .fest-stamp, .fest-say { animation: none; }
  .fest-stage, .fest-ticket, .fest-book { transition: none; }
}
