/* V0.228a – Startseite Mobile + countdown WebView fit.
   Loaded only by public/index.html. No game styles/assets are changed.
   Desktop: only the agreed arrow and the single portal artwork source change. */

/* Do not also download the obsolete background variants behind <picture>. */
body.portal-page .portal-wrap { background-image: none; }

/* One unobtrusive arrow; the 48px hit area itself does not move. */
body.portal-page .portal-scroll-hint {
  left: auto;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: 54px;
  transform: none;
  width: 48px;
  height: 48px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  color: #d9b769;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color .15s ease;
}
body.portal-page .portal-scroll-hint:hover,
body.portal-page .portal-scroll-hint:focus-visible {
  background: none;
  box-shadow: none;
  transform: none;
  color: #ffe2a0;
}
body.portal-page .portal-scroll-hint:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}
body.portal-page .portal-scroll-arrow {
  display: block;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px #000);
  animation: portalScrollArrow 2.2s ease-in-out infinite;
}
/* The dropdown/dialog must never compete with the scroll target. */
.portal-topnav.is-open ~ .login-screen .portal-scroll-hint,
body.portal-register-active .portal-scroll-hint,
body.portal-document-open .portal-scroll-hint {
  visibility: hidden;
  pointer-events: none;
}

/* Touch devices only: do not change the existing desktop canvas at any height.
   Keep this query in sync with assets/portal_mobile.js. */
@media (max-width: 1100px) and (pointer: coarse) {
  html {
    scroll-padding-top: calc(var(--portal-header-height, 45px) + 8px);
  }
  body.portal-page .portal-topnav {
    box-sizing: border-box;
    min-height: 45px;
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: 0 3px 12px rgba(0,0,0,.24);
  }
  body.portal-page .portal-topnav-inner {
    min-height: 44px;
    width: auto;
    flex: 1 1 auto;
    gap: 12px;
    margin-left: max(12px, env(safe-area-inset-left, 0px));
    margin-right: max(12px, env(safe-area-inset-right, 0px));
  }
  body.portal-page .portal-topnav-brand {
    min-height: 44px;
    gap: 8px;
    font-size: 14px;
    letter-spacing: 3px;
  }
  body.portal-page .portal-topnav-brand img { width: 25px; height: 21px; }
  body.portal-page .portal-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 5px;
  }
  body.portal-page .portal-nav-links {
    position: absolute;
    top: 100%;
    left: auto;
    right: max(12px, env(safe-area-inset-right, 0px));
    width: min(360px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    box-sizing: border-box;
    max-height: calc(var(--portal-visible-height, 100dvh) - var(--portal-header-height, 45px) - 10px);
    margin: 0;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(212,175,55,.30);
    border-top: 0;
    border-radius: 0 0 10px 10px;
    background: rgba(11,7,4,.98);
    box-shadow: 0 12px 24px rgba(0,0,0,.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-7px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
  }
  body.portal-page .portal-topnav.is-open .portal-nav-links {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
  }
  body.portal-page .portal-nav-link {
    min-height: 44px;
    box-sizing: border-box;
    padding: 4px 8px;
    font-size: 13px;
    border-color: rgba(212,175,55,.10);
    background: rgba(255,255,255,.018);
  }
  body.portal-page .portal-nav-register {
    grid-column: span 1;
    border-color: rgba(212,175,55,.42);
    background: linear-gradient(180deg, rgba(157,91,24,.42), rgba(88,45,12,.36));
  }

  /* The header is measured including its border/safe inset. The entire canvas
     (picture, video, login and registration) is laid out below it as one unit.
     Extra page height remains scrollable when the keyboard reduces the view. */
  body.portal-page .login-screen {
    width: 100%;
    height: auto;
    min-height: var(--portal-layout-height, 100svh);
    box-sizing: border-box;
    padding-top: var(--portal-header-height, 45px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  body.portal-page .portal-wrap {
    flex: 0 0 auto;
    width: var(--portal-canvas-width, min(100vw, calc((100svh - 45px) * 4370 / 2160)));
    max-width: none;
    height: auto;
    aspect-ratio: 4370 / 2160;
    margin: 0;
  }

  /* Exact original input rectangles. A 16px logical font avoids iOS focus
     zoom; uniform scaling keeps the visible text inside the drawn fields. */
  body.portal-page #login .portal-input {
    font-size: 16px;
    line-height: 1;
    padding: 0 .35em;
    width: calc(14.94% / var(--portal-input-scale, 1));
    transform: scale(var(--portal-input-scale, 1));
    transform-origin: top left;
    scroll-margin-block: calc(var(--portal-header-height, 45px) + 12px) 18px;
  }
  body.portal-page #login .portal-input.user {
    height: calc(3.66% / var(--portal-input-scale, 1));
  }
  body.portal-page #login .portal-input.pass {
    height: calc(3.75% / var(--portal-input-scale, 1));
  }
  /* Recovery gets its own line below the drawn Arena button on phones,
     instead of colliding with the baked-in password label above the field. */
  body.portal-page #login .portal-forgot-link {
    left: 49.56%;
    top: 75.5%;
    width: 22cqw;
    min-height: clamp(16px, 3.2cqw, 24px);
    padding: 0;
    box-sizing: border-box;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #532c16;
    text-shadow: 0 1px rgba(255,239,193,.3);
    font-size: clamp(8px, 1.3cqw, 11px);
    line-height: 1.15;
    white-space: nowrap;
    text-align: center;
  }
  body.portal-page #login .portal-forgot-link:focus-visible {
    outline: 1px solid #754817;
    outline-offset: 1px;
  }
  body.portal-page .portal-socials { top: 85%; gap: .8cqw; }
  body.portal-page .portal-social-link { width: min(24px, 4cqw); height: min(24px, 4cqw); }
  body.portal-page .portal-copyright {
    bottom: 1%;
    font-size: clamp(8px, 1.2cqw, 11px);
    line-height: 1.15;
  }
  /* A long login status must not paint across the submit/recovery controls. */
  body.portal-page #login .portal-msg {
    left: 4%;
    top: 62%;
    width: 30%;
    box-sizing: border-box;
    min-height: 0;
    max-height: 27%;
    overflow-y: auto;
    overflow-wrap: anywhere;
    font-size: clamp(10px, 1.4cqw, 12px);
    line-height: 1.25;
  }
  body.portal-page #login .portal-msg:not(:empty) {
    padding: 6px;
    border-radius: 5px;
    background: rgba(8,5,3,.85);
  }
  body.portal-page .portal-scroll-hint {
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  /* Same parchment, same registration fields/handlers, reachable scroll area.
     Replace only the fixed +45px inset that escaped the parchment on phones. */
  body.portal-page #registerWrap .portal-register-sheet {
    top: 32.8% !important;
    height: 48.8% !important;
  }
  body.portal-page #registerWrap .portal-register-form {
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(113,73,28,.6) transparent;
    scroll-padding-block: 8px;
  }
  body.portal-page #registerWrap .portal-register-form::-webkit-scrollbar {
    display: block;
    width: 3px;
  }
  body.portal-page #registerWrap .portal-register-form::-webkit-scrollbar-thumb {
    background: rgba(113,73,28,.6);
    border-radius: 3px;
  }

  /* Existing same-origin document/recovery iframe; just fit the visible area. */
  body.portal-page .portal-document-overlay {
    top: var(--portal-visible-top, 0px);
    bottom: auto;
    height: var(--portal-visible-height, 100dvh);
    box-sizing: border-box;
    padding: 6px;
  }
  body.portal-page .portal-document-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 9px;
  }
  body.portal-page .portal-document-header {
    min-height: 44px;
    padding: 0 4px 0 12px;
  }
  body.portal-page .portal-document-header button { width: 44px; height: 44px; }
  body.portal-page #portalDocumentFrame { min-height: 0; }
}

/* V0.228a: the viewport script applies this to small touch screens and to
   the Gladiatorz app (whose primary pointer need not be reported as coarse).
   A measured pixel unit replaces cqw here, including the left offset. */
body.portal-page .portal-beta-countdown.portal-countdown-mobile {
  top: auto !important;
  bottom: 32.6% !important;
  left: calc(50% - 5px);
  left: calc(50% - clamp(5px, calc(var(--portal-countdown-unit, 1vw) * .59), 10px));
  width: 20%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body.portal-page .portal-countdown-mobile .portal-beta-title {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 900;
  margin-bottom: calc(var(--portal-countdown-unit, 1vw) * .12);
  font-size: calc(var(--portal-countdown-unit, 1vw) * .64);
  line-height: 1.05;
  letter-spacing: calc(var(--portal-countdown-unit, 1vw) * .075);
  white-space: nowrap;
}
body.portal-page .portal-countdown-mobile .portal-beta-time {
  gap: calc(var(--portal-countdown-unit, 1vw) * .22);
}
body.portal-page .portal-countdown-mobile .portal-beta-unit {
  min-width: calc(var(--portal-countdown-unit, 1vw) * 2.6);
}
body.portal-page .portal-countdown-mobile .portal-beta-unit strong {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  font-size: calc(var(--portal-countdown-unit, 1vw) * 1.5);
  line-height: .95;
}
body.portal-page .portal-countdown-mobile .portal-beta-unit small {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 850;
  margin-top: calc(var(--portal-countdown-unit, 1vw) * .1);
  font-size: calc(var(--portal-countdown-unit, 1vw) * .46);
  line-height: 1;
  letter-spacing: calc(var(--portal-countdown-unit, 1vw) * .025);
}
body.portal-page .portal-countdown-mobile .portal-beta-sep {
  margin-top: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  font-size: calc(var(--portal-countdown-unit, 1vw) * 1.3);
  line-height: 1;
}
body.portal-page .portal-countdown-mobile .portal-beta-date {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 750;
  margin-top: calc(var(--portal-countdown-unit, 1vw) * .12);
  font-size: calc(var(--portal-countdown-unit, 1vw) * .5);
  line-height: 1.05;
  letter-spacing: calc(var(--portal-countdown-unit, 1vw) * .018);
  white-space: nowrap;
}
body.portal-page .portal-countdown-mobile.is-live .portal-beta-title {
  margin: 0 0 calc(var(--portal-countdown-unit, 1vw) * .15);
  font-size: calc(var(--portal-countdown-unit, 1vw) * 1);
}
body.portal-page .portal-countdown-mobile.is-live .portal-beta-date {
  font-size: calc(var(--portal-countdown-unit, 1vw) * .7);
}
/* Activated only when the natural text actually exceeds its available slot.
   Scale the whole countdown, never the picture or any login control. */
body.portal-page .portal-beta-countdown.portal-countdown-fitted {
  top: var(--portal-countdown-top) !important;
  bottom: auto !important;
  transform: translateX(-50%) scale(var(--portal-countdown-scale, 1));
  transform-origin: 50% 0;
}

@media (prefers-reduced-motion: reduce) {
  body.portal-page .portal-scroll-arrow { animation: none; }
  body.portal-page .portal-scroll-hint,
  body.portal-page .portal-nav-links { transition: none; }
}
