/*** VERSION: v0.1.0 ***/
/*** SHA: 9234422cbfcad5b7817c08b978ffb2060be94855 ***/
:root {
  --crs-bg: rgba(0, 0, 0, 0.5); /* TODO: Change color or alpha if needed */
}

body {
  background: none !important;
  overflow: hidden;
}

canvas {
  touch-action: none;
}

#canvasView {
  display: block;
  position: fixed;
}

.unselectable,
#customDialogContainer {
  -moz-user-select: none !important;
  /*firefox*/
  -webkit-user-select: none;
  /*chrome, safari, and soon edge*/
  -ms-user-select: none;
  /* IE10+ */
  user-select: none;
}

#customDialogContainer p {
  -moz-user-select: text !important;
  /*firefox*/
  -webkit-user-select: unset;
  /*chrome, safari, and soon edge*/
  -ms-user-select: unset;
  /* IE10+ */
  user-select: none;
}

.progress-container {
  position: absolute;
  bottom: 20px;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  max-height: 100vh;
  align-items: center;
  justify-content: center;
  align-content: center;
  width: 94%;
  --ratioSize: 2vh;
  --barRatio: calc(var(--ratioSize) * 0.6);
  font-size: small;
  /* background-color: #000; */
  margin-bottom: var(--titanSafeAreaBottom);
}

.smooth-progression {
  transition: width 100ms;
  transition-timing-function: linear;
}

.smooth-appear {
  transition: display 100ms;
  transition-timing-function: linear;
}

#gameNFDContainer {
  position: absolute;
  width: 100dvw;
  height: 100dvh;
  touch-action: manipulation;
  z-index: 1;
}

#nfd-preloader {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Noto Sans', Arial, sans-serif;
}

.continue-text-container {
  width: 100%;
  height: 100%;
}

#universalPreloaderContent #nfd-preloader {
  width: 100dvw;
  height: 100dvh;
}

@media only screen and (-webkit-min-device-pixel-ratio: 2) {
  /* CSS rules for webkit devices */
  #gameNFDContainer {
    position: fixed;
    min-width: -webkit-fill-available;
    min-width: fill-available;
    min-height: -webkit-fill-available;
    min-height: fill-available;
  }
}

#progress-backround {
  position: absolute;
  z-index: 1;
  height: 100%;
  width: 100%;
  outline: 4px solid #6f1105;
}

@media only screen and (max-device-width: 480px) and (-webkit-max-device-pixel-ratio: 1) {
  html {
    overflow: hidden;
  }

  body {
    position: fixed;
    -webkit-overflow-scrolling: touch;
  }
}

.visuallyhidden {
  display: none;
}

#game-preloader {
  display: none;
}

@keyframes loading {
  from {
    transform: translateX(-170px);
  }
  to {
    transform: translateX(120vh);
  }
}

.meter {
  border-color: #fff;
  border-style: solid;
  border: outset;
  border-width: 1px;
  border-radius: calc(var(--barRatio) * 0.5);
  width: 100%;
  max-width: calc(var(--ratioSize) * 30);
  height: var(--barRatio);
  margin: calc(var(--ratioSize) * 3) auto 0;
  position: relative;
  background: #000;
  box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
}
.meter > span {
  display: block;
  height: calc(var(--barRatio) * 0.5);
  width: 10%;
  max-width: 99.8%;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  background-color: #0066cc;
  position: relative;
  overflow: hidden;
}

.blue > span {
  border-radius: calc(var(--barRatio) * 0.5);
  background: linear-gradient(#0066cc, #ffffff, #0066cc);
  box-shadow: 0 0 calc(var(--ratioSize) * 0.25) #96ecff,
    0 0 calc(var(--ratioSize) * 2) var(--ratioSize) rgba(0, 102, 204, 0.5);
  margin: calc(var(--barRatio) * 0.24) 0 0 calc(var(--barRatio) * 0.5);
}

#gameVersionOverlay {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 2px;
}

/*--- NFD SPECIFIC - CHANGE THIS PART IF NEEDED ---*/
.bg-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: black; /* fallback while image loads */
  background-image: var(--backgroundData);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
  user-select: none;
  width: 100vw;
  height: 100vh;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Responsive scaling wrapper for landscape */
@media (orientation: landscape) {
  .progress-container {
    width: 32%;
    bottom: 8%;
  }
  .bg-container {
    /* Center the content and scale to fit like object-contain */
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ----------  COMMON ELEMENT STYLES  ---------- */
.item {
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-bg {
  height: 100%;
  width: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Background image classes */
.bg-logo {
  background-image: var(--logoData);
}
.bg-crs1 {
  background-image: var(--crs1Data);
}
.bg-crs2 {
  background-image: var(--crs2Data);
}
.bg-crs3 {
  background-image: var(--crs3Data);
}
.bg-crs4 {
  background-image: var(--crs4Data);
}
.bg-tap {
  background-image: var(--tapData);
}
.bg-click {
  background-image: var(--clickData);
}

/* CRS images inside a black rounded rectangle */
.crs {
  background: var(--crs-bg);
  border-radius: 3dvi;
  padding: 0.86%; /* TODO: Change this if the carousels have no padding within their canvas */
  box-sizing: border-box;
  aspect-ratio: 324 / 226; /* maintain CRS image aspect ratio */
  max-height: 40dvh;
}

/* ----------  DEFAULT (PORTRAIT) LAYOUT  ---------- */
.display-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 1vh; /* 1% dynamic viewport height gap between items */
  padding-top: 1vh; /* same vertical gap before first item */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: 2vh;
  box-sizing: border-box;
}
.display-container .logo {
  height: 24%; /* TODO: Change size of logo */
  width: 100%;
  margin: 0;
  margin-bottom: 0px; /* TODO: If your logo has lots of vertical space adjust this */
}
.display-container .crs {
  height: 16.6%;
  margin: 0;
}
.display-container .text {
  height: 5vh; /* slightly shorter to stay within 100dvh */
  margin-top: 2vh; /* extra space above text image */
  width: min(95%, calc(100vw - 2rem));
}

/* ----------  LANDSCAPE LAYOUT  ---------- */
@media (orientation: landscape) {
  .display-container {
    display: grid;
    grid-template-columns: 29fr 40fr 29fr; /* expanded center column for larger logo */
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
      'crs1  center  crs2'
      'crs3  center  crs4';

    /* Dynamic scaling with aspect ratio constraints */
    /* Minimum aspect ratio: 16:9 (1.78:1), Maximum: 2.17:1 */
    width: 100%;
    height: 100%;

    align-content: center; /* center rows vertically if extra space */
    column-gap: min(2vw, 2vh); /* responsive gap */
    row-gap: min(1.5vh, 1.5vw);
    align-items: stretch;
    padding: min(3vh, 3vw) min(32px, 2vw); /* responsive padding */
    box-sizing: border-box; /* include padding in declared width */
  }

  /* Reset the fixed heights we used in portrait */
  .display-container .logo,
  .display-container .crs,
  .display-container .text {
    height: auto;
  }

  /* Positioning inside grid */
  .logo {
    grid-area: logo;
    align-self: end;
    justify-self: center;
    width: 100%;
    padding: 0 0; /* horizontal space like carousels */
    box-sizing: border-box; /* include padding in width */
  }
  .text {
    grid-area: text;
    align-self: start;
    justify-self: center;
    width: 100%;
  }
  .crs1 {
    grid-area: crs1;
    align-self: start;
  }
  .crs3 {
    grid-area: crs3;
    align-self: end;
  }
  .crs2 {
    grid-area: crs2;
    align-self: start;
  }
  .crs4 {
    grid-area: crs4;
    align-self: end;
  }

  /* Make background divs scale to item width in landscape */
  .display-container .item .item-bg {
    width: 100%;
    height: 100%;
    max-height: 100%;
  }
  /* Ensure grid items fill their tracks and don't visually bleed */
  .display-container > .item {
    height: 100%;
    overflow: hidden;
  }
  
  /* Allow CRS items to scale with column width while maintaining aspect ratio */
  .crs {
    width: 100%;
    margin: 0;
    height: 100%;
    min-height: 0;
  }

  /* Hide individual logo & text items, show combined wrapper */
  .display-container > .item.logo,
  .display-container > .item.text {
    display: none;
  }
  .middle-center {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 3vh;
    grid-area: center; /* occupy central area spanning both rows */
    width: 100%;
    padding: 0 32px;
    box-sizing: border-box;
    height: 100%; /* ensure container has height */
  }
  .middle-center .item {
    height: auto;
    min-height: 0;
  }
  .middle-center .item .item-bg {
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  .middle-center .logo {
    min-height: 10dvh;
    max-height: 44dvh;
    flex: 1;
  }
  .middle-center .logo .item-bg {
    min-height: 0;
  }

  /* Center the tap-text block horizontally by shrinking to its content width */
  .middle-center .text {
    align-self: center; /* center block itself */
    width: 100%; /* span the available column width */
    text-align: center; /* center inline content */
  }
  .middle-center .text .item-bg {
    width: 100%; /* scale to container width */
    height: 9dvh; /* fixed height for text image */
    min-height: 0; /* maintain minimum */
    background-position: center top; /* align tap text to top */
  }
}

/* Hide the combined center wrapper only in portrait */
@media (orientation: portrait) {
  .middle-center {
    display: none;
  }
}

/* ----------  ULTRA-SMALL SCREENS ---------- */
@media (max-width: 299px), (max-height: 199px) {
  /* Hide carousels and text */
  .item.crs,
  .item.text,
  .middle-center {
    display: none !important;
  }

  /* Ensure the logo fills the screen proportionally */
  .display-container {
    display: flex; /* override grid for ultra-small screens */
    flex-direction: column;
    gap: 0;
    padding: 0;
    width: 90vw;
    height: 90vh;
    align-items: center;
    justify-content: center;
  }
  .display-container .logo {
    width: 100%;
    height: 100%; /* allow full height too */
  }
  .display-container .logo .item-bg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background-size: contain;
  }

  /* Re-show the standalone logo that landscape would normally hide */
  .display-container > .item.logo {
    display: flex !important;
  }
}
/*--- NFD SPECIFIC - CHANGE THIS PART IF NEEDED ---*/