#pvp-overlay {
  --pvp-scale: 1;
  position: fixed;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  background: rgba(24, 17, 12, 0.58);
  color: #3a2519;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  isolation: isolate;
}

#pvp-overlay * {
  box-sizing: border-box;
  letter-spacing: 0;
}

.pvp-window-shell {
  width: 582px;
  flex: 0 0 582px;
  transform: scale(var(--pvp-scale));
  transform-origin: center center;
}

.pvp-window {
  position: relative;
  width: 582px;
  min-height: 560px;
  padding: 70px 54px 42px;
  background: url("../../../resources/img/battleUI/giveUpDialog/bg.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 16px 12px rgba(24, 13, 7, 0.45));
  animation: pvp-window-enter 180ms ease-out both;
}

.pvp-window.is-compact {
  min-height: 470px;
  padding-top: 62px;
}

.pvp-window.is-room {
  min-height: 540px;
}

.pvp-close {
  position: absolute;
  top: 27px;
  right: 31px;
  width: 54px;
  height: 52px;
  padding: 0;
  border: 0;
  background: url("../../../resources/img/pvpUI/close.png") center / contain no-repeat;
  cursor: pointer;
  transition: transform 100ms ease-out;
}

.pvp-close:hover {
  transform: rotate(5deg) scale(1.05);
}

.pvp-close:active {
  transform: translateY(3px) scale(0.94);
}

.pvp-emblem {
  position: absolute;
  top: -40px;
  left: 50%;
  width: 244px;
  height: 122px;
  transform: translateX(-50%);
  pointer-events: none;
  animation: pvp-emblem-float 1800ms steps(6, end) infinite;
}

.pvp-emblem img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.pvp-heading {
  text-align: center;
}

.pvp-title-ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 310px;
  height: 72px;
  margin: 0 auto;
  background: url("../../../resources/img/pvpUI/titleShadow.png") center / 100% 100% no-repeat;
}

.pvp-title-ribbon h2 {
  margin: -4px 0 0;
  font-size: 38px;
  line-height: 1;
  font-weight: 800;
  color: #3b2016;
  text-shadow: 0 2px 0 #f5dfae;
}

.pvp-kicker {
  margin: 10px 0 0;
  font-size: 24px;
  line-height: 1.3;
  font-weight: 700;
  color: #7c4b27;
}

.pvp-copy {
  min-height: 31px;
  margin: 7px auto 0;
  font-size: 21px;
  line-height: 1.45;
  color: #5a3b27;
  text-align: center;
}

.pvp-divider {
  width: 390px;
  height: 2px;
  margin: 17px auto 15px;
  background: rgba(91, 49, 26, 0.35);
  box-shadow: 0 2px 0 rgba(255, 245, 211, 0.55);
}

.pvp-actions {
  display: grid;
  grid-template-columns: 228px 228px;
  justify-content: center;
  gap: 9px 17px;
}

.pvp-actions.is-secondary {
  grid-template-columns: 196px 196px;
  gap: 12px;
  margin-top: 8px;
}

.pvp-actions.is-single {
  grid-template-columns: 228px;
}

.pvp-game-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 228px;
  height: 104px;
  padding: 0 12px 8px;
  border: 0;
  color: #ffffff;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  font-family: inherit;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  text-shadow:
    -2px -2px 0 #342018,
    2px -2px 0 #342018,
    -2px 2px 0 #342018,
    2px 2px 0 #342018;
  cursor: pointer;
  transition: transform 90ms ease-out, filter 90ms ease-out;
}

.pvp-game-btn.is-blue {
  background-image: url("../../../resources/img/pvpUI/blueBtn.png");
}

.pvp-game-btn.is-red {
  background-image: url("../../../resources/img/pvpUI/redBtn.png");
}

.pvp-game-btn.is-small {
  width: 196px;
  height: 90px;
  gap: 6px;
  padding: 0 10px 7px;
  font-size: 24px;
}

.pvp-game-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.pvp-game-btn:active:not(:disabled) {
  filter: brightness(0.92);
  transform: translateY(5px) scale(0.98);
}

.pvp-game-btn:disabled {
  filter: grayscale(0.8);
  opacity: 0.56;
  cursor: default;
}

.pvp-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  font-family: Arial, sans-serif;
  font-size: 35px;
  font-weight: 900;
  line-height: 1;
}

.pvp-btn-icon.is-arrow {
  transform: translateY(-1px);
}

.pvp-btn-image-icon {
  width: 31px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}

.pvp-input-panel,
.pvp-code-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 466px;
  min-height: 132px;
  margin: 15px auto 9px;
  padding: 24px 40px 30px;
  background: url("../../../resources/img/pvpUI/panelBg.png") center / 100% 100% no-repeat;
}

.pvp-field {
  width: 100%;
  height: 58px;
  padding: 6px 16px 4px;
  border: 3px solid #5e3926;
  border-radius: 5px;
  outline: 0;
  color: #321e14;
  background: #f7e9c8;
  box-shadow: inset 0 4px 0 rgba(115, 74, 42, 0.16);
  font-family: inherit;
  font-size: 25px;
  line-height: 1;
  text-align: center;
}

.pvp-field:focus {
  border-color: #8a3025;
  box-shadow: inset 0 4px 0 rgba(115, 74, 42, 0.16), 0 0 0 3px rgba(198, 145, 57, 0.4);
}

.pvp-field.is-code {
  height: 69px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 14px;
  padding-left: 29px;
}

.pvp-field.is-invalid {
  border-color: #b72f24;
  animation: pvp-input-shake 180ms linear 2;
}

.pvp-field-label {
  margin: 12px 0 0;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  color: #4b2d1e;
}

.pvp-field-hint {
  margin: 2px 0 10px;
  font-size: 19px;
  color: #795739;
  text-align: center;
}

.pvp-room-code {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.pvp-room-code span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 70px;
  border-bottom: 5px solid #563321;
  color: #3b2117;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 51px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 0 2px 0 #f7dfab;
}

.pvp-waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 7px 0 10px;
  color: #694127;
  font-size: 22px;
  font-weight: 800;
}

.pvp-waiting-dots {
  display: inline-flex;
  gap: 5px;
}

.pvp-waiting-dots i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8d3027;
  animation: pvp-waiting-dot 900ms steps(3, end) infinite;
}

.pvp-waiting-dots i:nth-child(2) {
  animation-delay: 150ms;
}

.pvp-waiting-dots i:nth-child(3) {
  animation-delay: 300ms;
}

.pvp-status-mark {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 18px auto 10px;
}

.pvp-status-mark::before,
.pvp-status-mark::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 8px solid #853027;
  transform: rotate(45deg);
  animation: pvp-status-pulse 720ms steps(4, end) infinite alternate;
}

.pvp-status-mark::after {
  inset: 29px;
  border-color: #d7a43b;
  animation-delay: 180ms;
}

.pvp-status-mark.is-error::before,
.pvp-status-mark.is-error::after {
  animation: none;
  border: 0;
}

.pvp-status-mark.is-error::before {
  content: "!";
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: #8e2d24;
  clip-path: polygon(50% 3%, 98% 92%, 2% 92%);
  font-family: Arial, sans-serif;
  font-size: 54px;
  font-weight: 900;
  transform: none;
}

.pvp-error-copy {
  width: 430px;
  margin: 5px auto 13px;
  color: #6b2a21;
  font-size: 20px;
  line-height: 1.45;
  text-align: center;
}

.pvp-confirm-copy {
  width: 420px;
  margin: 18px auto 22px;
  color: #5c3825;
  font-size: 25px;
  line-height: 1.5;
  font-weight: 700;
  text-align: center;
}

.pvp-copy-result {
  height: 24px;
  margin: -2px 0 0;
  color: #7b3025;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

@keyframes pvp-window-enter {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pvp-emblem-float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

@keyframes pvp-waiting-dot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-5px); }
}

@keyframes pvp-status-pulse {
  from { opacity: 0.42; transform: rotate(45deg) scale(0.78); }
  to { opacity: 0.95; transform: rotate(45deg) scale(1); }
}

@keyframes pvp-input-shake {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(7px); }
}

@media (prefers-reduced-motion: reduce) {
  .pvp-window,
  .pvp-emblem,
  .pvp-waiting-dots i,
  .pvp-status-mark::before,
  .pvp-status-mark::after {
    animation: none;
  }
}
