html {
  -ms-touch-action: none;
}

body, canvas, div {
  display: block;
  outline: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -khtml-user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    /* display: none; <- Crashes Chrome on hover */
    -webkit-appearance: none;
    margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}

body {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;

  cursor: default;
  color: #888;
  background-color: #333;

  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;

  display: flex;
  flex-direction: column;
}

canvas {
  background-color: rgba(0, 0, 0, 0);
}

#GameDiv, #Cocos3dGameContainer, #GameCanvas {
  width: 100%;
  height: 100%;
}

:root {
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --auth-ink: #171a19;
  --auth-paper: #f8f2e5;
  --auth-red: #9c2b24;
  --auth-cyan: #d9ffff;
}

[hidden] {
  display: none !important;
}

body.auth-required {
  overflow: hidden;
  background: #172825;
}

body.auth-required #GameDiv {
  visibility: hidden;
}

.auth-gate {
  position: fixed;
  z-index: 1000;
  inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  overflow: auto;
  color: var(--auth-ink);
  background: #d9ddd1;
  opacity: 1;
  transition: opacity 360ms ease, transform 360ms ease;
}

.auth-scenery {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(17, 31, 29, 0.08) 0%, rgba(17, 31, 29, 0.02) 48%, rgba(17, 31, 29, 0.76) 100%),
    url("../assets/jianghu-game-hero-v2.jpg") center / cover no-repeat;
}

.auth-scenery::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 17, 16, 0.02), rgba(8, 17, 16, 0.34));
}

.auth-brand {
  position: relative;
  z-index: 1;
  align-self: end;
  padding: clamp(36px, 7vw, 110px);
  padding-bottom: max(clamp(48px, 8vh, 110px), calc(var(--safe-bottom) + 34px));
  color: #f7f2e7;
  text-align: left;
  text-shadow: 0 2px 18px rgba(8, 17, 16, 0.42);
}

.auth-seal {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  color: #ffffff;
  background: rgba(145, 38, 30, 0.88);
  font-family: STKaiti, KaiTi, serif;
  font-size: 30px;
}

.auth-brand p {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.68);
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.32em;
}

.auth-brand h1 {
  margin: 0;
  font-family: STKaiti, KaiTi, "Songti SC", serif;
  font-size: clamp(58px, 8vw, 118px);
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 0.95;
}

.auth-brand strong {
  display: block;
  margin-top: 26px;
  color: var(--auth-cyan);
  font-family: STKaiti, KaiTi, serif;
  font-size: clamp(20px, 2.4vw, 34px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.35;
  text-shadow: 0 0 10px rgba(0, 175, 191, 0.85), 0 2px 14px rgba(4, 22, 24, 0.7);
}

.auth-card {
  position: relative;
  z-index: 2;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  flex-direction: column;
  justify-self: end;
  padding: max(46px, calc(var(--safe-top) + 28px)) clamp(34px, 5vw, 72px) max(30px, calc(var(--safe-bottom) + 22px));
  border-left: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(248, 242, 229, 0.94);
  box-shadow: -24px 0 60px rgba(15, 27, 25, 0.22);
  backdrop-filter: blur(16px);
  box-sizing: border-box;
  text-align: left;
}

.auth-card-head p {
  margin: 0 0 8px;
  color: #68716d;
  font-size: 11px;
  letter-spacing: 0.16em;
}

.auth-card-head h2 {
  margin: 0;
  font-family: STKaiti, KaiTi, serif;
  font-size: clamp(38px, 5vw, 56px);
  line-height: 1;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 34px 0 26px;
  border-bottom: 1px solid rgba(23, 26, 25, 0.22);
}

.auth-tabs button {
  position: relative;
  padding: 13px 10px;
  border: 0;
  color: #777a77;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.auth-tabs button::after {
  content: "";
  position: absolute;
  right: 22%;
  bottom: -1px;
  left: 22%;
  height: 3px;
  background: var(--auth-red);
  opacity: 0;
  transform: scaleX(0.5);
  transition: opacity 180ms ease, transform 180ms ease;
}

.auth-tabs button.is-active {
  color: var(--auth-ink);
}

.auth-tabs button.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

#authForm {
  display: grid;
  gap: 17px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field > span:first-child {
  color: #515754;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.auth-field input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid rgba(23, 26, 25, 0.24);
  border-radius: 0;
  outline: none;
  color: var(--auth-ink);
  background: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 16px;
  line-height: 50px;
  user-select: text;
  -webkit-user-select: text;
  box-sizing: border-box;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.auth-field input:focus {
  border-color: var(--auth-red);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(156, 43, 36, 0.1);
}

.auth-field input::placeholder {
  color: #a5a9a5;
  font-size: 13px;
}

.auth-password-wrap {
  position: relative;
  display: block;
}

.auth-password-wrap input {
  padding-right: 62px;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  height: 38px;
  padding: 0 11px;
  border: 0;
  color: var(--auth-red);
  background: transparent;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transform: translateY(-50%);
}

.auth-consent {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  color: #6f7471;
  font-size: 11px;
  line-height: 1.7;
  cursor: pointer;
}

.auth-consent input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.auth-consent i {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  margin-right: 3px;
  border: 1px solid rgba(23, 26, 25, 0.4);
  background: rgba(255, 255, 255, 0.68);
  box-sizing: border-box;
}

.auth-consent input:checked + i {
  border-color: var(--auth-red);
  background: var(--auth-red);
}

.auth-consent input:checked + i::after {
  content: "✓";
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
}

.auth-consent button,
.auth-mode-hint button {
  padding: 0;
  border: 0;
  color: var(--auth-red);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-message {
  min-height: 18px;
  margin: -2px 0 -3px;
  color: #747975;
  font-size: 12px;
  line-height: 1.5;
}

.auth-message.is-error {
  color: #aa2c25;
}

.auth-message.is-success {
  color: #28725b;
}

.auth-submit {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 24px;
  border: 1px solid var(--auth-red);
  color: #fffaf0;
  background: var(--auth-red);
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.16em;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(98, 25, 20, 0.2);
  transition: transform 180ms ease, filter 180ms ease;
}

.auth-submit:active {
  transform: translateY(1px);
}

.auth-submit:disabled {
  cursor: wait;
  filter: grayscale(0.25) opacity(0.75);
}

.auth-submit b {
  font-family: Arial, sans-serif;
  font-size: 20px;
}

.auth-submit.is-busy b {
  animation: auth-arrow 800ms ease-in-out infinite alternate;
}

@keyframes auth-arrow {
  to { transform: translateX(5px); }
}

.auth-mode-hint {
  margin: 19px 0 0;
  color: #737773;
  font-size: 12px;
  text-align: center;
}

.auth-record {
  display: grid;
  justify-items: center;
  gap: 5px;
  margin-top: clamp(28px, 7vh, 64px);
  color: rgba(23, 26, 25, 0.54);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.auth-record a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(23, 26, 25, 0.22);
}

.auth-legal {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 14, 13, 0.72);
  backdrop-filter: blur(8px);
}

.auth-legal-card {
  position: relative;
  width: min(100%, 430px);
  max-height: min(78vh, 620px);
  overflow: auto;
  padding: 34px 28px 28px;
  color: var(--auth-ink);
  background: var(--auth-paper);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  text-align: left;
}

.auth-legal-card h2 {
  margin: 0 0 20px;
  font-family: STKaiti, KaiTi, serif;
  font-size: 30px;
}

.auth-legal-card p {
  margin: 0 0 12px;
  color: #555d59;
  font-size: 14px;
  line-height: 1.8;
}

.auth-legal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  color: #626864;
  background: transparent;
  font-size: 26px;
  cursor: pointer;
}

.auth-legal-confirm {
  width: 100%;
  height: 46px;
  margin-top: 12px;
  border: 0;
  color: #ffffff;
  background: var(--auth-red);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

body.auth-launching .auth-gate {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.015);
}

.game-consent {
  position: fixed;
  z-index: 900;
  left: 50%;
  bottom: max(calc(var(--safe-bottom) + 18px), 16.5vh);
  width: max-content;
  max-width: calc(100vw - 24px);
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px;
  padding: 6px 12px;
  border: 1px solid rgba(219, 255, 250, 0.32);
  border-radius: 6px;
  color: #f5f8f6;
  background: rgba(7, 25, 30, 0.7);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
  box-sizing: border-box;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(11px, 3vw, 15px);
  line-height: 1.5;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.72);
  transform: translateX(-50%);
}

.game-consent label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.game-consent input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.game-consent i {
  width: 20px;
  height: 20px;
  display: grid;
  flex: 0 0 20px;
  place-items: center;
  border: 2px solid #f4dc4b;
  border-radius: 2px;
  background: rgba(9, 20, 22, 0.56);
  box-sizing: border-box;
}

.game-consent input:checked + i {
  background: #f4dc4b;
}

.game-consent input:checked + i::after {
  content: "✓";
  color: #15201c;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.game-consent button {
  padding: 2px 1px;
  border: 0;
  color: #77e86f;
  background: transparent;
  font: inherit;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.76);
  cursor: pointer;
}

body.auth-required .game-consent {
  display: none !important;
}

@media (orientation: landscape) {
  .game-consent {
    bottom: max(calc(var(--safe-bottom) + 12px), 4vh);
  }
}

@media (max-width: 760px) {
  .auth-gate {
    grid-template-columns: 1fr;
    align-content: end;
  }

  .auth-scenery {
    background:
      linear-gradient(180deg, rgba(12, 25, 23, 0.02) 0%, rgba(12, 25, 23, 0.16) 34%, rgba(12, 25, 23, 0.86) 67%, rgba(12, 25, 23, 0.92) 100%),
      url("../assets/jianghu-game-hero-v2.jpg") 64% center / cover no-repeat;
  }

  .auth-brand {
    position: absolute;
    top: max(38px, calc(var(--safe-top) + 20px));
    left: 0;
    align-self: auto;
    padding: 0 24px;
  }

  .auth-seal {
    width: 42px;
    height: 42px;
    margin-bottom: 14px;
    font-size: 24px;
  }

  .auth-brand p {
    margin-bottom: 6px;
    font-size: 8px;
  }

  .auth-brand h1 {
    font-size: clamp(48px, 15vw, 76px);
  }

  .auth-brand strong {
    margin-top: 13px;
    font-size: clamp(17px, 5.2vw, 25px);
  }

  .auth-card {
    width: 100%;
    min-height: auto;
    justify-self: stretch;
    padding: 26px 22px max(18px, calc(var(--safe-bottom) + 14px));
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-left: 0;
    background: rgba(248, 242, 229, 0.96);
    box-shadow: 0 -18px 48px rgba(8, 17, 16, 0.28);
  }

  .auth-card-head p {
    display: none;
  }

  .auth-card-head h2 {
    font-size: 34px;
  }

  .auth-tabs {
    margin: 18px 0 18px;
  }

  #authForm {
    gap: 12px;
  }

  .auth-field {
    gap: 6px;
  }

  .auth-field input {
    height: 46px;
    line-height: 46px;
  }

  .auth-submit {
    min-height: 50px;
  }

  .auth-mode-hint {
    margin-top: 13px;
  }

  .auth-record {
    margin-top: 17px;
    font-size: 9px;
  }
}

@media (max-height: 720px) and (max-width: 760px) {
  .auth-gate {
    display: block;
  }

  .auth-brand {
    position: relative;
    top: auto;
    min-height: 210px;
    padding-top: max(24px, calc(var(--safe-top) + 14px));
  }

  .auth-brand strong {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-gate,
  .auth-tabs button::after,
  .auth-field input,
  .auth-submit {
    transition: none;
  }

  .auth-submit.is-busy b {
    animation: none;
  }
}
