/* Knife Duels: HUD, touch controls, rotate overlay. */

.kd-hud,
.kd-touch {
  position: absolute;
  inset: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  pointer-events: none;
  user-select: none;
}

.kd-hud * {
  box-sizing: border-box;
}

.kd-text-stroke {
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Top centre: team chips + timer */
.kd-top {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.kd-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.kd-chip-avatar {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  background: #b8bcc3 center / cover no-repeat;
  border-radius: 3px 3px 0 0;
}

.kd-chip-bar {
  width: 42px;
  height: 4px;
  background: #888;
}

.kd-chip.kd-mine .kd-chip-bar {
  background: #3ddc84;
}

.kd-chip.kd-enemy .kd-chip-bar {
  background: #ff4d4d;
}

.kd-chip-score {
  margin-top: 2px;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  padding: 0 8px;
  border-radius: 3px;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
}

.kd-chip.kd-mine .kd-chip-score {
  color: #3ddc84;
}

.kd-chip.kd-enemy .kd-chip-score {
  color: #ff4d4d;
}

.kd-timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 84px;
  height: 42px;
  background: rgba(20, 20, 24, 0.85);
  border-radius: 4px;
}

.kd-timer {
  font-weight: 800;
  font-size: 24px;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
}

.kd-timer.kd-timer-red {
  color: #ff4d4d;
}

.kd-firstto {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.kd-firstto.kd-show {
  opacity: 1;
}

.kd-finish-duel {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 20px;
  background: rgba(60, 60, 65, 0.75);
  border-bottom: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  border-radius: 2px;
  display: none;
}

.kd-finish-duel.kd-show {
  display: block;
}

/* Countdown */
.kd-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 110px;
  font-weight: 800;
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  display: none;
}

.kd-matchpoint {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  padding: 6px 18px;
  border-radius: 999px;
  background: #ffd166;
  color: #1a1200;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.kd-matchpoint.kd-show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Vignette: full screen pink/red wash on low HP (not just edges) */
.kd-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 30, 70, 0.35) 0%,
    rgba(255, 10, 40, 0.6) 100%
  );
  transition: opacity 0.2s ease;
}

/* Round end: darken + desaturate the screen behind the banner */
.kd-round-dim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: grayscale(0.7) brightness(0.6);
  -webkit-backdrop-filter: grayscale(0.7) brightness(0.6);
  transition: opacity 0.25s ease;
}

.kd-round-dim.kd-show {
  opacity: 1;
}

/* HP bar */
.kd-hp-box {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.kd-hp-bar {
  width: 300px;
  height: 10px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.kd-hp-fill {
  height: 100%;
  width: 100%;
  transition: width 0.15s ease;
}

.kd-hp-fill.kd-hp-green {
  background: #3ddc84;
}

.kd-hp-fill.kd-hp-orange {
  background: #f2a83c;
}

.kd-hp-fill.kd-hp-red {
  background: #ff4d4d;
}

.kd-hp-text {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
}

/* Kill feed */
.kd-killfeed {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.kd-kill-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.kd-kill-row.kd-kill-mine {
  background: rgba(61, 220, 132, 0.25);
}

.kd-knife-glyph {
  color: #ff4d4d;
  font-size: 11px;
}

.kd-headshot {
  margin-left: 4px;
  color: #ffd166;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

/* Eliminated toast, shown under the round banner on your own kills */
.kd-eliminated {
  position: absolute;
  top: 58%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.kd-eliminated.kd-show {
  opacity: 1;
}

.kd-eliminated-name {
  color: #ff4d4d;
}

/* Crosshair and hit marker */
.kd-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.kd-hitmarker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.kd-hitmarker span {
  position: absolute;
  width: 8px;
  height: 2px;
  background: #fff;
  top: 50%;
  left: 50%;
}

.kd-hitmarker span:nth-child(1) {
  transform: translate(-14px, -8px) rotate(45deg);
}
.kd-hitmarker span:nth-child(2) {
  transform: translate(6px, -8px) rotate(-45deg);
}
.kd-hitmarker span:nth-child(3) {
  transform: translate(-14px, 6px) rotate(-45deg);
}
.kd-hitmarker span:nth-child(4) {
  transform: translate(6px, 6px) rotate(45deg);
}

.kd-hitmarker.kd-head span {
  background: #ff4d4d;
}

.kd-hitmarker.kd-show {
  opacity: 1;
}

.kd-rearm {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: none;
}

.kd-rearm.kd-show {
  display: block;
  background: conic-gradient(
    rgba(255, 255, 255, 0.5) calc(var(--kd-rearm-frac, 1) * 360deg),
    transparent 0
  );
}

/* Round banner */
.kd-banner {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.kd-banner.kd-show {
  opacity: 1;
}

.kd-banner-title {
  font-size: 46px;
  font-weight: 900;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
}

.kd-banner.kd-banner-win .kd-banner-title {
  color: #3ddc84;
}

.kd-banner.kd-banner-lose .kd-banner-title {
  color: #ff4d4d;
}

.kd-banner.kd-banner-info .kd-banner-title {
  color: #fff;
}

.kd-banner-sub {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
}

.kd-banner-score-row {
  margin-top: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(10, 10, 14, 0.7);
  padding: 8px 14px;
  border-radius: 6px;
}

.kd-banner-score-row.kd-show {
  display: flex;
}

.kd-chip-mini {
  width: 30px;
  height: 30px;
  border-radius: 3px;
  background: #b8bcc3 center / cover no-repeat;
  border-bottom: 3px solid #888;
}

.kd-chip-mini.kd-mine {
  border-bottom-color: #3ddc84;
}

.kd-chip-mini.kd-enemy {
  border-bottom-color: #ff4d4d;
}

.kd-banner-score {
  font-size: 30px;
  font-weight: 900;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

.kd-banner-score.kd-score-green {
  color: #3ddc84;
}

.kd-banner-score.kd-score-red {
  color: #ff4d4d;
}

/* Scoreboard */
.kd-scoreboard {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 260px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
  color: #fff;
  font-size: 13px;
}

.kd-scoreboard.kd-show {
  display: flex;
}

.kd-score-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 6px;
}

.kd-score-row.kd-team-a {
  color: #3ddc84;
}

.kd-score-row.kd-team-b {
  color: #ff4d4d;
}

/* Match end */
.kd-matchend {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding-top: 60px;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: grayscale(0.4) brightness(0.8);
  -webkit-backdrop-filter: grayscale(0.4) brightness(0.8);
  pointer-events: auto;
}

.kd-matchend.kd-show {
  display: flex;
}

.kd-matchend-title {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
}

.kd-matchend.kd-win .kd-matchend-title {
  color: #3ddc84;
}

.kd-matchend.kd-lose .kd-matchend-title {
  color: #ff4d4d;
}

.kd-matchend-score {
  font-size: 30px;
  font-weight: 900;
}

.kd-matchend-score .kd-score-green {
  color: #3ddc84;
}

.kd-matchend-score .kd-score-red {
  color: #ff4d4d;
}

.kd-matchend-score-sep {
  color: #fff;
  margin: 0 8px;
}

.kd-matchend-card {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  background: rgba(10, 10, 14, 0.75);
  border-top: 3px solid #ffd166;
  padding: 10px 26px;
  border-radius: 4px;
}

.kd-endstat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.kd-endstat-value {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.kd-endstat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #ccc;
  text-transform: uppercase;
}

.kd-matchend button {
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  position: absolute;
  bottom: 28px;
}

.kd-btn-leave {
  right: 24px;
  background: #b3271f;
  color: #fff;
}

.kd-btn-again {
  left: 24px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
}

/* Damage numbers */
.kd-damage-number {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
  animation: kd-dmg-float 0.7s ease-out forwards;
}

@keyframes kd-dmg-float {
  from {
    opacity: 1;
    translate: 0 0;
  }
  to {
    opacity: 0;
    translate: 0 -30px;
  }
}

/* Touch controls */
.kd-joystick-zone,
.kd-look-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
}

.kd-joystick-zone {
  left: 0;
}

.kd-look-zone {
  right: 0;
}

.kd-joystick-ring {
  position: absolute;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  margin-top: -60px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.kd-tbtn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.05em;
  pointer-events: auto;
  touch-action: none;
}

.kd-tbtn-throw {
  right: 24px;
  bottom: 24px;
  width: 96px;
  height: 96px;
  font-size: 14px;
  background: rgba(255, 77, 77, 0.35);
}

.kd-tbtn-stab {
  right: 130px;
  bottom: 90px;
  width: 58px;
  height: 58px;
}

.kd-tbtn-jump {
  right: 150px;
  bottom: 30px;
  width: 58px;
  height: 58px;
}

.kd-tbtn-dash {
  right: 34px;
  bottom: 130px;
  width: 58px;
  height: 58px;
}

.kd-tbtn-crouch {
  right: 110px;
  bottom: 165px;
  width: 58px;
  height: 58px;
}

/* Rotate your phone overlay: portrait + coarse pointer only */
.kd-rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: #000;
  pointer-events: auto;
}

.kd-rotate-text {
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  text-align: center;
  padding: 20px;
}

@media (pointer: coarse) and (orientation: portrait) {
  .kd-rotate-overlay {
    display: flex;
  }
}

/* Scale down HUD on narrow screens */
@media (max-width: 700px) {
  .kd-chip-avatar,
  .kd-chip-bar {
    width: 34px;
  }

  .kd-chip-avatar {
    height: 34px;
    font-size: 15px;
  }

  .kd-timer {
    font-size: 20px;
  }

  .kd-hp-bar {
    width: 200px;
  }

  .kd-countdown {
    font-size: 84px;
  }

  .kd-banner-title {
    font-size: 32px;
  }

  .kd-matchend-title {
    font-size: 40px;
  }

  .kd-tbtn-throw {
    width: 76px;
    height: 76px;
  }

  .kd-tbtn-stab,
  .kd-tbtn-jump,
  .kd-tbtn-dash,
  .kd-tbtn-crouch {
    width: 46px;
    height: 46px;
    font-size: 9px;
  }
}

/* ===== Knife Duels: victory/defeat end screen (js/victory.js) ===== */

.kd-victory-root {
  position: absolute;
  inset: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  user-select: none;
  z-index: 40;
}

.kd-victory-root * {
  box-sizing: border-box;
}

.kd-victory-title {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000,
    0 4px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.kd-victory-title-win {
  color: #3cff5a;
}

.kd-victory-title-lose {
  color: #ff3c3c;
}

.kd-victory-scores {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.kd-victory-tile {
  width: 68px;
  height: 92px;
  background: rgba(20, 22, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
}

.kd-victory-tile-mine {
  color: #3ddc84;
}

.kd-victory-tile-enemy {
  color: #ff4d4d;
}

.kd-victory-card {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  padding: 10px 12px 14px;
  background: rgba(12, 13, 16, 0.72);
  border-radius: 6px;
  text-align: center;
  pointer-events: none;
}

.kd-victory-name {
  color: #ffffff;
  font-weight: 700;
  font-size: 17px;
}

.kd-victory-handle {
  color: #9aa0a8;
  font-size: 12px;
  margin-top: 1px;
  margin-bottom: 8px;
}

.kd-victory-stats {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.kd-victory-stat {
  flex: 1;
}

.kd-victory-stat-value {
  color: #ffffff;
  font-weight: 800;
  font-size: 17px;
}

.kd-victory-stat-label {
  color: #9aa0a8;
  font-size: 10px;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.kd-victory-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: #f2c14e;
  border-radius: 0 0 6px 6px;
}

.kd-victory-leave {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 165px;
  height: 54px;
  background: #7a1414;
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
}

.kd-victory-leave:hover {
  background: #8f1919;
}
