html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #10131a;
  color: #f6f7fb;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  user-select: none;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #edf2e7;
  cursor: crosshair;
  touch-action: none;
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.top-hud {
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 12px 252px;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(to bottom, rgba(12, 16, 24, 0.72), rgba(12, 16, 24, 0));
}

.leaderboard-panel {
  position: fixed;
  top: 58px;
  right: 14px;
  z-index: 9;
  box-sizing: border-box;
  width: 220px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(10, 14, 22, 0.7);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.leaderboard-title {
  margin-bottom: 6px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.leaderboard-list {
  display: grid;
  gap: 3px;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: rgba(255, 255, 255, 0.86);
}

.leaderboard-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-row strong {
  flex: 0 0 auto;
  color: #fff1b8;
}

.leaderboard-row.blue.self {
  color: #9ad4ff;
}

.leaderboard-row.red.self {
  color: #ffaaa6;
}

.leaderboard-row.self strong {
  color: #ffffff;
}

.leaderboard-separator {
  height: 1px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.18);
}

.leaderboard-empty {
  color: rgba(255, 255, 255, 0.62);
}

.element-unlock-panel {
  position: fixed;
  top: 92px;
  left: 50%;
  z-index: 22;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  padding: 14px 16px 16px;
  border: 1px solid rgba(255, 245, 220, 0.3);
  border-radius: 18px;
  background: rgba(10, 16, 24, 0.82);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.element-unlock-title {
  margin-bottom: 12px;
  color: #fff1dc;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.element-unlock-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.element-unlock-choice {
  position: relative;
  min-height: 84px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05)),
    rgba(18, 24, 34, 0.78);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13), 0 10px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.element-unlock-choice:hover:not(:disabled) {
  transform: translateY(-2px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08)),
    rgba(26, 34, 48, 0.86);
  border-color: rgba(255, 255, 255, 0.58);
}

.element-unlock-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

.element-unlock-choice strong {
  line-height: 1;
}

.element-unlock-choice em {
  color: rgba(255, 245, 224, 0.76);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
}

.element-unlock-choice span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.78;
}

.element-unlock-choice .element-unlock-recommend {
  position: absolute;
  right: 5px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  opacity: 1;
  pointer-events: none;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
}

.element-unlock-choice.unlocked {
  cursor: default;
  filter: grayscale(0.55) brightness(0.72);
  opacity: 0.58;
}

.element-tutorial-panel {
  position: fixed;
  left: min(184px, calc(100vw - 408px));
  bottom: 86px;
  z-index: 11;
  max-width: min(390px, calc(100vw - 36px));
  padding: 13px 42px 13px 16px;
  border: 1px solid rgba(255, 245, 220, 0.24);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(10, 16, 24, 0.78);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  color: rgba(255, 246, 232, 0.94);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.65;
  pointer-events: auto;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.42);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 650ms ease, transform 650ms ease;
  backdrop-filter: blur(8px);
}

.element-tutorial-close {
  position: absolute;
  top: 5px;
  right: 10px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 246, 232, 0.82);
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  aspect-ratio: 1;
}

.element-tutorial-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

button.element-tutorial-close {
  min-width: 20px;
  min-height: 20px;
  max-width: 20px;
  max-height: 20px;
  border: 0;
  border-radius: 50%;
  padding: 0;
}

.element-tutorial-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.element-tutorial-panel.is-hiding {
  opacity: 0;
  transform: translateY(8px);
}

.bottom-hud {
  bottom: calc(0.7vh + min(2.6vh, 16px) + 2px);
  display: flex;
  justify-content: flex-start;
  gap: 18px;
  padding: 8px 16px 10px;
  font-size: 15px;
  font-weight: 700;
  background: transparent;
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.88),
    1px -1px 0 rgba(0, 0, 0, 0.88),
    -1px 1px 0 rgba(0, 0, 0, 0.88),
    1px 1px 0 rgba(0, 0, 0, 0.88),
    0 2px 5px rgba(0, 0, 0, 0.82);
}

.earth-skill-slot {
  position: fixed;
  left: 16px;
  bottom: 86px;
  z-index: 9;
  box-sizing: border-box;
  width: 150px;
  min-height: 126px;
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(12, 16, 24, 0.78);
  color: #ffffff;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.earth-skill-slot.ready {
  border-color: #d39a45;
  background: rgba(44, 33, 21, 0.86);
  box-shadow: 0 0 12px rgba(211, 154, 69, 0.8), 0 10px 28px rgba(0, 0, 0, 0.32);
}

.earth-skill-slot.cooldown {
  opacity: 0.75;
  border-color: rgba(255, 255, 255, 0.25);
}

.earth-skill-slot.empty {
  opacity: 0.5;
}

.earth-slot-key {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.earth-slot-elements {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 800;
}

.earth-slot-name {
  margin-top: 8px;
  min-height: 20px;
  font-size: 16px;
  font-weight: 700;
}

.earth-slot-status {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  font-weight: 700;
}

.levelup-button {
  position: fixed;
  left: 14px;
  top: 50%;
  z-index: 30;
  display: none;
  min-width: 76px;
  min-height: 46px;
  padding: 0 16px;
  transform: translateY(-50%);
}

.levelup-button.ready {
  display: block;
  border-color: #ffd966;
  background: rgba(80, 63, 21, 0.92);
  box-shadow: 0 0 14px rgba(255, 217, 102, 0.9);
}

.levelup-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ff4a4a;
  color: #ffffff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.debug-panel {
  position: fixed;
  right: 12px;
  top: 50%;
  z-index: 30;
  width: 148px;
  padding: 8px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(10, 14, 22, 0.72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.debug-toggle {
  min-height: 32px;
  width: 100%;
  padding: 0 8px;
  font-size: 13px;
}

.debug-actions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.debug-panel.collapsed .debug-actions {
  display: none;
}

.debug-actions button {
  min-height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
}

.exp-wrap {
  width: min(220px, 24vw);
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.28);
}

.exp-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #41d97b, #96f4bb);
  transition: background 120ms ease;
}

.bottom-exp-bar {
  position: fixed;
  left: 10vw;
  right: 10vw;
  bottom: 0.7vh;
  z-index: 8;
  height: min(2.6vh, 16px);
  min-height: 6px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.42);
  pointer-events: none;
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.32), 0 5px 14px rgba(0, 0, 0, 0.14);
}

.bottom-exp-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #f5b942, #ffe27a);
}

.bottom-exp-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.94);
  font-size: clamp(9px, 1.15vh, 12px);
  font-weight: 800;
  letter-spacing: 0.02em;
  transform: translateY(-1px);
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.88),
    1px -1px 0 rgba(0, 0, 0, 0.88),
    -1px 1px 0 rgba(0, 0, 0, 0.88),
    1px 1px 0 rgba(0, 0, 0, 0.88),
    0 2px 4px rgba(0, 0, 0, 0.72);
  white-space: nowrap;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.62);
  backdrop-filter: blur(4px);
}

.start-overlay {
  z-index: 19;
}

.panel {
  width: min(720px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(23, 28, 38, 0.94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.panel h1,
.panel h2 {
  margin: 0 0 18px;
  letter-spacing: 0;
}

.start-panel {
  display: grid;
  gap: 18px;
}

.start-panel h1 {
  margin-bottom: 4px;
}

.start-panel button {
  justify-self: center;
  min-width: 180px;
  padding: 0 24px;
}

.start-panel button:disabled,
.start-panel button.is-connecting {
  cursor: wait;
  opacity: 0.72;
}

.start-form {
  display: grid;
  gap: 10px;
  width: min(420px, 100%);
  justify-self: center;
  text-align: left;
}

.mobile-start-rotate-hint {
  display: none;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 220, 150, 0.34);
  border-radius: 8px;
  background: rgba(78, 48, 18, 0.58);
  color: #fff1dc;
  text-align: center;
}

.mobile-start-rotate-hint strong,
.mobile-start-rotate-hint span {
  display: block;
}

.mobile-start-rotate-hint strong {
  font-size: 15px;
}

.mobile-start-rotate-hint span {
  color: rgba(255, 241, 220, 0.82);
  font-size: 12px;
}

.field-label {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  font-weight: 700;
}

.id-input {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 16px;
}

.id-input:focus {
  border-color: #ffffff;
}

.team-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.server-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.34);
}

.server-choice {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
}

.server-choice.is-selected {
  border-color: rgba(255, 217, 102, 0.82);
  background: rgba(255, 217, 102, 0.24);
  color: #fff4c5;
  box-shadow: inset 0 0 0 1px rgba(255, 245, 190, 0.16);
}

.team-choice {
  min-width: 0;
  min-height: 46px;
}

.blue-choice.is-selected {
  border-color: #3da5ff;
  background: rgba(61, 165, 255, 0.34);
}

.red-choice.is-selected {
  border-color: #ff4a4a;
  background: rgba(255, 74, 74, 0.34);
}

.start-error {
  min-height: 18px;
  color: #ff9f9f;
  font-size: 13px;
  text-align: center;
}

.network-status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 22px;
}

.network-status-row .network-status {
  min-height: 0;
}

.retry-server-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-color: rgba(255, 96, 96, 0.72);
  border-radius: 999px;
  background: rgba(115, 20, 28, 0.82);
  color: #ffd5d5;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  touch-action: manipulation;
}

.retry-server-button:hover {
  border-color: rgba(255, 150, 150, 0.96);
  background: rgba(178, 35, 45, 0.95);
  color: #ffffff;
}

.retry-server-button[hidden] {
  display: none;
}

.inherit-info {
  min-height: 18px;
  color: #ffd966;
  font-size: 13px;
  text-align: center;
}

.start-controls {
  display: none;
}

.start-controls p {
  margin: 0;
}

.upgrade-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px;
}

.upgrade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.upgrade-header h2 {
  margin: 0;
  font-size: 1.5em;
}

.upgrade-minimize {
  min-width: 53px;
  min-height: 41px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 17px;
}

.upgrade-card {
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 14px;
  line-height: 1.25;
}

.upgrade-card strong {
  font-size: 19px;
}

.upgrade-card span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 500;
}

button {
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #263145;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #33425c;
}

.help {
  position: fixed;
  right: 14px;
  top: 218px;
  z-index: 5;
  display: none;
  max-width: 290px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15, 19, 27, 0.62);
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.55;
  pointer-events: none;
}

.stats-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  min-width: 190px;
  max-width: 240px;
  max-height: calc(100vh - 236px);
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(10, 14, 22, 0.68);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.35;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.stats-toggle {
  min-height: 0;
  width: 100%;
  padding: 4px 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.stats-toggle:hover {
  background: transparent;
}

.stats-content {
  display: grid;
  gap: 3px;
  max-height: calc(100vh - 286px);
  overflow-y: auto;
  padding-right: 4px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  white-space: nowrap;
}

.stats-row span:first-child {
  color: rgba(255, 255, 255, 0.72);
}

.stats-panel.collapsed {
  min-width: 72px;
}

.stats-panel.collapsed .stats-content {
  display: none;
}

.local-file-warning {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 12, 18, 0.88);
}

.local-file-warning.is-visible {
  display: flex;
}

.local-file-warning .panel {
  text-align: left;
}

.local-file-warning code {
  display: inline-block;
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: none;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.mobile-controls-enabled {
  --mobile-hud-left: 96px;
  --mobile-hud-right: 188px;
  --mobile-exp-bar-height: 12px;
  --mobile-bottom-control-gap: 8px;
  overscroll-behavior: none;
  touch-action: none;
}

body.mobile-controls-enabled .mobile-controls {
  display: block;
}

body.mobile-controls-enabled.mobile-death-active .mobile-controls,
body.mobile-controls-enabled.mobile-death-active .top-hud,
body.mobile-controls-enabled.mobile-death-active .bottom-hud,
body.mobile-controls-enabled.mobile-death-active .bottom-exp-bar,
body.mobile-controls-enabled.mobile-death-active .stats-panel,
body.mobile-controls-enabled.mobile-death-active .leaderboard-panel,
body.mobile-controls-enabled.mobile-death-active .levelup-button,
body.mobile-controls-enabled.mobile-death-active .earth-skill-slot {
  display: none;
}

body.mobile-controls-enabled .start-panel {
  width: min(504px, calc(100vw - 22px));
  max-height: calc(100vh - 10px);
  gap: 8px;
  padding: 12px 14px;
  overflow: auto;
}

body.mobile-controls-enabled .start-panel h1 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.05;
}

body.mobile-controls-enabled .start-mode-note {
  margin: 0;
  font-size: 10px;
  line-height: 1.2;
}

body.mobile-controls-enabled .start-form {
  gap: 5px;
  width: min(294px, 100%);
}

body.mobile-controls-enabled .field-label {
  font-size: 10px;
}

body.mobile-controls-enabled .id-input {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
}

body.mobile-controls-enabled .team-picker {
  gap: 5px;
}

body.mobile-controls-enabled .server-selector {
  gap: 4px;
  padding: 2px;
  border-radius: 6px;
}

body.mobile-controls-enabled .server-choice {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 10px;
}

body.mobile-controls-enabled .team-choice {
  min-height: 28px;
  font-size: 11px;
}

body.mobile-controls-enabled .start-panel button {
  min-width: 126px;
  min-height: 31px;
  padding: 0 17px;
  font-size: 11px;
}

body.mobile-controls-enabled .start-panel > #startButton {
  margin-top: -24px;
}

body.mobile-controls-enabled .start-error,
body.mobile-controls-enabled .inherit-info,
body.mobile-controls-enabled .network-status {
  min-height: 13px;
  font-size: 9px;
}

body.mobile-controls-enabled .network-status-row {
  min-height: 14px;
  gap: 6px;
}

body.mobile-controls-enabled .retry-server-button {
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  font-size: 17px;
}

body.mobile-controls-enabled .mobile-start-rotate-hint {
  padding: 5px 8px;
  border-radius: 6px;
}

body.mobile-controls-enabled .mobile-start-rotate-hint strong {
  font-size: 11px;
}

body.mobile-controls-enabled .mobile-start-rotate-hint span {
  font-size: 8px;
}

body.mobile-controls-enabled #endOverlay .panel {
  width: min(504px, calc(100vw - 22px));
  padding: 17px;
  transform: scale(0.7);
  transform-origin: center center;
}

body.mobile-controls-enabled #endOverlay .panel h1 {
  margin-bottom: 13px;
  font-size: 25px;
}

body.mobile-controls-enabled #endOverlay .panel button {
  min-width: 126px;
  min-height: 38px;
  padding: 0 17px;
  font-size: 14px;
}

body.mobile-controls-enabled .earth-skill-slot {
  display: none;
}

body.mobile-controls-enabled .top-hud {
  box-sizing: border-box;
  left: var(--mobile-hud-left);
  right: var(--mobile-hud-right);
  top: 0;
  min-height: 27px;
  max-width: none;
  flex-wrap: nowrap;
  gap: 7px 10px;
  padding: 6px 8px 4px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  color: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  line-height: 1.2;
  justify-content: flex-start;
  overflow: hidden;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.96),
    1px 0 2px rgba(0, 0, 0, 0.96),
    -1px 0 2px rgba(0, 0, 0, 0.96),
    0 -1px 2px rgba(0, 0, 0, 0.96);
  -webkit-text-stroke: 0.45px rgba(0, 0, 0, 0.72);
}

body.mobile-controls-enabled .top-hud .exp-wrap {
  width: 88px;
  height: 9px;
}

body.mobile-controls-enabled .bottom-exp-bar {
  left: 10vw;
  right: 10vw;
  bottom: env(safe-area-inset-bottom, 0px);
  height: var(--mobile-exp-bar-height);
  min-height: 8px;
}

body.mobile-controls-enabled .bottom-exp-label {
  font-size: 9px;
}

body.mobile-controls-enabled .bottom-hud {
  box-sizing: border-box;
  left: var(--mobile-hud-left);
  right: var(--mobile-hud-right);
  top: 27px;
  bottom: auto;
  max-width: none;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px 9px;
  padding: 4px 8px 10px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  line-height: 1.2;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.96),
    1px 0 2px rgba(0, 0, 0, 0.96),
    -1px 0 2px rgba(0, 0, 0, 0.96),
    0 -1px 2px rgba(0, 0, 0, 0.96);
  -webkit-text-stroke: 0.35px rgba(0, 0, 0, 0.7);
}

body.mobile-controls-enabled .stats-panel {
  top: 0;
  left: 0;
  min-width: 133px;
  max-width: 168px;
  max-height: calc(100vh - 104px);
  padding: 6px 7px;
  font-size: 9px;
  line-height: 1.25;
}

body.mobile-controls-enabled .stats-toggle {
  padding: 3px 0 4px;
  font-size: 9px;
}

body.mobile-controls-enabled .stats-content {
  max-height: calc(100vh - 158px);
  gap: 2px;
  padding-right: 3px;
}

body.mobile-controls-enabled .stats-row {
  gap: 8px;
}

body.mobile-controls-enabled .stats-panel.collapsed {
  min-width: 50px;
}

body.mobile-controls-enabled .leaderboard-panel {
  top: 0;
  right: 0;
  width: 116px;
  padding: 5px 6px;
  font-size: 7px;
  line-height: 1.25;
}

body.mobile-controls-enabled .leaderboard-title {
  margin-bottom: 3px;
}

body.mobile-controls-enabled .leaderboard-list {
  gap: 2px;
}

body.mobile-controls-enabled .element-unlock-panel {
  top: 18px;
  z-index: 30;
  width: min(286px, calc(100vw - 18px));
  padding: 7px 8px 8px;
  border-radius: 9px;
}

body.mobile-controls-enabled .element-unlock-title {
  margin-bottom: 6px;
  font-size: 9px;
}

body.mobile-controls-enabled .element-unlock-options {
  gap: 5px;
}

body.mobile-controls-enabled .element-unlock-choice {
  min-height: 43px;
  gap: 2px;
  border-radius: 7px;
}

body.mobile-controls-enabled .element-unlock-choice .element-unlock-recommend {
  right: 2px;
  bottom: 2px;
  width: 18px;
  height: 18px;
  font-size: 16px;
}

body.mobile-controls-enabled .element-unlock-icon {
  width: 18px;
  height: 18px;
}

body.mobile-controls-enabled .element-unlock-choice em,
body.mobile-controls-enabled .element-unlock-choice span {
  font-size: 7px;
}

body.mobile-controls-enabled .element-tutorial-panel {
  left: min(188px, calc(100vw - 286px));
  bottom: 60px;
  z-index: 24;
  max-width: min(273px, calc(100vw - 24px));
  padding: 9px 36px 9px 11px;
  border-radius: 10px;
  font-size: 10px;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

body.mobile-controls-enabled .element-tutorial-close {
  top: 3px;
  right: 7px;
  width: 26px;
  height: 26px;
  font-size: 14px;
}

body.mobile-controls-enabled button.element-tutorial-close {
  min-width: 26px;
  min-height: 26px;
  max-width: 26px;
  max-height: 26px;
}

body.mobile-controls-enabled .levelup-button {
  min-width: 0;
  min-height: 0;
  padding: 6px 8px;
  font-size: 8.4px;
  line-height: 1;
}

body.mobile-controls-enabled .levelup-badge {
  top: -10px;
  right: -10px;
  min-width: 11px;
  height: 11px;
  padding: 0 4px;
  font-size: 8.4px;
  line-height: 11px;
}

body.mobile-controls-enabled #upgradeOverlay {
  z-index: 60;
  pointer-events: auto;
}

body.mobile-controls-enabled #upgradeOverlay .panel {
  width: min(360px, calc(100vw - 16px));
  padding: 14px;
  border-radius: 6px;
  font-size: 10px;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-header {
  gap: 10px;
  margin-bottom: 11px;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-header h2 {
  margin: 0;
  font-size: 14px;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-minimize {
  min-width: 38px;
  min-height: 38px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11px;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-options {
  gap: 8px;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-card {
  min-height: 43px;
  gap: 4px;
  padding: 7px;
  border-radius: 5px;
  line-height: 1.18;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-card strong {
  font-size: 10px;
}

body.mobile-controls-enabled #upgradeOverlay .upgrade-card span {
  font-size: 7px;
}

body.mobile-controls-enabled.mobile-upgrade-open .mobile-aim-zone,
body.mobile-controls-enabled.mobile-upgrade-open .mobile-joystick,
body.mobile-controls-enabled.mobile-upgrade-open .mobile-element-bar,
body.mobile-controls-enabled.mobile-upgrade-open .mobile-earth-skill-button {
  pointer-events: none !important;
}

.mobile-aim-zone {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 52vw;
  pointer-events: none;
  touch-action: none;
}

body.mobile-controls-enabled.mobile-game-active .mobile-aim-zone {
  pointer-events: auto;
}

.mobile-joystick {
  position: absolute;
  left: max(36px, calc(env(safe-area-inset-left) + 14px));
  bottom: max(38px, calc(env(safe-area-inset-bottom) + 14px));
  z-index: 3;
  width: 126px;
  height: 126px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.38);
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.08), 0 10px 28px rgba(0, 0, 0, 0.26);
  pointer-events: none;
  touch-action: none;
  backdrop-filter: blur(5px);
}

body.mobile-controls-enabled.mobile-game-active .mobile-joystick {
  pointer-events: auto;
}

.mobile-joystick::before {
  content: "";
  position: absolute;
  inset: 36px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: inherit;
}

.mobile-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  transform: translate3d(0, 0, 0);
}

.mobile-element-bar {
  position: absolute;
  left: 50%;
  bottom: max(4px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  gap: 8px;
  align-items: end;
  pointer-events: none;
  transform: translateX(-50%) scale(0.9);
  transform-origin: bottom center;
}

body.mobile-controls-enabled .mobile-element-bar {
  bottom: calc(var(--mobile-exp-bar-height) + env(safe-area-inset-bottom, 0px) + var(--mobile-bottom-control-gap));
}

body.mobile-controls-enabled.mobile-game-active .mobile-element-bar {
  pointer-events: auto;
}

.mobile-element-button,
.mobile-confirm-button,
.mobile-earth-skill-button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-element-button {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  box-sizing: border-box;
  width: 58px;
  min-width: 0;
  min-height: 62px;
  padding: 5px 4px 6px;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(16, 22, 32, 0.72);
  font-size: 12px;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.mobile-element-button img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  pointer-events: none;
}

.mobile-element-button.locked,
.mobile-element-button:disabled {
  opacity: 0.42;
  filter: grayscale(0.75);
}

.mobile-element-button.water:not(:disabled) {
  border-color: rgba(83, 194, 255, 0.68);
}

.mobile-element-button.fire:not(:disabled) {
  border-color: rgba(255, 116, 63, 0.7);
}

.mobile-element-button.wind:not(:disabled) {
  border-color: rgba(112, 255, 179, 0.68);
}

.mobile-element-button.earth:not(:disabled) {
  border-color: rgba(213, 154, 78, 0.72);
}

.mobile-confirm-button,
.mobile-earth-skill-button {
  box-sizing: border-box;
  width: 62px;
  min-width: 0;
  min-height: 62px;
  padding: 0 10px;
  background: rgba(235, 235, 235, 0.22);
  font-size: 15px;
  backdrop-filter: blur(6px);
}

.mobile-confirm-button.empty {
  opacity: 0.48;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(18, 24, 34, 0.62);
  box-shadow: none;
}

.mobile-confirm-button.ready {
  opacity: 1;
  border-color: rgba(255, 230, 150, 0.86);
  background: rgba(92, 69, 26, 0.82);
  box-shadow: 0 0 13px rgba(255, 217, 102, 0.48);
}

.mobile-earth-skill-button {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 5px 4px 6px;
  border-color: rgba(211, 154, 69, 0.8);
  border-radius: 8px;
  background: rgba(47, 33, 22, 0.72);
  box-shadow: 0 0 12px rgba(211, 154, 69, 0.24);
  pointer-events: none;
  backdrop-filter: blur(6px);
}

body.mobile-controls-enabled.mobile-game-active .mobile-earth-skill-button {
  pointer-events: auto;
}

body.mobile-controls-enabled .mobile-earth-skill-button.targeting {
  opacity: 1;
  border-color: rgba(255, 230, 150, 0.96);
  background: rgba(68, 48, 22, 0.9);
  box-shadow: 0 0 16px rgba(255, 217, 102, 0.68), 0 8px 22px rgba(0, 0, 0, 0.24);
  transform: scale(1.06);
}

.mobile-earth-skill-button.empty,
.mobile-earth-skill-button.cooldown,
.mobile-earth-skill-button:disabled {
  opacity: 0.52;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(18, 24, 34, 0.72);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

.mobile-earth-key {
  max-width: 68px;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
  text-overflow: ellipsis;
  white-space: normal;
}

body.mobile-controls-enabled .mobile-earth-skill-button.empty .mobile-earth-key,
body.mobile-controls-enabled .mobile-earth-skill-button.cooldown .mobile-earth-key {
  font-size: 15px;
}

.mobile-earth-status {
  max-width: 68px;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 18, 0.76);
  pointer-events: none;
  text-align: center;
  touch-action: none;
}

body.mobile-controls-enabled.mobile-game-active .mobile-rotate-overlay {
  pointer-events: auto;
}

.mobile-rotate-overlay div {
  display: grid;
  gap: 8px;
  padding: 20px 22px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(18, 24, 34, 0.86);
}

.mobile-rotate-overlay strong {
  font-size: 22px;
}

.mobile-rotate-overlay span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

@media (orientation: portrait) and (pointer: coarse) {
  body.mobile-controls-enabled .mobile-start-rotate-hint {
    display: grid;
  }

  body.mobile-controls-enabled .start-form > :not(.mobile-start-rotate-hint),
  body.mobile-controls-enabled .start-panel > #startButton,
  body.mobile-controls-enabled .start-panel > .start-controls {
    filter: blur(3px);
    opacity: 0.36;
    pointer-events: none;
    user-select: none;
  }

  body.mobile-controls-enabled.mobile-game-active .mobile-rotate-overlay {
    display: flex;
  }
}

@media (max-height: 460px) {
  .mobile-joystick {
    width: 108px;
    height: 108px;
  }

  .mobile-element-button {
    width: 52px;
    min-height: 56px;
  }

  .mobile-confirm-button {
    width: 56px;
    min-width: 0;
    min-height: 56px;
  }

  .mobile-earth-skill-button {
    width: 56px;
    min-height: 56px;
  }
}
