: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);
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background: #2b2018;
  -ms-touch-action: none;
}

* {
  box-sizing: border-box;
}

body,
canvas,
div {
  display: block;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  overflow-x: hidden;
  cursor: default;
  color: #f7efd8;
  background: #2b2018;
  text-align: center;
  font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input.cocosEditBox,
textarea.cocosEditBox {
  max-width: 100%;
  margin-bottom: var(--cocos-edit-offset-y, 0px);
  margin-left: var(--cocos-edit-offset-x, 0px);
  font-size: 16px !important;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
}

canvas {
  background: transparent;
}

#AccessibilityControls {
  position: fixed;
  z-index: 1000;
  top: calc(12px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  display: flex;
  gap: 8px;
  transform: translateY(calc(-100% - 24px));
  transition: transform 0.15s ease;
}

#AccessibilityControls:focus-within {
  transform: translateY(0);
}

#AccessibilityControls button {
  min-width: 104px;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid #deaa5b;
  border-radius: 10px;
  color: #fff6da;
  background: #436f5d;
  font: 600 16px/1.2 "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

#AccessibilityControls button:focus-visible {
  outline: 3px solid #fff6da;
  outline-offset: 2px;
}

#GameStatus {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

#GameDiv,
#Cocos3dGameContainer,
#GameCanvas {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#GameDiv {
  position: absolute;
  top: 0;
  left: 0;
}

#BootScreen {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(111, 71, 30, 0.34), transparent 46%),
    #1a100a;
  opacity: 1;
  transition: opacity 0.42s ease, visibility 0.42s ease;
}

#BootScreen::before {
  position: absolute;
  z-index: 0;
  inset: -32px;
  background:
    linear-gradient(90deg, rgba(20, 12, 7, 0.62), rgba(20, 12, 7, 0.24) 38%, rgba(20, 12, 7, 0.24) 62%, rgba(20, 12, 7, 0.62)),
    url("boot-background.jpg") center / cover no-repeat;
  content: "";
  filter: blur(18px) saturate(0.72);
  opacity: 0.58;
  transform: scale(1.06);
}

#BootScreen.is-ready {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.boot-portrait {
  position: relative;
  z-index: 1;
  width: min(100%, 56.25vh);
  height: 100vh;
  overflow: hidden;
  border-right: 3px solid #6d431d;
  border-left: 3px solid #6d431d;
  background:
    linear-gradient(180deg, rgba(35, 20, 10, 0.12), rgba(17, 9, 5, 0.76)),
    url("boot-background.jpg") center / cover no-repeat;
  box-shadow: 0 0 54px rgba(0, 0, 0, 0.72);
}

.boot-portrait::before {
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(18, 10, 5, 0.64) 0%, transparent 20%, transparent 66%, rgba(17, 9, 5, 0.78) 100%),
    radial-gradient(circle at 50% 42%, rgba(255, 204, 101, 0.18), transparent 45%);
  content: "";
}

.boot-portrait::after {
  position: absolute;
  z-index: 5;
  inset: 10px;
  border: 1px solid rgba(232, 174, 77, 0.36);
  box-shadow: inset 0 0 0 3px rgba(43, 24, 12, 0.58);
  content: "";
  pointer-events: none;
}

.boot-title-plaque {
  position: absolute;
  z-index: 4;
  top: 5.5%;
  left: 50%;
  display: flex;
  width: 82%;
  min-height: 112px;
  align-items: center;
  justify-content: center;
  border: 5px solid #3a210f;
  background:
    linear-gradient(180deg, rgba(111, 69, 29, 0.94), rgba(47, 27, 14, 0.98)),
    #432714;
  box-shadow:
    0 7px 0 rgba(20, 10, 5, 0.66),
    inset 0 0 0 2px #d39842,
    inset 0 0 18px rgba(0, 0, 0, 0.52),
    0 0 28px rgba(225, 157, 58, 0.18);
  clip-path: polygon(8% 0, 92% 0, 100% 28%, 100% 72%, 92% 100%, 8% 100%, 0 72%, 0 28%);
  transform: translateX(-50%);
}

.boot-title-plaque::before {
  position: absolute;
  inset: 9px 14px;
  border: 2px solid rgba(238, 183, 85, 0.66);
  clip-path: inherit;
  content: "";
}

.boot-game-title {
  position: relative;
  z-index: 1;
  color: #ffe0a0;
  font: 700 clamp(24px, 7.2vh, 58px)/1 "STKaiti", "KaiTi", "Microsoft YaHei", serif;
  letter-spacing: 0.08em;
  text-shadow: 0 3px 0 #4f2a12, 0 0 12px rgba(255, 211, 119, 0.3);
}

.boot-game-kicker {
  position: absolute;
  z-index: 1;
  bottom: -30px;
  left: 50%;
  width: 100%;
  color: #e6bd6d;
  font: 600 15px/1.3 "STKaiti", "KaiTi", "Microsoft YaHei", serif;
  letter-spacing: 0.2em;
  text-shadow: 0 2px 3px rgba(24, 12, 5, 0.94);
  transform: translateX(-50%);
}

.boot-characters {
  position: absolute;
  z-index: 3;
  top: 28%;
  left: 50%;
  width: 104%;
  height: auto;
  filter: drop-shadow(0 16px 14px rgba(23, 12, 5, 0.58));
  pointer-events: none;
  transform: translateX(-50%);
}

.boot-loading-panel {
  position: absolute;
  z-index: 4;
  right: 10%;
  bottom: 8.5%;
  left: 10%;
  display: flex;
  min-height: 118px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 3px solid #3b2212;
  border-radius: 8px;
  color: #f9d890;
  background: linear-gradient(180deg, rgba(62, 35, 18, 0.96), rgba(30, 17, 10, 0.98));
  box-shadow: inset 0 0 0 1px #c68a38, 0 7px 16px rgba(0, 0, 0, 0.45);
}

.boot-loading-title {
  font: 700 26px/1.2 "STKaiti", "KaiTi", "Microsoft YaHei", serif;
  letter-spacing: 0.16em;
}

.boot-loading-copy {
  margin-top: 6px;
  color: #cfa967;
  font: 15px/1.2 "Microsoft YaHei", sans-serif;
  letter-spacing: 0.08em;
}

.boot-progress {
  position: relative;
  width: 72%;
  height: 10px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid #8d5d27;
  border-radius: 999px;
  background: #160d08;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
}

.boot-progress i {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: -42%;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #e2a23d 24%, #fff0a2 62%, #b86c20 100%);
  box-shadow: 0 0 12px rgba(255, 196, 76, 0.66);
  animation: boot-progress 1.2s ease-in-out infinite;
}

#BootScreen.is-error .boot-loading-panel {
  border-color: #52251b;
  box-shadow: inset 0 0 0 1px #b45737, 0 7px 16px rgba(0, 0, 0, 0.45);
}

#BootScreen.is-error .boot-progress i {
  width: 100%;
  animation: none;
  background: #9b3d2f;
}

@keyframes boot-progress {
  0% { left: -42%; }
  62%, 100% { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  #BootScreen,
  #AccessibilityControls {
    transition: none;
  }

  .boot-progress i {
    left: 20%;
    width: 60%;
    animation: none;
    box-shadow: none;
  }
}

textarea[id^="EditBoxId_"] {
  overflow: hidden !important;
}
