:root {
  color-scheme: dark;
  --ink: #eaf2df;
  --muted: #a9b7a5;
  --gold: #e9c768;
  --gold-bright: #ffe29a;
  --moss: #7fbf74;
  --teal: #69d7cc;
  --danger: #e5574f;
  --danger-bright: #ff8175;
  --panel: rgba(12, 21, 18, 0.82);
  --panel-solid: #111d19;
  --line: rgba(225, 239, 200, 0.16);
  --shadow: 0 14px 50px rgba(0, 0, 0, 0.45);
  font-family:
    Inter, "Noto Sans SC", "Microsoft YaHei UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0c1512;
  color: var(--ink);
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.mobile-only,
.touch-control-guide {
  display: none;
}

#game-root,
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  cursor: default;
  outline: none;
  filter: brightness(1.025) saturate(0.93);
}

.hidden {
  display: none !important;
}

.screen-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 62%, rgba(28, 49, 50, 0.08) 86%, rgba(22, 37, 42, 0.2)),
    linear-gradient(180deg, rgba(123, 177, 196, 0.05), transparent 28%, transparent 82%, rgba(33, 54, 46, 0.11));
}

#hit-flash {
  position: fixed;
  inset: 0;
  z-index: 14;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(255, 247, 215, 0.38), transparent 44%),
    rgba(255, 88, 70, 0.16);
  mix-blend-mode: screen;
}

#hit-flash.active {
  animation: hit-flash 170ms ease-out;
}

@keyframes hit-flash {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

#damage-direction {
  --hit-angle: 0rad;
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 15;
  width: 178px;
  height: 178px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(var(--hit-angle));
}

#damage-direction span {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 58px;
  height: 13px;
  transform: translateX(-50%);
  border-top: 5px solid #ff5549;
  border-radius: 50%;
  filter: drop-shadow(0 0 6px rgba(255, 45, 35, 0.95));
}

#damage-direction span::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  border-right: 7px solid transparent;
  border-bottom: 8px solid #ff6b5f;
  border-left: 7px solid transparent;
  transform: translateX(-50%);
}

#damage-direction.active {
  animation: damage-direction 520ms ease-out;
}

@keyframes damage-direction {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--hit-angle)) scale(0.82);
  }
  45% {
    opacity: 0.96;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--hit-angle)) scale(1.08);
  }
}

#critical-vignette {
  --danger-strength: 0;
  --danger-opacity: 0.42;
  --danger-blur: 80px;
  --danger-period: 1.18s;
  position: fixed;
  inset: 0;
  z-index: 13;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

#critical-vignette::before {
  position: absolute;
  inset: -4%;
  border: 2px solid rgba(255, 50, 41, 0.42);
  box-shadow:
    inset 0 0 var(--danger-blur) rgba(126, 0, 8, 0.68),
    inset 0 0 22px rgba(255, 58, 42, 0.32);
  background:
    radial-gradient(circle at center, transparent 48%, rgba(90, 0, 5, 0.08) 68%, rgba(111, 0, 8, 0.48) 100%),
    linear-gradient(90deg, rgba(94, 0, 7, 0.16), transparent 20%, transparent 80%, rgba(94, 0, 7, 0.16));
  content: "";
}

#critical-vignette > div {
  position: absolute;
  bottom: 21%;
  left: 50%;
  display: grid;
  gap: 2px;
  min-width: 250px;
  padding: 7px 22px 8px;
  border-top: 1px solid rgba(255, 105, 86, 0.7);
  border-bottom: 1px solid rgba(255, 105, 86, 0.24);
  color: #ffd8cd;
  background: linear-gradient(90deg, transparent, rgba(82, 0, 5, 0.68) 25%, rgba(82, 0, 5, 0.68) 75%, transparent);
  text-align: center;
  text-shadow: 0 2px 8px #210000;
  transform: translateX(-50%);
}

#critical-vignette strong {
  color: #ff6b5e;
  font-size: 15px;
  letter-spacing: 0.28em;
}

#critical-vignette span {
  font-size: 9px;
  letter-spacing: 0.06em;
  opacity: 0.86;
}

#critical-vignette.active {
  opacity: var(--danger-opacity);
  animation: critical-vignette-pulse var(--danger-period) ease-in-out infinite;
}

@keyframes critical-vignette-pulse {
  0%,
  100% {
    filter: saturate(0.9);
  }
  14% {
    filter: saturate(1.4) brightness(1.16);
  }
  28% {
    filter: saturate(1);
  }
  42% {
    filter: saturate(1.3) brightness(1.1);
  }
}

#join-screen {
  overflow: auto;
  background:
    linear-gradient(105deg, rgba(8, 15, 12, 0.92), rgba(8, 15, 12, 0.52) 50%, rgba(8, 15, 12, 0.82)),
    radial-gradient(circle at 66% 45%, rgba(214, 163, 65, 0.14), transparent 35%);
  backdrop-filter: blur(4px);
}

.join-card {
  position: relative;
  width: min(580px, 100%);
  padding: 42px 42px 32px;
  border: 1px solid rgba(239, 215, 143, 0.28);
  border-radius: 5px 28px 5px 28px;
  background:
    linear-gradient(145deg, rgba(31, 47, 38, 0.94), rgba(10, 18, 15, 0.95)),
    var(--panel-solid);
  box-shadow: var(--shadow), inset 0 0 70px rgba(189, 145, 52, 0.045);
}

.join-card::before,
.join-card::after {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  pointer-events: none;
}

.join-card::before {
  top: 10px;
  left: 10px;
  border-top: 1px solid rgba(235, 204, 123, 0.62);
  border-left: 1px solid rgba(235, 204, 123, 0.62);
}

.join-card::after {
  right: 10px;
  bottom: 10px;
  border-right: 1px solid rgba(235, 204, 123, 0.36);
  border-bottom: 1px solid rgba(235, 204, 123, 0.36);
}

.crest {
  position: absolute;
  top: -35px;
  left: 50%;
  width: 74px;
  height: 74px;
  transform: translateX(-50%) rotate(45deg);
  border: 1px solid rgba(233, 199, 104, 0.55);
  background: #16241e;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.36);
}

.crest-ring {
  position: absolute;
  inset: 17px;
  border: 4px solid var(--gold);
  border-radius: 50%;
}

.crest-blade {
  position: absolute;
  top: 12px;
  left: 34px;
  width: 5px;
  height: 50px;
  border-radius: 5px 5px 1px 1px;
  background: var(--gold-bright);
  box-shadow: 0 0 12px rgba(255, 226, 154, 0.35);
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.join-card h1 {
  margin: 10px 0 2px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(48px, 8vw, 76px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.12em;
  text-shadow: 0 5px 24px rgba(0, 0, 0, 0.5);
}

.join-subtitle {
  margin: 8px 0 30px;
  color: var(--muted);
  letter-spacing: 0.14em;
}

#join-form label {
  display: block;
  margin: 0 0 8px;
  color: #dbe5d3;
  font-size: 13px;
  font-weight: 700;
}

.join-row {
  display: flex;
  gap: 10px;
}

#player-name {
  min-width: 0;
  flex: 1;
  height: 52px;
  padding: 0 16px;
  border: 1px solid rgba(223, 236, 208, 0.2);
  border-radius: 3px;
  outline: none;
  color: var(--ink);
  background: rgba(2, 8, 6, 0.55);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.18);
}

#player-name:focus {
  border-color: rgba(233, 199, 104, 0.75);
  box-shadow: 0 0 0 3px rgba(233, 199, 104, 0.09);
}

.primary-button {
  position: relative;
  min-width: 150px;
  border: 1px solid rgba(255, 235, 171, 0.45);
  border-radius: 3px 14px 3px 14px;
  overflow: hidden;
  cursor: pointer;
  color: #1b2119;
  background: linear-gradient(135deg, #f2d77d, #c89b3c);
  font-weight: 900;
  letter-spacing: 0.08em;
  transition: transform 120ms ease, filter 120ms ease;
}

.primary-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.45);
  opacity: 0.72;
}

.connection-copy {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.connection-copy.error {
  color: var(--danger-bright);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.control-grid div {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 8px 4px;
  border: 1px solid rgba(224, 238, 207, 0.08);
  background: rgba(255, 255, 255, 0.018);
}

kbd {
  min-width: 34px;
  padding: 4px 7px;
  border: 1px solid rgba(236, 218, 156, 0.34);
  border-radius: 4px;
  color: var(--gold-bright);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.control-grid span {
  color: var(--muted);
  font-size: 10px;
}

.join-note {
  margin: 18px 0 0;
  color: #b8c4b4;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.lore-brief {
  margin-top: 12px;
  border: 1px solid rgba(235, 204, 123, 0.16);
  background: rgba(217, 184, 105, 0.035);
  color: #b8c4b4;
  font-size: 11px;
  line-height: 1.65;
}

.lore-brief summary {
  padding: 10px 12px;
  color: #d9c989;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.12em;
  list-style-position: inside;
}

.lore-brief[open] summary {
  border-bottom: 1px solid rgba(235, 204, 123, 0.12);
}

.lore-brief p {
  margin: 0;
  padding: 10px 12px 0;
}

.lore-brief p:last-child {
  padding-bottom: 12px;
}

#panel-shortcuts {
  position: absolute;
  top: 52%;
  right: 18px;
  display: grid;
  gap: 7px;
  transform: translateY(-50%);
  pointer-events: auto;
}

#panel-shortcuts button {
  min-width: 76px;
  padding: 8px 10px;
  border: 1px solid rgba(233, 199, 104, 0.24);
  border-radius: 3px 10px 3px 10px;
  cursor: pointer;
  color: #dfe7da;
  background: rgba(7, 14, 11, 0.76);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  font-size: 10px;
}

#panel-shortcuts button:hover {
  border-color: rgba(233, 199, 104, 0.5);
  background: rgba(27, 42, 34, 0.92);
}

#panel-shortcuts kbd {
  margin-right: 5px;
  color: var(--gold-bright);
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.top-hud {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 22px;
  right: 22px;
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(430px, 1.55fr) minmax(285px, 0.86fr);
  align-items: start;
  gap: 18px;
}

.hud-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(115deg, rgba(29, 45, 37, 0.86), rgba(9, 17, 14, 0.74)),
    var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(7px);
}

.objective-panel {
  position: relative;
  padding: 14px 16px 12px;
  border-radius: 3px 14px 3px 14px;
}

.objective-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 3px;
  height: calc(100% + 2px);
  background: var(--gold);
  box-shadow: 0 0 10px rgba(233, 199, 104, 0.45);
}

.objective-panel h2 {
  margin: 5px 0 4px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 20px;
  letter-spacing: 0.04em;
}

#objective-detail {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.objective-progress {
  height: 3px;
  margin-top: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.objective-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #82c77d, var(--gold));
  transition: width 300ms ease;
}

#boss-stack {
  grid-column: 2;
  width: 100%;
  max-width: 760px;
  justify-self: center;
}

.boss-bar {
  position: relative;
  margin-bottom: 7px;
  padding: 11px 15px 13px;
  border: 1px solid rgba(241, 213, 157, 0.24);
  border-radius: 3px 16px 3px 16px;
  overflow: hidden;
  background: rgba(12, 12, 14, 0.78);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
}

.boss-bar.active {
  border-color: rgba(255, 108, 92, 0.72);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42), 0 0 22px rgba(213, 71, 61, 0.16);
  animation: boss-bar-enter 260ms ease-out;
}

@keyframes boss-bar-enter {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

.boss-bar.defeated {
  filter: grayscale(0.86);
  opacity: 0.58;
}

.boss-bar-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  font-size: 12px;
}

.boss-bar-header strong {
  font-family: "STKaiti", "KaiTi", serif;
  color: #fff0dc;
  font-size: 20px;
  letter-spacing: 0.08em;
}

.boss-bar-header span {
  color: #c7c9c2;
}

.boss-track {
  position: relative;
  z-index: 2;
  height: 13px;
  margin-top: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.boss-track > span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #8e2029, #e35446 68%, #ffad66);
  box-shadow: 0 0 12px rgba(230, 72, 60, 0.42);
  transition: width 180ms ease;
}

.boss-cast {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  color: #ffd4a8;
  font-size: 10px;
}

.boss-cast > strong {
  letter-spacing: 0.08em;
  text-shadow: 0 0 10px rgba(255, 92, 75, 0.7);
}

.boss-cast > span {
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.boss-cast i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffca6f, #ff564f);
  box-shadow: 0 0 10px rgba(255, 78, 65, 0.8);
}

.team-panel {
  grid-column: 3;
  min-width: 285px;
  max-width: 350px;
  justify-self: end;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
  color: #dce7d8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #86d788;
  font-size: 9px;
  font-weight: 600;
}

.connection-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.connection-state.warn {
  color: #f2bd63;
}

.connection-state.error {
  color: #ff7166;
}

#team-list {
  display: grid;
  max-height: min(64vh, 540px);
  gap: 3px;
  padding: 5px;
  overflow: auto;
}

.team-member {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 5px 7px;
  border-left: 2px solid transparent;
  background: rgba(255, 255, 255, 0.022);
}

.team-member.local {
  border-left-color: var(--gold);
  background: rgba(233, 199, 104, 0.08);
}

.team-member.dead {
  filter: grayscale(0.8);
  opacity: 0.52;
}

.team-emblem {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: #182019;
  background: var(--member-color, #89c790);
  font-size: 9px;
  font-weight: 900;
}

.team-copy {
  min-width: 0;
}

.team-copy strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-member-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.team-member-heading strong {
  min-width: 0;
}

.team-role {
  flex: none;
  color: var(--gold);
  font-size: 8px;
}

.team-health {
  position: relative;
  height: 7px;
  margin-top: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.team-health span {
  display: block;
  height: 100%;
  background: #6cc271;
}

.team-health em {
  position: absolute;
  top: -2px;
  right: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 7px;
  font-style: normal;
  line-height: 7px;
  text-shadow: 0 1px 2px #000;
}

.team-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  color: #82948a;
  font-size: 7px;
}

.team-level {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 9px;
}

.team-level[data-shield]::after {
  content: attr(data-shield);
  color: #9fdaf3;
  font-size: 7px;
}

#compass {
  position: absolute;
  top: 190px;
  left: 50%;
  display: flex;
  width: 200px;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transform: translateX(-50%);
  color: rgba(231, 239, 224, 0.55);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 4px #000;
}

#compass::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  width: 1px;
  height: 20px;
  background: var(--gold);
  box-shadow: 0 0 7px var(--gold);
}

#compass-heading {
  color: var(--gold-bright);
  font-size: 12px;
}

#world-time {
  position: absolute;
  top: 24px;
  left: 50%;
  min-width: 112px;
  transform: translateX(-50%);
  color: rgba(230, 224, 195, 0.84);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  transition: color 900ms ease, text-shadow 900ms ease;
}

#world-time[data-period="黎明"],
#world-time[data-period="黄昏"] {
  color: #ffc48c;
  text-shadow: 0 0 9px rgba(255, 128, 75, 0.46);
}

#world-time[data-period="深夜"],
#world-time[data-period="夜晚"] {
  color: #a9c8ff;
  text-shadow: 0 0 9px rgba(92, 137, 232, 0.44);
}

.compass-mark {
  width: 1px;
  height: 5px;
  background: currentColor;
}

#interaction-prompt,
#pointer-hint {
  position: absolute;
  left: 50%;
  min-width: 240px;
  padding: 9px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(239, 219, 157, 0.24);
  border-radius: 3px;
  color: #eef3e9;
  background: rgba(8, 14, 12, 0.82);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.32);
  font-size: 12px;
  text-align: center;
  backdrop-filter: blur(6px);
}

#interaction-prompt {
  top: 59%;
}

#interaction-prompt kbd {
  margin-right: 8px;
}

#pointer-hint {
  bottom: 148px;
  color: var(--gold-bright);
}

#event-feed {
  position: absolute;
  right: 26px;
  bottom: 166px;
  display: flex;
  width: min(350px, 40vw);
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#chat-box {
  position: absolute;
  bottom: 154px;
  left: 25px;
  z-index: 13;
  display: flex;
  width: min(390px, 34vw);
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

#chat-messages {
  display: flex;
  max-height: 196px;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  overflow: hidden;
}

.chat-message {
  width: fit-content;
  max-width: 100%;
  padding: 5px 9px;
  border-left: 2px solid color-mix(in srgb, var(--chat-color, var(--gold)) 70%, transparent);
  border-radius: 2px 9px 2px 2px;
  color: #e4ece0;
  background: linear-gradient(90deg, rgba(7, 15, 12, 0.88), rgba(7, 15, 12, 0.58));
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.16);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  animation: feed-in 160ms ease-out;
  transition: opacity 600ms ease;
}

.chat-message.history,
.chat-message.aged {
  opacity: 0.55;
}

.chat-name {
  margin-right: 4px;
  color: var(--chat-color, var(--gold-bright));
  font-weight: 900;
}

#chat-form {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

#chat-input {
  min-width: 0;
  flex: 1;
  padding: 9px 11px;
  border: 1px solid rgba(233, 199, 104, 0.48);
  border-radius: 3px 10px 3px 10px;
  outline: none;
  color: #edf3e8;
  background: rgba(8, 16, 13, 0.94);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  user-select: text;
}

#chat-input:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(233, 199, 104, 0.12), 0 10px 28px rgba(0, 0, 0, 0.32);
}

#chat-send {
  padding: 8px 13px;
  border: 1px solid rgba(233, 199, 104, 0.45);
  border-radius: 3px 10px 3px 10px;
  cursor: pointer;
  color: #1a211a;
  background: var(--gold);
  font-size: 10px;
  font-weight: 900;
}

#chat-hint {
  align-self: flex-start;
  padding: 3px 7px;
  color: rgba(221, 231, 216, 0.52);
  background: rgba(7, 14, 11, 0.48);
  font-size: 8px;
}

#chat-box.input-open #chat-hint {
  display: none;
}

.feed-line {
  max-width: 100%;
  padding: 7px 10px;
  overflow: hidden;
  border-right: 2px solid var(--feed-color, var(--gold));
  color: #dfe9dc;
  background: linear-gradient(90deg, transparent, rgba(8, 14, 12, 0.76) 20%);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: feed-in 180ms ease-out;
}

@keyframes feed-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
}

#player-vitals {
  position: absolute;
  bottom: 28px;
  left: 25px;
  width: min(320px, 27vw);
  padding: 11px 14px 12px;
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, rgba(6, 12, 10, 0.86), rgba(6, 12, 10, 0.28));
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
}

#damage-status {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 9px);
  padding: 5px 9px;
  border-right: 3px solid #ff5147;
  color: #ffd7d1;
  background: linear-gradient(90deg, transparent, rgba(69, 4, 6, 0.9));
  font-size: 13px;
  opacity: 0;
  text-shadow: 0 1px 3px #000;
  transform: translateY(6px);
  pointer-events: none;
}

#damage-status.active {
  animation: damage-status 1.2s ease-out;
}

@keyframes damage-status {
  0%,
  55% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-9px);
  }
}

#player-vitals.damaged {
  animation: vitals-damaged 420ms ease-out;
}

#player-vitals.damaged .health-bar {
  box-shadow: 0 0 18px rgba(255, 57, 48, 0.95);
}

@keyframes vitals-damaged {
  0%,
  28% {
    border-left-color: #ff4338;
    background: linear-gradient(90deg, rgba(92, 8, 8, 0.96), rgba(40, 4, 4, 0.42));
    transform: translateX(-7px);
  }
  14%,
  42% {
    transform: translateX(7px);
  }
  100% {
    border-left-color: var(--gold);
    transform: translateX(0);
  }
}

#player-vitals.critical-health:not(.damaged) {
  border-left-color: #ff4b42;
  animation: critical-health 1.1s ease-in-out infinite alternate;
}

@keyframes critical-health {
  from {
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
  }
  to {
    filter: drop-shadow(0 0 13px rgba(255, 49, 42, 0.65));
  }
}

.identity-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
}

#player-level {
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
}

#player-nameplate {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#player-role {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
}

.bar {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
}

.bar > span {
  display: block;
  width: 100%;
  height: 100%;
  transition: width 160ms ease;
}

.health-bar {
  height: 15px;
  border: 1px solid rgba(255, 218, 203, 0.16);
  transform: skewX(-10deg);
}

.health-bar > span {
  background: linear-gradient(90deg, #781f29, #d7473f 70%, #eb6b52);
  box-shadow: inset 0 0 10px rgba(255, 171, 124, 0.17);
}

#player-vitals.safe-healing .health-bar > span {
  background: linear-gradient(90deg, #27744d, #58c982 72%, #9be7a9);
  box-shadow: inset 0 0 10px rgba(210, 255, 221, 0.24), 0 0 9px rgba(91, 222, 143, 0.32);
}

.health-bar em {
  position: absolute;
  inset: 0;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  line-height: 13px;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  transform: skewX(10deg);
}

.stamina-bar {
  width: 72%;
  height: 5px;
  margin-top: 4px;
}

.stamina-bar > span {
  background: linear-gradient(90deg, #4e9056, #a6e06e);
}

.xp-bar {
  width: 88%;
  height: 2px;
  margin-top: 5px;
}

.xp-bar > span {
  background: var(--gold);
}

#resource-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 7px;
  color: #aebbae;
  font-size: 8px;
}

#resource-strip span:first-child {
  color: var(--gold);
}

#resource-strip b {
  margin-left: 2px;
  color: #edf1e8;
  font-size: 9px;
}

#active-buffs {
  display: flex;
  flex-wrap: wrap;
  min-height: 0;
  gap: 4px;
  margin-top: 6px;
}

.active-buff-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 3px;
  border: 1px solid color-mix(in srgb, var(--buff-color) 58%, transparent);
  border-radius: 12px;
  color: #eef6eb;
  background: color-mix(in srgb, var(--buff-color) 15%, rgba(5, 11, 9, 0.9));
  box-shadow: 0 0 10px color-mix(in srgb, var(--buff-color) 20%, transparent);
  font-size: 8px;
}

.active-buff-chip b {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--buff-color);
  font-size: 9px;
}

.active-buff-chip em,
.active-buff-chip i {
  font-style: normal;
}

.active-buff-chip i {
  color: var(--buff-color);
  font-weight: 900;
}

.safe-zone-chip.healing {
  animation: safe-heal-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes safe-heal-pulse {
  to {
    box-shadow: 0 0 14px color-mix(in srgb, var(--buff-color) 42%, transparent);
  }
}

#action-bar {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  align-items: flex-end;
  gap: 11px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.slot-group {
  display: flex;
  gap: 7px;
}

.action-slot {
  --slot-color: #79c686;
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--slot-color) 54%, transparent);
  border-radius: 4px 14px 4px 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--slot-color) 22%, transparent), transparent 68%),
    rgba(7, 14, 11, 0.86);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.3), 0 7px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 100ms ease, filter 100ms ease;
}

.action-slot.skill-card {
  width: 72px;
  height: 92px;
  border-width: 2px 1px;
  border-radius: 5px 17px 5px 17px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--slot-color) 18%, transparent), transparent 44%),
    radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--slot-color) 30%, transparent), transparent 55%),
    rgba(7, 14, 11, 0.93);
}

.action-slot.item-slot {
  width: 45px;
  height: 45px;
  border-radius: 5px;
}

.action-slot.pulse {
  filter: brightness(1.65);
  transform: translateY(-3px) scale(1.06);
}

.slot-key {
  position: absolute;
  top: 3px;
  left: 5px;
  color: var(--gold-bright);
  font-size: 9px;
  font-weight: 900;
  text-shadow: 0 1px 2px #000;
}

.slot-glyph {
  color: var(--slot-color);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  font-weight: 900;
  text-shadow: 0 0 12px color-mix(in srgb, var(--slot-color) 56%, transparent);
}

.skill-card .slot-glyph {
  font-size: 30px;
}

.item-slot .slot-glyph {
  font-size: 18px;
}

.slot-name {
  position: absolute;
  right: 2px;
  bottom: 5px;
  left: 2px;
  overflow: hidden;
  color: #d8e2d5;
  font-size: 8px;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-slot.empty {
  border-style: dashed;
  border-color: rgba(210, 222, 210, 0.2);
  background: rgba(7, 14, 11, 0.52);
  opacity: 0.62;
  cursor: default;
}

.action-slot.empty .slot-glyph {
  color: #65746b;
  text-shadow: none;
}

.slot-count {
  position: absolute;
  right: 4px;
  bottom: 3px;
  color: #fff4cf;
  font-size: 9px;
  font-weight: 900;
}

.cooldown-mask {
  position: absolute;
  inset: 0;
  transform: translateY(100%);
  background: rgba(3, 6, 5, 0.75);
  transition: transform 80ms linear;
}

.cooldown-copy {
  position: absolute;
  z-index: 2;
  color: white;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 1px 3px #000;
}

.weapon-sigil {
  display: grid;
  width: 75px;
  height: 75px;
  place-items: center;
  border: 1px solid rgba(237, 207, 119, 0.3);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(233, 199, 104, 0.17), rgba(5, 11, 9, 0.9) 65%),
    rgba(5, 11, 9, 0.9);
  box-shadow: 0 0 25px rgba(233, 199, 104, 0.1);
}

#weapon-icon {
  margin-top: 7px;
  color: var(--gold-bright);
  font-size: 25px;
  text-shadow: 0 0 12px rgba(233, 199, 104, 0.35);
}

#weapon-name {
  align-self: start;
  max-width: 67px;
  overflow: hidden;
  color: var(--muted);
  font-size: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#death-overlay {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(58, 15, 16, 0.34), rgba(5, 6, 6, 0.75));
  backdrop-filter: grayscale(0.8) blur(2px);
}

#death-overlay > div {
  text-align: center;
  text-shadow: 0 4px 18px #000;
}

#death-overlay p {
  margin: 0;
  color: #d15f59;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 42px;
  letter-spacing: 0.14em;
}

#death-overlay strong,
#death-overlay span {
  display: block;
}

#death-overlay strong {
  margin-top: 8px;
  color: #f2dfbd;
  font-size: 15px;
}

#death-overlay span {
  margin-top: 7px;
  color: #bbb8ae;
  font-size: 11px;
}

.modal-panel {
  position: fixed;
  top: 50%;
  right: 34px;
  z-index: 25;
  width: min(430px, calc(100vw - 40px));
  max-height: min(650px, calc(100vh - 60px));
  padding: 20px;
  transform: translateY(-50%);
  overflow: auto;
  pointer-events: auto;
  border: 1px solid rgba(235, 207, 133, 0.32);
  border-radius: 4px 22px 4px 22px;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(28, 43, 35, 0.98), rgba(8, 15, 12, 0.98)),
    var(--panel-solid);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 5px 0 0;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 28px;
}

#service-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  color: #d4ddcf;
  background: rgba(255, 255, 255, 0.04);
  font-size: 22px;
}

#service-description,
.service-help {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

#service-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.service-entry {
  display: grid;
  grid-template-columns: 39px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid rgba(226, 238, 210, 0.09);
  background: rgba(255, 255, 255, 0.025);
}

.service-entry.advanced-recipe,
.service-entry.advanced-gear {
  border-color: rgba(218, 159, 255, 0.38);
  background:
    linear-gradient(100deg, rgba(176, 104, 225, 0.13), transparent 52%),
    rgba(255, 255, 255, 0.025);
}

.service-entry.advanced-recipe .service-icon,
.service-entry.advanced-gear .service-icon {
  border-color: rgba(218, 159, 255, 0.46);
  color: #e6bcff;
  background: rgba(176, 104, 225, 0.12);
}

.service-entry.cosmetic-gear {
  border-color: rgba(116, 220, 196, 0.42);
  background:
    linear-gradient(100deg, rgba(70, 166, 147, 0.15), rgba(233, 199, 104, 0.05) 64%, transparent),
    rgba(255, 255, 255, 0.025);
}

.service-entry.cosmetic-gear .service-icon {
  border-color: rgba(126, 229, 205, 0.5);
  color: #f5dda0;
  background: rgba(72, 170, 151, 0.14);
}

.service-entry.service-entry-available {
  border-color: rgba(103, 229, 143, 0.72);
  background:
    linear-gradient(100deg, rgba(56, 177, 98, 0.2), rgba(80, 191, 117, 0.07) 70%, transparent),
    rgba(255, 255, 255, 0.025);
  box-shadow:
    inset 3px 0 0 rgba(111, 239, 151, 0.82),
    0 0 18px rgba(54, 180, 97, 0.08);
}

.service-entry.service-entry-available .service-copy strong {
  color: #d9ffe4;
}

.service-entry.service-entry-available .service-icon {
  border-color: rgba(119, 239, 157, 0.62);
  color: #ddffe7;
  background: rgba(63, 184, 103, 0.2);
}

.service-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(234, 205, 122, 0.22);
  border-radius: 50%;
  color: var(--gold-bright);
  background: rgba(233, 199, 104, 0.08);
  font-family: "STKaiti", "KaiTi", serif;
  font-weight: 900;
}

.service-copy strong,
.service-copy span {
  display: block;
}

.service-copy strong {
  font-size: 12px;
}

.service-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.service-entry button {
  padding: 7px 9px;
  border: 1px solid rgba(233, 199, 104, 0.32);
  border-radius: 3px;
  cursor: pointer;
  color: #f4dfaa;
  background: rgba(233, 199, 104, 0.08);
  font-size: 9px;
}

.service-entry button:hover {
  background: rgba(233, 199, 104, 0.16);
}

.service-entry button.service-action-available {
  border-color: rgba(116, 239, 156, 0.72);
  color: #e1ffe9;
  background: rgba(55, 181, 98, 0.24);
  box-shadow: 0 0 12px rgba(64, 196, 109, 0.12);
}

.service-entry button.service-action-available:hover {
  background: rgba(66, 202, 113, 0.34);
}

.service-section-title {
  margin: 14px 0 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.service-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed rgba(226, 238, 210, 0.13);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  font-size: 10px;
  line-height: 1.55;
}

.skill-card-entry {
  border-color: rgba(233, 199, 104, 0.18);
  background:
    linear-gradient(100deg, rgba(233, 199, 104, 0.07), transparent 42%),
    rgba(255, 255, 255, 0.025);
}

.skill-card-entry .service-icon {
  border-radius: 3px 11px 3px 11px;
}

.service-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.service-actions button {
  min-width: 30px;
}

.skill-slot-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.skill-slot-chip {
  display: grid;
  min-height: 66px;
  place-items: center;
  gap: 4px;
  padding: 8px 5px;
  border: 1px dashed rgba(226, 238, 210, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  font-size: 9px;
}

.skill-slot-chip.filled {
  border-style: solid;
  border-color: color-mix(in srgb, var(--skill-color) 58%, transparent);
  color: #f2f6ec;
  background: color-mix(in srgb, var(--skill-color) 11%, transparent);
}

.skill-slot-chip kbd {
  color: var(--gold-bright);
  font-size: 13px;
  font-weight: 900;
}

.skill-slot-chip button {
  border: 0;
  cursor: pointer;
  color: #d9b3a7;
  background: transparent;
  font-size: 8px;
}

#service-panel.leaderboard-panel {
  width: min(640px, calc(100vw - 40px));
}

.leaderboard-summary {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  padding: 10px 14px;
  border: 1px solid rgba(233, 199, 104, 0.2);
  color: #dce6d8;
  background: rgba(233, 199, 104, 0.055);
  font-size: 10px;
}

.leaderboard-summary strong {
  color: var(--gold-bright);
  font-size: 17px;
  text-align: center;
}

.leaderboard-summary span:last-child {
  text-align: right;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 38px minmax(250px, 1fr) 92px;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid rgba(226, 238, 210, 0.09);
  background: rgba(255, 255, 255, 0.025);
}

.leaderboard-entry.local {
  border-color: rgba(233, 199, 104, 0.5);
  background:
    linear-gradient(100deg, rgba(233, 199, 104, 0.12), transparent 52%),
    rgba(255, 255, 255, 0.03);
}

.leaderboard-entry.offline {
  background: rgba(255, 255, 255, 0.016);
}

.leaderboard-entry.rank-1,
.leaderboard-entry.rank-2,
.leaderboard-entry.rank-3 {
  border-left-width: 3px;
}

.leaderboard-entry.rank-1 {
  border-left-color: #f0ca62;
}

.leaderboard-entry.rank-2 {
  border-left-color: #b9c7ce;
}

.leaderboard-entry.rank-3 {
  border-left-color: #bd895a;
}

.leaderboard-rank {
  color: #9dac9f;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.rank-1 .leaderboard-rank {
  color: #ffd86d;
  text-shadow: 0 0 10px rgba(255, 196, 61, 0.35);
}

.rank-2 .leaderboard-rank {
  color: #d9e6eb;
}

.rank-3 .leaderboard-rank {
  color: #d7a26b;
}

.leaderboard-copy strong,
.leaderboard-copy small,
.leaderboard-stats span,
.leaderboard-power strong,
.leaderboard-power small {
  display: block;
}

.leaderboard-copy strong {
  color: #eef3e9;
  font-size: 12px;
}

.leaderboard-copy small,
.leaderboard-stats,
.leaderboard-power small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
}

.leaderboard-presence {
  color: #89978c;
}

.leaderboard-entry.online .leaderboard-presence {
  color: #7ee598;
}

.leaderboard-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
}

.leaderboard-power {
  text-align: right;
}

.leaderboard-power strong {
  color: #ffe18e;
  font-size: 17px;
  letter-spacing: 0.03em;
}

.boss-kill-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 12px 2px 7px;
  border-top: 1px solid rgba(210, 164, 235, 0.22);
}

.boss-kill-history-header strong {
  color: #e8c3f3;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.boss-kill-history-header span,
.boss-kill-history-empty {
  color: var(--muted);
  font-size: 9px;
}

.boss-kill-history-empty {
  margin: 0;
  padding: 18px 12px;
  border: 1px dashed rgba(210, 164, 235, 0.2);
  text-align: center;
}

.boss-kill-record {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: stretch;
  min-height: 74px;
  overflow: hidden;
  border: 1px solid rgba(210, 164, 235, 0.2);
  background:
    linear-gradient(105deg, rgba(153, 91, 181, 0.13), transparent 55%),
    rgba(255, 255, 255, 0.025);
}

.boss-kill-sequence {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border-right: 1px solid rgba(210, 164, 235, 0.18);
  color: #eed191;
  background: rgba(111, 67, 130, 0.14);
}

.boss-kill-sequence strong,
.boss-kill-sequence small,
.boss-kill-copy strong,
.boss-kill-copy span {
  display: block;
}

.boss-kill-sequence strong {
  font-size: 16px;
}

.boss-kill-sequence small {
  color: #bca8c1;
  font-size: 8px;
}

.boss-kill-copy {
  min-width: 0;
  padding: 9px 11px;
}

.boss-kill-copy > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.boss-kill-copy > div:first-child strong {
  overflow: hidden;
  color: #f1e8f3;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-kill-copy > div:first-child span {
  flex: 0 0 auto;
  color: #9e919f;
  font-size: 8px;
}

.boss-kill-honors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.boss-kill-honors span {
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 2px;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boss-kill-honors .final-blow {
  color: #ffd58d;
  background: rgba(214, 133, 56, 0.12);
}

.boss-kill-honors .top-damage {
  color: #d9b8f3;
  background: rgba(164, 101, 199, 0.13);
}

.gear-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(233, 199, 104, 0.17);
  color: #d9e3d5;
  background: rgba(233, 199, 104, 0.05);
  font-size: 10px;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.equipment-slot {
  min-height: 82px;
  padding: 8px 5px;
  border: 1px dashed rgba(226, 238, 210, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  text-align: center;
}

.equipment-slot.filled {
  border-style: solid;
  border-color: color-mix(in srgb, var(--gear-color, #d5bd78) 55%, transparent);
  background: color-mix(in srgb, var(--gear-color, #d5bd78) 9%, transparent);
}

.equipment-slot.advanced-gear {
  border-color: rgba(218, 159, 255, 0.58);
  box-shadow: inset 0 0 18px rgba(176, 104, 225, 0.09);
}

.equipment-slot.cosmetic-gear.filled {
  border-color: rgba(116, 220, 196, 0.58);
  box-shadow:
    inset 0 0 18px rgba(70, 166, 147, 0.1),
    0 0 0 1px rgba(233, 199, 104, 0.08);
}

.equipment-slot strong,
.equipment-slot span {
  display: block;
}

.equipment-slot strong {
  margin: 6px 0 4px;
  color: #edf1e8;
  font-size: 9px;
}

.equipment-slot span {
  font-size: 8px;
}

.equipment-slot button {
  margin-top: 7px;
  padding: 4px 7px;
  border: 1px solid rgba(233, 199, 104, 0.25);
  color: #e8d69e;
  background: rgba(233, 199, 104, 0.05);
  font-size: 8px;
}

.settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 28;
  width: min(390px, calc(100vw - 36px));
  padding: 26px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  border: 1px solid rgba(233, 199, 104, 0.35);
  border-radius: 5px 22px 5px 22px;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 0%, rgba(116, 156, 105, 0.17), transparent 38%),
    linear-gradient(145deg, rgba(27, 43, 35, 0.99), rgba(8, 15, 12, 0.99));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.62);
}

.settings-panel::before {
  content: "";
  position: fixed;
  inset: -100vh -100vw;
  z-index: -1;
  background: rgba(5, 10, 8, 0.5);
  backdrop-filter: blur(3px);
}

.settings-panel h2 {
  margin: 6px 0 8px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 32px;
}

.settings-panel > p:not(.panel-kicker) {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.settings-actions {
  display: grid;
  gap: 8px;
}

.settings-actions button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(226, 238, 210, 0.16);
  border-radius: 3px 12px 3px 12px;
  cursor: pointer;
  color: #e5ece1;
  background: rgba(255, 255, 255, 0.035);
  font-size: 11px;
  font-weight: 800;
}

.settings-actions button:hover {
  border-color: rgba(233, 199, 104, 0.48);
  background: rgba(233, 199, 104, 0.1);
}

.settings-actions .settings-primary {
  color: #172017;
  background: linear-gradient(100deg, #d7ba64, #f2dc91);
}

.settings-actions .settings-danger {
  border-color: rgba(231, 95, 83, 0.32);
  color: #ffc4bd;
}

.settings-panel > small {
  display: block;
  margin-top: 14px;
  color: rgba(225, 235, 221, 0.45);
  font-size: 8px;
  text-align: center;
}

.quit-card .primary-button {
  width: 100%;
  margin-top: 14px;
}

#toast-layer {
  position: fixed;
  top: 20%;
  left: 50%;
  z-index: 24;
  display: grid;
  width: min(440px, 80vw);
  gap: 7px;
  transform: translateX(-50%);
  pointer-events: none;
}

#loot-reveal {
  position: fixed;
  top: 23%;
  left: 50%;
  z-index: 23;
  width: min(590px, calc(100vw - 34px));
  padding: 16px 20px 14px;
  transform: translateX(-50%);
  pointer-events: none;
  border: 1px solid rgba(255, 226, 143, 0.54);
  border-radius: 5px 22px 5px 22px;
  color: #f9f4df;
  background:
    linear-gradient(105deg, rgba(38, 73, 55, 0.96), rgba(18, 39, 46, 0.95)),
    rgba(20, 42, 35, 0.96);
  box-shadow: 0 18px 46px rgba(22, 36, 31, 0.34), 0 0 30px rgba(233, 199, 104, 0.12);
}

#loot-reveal.enter {
  animation: loot-reveal-enter 300ms cubic-bezier(0.18, 0.86, 0.25, 1.1);
}

#loot-reveal-kicker,
#loot-reveal-change {
  margin: 0;
}

#loot-reveal-kicker {
  color: #ffd974;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

#loot-reveal h2 {
  margin: 5px 0 11px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  letter-spacing: 0.06em;
}

#loot-reveal-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 6px;
}

.loot-reward-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 49px;
  padding: 6px 8px;
  border: 1px solid rgba(208, 237, 207, 0.16);
  background: rgba(255, 255, 255, 0.045);
}

.loot-reward-card > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 4px 12px 4px 12px;
  color: #ffe08a;
  background: rgba(233, 199, 104, 0.14);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 18px;
  font-weight: 900;
}

.loot-reward-card.gear > span {
  color: #9de1ff;
  background: rgba(106, 184, 222, 0.18);
}

.loot-reward-card.skillcard > span {
  color: #d6b5ff;
  background: rgba(161, 109, 222, 0.18);
}

.loot-reward-card strong,
.loot-reward-card small {
  display: block;
}

.loot-reward-card strong {
  color: #f7f3df;
  font-size: 11px;
}

.loot-reward-card small {
  margin-top: 3px;
  color: #bcd2c5;
  font-size: 8px;
}

#loot-reveal-change {
  margin-top: 10px;
  color: #cae4cf;
  font-size: 9px;
}

@keyframes loot-reveal-enter {
  from {
    opacity: 0;
    transform: translate(-50%, -14px) scale(0.96);
  }
}

.toast {
  padding: 10px 16px;
  border: 1px solid rgba(231, 211, 148, 0.2);
  border-radius: 3px;
  color: #f3eee0;
  background: rgba(7, 13, 11, 0.88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  font-size: 12px;
  text-align: center;
  animation: toast-in 180ms ease-out;
}

.toast.good {
  border-color: rgba(111, 213, 127, 0.35);
  color: #c9f4cf;
}

.toast.bad {
  border-color: rgba(244, 93, 79, 0.38);
  color: #ffd0cb;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-7px);
  }
}

#damage-layer {
  position: fixed;
  inset: 0;
  z-index: 16;
  overflow: hidden;
  pointer-events: none;
}

.damage-number {
  position: absolute;
  top: 0;
  left: 0;
  color: #fff1bd;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 1px #3d120c, 0 0 8px rgba(255, 93, 59, 0.55);
  will-change: transform, opacity;
}

.damage-number.critical {
  color: #ffb05f;
  font-size: 28px;
}

.damage-number.heal {
  color: #83f09a;
  text-shadow: 0 2px 1px #133f22, 0 0 8px rgba(82, 226, 119, 0.5);
}

.damage-number.kill {
  display: grid;
  gap: 2px;
  min-width: 120px;
  color: #ffe39a;
  font-family: "STKaiti", "KaiTi", serif;
  text-align: center;
  text-shadow: 0 2px 1px #3b2510, 0 0 16px rgba(255, 202, 92, 0.78);
}

.damage-number.kill strong {
  font-size: 34px;
  letter-spacing: 0.14em;
}

.damage-number.kill small {
  color: #fff5d7;
  font: 900 11px/1.2 system-ui, sans-serif;
  letter-spacing: 0.08em;
}

.error-card {
  max-width: 450px;
  padding: 30px;
  border: 1px solid rgba(235, 95, 82, 0.32);
  background: rgba(22, 15, 15, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-card h2 {
  color: #ff8c80;
}

@media (max-width: 980px) {
  .top-hud {
    grid-template-columns: 1fr 1.2fr;
  }

  .team-panel {
    position: fixed;
    top: 124px;
    right: 12px;
    width: 270px;
    min-width: 0;
  }

  #boss-stack {
    grid-column: 2;
  }

  #player-vitals {
    bottom: 105px;
    width: 270px;
  }

  #chat-box {
    bottom: 205px;
    width: min(340px, 48vw);
  }

  .action-slot {
    width: 50px;
    height: 50px;
  }

  .action-slot.skill-card {
    width: 54px;
    height: 68px;
  }

  .action-slot.item-slot:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 720px) {
  .join-card {
    padding: 35px 22px 24px;
  }

  .join-row {
    flex-direction: column;
  }

  .primary-button {
    height: 50px;
  }

  .control-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .top-hud {
    top: 10px;
    right: 10px;
    left: 10px;
    display: block;
  }

  .objective-panel {
    display: none;
  }

  #boss-stack {
    max-width: none;
  }

  .team-panel {
    display: none;
  }

  .boss-bar:nth-child(n + 2) {
    display: none;
  }

  #compass {
    top: 87px;
  }

  #player-vitals {
    bottom: 94px;
    left: 12px;
    width: calc(100vw - 24px);
  }

  #action-bar {
    bottom: 14px;
    gap: 6px;
  }

  .action-slot {
    width: 46px;
    height: 46px;
  }

  .action-slot.skill-card {
    width: 46px;
    height: 52px;
  }

  .action-slot.item-slot {
    width: 38px;
    height: 38px;
  }

  .item-slot:nth-child(n + 3) {
    display: none;
  }

  #service-panel.leaderboard-panel {
    right: 12px;
    width: calc(100vw - 24px);
  }

  .leaderboard-entry {
    grid-template-columns: 30px minmax(0, 1fr) 68px;
    gap: 6px;
    padding: 7px 6px;
  }

  .leaderboard-stats {
    grid-template-columns: 1fr 1fr;
  }

  .leaderboard-power strong {
    font-size: 14px;
  }

  .boss-kill-copy > div:first-child {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .boss-kill-honors {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .weapon-sigil {
    width: 55px;
    height: 55px;
  }

  #event-feed {
    display: none;
  }

  #chat-box {
    bottom: 200px;
    left: 12px;
    width: min(360px, calc(100vw - 24px));
  }

  #chat-messages {
    max-height: 98px;
  }
}

/* 手机端采用左摇杆、右侧拖动视角与右侧动作键；桌面键鼠布局保持不变。 */
.touch-capable,
.touch-capable body {
  height: var(--visual-height, 100dvh);
  overscroll-behavior: none;
}

.touch-capable button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.touch-capable input {
  touch-action: manipulation;
  user-select: text;
}

.touch-capable #game-canvas {
  touch-action: none;
}

.touch-capable #join-screen {
  padding:
    max(30px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  touch-action: pan-y;
}

.touch-capable .join-card {
  width: min(620px, 100%);
  padding: 58px 24px 24px;
}

.touch-capable .join-card h1 {
  font-size: clamp(42px, 12vw, 66px);
}

.touch-capable .join-subtitle {
  margin-bottom: 20px;
  font-size: 12px;
}

.touch-capable .desktop-control-guide {
  display: none;
}

.touch-capable .touch-control-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.touch-capable .touch-control-guide div {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 4px;
  padding: 7px 3px;
  border: 1px solid rgba(224, 238, 207, 0.08);
  background: rgba(255, 255, 255, 0.018);
  text-align: center;
}

.touch-capable .touch-control-guide kbd {
  min-width: 58px;
  font-size: 10px;
}

.touch-capable .touch-control-guide span {
  color: var(--muted);
  font-size: 9px;
}

.touch-capable #pointer-hint,
.touch-capable #interaction-prompt {
  display: none !important;
}

.touch-capable .top-hud {
  top: max(6px, env(safe-area-inset-top));
  right: max(56px, calc(env(safe-area-inset-right) + 50px));
  left: max(56px, calc(env(safe-area-inset-left) + 50px));
  display: block;
}

.touch-capable .objective-panel {
  display: none;
}

.touch-capable #boss-stack {
  width: min(62vw, 560px);
  max-width: none;
  margin: 0 auto;
}

.touch-capable .boss-bar {
  margin-bottom: 4px;
  padding: 7px 10px 8px;
  border-radius: 3px 12px 3px 12px;
}

.touch-capable .boss-bar:nth-child(n + 2) {
  display: none;
}

.touch-capable .boss-bar-header {
  gap: 8px;
  font-size: 9px;
}

.touch-capable .boss-bar-header strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.touch-capable .boss-track {
  height: 9px;
  margin-top: 5px;
}

.touch-capable .boss-cast {
  gap: 6px;
  margin-top: 4px;
  font-size: 8px;
}

.touch-capable #compass {
  top: max(70px, calc(env(safe-area-inset-top) + 64px));
  width: 160px;
  gap: 13px;
}

.touch-capable #world-time {
  top: 20px;
}

.touch-capable #mobile-menu-button {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 24;
  display: flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid rgba(233, 199, 104, 0.34);
  border-radius: 50%;
  color: #f5df9f;
  background: rgba(7, 14, 11, 0.84);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.touch-capable #mobile-menu-button b {
  font-size: 17px;
  line-height: 16px;
}

.touch-capable #mobile-menu-button span {
  font-size: 7px;
}

.touch-capable #panel-shortcuts {
  top: max(60px, calc(env(safe-area-inset-top) + 54px));
  right: max(8px, env(safe-area-inset-right));
  z-index: 23;
  display: none;
  max-height: calc(var(--visual-height, 100dvh) - 74px);
  gap: 5px;
  padding: 7px;
  transform: none;
  overflow: auto;
  border: 1px solid rgba(233, 199, 104, 0.24);
  border-radius: 12px 3px 12px 3px;
  background: rgba(7, 14, 11, 0.9);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(7px);
}

.touch-capable.mobile-menu-open #panel-shortcuts {
  display: grid;
}

.touch-capable #panel-shortcuts button {
  display: block;
  min-width: 112px;
  min-height: 42px;
  padding: 9px 11px;
  font-size: 11px;
  text-align: left;
}

.touch-capable #panel-shortcuts .mobile-only {
  display: block;
}

.touch-capable .team-panel {
  position: fixed;
  top: max(62px, calc(env(safe-area-inset-top) + 56px));
  right: max(8px, env(safe-area-inset-right));
  z-index: 23;
  display: none;
  width: min(300px, calc(100vw - 20px));
  min-width: 0;
  max-width: none;
  max-height: calc(var(--visual-height, 100dvh) - 76px);
  overflow: hidden;
  pointer-events: auto;
}

.touch-capable.mobile-team-open .team-panel {
  display: block;
}

.touch-capable .team-panel .panel-heading {
  display: grid;
  grid-template-columns: 1fr auto 34px;
  gap: 8px;
}

.touch-capable #team-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(233, 199, 104, 0.24);
  border-radius: 50%;
  color: #f2dfaa;
  background: rgba(255, 255, 255, 0.04);
  font-size: 20px;
}

.touch-capable #team-list {
  max-height: calc(var(--visual-height, 100dvh) - 132px);
}

.touch-capable #player-vitals {
  top: max(102px, calc(env(safe-area-inset-top) + 96px));
  bottom: auto;
  left: max(10px, env(safe-area-inset-left));
  width: min(250px, 42vw);
  padding: 8px 10px 9px;
}

.touch-capable #player-nameplate {
  font-size: 12px;
}

.touch-capable #resource-strip {
  gap: 3px 7px;
  margin-top: 5px;
}

.touch-capable #active-buffs {
  max-height: 48px;
  overflow: hidden;
}

.touch-capable .active-buff-chip {
  padding: 2px 4px 2px 2px;
}

.touch-capable .active-buff-chip em {
  display: none;
}

.touch-capable #mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 17;
  display: block;
  -webkit-touch-callout: none;
  pointer-events: none;
}

.touch-capable #mobile-look-hint {
  position: fixed;
  right: max(110px, calc(env(safe-area-inset-right) + 104px));
  bottom: max(188px, calc(env(safe-area-inset-bottom) + 180px));
  padding: 5px 9px;
  border-radius: 12px;
  color: rgba(235, 242, 230, 0.68);
  background: rgba(6, 13, 10, 0.48);
  font-size: 8px;
  animation: mobile-hint-fade 4.8s 1.4s forwards;
}

.touch-capable #mobile-look-hint.used {
  display: none;
}

@keyframes mobile-hint-fade {
  to {
    opacity: 0;
  }
}

.touch-capable #move-stick {
  position: fixed;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  left: max(18px, calc(env(safe-area-inset-left) + 12px));
  width: 126px;
  height: 126px;
  border: 1px solid rgba(220, 238, 212, 0.18);
  border-radius: 50%;
  outline: none;
  background:
    radial-gradient(circle, rgba(230, 240, 223, 0.08) 0 25%, transparent 26%),
    rgba(6, 13, 10, 0.24);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  touch-action: none;
}

.touch-capable #move-stick::before,
.touch-capable #move-stick::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: rgba(225, 237, 219, 0.08);
  transform: translate(-50%, -50%);
}

.touch-capable #move-stick::before {
  width: 1px;
  height: 78%;
}

.touch-capable #move-stick::after {
  width: 78%;
  height: 1px;
}

.touch-capable #move-stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 54px;
  height: 54px;
  margin: -27px;
  border: 1px solid rgba(255, 226, 154, 0.44);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, rgba(255, 236, 178, 0.24), transparent 42%),
    rgba(30, 47, 38, 0.78);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.32);
  will-change: transform;
}

.touch-capable #move-stick.active #move-stick-knob {
  border-color: rgba(255, 226, 154, 0.8);
  background-color: rgba(54, 77, 57, 0.9);
}

.touch-capable #move-stick small {
  position: absolute;
  bottom: 12px;
  left: 50%;
  color: rgba(225, 235, 220, 0.5);
  font-size: 8px;
  transform: translateX(-50%);
}

.touch-capable #mobile-action-cluster button {
  position: fixed;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid rgba(233, 199, 104, 0.34);
  border-radius: 50%;
  color: #f6e8ba;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 232, 157, 0.18), transparent 45%),
    rgba(7, 14, 11, 0.78);
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}

.touch-capable #mobile-action-cluster button:active,
.touch-capable #mobile-action-cluster button.active {
  border-color: rgba(255, 228, 152, 0.9);
  filter: brightness(1.35);
  transform: scale(0.94);
}

.touch-capable #mobile-attack {
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px));
  width: 72px;
  height: 72px;
}

.touch-capable #mobile-attack b {
  margin-top: 7px;
  font-size: 27px;
}

.touch-capable #mobile-attack span {
  align-self: start;
  font-size: 8px;
}

.touch-capable #mobile-jump,
.touch-capable #mobile-dodge {
  width: 48px;
  height: 48px;
  font-size: 14px;
  font-weight: 900;
}

.touch-capable #mobile-jump {
  right: max(22px, calc(env(safe-area-inset-right) + 16px));
  bottom: max(100px, calc(env(safe-area-inset-bottom) + 94px));
}

.touch-capable #mobile-dodge {
  right: max(96px, calc(env(safe-area-inset-right) + 90px));
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 16px));
}

.touch-capable #mobile-interact {
  right: max(16px, calc(env(safe-area-inset-right) + 10px));
  bottom: max(162px, calc(env(safe-area-inset-bottom) + 156px));
  width: 60px;
  height: 60px;
  border-color: rgba(108, 224, 176, 0.62);
  color: #c9f7db;
}

.touch-capable #mobile-interact b {
  margin-top: 6px;
  font-size: 19px;
}

.touch-capable #mobile-interact span {
  align-self: start;
  font-size: 8px;
}

.touch-capable #action-bar {
  right: max(94px, calc(env(safe-area-inset-right) + 88px));
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 80px));
  left: auto;
  display: block;
  transform: none;
}

.touch-capable #skill-bar {
  gap: 4px;
}

.touch-capable .action-slot.skill-card {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.touch-capable .skill-card .slot-glyph {
  font-size: 21px;
}

.touch-capable .action-slot .slot-name {
  display: none;
}

.touch-capable .action-slot .slot-key {
  top: 2px;
  left: 4px;
  font-size: 8px;
}

.touch-capable #item-bar {
  position: absolute;
  right: 0;
  bottom: 50px;
  gap: 4px;
}

.touch-capable .action-slot.item-slot {
  display: grid;
  width: 32px;
  height: 32px;
}

.touch-capable .item-slot .slot-glyph {
  font-size: 15px;
}

.touch-capable .weapon-sigil {
  display: none;
}

.touch-capable #event-feed {
  display: none;
}

.touch-capable #chat-box {
  right: auto;
  bottom: max(154px, calc(env(safe-area-inset-bottom) + 148px));
  left: max(10px, env(safe-area-inset-left));
  width: min(280px, 42vw);
}

.touch-capable #chat-messages {
  max-height: 64px;
}

.touch-capable #chat-hint {
  display: none;
}

.touch-capable.mobile-chat-open #chat-box {
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  left: max(8px, env(safe-area-inset-left));
  z-index: 31;
  width: auto;
}

.touch-capable.mobile-chat-open #chat-messages {
  max-height: 96px;
}

.touch-capable.mobile-chat-open #chat-input,
.touch-capable.mobile-chat-open #chat-send {
  min-height: 44px;
}

.touch-capable.mobile-chat-open #mobile-controls,
.touch-capable.mobile-chat-open #action-bar,
.touch-capable.mobile-chat-open #mobile-menu-button,
.touch-capable:has(#service-panel:not(.hidden)) #mobile-controls,
.touch-capable:has(#service-panel:not(.hidden)) #action-bar,
.touch-capable:has(#service-panel:not(.hidden)) #mobile-menu-button,
.touch-capable:has(#settings-panel:not(.hidden)) #mobile-controls,
.touch-capable:has(#settings-panel:not(.hidden)) #action-bar,
.touch-capable:has(#settings-panel:not(.hidden)) #mobile-menu-button {
  display: none;
}

.touch-capable #toast-layer {
  top: max(92px, calc(env(safe-area-inset-top) + 86px));
  width: min(390px, 72vw);
}

.touch-capable #loot-reveal {
  top: max(88px, calc(env(safe-area-inset-top) + 82px));
  width: min(520px, calc(100vw - 24px));
  padding: 11px 13px;
}

.touch-capable #loot-reveal h2 {
  margin: 3px 0 7px;
  font-size: 18px;
}

.touch-capable #loot-reveal-list {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.touch-capable .modal-panel {
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  width: min(430px, 58vw);
  max-height: none;
  padding: 15px;
  transform: none;
  overscroll-behavior: contain;
}

.touch-capable .modal-header {
  position: sticky;
  top: -15px;
  z-index: 3;
  padding-top: 6px;
  background: rgba(17, 29, 25, 0.96);
}

.touch-capable #service-close {
  width: 44px;
  height: 44px;
}

.touch-capable .service-entry button,
.touch-capable .equipment-slot button,
.touch-capable .skill-slot-chip button {
  min-height: 38px;
}

.touch-capable .settings-panel {
  max-height: calc(var(--visual-height, 100dvh) - 24px);
  padding: 20px;
  overflow: auto;
}

.touch-capable .settings-actions button {
  min-height: 46px;
}

@media (orientation: portrait) {
  .touch-capable .touch-control-guide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .touch-capable .top-hud {
    right: max(58px, calc(env(safe-area-inset-right) + 52px));
    left: max(8px, env(safe-area-inset-left));
  }

  .touch-capable #boss-stack {
    width: 100%;
  }

  .touch-capable #compass {
    top: max(76px, calc(env(safe-area-inset-top) + 70px));
  }

  .touch-capable #player-vitals {
    top: max(112px, calc(env(safe-area-inset-top) + 106px));
    width: min(235px, calc(100vw - 24px));
  }

  .touch-capable #chat-box {
    bottom: max(236px, calc(env(safe-area-inset-bottom) + 230px));
    width: min(270px, calc(100vw - 24px));
  }

  .touch-capable #action-bar {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(154px, calc(env(safe-area-inset-bottom) + 148px));
  }

  .touch-capable #item-bar {
    bottom: 49px;
  }

  .touch-capable .action-slot.skill-card {
    width: 42px;
    height: 42px;
  }

  .touch-capable #mobile-look-hint {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(338px, calc(env(safe-area-inset-bottom) + 332px));
  }

  .touch-capable #mobile-interact {
    bottom: max(274px, calc(env(safe-area-inset-bottom) + 268px));
  }

  .touch-capable .modal-panel,
  .touch-capable #service-panel.leaderboard-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(72dvh, var(--visual-height, 100dvh));
    padding:
      16px
      max(14px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
    border-radius: 18px 18px 0 0;
  }

  .touch-capable .modal-header {
    top: -16px;
  }

  .touch-capable .leaderboard-summary {
    grid-template-columns: 1fr;
    gap: 3px;
    text-align: center;
  }

  .touch-capable .leaderboard-summary span:last-child {
    text-align: center;
  }

  .touch-capable .settings-panel {
    width: calc(100vw - 24px);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .touch-capable #player-vitals {
    top: max(86px, calc(env(safe-area-inset-top) + 80px));
    width: min(235px, 31vw);
  }

  .touch-capable #resource-strip {
    max-height: 27px;
    overflow: hidden;
  }

  .touch-capable #active-buffs {
    max-height: 24px;
  }

  .touch-capable #chat-box {
    display: none;
  }

  .touch-capable.mobile-chat-open #chat-box {
    display: flex;
  }

  .touch-capable #move-stick {
    width: 116px;
    height: 116px;
  }

  .touch-capable #action-bar {
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 74px));
  }

  .touch-capable #mobile-interact {
    bottom: max(150px, calc(env(safe-area-inset-bottom) + 144px));
  }

  .touch-capable #loot-reveal {
    top: max(70px, calc(env(safe-area-inset-top) + 64px));
    max-height: calc(var(--visual-height, 100dvh) - 82px);
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
