:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  background: #182129;
  color: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { overscroll-behavior: none; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid #ffd166; outline-offset: 3px; }

#game-viewport {
  position: fixed;
  inset: 0;
  inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow: hidden;
}

/* 固定逻辑尺寸；适配层负责缩放、横竖屏旋转和对应的触控坐标换算。 */
#game-shell {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1334px;
  height: 750px;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: #182129;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#h5-ui { position: absolute; inset: 0; pointer-events: none; }
#h5-ui button, #h5-ui input { pointer-events: auto; }

#boot-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 80px;
  text-align: center;
  background: #182129;
  font-size: 30px;
}

#boot-status h1 { margin: 0; font-size: 60px; color: #ffd166; }
#boot-status p { margin: 0; white-space: pre-line; }
#boot-retry, .h5-dialog button {
  min-width: 160px;
  border: 0;
  border-radius: 10px;
  padding: 18px 30px;
  background: #e3aa41;
  color: #182129;
}

.h5-toast, .h5-loading {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  max-width: 1050px;
  border-radius: 12px;
  padding: 22px 36px;
  background: rgba(0, 0, 0, .86);
  color: white;
  font-size: 28px;
  text-align: center;
  white-space: pre-line;
}

.h5-toast { z-index: 30; }
.h5-loading { z-index: 20; }
.h5-mask { position: absolute; inset: 0; pointer-events: auto; background: rgba(0, 0, 0, .25); }
.h5-dialog-mask { z-index: 40; display: flex; align-items: center; justify-content: center; }
.h5-dialog {
  width: 760px;
  max-height: 670px;
  overflow: auto;
  padding: 36px;
  border: 2px solid #67737e;
  border-radius: 16px;
  background: #26323c;
  font-size: 28px;
  pointer-events: auto;
}
.h5-dialog h2 { margin: 0 0 24px; font-size: 36px; }
.h5-dialog p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.h5-dialog input { width: 100%; border: 1px solid #67737e; border-radius: 8px; padding: 18px; background: #182129; color: white; }
.h5-dialog-actions { display: flex; justify-content: flex-end; gap: 20px; margin-top: 32px; }
.h5-dialog .h5-cancel { background: #4b5b68; color: white; }
