:root {
  --safe-area-top: env(safe-area-inset-top);
  --safe-area-left: env(safe-area-inset-left);
  --safe-area-right: env(safe-area-inset-right);
  --safe-area-bottom: env(safe-area-inset-bottom);
  --font-family: 'Droid', sans-serif;
  --loading-bar-width: 500px;
}

::selection {
  color: none;
  background: none;
}

/* For Mozilla Firefox */
::-moz-selection {
  color: none;
  background: none;
}

* {
  margin: 0;
  padding: 0;
}

body {
    background-color: #061831;
    font-family: var(--font-family);
}

#section-main {
  width: 100vw;
  max-width: 100%;
  height: 100dvh;
  display: block;
  overflow: hidden;
}

#game-container {
  background-color: #0D2A52;
  width: calc(100dvh * (1125 / 2436));
  height: 100%;
  margin: 0 auto;
  border-left: 2px solid #000;
  border-right: 2px solid #000;
  position: relative;
}

#game-canvas {
  z-index: 0;
  float: right;
  background-color: #0D2A52;
  width: 100%;
  height: 100%;
  padding: 0;
  display: block;
  position: static;
}

@keyframes pulseAlpha {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

@keyframes fadeIn {
   from { opacity: 0; }
   to { opacity: 1; }
}

@-webkit-keyframes fadeIn { /* For older iOS Safari */
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulseScale {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.fade-in-overlay {
  animation: fadeIn 1s forwards;
  -webkit-animation: fadeIn 1s forwards; /* Safari & older mobile browsers */
}

#loading-container {
    z-index: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: scale(0.4);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.4); /* Perfect centering */
}

#overlay {
    z-index: 3;
    visibility: hidden;
    background-color: #000;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    opacity: 0;
    transform: translate(-50%, -50%);
}

.loading-logo {
    position: relative;
    width: 154px;
    height: 154px;
    bottom: 20px;
    background: url('../img/logo.png') no-repeat center;
    background-size: contain;
    -webkit-background-size: contain;
    z-index: 1;
    animation: pulseAlpha 2s infinite;
}

.loading-title {
    width: 663px;
    height: 317px;
    background: url('../img/title.png') no-repeat center;
    mask-image: url('../img/title.png');
    mask-size: contain;
    -webkit-mask-image: url('../img/title.png');
    -webkit-mask-size: contain;
    position: relative;
    z-index: 1;
    animation: pulseScale 1.5s infinite;
}

.loading-title-glow {
    width: 480px;
    height: 480px;
    background: url('../img/title-glow.png') no-repeat center;
    background-size: contain;
    -webkit-background-size: contain;
    animation: sweep-light 7s infinite cubic-bezier(0.13, 0, 0.6, 1);
    opacity: 0.3;
    mix-blend-mode: plus-lighter;
}

@keyframes sweep-light {
    0% {
        transform: translate(0%, 0%) rotate(0deg) translateX(0px);
        opacity: 0.3;
    }
    33% {
        transform: translate(70%, -20%) rotate(40deg) translateX(50px);
        opacity: 0.7;
    }
    66% {
        transform: translate(-70%, -20%) rotate(130deg) translateX(-50px);
        opacity: 0.7;
    }
    100% {
        transform: translate(0%, 0%) rotate(180deg) translateX(0px);
        opacity: 0.3;
    }
}

.loading-bar {
    margin-top: 40px;
    width: var(--loading-bar-width);
    height: 85px;
    background: url('../img/load-bar-background.png') no-repeat center;
    background-size: cover;
    -webkit-mask-image: url('../img/load-bar-background.png');
    -webkit-mask-size: cover;
    position: relative;
}

#loading-progress {
    width: var(--loading-bar-width);
    height: 100%;
    left: -500px;
    padding: 0;
    position: relative;
    background: url('../img/load-bar-fill.png') no-repeat center;
    background-size: cover;
    -webkit-background-size: cover;
}

#loading-label {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    font-size: 40px;
    color: black;
    white-space: nowrap;
    text-align: right;
}

#loading-label.centered {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#loading-message {
    margin-top: 20px;
    width: 196px;
    height: 30px;
    background: url('../img/label-loading.png') no-repeat center;
    background-size: contain;
    position: relative;
    animation: pulseAlpha 2s infinite;
}

#rotate-message {
  position: absolute;
  display: none;
  z-index: 9999;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  background-color: #000;
}

#rotate-text {
  color: #fff;
  font-size: 18px;
  line-height: 50px;
  font-weight: 700;
  text-align: center;
}

@media screen and (max-width: 1125px) {
  #game-container {
    max-width: 100%;
    overflow: hidden;
    border-left: 0;
    border-right: 0;
  }
}

.export-btn {
    margin-left: auto;
    background-color: #4caf50;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.export-btn:hover {
    background-color: #45a049;
}
