/* ==========================================================================
   Tip-Top Studio — game player chrome
   --------------------------------------------------------------------------
   Deliberately thin: a fixed-height bar and everything else handed to the
   game. Uses dvh so mobile browser chrome collapsing can't clip the canvas.
   ========================================================================== */

@font-face {
  font-family: 'Archivo Black';
  src: url('/fonts/archivo-black-latin.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo-latin-var.woff2') format('woff2-variations');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --ink-deep: #0C0B09;
  --ink: #16130F;
  --paper: #F4EFE2;
  --paper-dim: #A9A297;
  --red: #FF3B1F;
  --teal: #22B5A0;
  --bar-h: 3.25rem;
  --display: 'Archivo Black', 'Arial Black', system-ui, sans-serif;
  --body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html, body {
  height: 100%;
  background: var(--ink-deep);
  color: var(--paper);
  font-family: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; }

:where(a, button):focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Top bar ------------------------------------------------------------ */
.bar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 1rem;
  height: var(--bar-h);
  padding-inline: clamp(.625rem, 2vw, 1rem);
  background: var(--ink-deep);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 1px 0 rgb(255 59 31 / .35);
}

.bar__back {
  display: inline-flex; align-items: center; gap: .5rem;
  flex: none;
  color: var(--paper);
  font-weight: 700; font-size: .9375rem;
  text-decoration: none;
  padding: .3rem .5rem .3rem .25rem;
  border-radius: 3px;
  transition: background-color .16s var(--ease);
}
.bar__back:hover { background: rgb(244 239 226 / .08); }
.bar__back img { width: 26px; height: 26px; }
.bar__arrow {
  width: 1.125rem; height: 1.125rem;
  fill: none; stroke: var(--paper-dim); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.bar__back:hover .bar__arrow { stroke: var(--paper); }

.bar__title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-family: var(--display);
  font-size: .9375rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar__title span { font-family: var(--body); font-weight: 400; font-style: italic; color: var(--paper-dim); }

.bar__tools { display: flex; align-items: center; gap: .5rem; flex: none; }

.bar__link {
  font-size: .875rem; font-weight: 600;
  color: var(--paper-dim); text-decoration: none;
  padding: .4rem .5rem;
}
.bar__link:hover { color: var(--teal); }

.bar__btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--body); font-size: .875rem; font-weight: 700;
  color: var(--paper);
  background: transparent;
  border: 2px solid #302a23;
  border-radius: 3px;
  padding: .4rem .7rem;
  cursor: pointer;
  transition: border-color .16s var(--ease), background-color .16s var(--ease);
}
.bar__btn:hover { border-color: var(--teal); background: rgb(34 181 160 / .12); }
.bar__icon {
  width: 1rem; height: 1rem;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Narrow screens: keep the icon, drop the words, drop the title. */
@media (max-width: 640px) {
  .bar__backtext, .bar__btntext, .bar__title span { display: none; }
}
@media (max-width: 460px) {
  .bar__title, .bar__link { display: none; }
}

/* --- Stage -------------------------------------------------------------- */
.stage {
  position: relative;
  width: 100%;
  height: calc(100dvh - var(--bar-h));
  background: #000;
}
.stage__frame {
  display: block;
  width: 100%; height: 100%;
  border: 0;
}

/* In fullscreen the bar is gone, so the stage owns the whole screen. */
.stage:fullscreen { height: 100dvh; }

/* --- Loading overlay ---------------------------------------------------- */
.loading {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-content: center; justify-items: center;
  gap: 1.25rem;
  padding: 2rem;
  text-align: center;
  background:
    radial-gradient(70% 70% at 50% 45%, #33224A, #150F20 70%, #0C0B09);
  transition: opacity .5s var(--ease), visibility .5s var(--ease);
}
.loading[hidden] {
  /* [hidden] alone would kill the fade, so drive it with opacity instead. */
  display: grid;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading__logo {
  width: min(74vw, 30rem); height: auto;
  filter: drop-shadow(0 6px 20px rgb(0 0 0 / .6));
}
.loading__bar {
  width: min(70vw, 20rem); height: 6px;
  background: rgb(244 239 226 / .12);
  border-radius: 999px;
  overflow: hidden;
}
/* Indeterminate: the iframe gives us a load event, not real byte progress,
   so promising a percentage here would be a lie. */
.loading__bar span {
  display: block; width: 40%; height: 100%;
  background: linear-gradient(90deg, var(--red), var(--teal));
  border-radius: 999px;
  animation: slide 1.5s var(--ease) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.loading__text { font-family: var(--display); font-size: 1.0625rem; }
.loading__hint { font-size: .875rem; color: var(--paper-dim); max-width: 26rem; }

.loading__text a { color: var(--teal); }

/* --- Landscape nudge ---------------------------------------------------- */
.rotate-hint { display: none; }
@media (max-width: 900px) and (orientation: portrait) and (pointer: coarse) {
  .rotate-hint {
    position: absolute; z-index: 2; inset-inline: 0; bottom: 0;
    display: block;
    padding: .625rem 1rem;
    background: var(--ink);
    border-top: 2px solid #302a23;
    font-size: .8125rem; text-align: center; color: var(--paper-dim);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .loading__bar span { width: 100%; }
}
