:root {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e8dec9;
  background: #191e1c;
  font-size: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
h1,
h2,
p {
  margin: 0;
}
h1,
h2 {
  font-family: "Songti SC", serif;
  font-weight: 500;
}
h1 {
  font-size: 26px;
  margin-bottom: 20px;
}
h1 small {
  display: block;
  font: 12px sans-serif;
  color: #b7b69f;
  margin-top: 6px;
}
.stage {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: radial-gradient(ellipse at center, #324237, #171e1a);
}
#arena {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
.stage img { -webkit-user-drag: none; }
.hud {
  position: absolute;
}
.stage.player-dead {
  filter: grayscale(1);
}
#targetNotice {
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 20px;
  text-align: center;
  font-size: 18px;
  color: #fff0ac;
  background: #15221cee;
  border: 1px solid #d6bb7e;
  pointer-events: none;
  z-index: 6;
}
#deathNotice {
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 5;
  padding: 24px 36px;
  background: #101511dd;
  border: 1px solid #b7b69f;
}
#deathNotice h2 {
  font-size: 30px;
  margin-bottom: 10px;
}
#deathNotice p {
  font-size: 14px;
}
.topline {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(34vw, 440px);
  text-align: center;
  pointer-events: none;
}
.boss-hp span {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
}
progress {
  width: 100%;
  height: 7px;
  accent-color: #bd7552;
}
#clock {
  display: block;
  margin-top: 5px;
  color: #d6bb7e;
  font: 12px monospace;
}
button,
select,
input {
  font: inherit;
  color: inherit;
  background: #29372eee;
  border: 1px solid #626751;
  border-radius: 2px;
  padding: 10px 12px;
  cursor: pointer;
}
button:hover {
  background: #424c3f;
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid #ddc17b;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
.entry {
  right: 24px;
  top: 24px;
  width: 240px;
}
#showLog {
  float: right;
  clear: right;
  margin-top: 8px;
}
#logMenu {
  width: min(800px, calc(100vw - 32px));
}
#fullLog {
  max-height: 55dvh;
  overflow: auto;
  white-space: pre-wrap;
  font: 12px/1.8 monospace;
}
#setup {
  padding: 48px;
}
#entryMenu {
  width: min(560px, calc(100vw - 32px));
  text-align: center;
}
.entry-eyebrow {
  color: #b7b69f;
  font-size: 13px;
  letter-spacing: 3px;
  margin-bottom: 12px;
}
#entryTitle {
  font-size: 38px;
  margin-bottom: 32px;
}
#start {
  display: block;
  width: 100%;
  margin-top: 32px;
  padding: 14px;
  color: #f0dfb7;
  border-color: #a5956a;
  font-size: 18px;
}
#setup label {
  display: block;
  margin-bottom: 8px;
}
select {
  width: 100%;
}
#assignment {
  color: #c3c9b4;
  font-size: 12px;
  line-height: 1.8;
  margin-top: 12px;
}
.contact-note {
  margin-top: 16px;
  color: #d6c697;
  font-size: 13px;
  line-height: 1.6;
}
#pause {
  float: right;
  min-width: 120px;
}
.notice {
  top: 136px;
  left: 50%;
  transform: translateX(-50%);
  width: min(50vw, 620px);
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 5px #000;
}
.notice h2 {
  color: #ead69d;
  font-size: 25px;
  margin-bottom: 5px;
}
.notice p {
  font-size: 12px;
  line-height: 1.6;
  color: #c3c9b4;
}
.raid {
  bottom: 24px;
  left: 24px;
  width: 280px;
  pointer-events: none;
}
.raid-title {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 8px;
}
#party {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.team-column {
  display: grid;
  gap: 4px;
}
.team-heading {
  font-size: 11px;
  color: #d5c49a;
  margin-bottom: 2px;
}
.member {
  background: #224f78ed;
  color: #eaf3ff;
  border: 1px solid #3c739c;
  padding: 6px 8px;
  font-size: 12px;
  min-width: 0;
}
.member.you {
  outline: 1px solid #f3d995;
  outline-offset: 1px;
}
.member span {
  display: flex;
  justify-content: space-between;
  gap: 3px;
}
.member b {
  font-size: 10px;
  font-weight: normal;
}
.member progress {
  display: block;
  height: 4px;
  margin-top: 5px;
  accent-color: #70b9ee;
}
.member.healer {
  background: #286245ed;
  border-color: #468560;
}
.member.healer progress {
  accent-color: #8be0a6;
}
.member.dead {
  opacity: 0.55;
}
#rescue {
  font-size: 11px;
  margin-top: 8px;
  color: #c3c9b4;
}
.keys {
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  white-space: nowrap;
  color: #afb6a8;
  font-size: 11px;
  pointer-events: none;
}
kbd {
  color: #e4d8b5;
}
#victoryBanner {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #0d130e80 0%, transparent 65%);
}
#victoryBanner img {
  width: min(850px, 92vw);
  height: auto;
  filter: drop-shadow(0 3px 14px #fff4bc55) drop-shadow(0 6px 6px #0008);
}
#victoryText {
  font-family: "Kaiti SC", "STKaiti", "Songti SC", serif;
  font-size: clamp(44px, 12vw, 128px);
  color: #fffcef;
  text-shadow: 0 3px 14px #fff4bc55, 0 6px 6px #0008;
}
dialog {
  border: 1px solid #a5956a;
  padding: 0;
  color: #e8dec9;
  background: #202a24;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
}
dialog::backdrop {
  background: #101511aa;
  backdrop-filter: blur(3px);
}
.menu-panel {
  padding: 30px;
}
.menu-panel h2 {
  font-size: 28px;
  margin-bottom: 12px;
}
.menu-panel p {
  line-height: 1.8;
  margin-bottom: 12px;
}
.menu-actions {
  display: flex;
  gap: 12px;
  margin: 24px 0 12px;
}
.muted,
details {
  font-size: 12px;
  color: #b3bca9;
}
details {
  margin-top: 24px;
  line-height: 1.8;
}
summary {
  cursor: pointer;
  color: #dcc993;
}
details label {
  display: block;
  margin: 12px 0 5px;
}
input {
  width: 100%;
}
#log {
  list-style: none;
  padding: 0;
  max-height: 140px;
  overflow: auto;
}
#log time {
  color: #ae9864;
  margin-right: 8px;
}
.touch {
  display: none;
  right: 16px;
  bottom: 16px;
  gap: 5px;
}
/* Apply directly to controls and their text: do not rely on ancestor
   user-select rules to suppress native long-press callouts in WebViews. */
[data-action],
[data-action] *,
#joystickZone,
#joystickZone * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  touch-action: none;
}
[data-action] * {
  pointer-events: none;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1100px) {
  .keys {
    left: auto;
    right: 20px;
    transform: none;
    gap: 9px;
    max-width: calc(100% - 40px);
    flex-wrap: wrap;
    justify-content: center;
  }
  .entry {
    width: 200px;
  }
  .raid {
    width: 248px;
  }
}
@media (max-width: 600px) {
  .entry {
    right: 12px;
    top: 12px;
    width: 164px;
  }
  #setup {
    padding: 28px 24px;
  }
  h1 {
    font-size: 22px;
  }
  .topline {
    left: 16px;
    transform: none;
    width: 38vw;
  }
  .notice {
    top: 126px;
    left: 12px;
    transform: none;
    width: 46vw;
  }
  .notice h2 {
    font-size: 20px;
  }
  .raid {
    left: 12px;
    bottom: 68px;
    width: 230px;
  }
  .keys {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: none;
    gap: 5px 10px;
    line-height: 16px;
  }
}
/* Touch controls occupy the side lanes, leaving the arena clear. */
.home-screen-help, #fullscreenStatus { margin-top: 12px; font-size: 12px; line-height: 1.6; color: #c3c9b4; }
.touch-speed { display: none; }
#mechanicControls { display: flex; gap: 6px; clear: both; padding-top: 8px; justify-content: flex-end; }
/* Compact keyboard/mouse windows, including desktop WeChat's narrow viewer. */
@media (max-width: 760px) {
  .entry {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 180px;
    gap: 6px;
  }
  .entry button {
    min-width: 0;
    min-height: 36px;
    padding: 7px 4px;
    font-size: 12px;
    white-space: nowrap;
  }
  .entry #pause { min-width: 0; float: none; }
  .entry #showLog { margin: 0; float: none; }
  .entry #mechanicControls {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 0;
  }
  .raid { width: 184px; }
  .raid-title { font-size: 10px; margin-bottom: 4px; }
  #party { gap: 5px; }
  .team-column { gap: 3px; }
  .team-heading { font-size: 10px; margin-bottom: 1px; }
  .member { padding: 3px 4px; font-size: 10px; }
  .member b { font-size: 9px; }
  .member progress { height: 3px; margin-top: 3px; }
  #rescue { font-size: 9px; margin-top: 5px; }
}
@media (max-width: 600px) {
  .entry { width: 164px; }
  .raid { width: 168px; }
  .topline { top: 12px; }
  .boss-hp span { font-size: 15px; }
  #clock { font-size: 10px; }
  .notice { top: 112px; width: calc(100% - 24px); }
  .notice h2 { font-size: 18px; }
  .notice p { font-size: 11px; }
  .keys { font-size: 10px; }
}
@media (any-pointer: coarse) {
  .keys { display: none; }
  .touch {
    display: block;
    inset: 0;
    max-width: none;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  #joystickZone {
    position: absolute;
    inset: 0 auto 0 0;
    width: 45%;
    pointer-events: auto;
    touch-action: none;
  }
  #joystick {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%);
    visibility: hidden;
    width: clamp(100px, 29dvh, 136px);
    aspect-ratio: 1;
    border: 1px solid #b8b08c80;
    border-radius: 50%;
    background: #15221c99;
    box-shadow: inset 0 0 0 12px #b8b08c0c;
    pointer-events: none;
    touch-action: none;
  }
  .joystick-cross::before, .joystick-cross::after {
    content: "";
    position: absolute;
    background: #b8b08c35;
    top: 50%; left: 15%; width: 70%; height: 1px;
  }
  .joystick-cross::after { transform: rotate(90deg); }
  #joystickKnob {
    position: absolute;
    left: 50%; top: 50%;
    width: 42%; aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #65705bef;
    border: 1px solid #e5d4a1;
    box-shadow: 0 3px 12px #0006;
    pointer-events: none;
  }
  #joystick.active { visibility: visible; border-color: #e5d4a1; }
  .touch-actions {
    position: absolute;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 152px;
    height: 144px;
    pointer-events: auto;
  }
  .touch-actions button {
    position: absolute;
    width: 64px;
    aspect-ratio: 1;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #bdac7d;
    background: #29372eee;
    font-size: 17px;
    font-weight: 600;
  }
  .touch-actions button[data-action="shift"] { right: 0; top: 0; }
  .touch-actions button[data-action="e"] { left: 0; top: 40px; }
  .touch-actions button[data-action="1"] { right: 0; bottom: 0; }
  .touch-actions small { display: block; margin-top: 3px; font-size: 10px; font-weight: 400; color: #c3c9b4; }
  .touch-actions button.active { background: #697152; box-shadow: 0 0 0 4px #ddc17b30; }
  .topline { top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 32vw; }
  .boss-hp span { font-size: 14px; line-height: 20px; }
  .boss-hp progress { display: block; height: 4px; margin-top: 4px; }
  #clock { font-size: 10px; line-height: 14px; margin-top: 4px; }
  .entry { top: max(8px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 152px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .entry button { min-width: 0; min-height: 44px; padding: 8px 4px; font-size: 12px; white-space: nowrap; }
  #pause { min-width: 0; float: none; }
  #mechanicControls { grid-column: 1 / -1; padding: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .touch-speed { display: block; grid-column: 1 / -1; touch-action: none; user-select: none; -webkit-user-select: none; }
  .touch-speed.active { background: #697152; }
  #showLog { margin: 0; }
  .notice { top: 65px; left: 50%; transform: translateX(-50%); width: 48vw; }
  .notice h2 { font-size: 17px; margin-bottom: 2px; }
  .notice p { font-size: 11px; line-height: 1.4; }
  .raid {
    left: max(12px, env(safe-area-inset-left));
    top: max(10px, env(safe-area-inset-top));
    bottom: auto;
    width: 156px;
  }
  .raid-title { font-size: 10px; margin-bottom: 3px; }
  #party { gap: 5px; }
  .team-column { gap: 2px; }
  .team-heading { font-size: 9px; margin: 0; }
  .member { padding: 2px 3px; font-size: 10px; }
  .member b { font-size: 9px; }
  .member progress { height: 3px; margin-top: 2px; }
  #rescue { font-size: 9px; margin-top: 4px; }
  #setup { padding: 20px 28px; }
  #entryTitle { font-size: 28px; margin-bottom: 16px; }
  #start { margin-top: 16px; padding: 10px; }
  .menu-panel { padding: 20px; }
  #deathNotice { padding: 12px 18px; }
  #deathNotice h2 { font-size: 22px; }
}
@media (any-pointer: coarse) and (max-height: 360px) {
  .touch-actions { width: 136px; height: 124px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .touch-actions button { width: 56px; font-size: 15px; }
  .touch-actions button[data-action="e"] { top: 34px; }
  .raid { width: 144px; }
  .member { padding: 1px 3px; font-size: 9px; }
  .member progress { margin-top: 1px; height: 2px; }
  .raid-title, .team-heading, #rescue { font-size: 8px; }
}
@media (any-pointer: coarse) and (orientation: portrait) {
  .topline { top: 180px; width: 72vw; }
  .notice { top: 240px; width: 86vw; }
}
