/* ลานเดือด and โหมดสู้ on screen (public/js/ui/pvp-ffa.js, ui/pvp-flag.js, game/pvpfx.js, game/ffafx.js): the duel's
   look (css/pvp.css: dark plum panels, gold edges, Mitr for the big words), a fighting game's bars and board, red for
   the flag. */

/* ------------------------------------------------------------ in an arena the modes' HUD pieces make way too */
body.in-arena .flag-btn,
body.in-arena .flag-board,
body.in-arena .worldboss.ffabar {
  display: none !important;
}

/* ------------------------------------------------------------ ลานเดือด's banner on the HUD (where the raid's would be) */
.worldboss.ffabar {
  top: calc(var(--gap) + var(--safe-t) + 84px);
  background: rgba(58, 16, 26, 0.94);
  border-color: var(--pvp-gold, #f5c93a);
}

.worldboss.ffabar.on {
  border-color: #ff5a3a;
}

.worldboss.ffabar b {
  color: #ffd76a;
}

.worldboss.ffabar .go {
  background: #d43b2a;
}

.worldboss.ffabar .go.wait {
  background: #6a5a72;
}

/* (a computer: no world boss banner above it, it takes that place; a raid's under it, below that. Never on a phone,
   where the banners are chips at the bottom: a top as well as a bottom stretched it over the screen) */
body:not(.touch) #hud:has(#worldboss[hidden]):not(:has(#raidbar:not([hidden]))) .worldboss.ffabar {
  top: calc(var(--gap) + var(--safe-t) + 42px);
}

body:not(.touch) #hud:has(#raidbar:not([hidden])) .worldboss.ffabar {
  top: calc(var(--gap) + var(--safe-t) + 126px);
}

/* (a computer: the toasts come in under the banner, never over it and its "เข้าลาน", as under the world boss's bar) */
@media (min-width: 561px) and (min-height: 521px) {
  body:not(.touch) #hud:has(.ffabar:not([hidden])) ~ #toasts {
    top: calc(var(--safe-t) + 100px);
  }

  body:not(.touch) #hud:has(.ffabar:not([hidden])):has(#worldboss:not([hidden])) ~ #toasts {
    top: calc(var(--safe-t) + 142px);
  }

  body:not(.touch) #hud:has(.ffabar:not([hidden])):has(#raidbar:not([hidden])) ~ #toasts {
    top: calc(var(--safe-t) + 184px);
  }
}

/* a phone: a chip above the hotbar like the others, above the boss's and the raid's when they are up */
body.touch #hud .worldboss.ffabar {
  bottom: var(--chip-b);
  top: auto;
}

body.touch #hud:has(#worldboss:not([hidden])) .worldboss.ffabar,
body.touch #hud:has(#raidbar:not([hidden])) .worldboss.ffabar {
  bottom: calc(var(--chip-b) + 30px);
}

body.touch #hud:has(#worldboss:not([hidden])):has(#raidbar:not([hidden])) .worldboss.ffabar {
  bottom: calc(var(--chip-b) + 60px);
}

/* (an upright phone with the pet's buttons up: the chips stand higher, css/pets-v2.css; this one above them too) */
body.touch.upright #hud:has(.pet-v2-controls:not([hidden])) .worldboss.ffabar {
  --chip-b: calc(var(--gap) + var(--safe-b) + 370px);
}

/* the open window's toast has its way in (the toasts let taps through to the game, but not this button) */
#toasts .ffa-join {
  pointer-events: auto;
}

/* ลานเดือด's courtyard: the screen's edges fall into shadow (the fires, the pads and the altar carry the light: the owner's
   look reference is a dark scene lit by its glows; over the world, under its names and every screen) */
body.in-ffa #game::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 78% 72% at 50% 50%, rgba(12, 8, 18, 0) 55%, rgba(12, 8, 18, 0.5) 100%);
}

/* ------------------------------------------------------------ ลานเดือด: the bars across the top */
.ffa-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) 16px calc(8px + var(--safe-l));
  background: linear-gradient(rgba(20, 12, 24, 0.82), rgba(20, 12, 24, 0.5) 62%, rgba(20, 12, 24, 0));
  pointer-events: none;
}

.ffa-me {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.ffa-face {
  flex: none;
  width: 44px;
  height: 44px;
  border: 3px solid var(--pvp-mine, #3bb8ff);
  border-radius: 10px;
  background: #2b1f2e;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.ffa-face img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.ffa-who {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  max-width: 340px;
}

.ffa-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.ffa-name b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 15px/1.2 var(--pvp-word, 'Mitr', sans-serif);
  /* (room inside the clip for Thai marks over an upper vowel: the layout stays as it was) */
  padding: 0.35em 0 0.15em;
  margin: -0.35em 0 -0.15em;
}

.ffa-name small {
  flex: none;
  color: #ffe9a8;
  font-size: 11px;
}

.ffa-bar {
  position: relative;
  height: 18px;
  border: 2px solid var(--pvp-gold, #f5c93a);
  border-radius: 4px;
  background: #3a1e26;
  overflow: hidden;
  transform: skewX(-12deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.ffa-bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
}

.ffa-bar .ghost {
  background: #fff3c4;
  transition: width 0.45s ease-out;
}

.ffa-bar .fill {
  background: linear-gradient(#ffe36e, #f0a92a 55%, #d47a14);
  transition: width 0.12s;
}

.ffa-bar .shield {
  width: 0;
  background: repeating-linear-gradient(-45deg, rgba(255, 245, 200, 0.85) 0 4px, rgba(255, 205, 70, 0.75) 4px 8px);
  mix-blend-mode: screen;
}

.ffa-me.low .ffa-bar .fill {
  background: linear-gradient(#ff8a6e, #e3402c);
  animation: pvp-low 0.8s ease-in-out infinite alternate;
}

/* (white with a dark outline, as the duel's bar: readable over the fill and over the dark empty part at low HP) */
.ffa-bar .num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: skewX(12deg);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #1f1624, 1px 0 0 #1f1624, -1px 0 0 #1f1624, 0 -1px 0 #1f1624, 0 0 3px rgba(31, 22, 36, 0.8);
}

.ffa-boosts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 0;
}

/* (a chip pops once, when the power-up is taken: ui/pvp-ffa.js keeps it and changes only its seconds; it grows from
   its left end, never off the screen's edge) */
.ffa-boost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 7px 0 3px;
  border-radius: 9px;
  background: rgba(31, 22, 36, 0.86);
  border: 1px solid var(--pvp-gold, #f5c93a);
  color: #fff3c4;
  font-size: 11px;
  font-weight: 700;
  transform-origin: left center;
  animation: ffa-chip-in 0.32s ease-out;
}

@keyframes ffa-chip-in {
  0% { transform: scale(1.3); filter: brightness(1.6); }
  100% { transform: scale(1); filter: none; }
}

.ffa-boost.boots { border-color: #ffb02e; }
.ffa-boost.armor { border-color: #ffd34a; }
.ffa-boost.blade { border-color: #ff6a2a; color: #ffd0b8; }
.ffa-boost.safe { border-color: #fff3a0; background: rgba(120, 90, 10, 0.86); }

.ffa-mid {
  display: grid;
  justify-items: center;
  min-width: 70px;
  padding: 2px 10px 4px;
  border: 3px solid var(--pvp-gold, #f5c93a);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: rgba(31, 22, 36, 0.92);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}

.ffa-time {
  color: #fff;
  font: 600 28px/1.1 var(--pvp-word, 'Mitr', sans-serif);
  text-shadow: 0 2px 0 #000;
}

.ffa-time.low {
  color: #ff6a5a;
  animation: pvp-tick 1s steps(2) infinite;
}

.ffa-state {
  color: var(--pvp-gold, #f5c93a);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.ffa-board {
  justify-self: end;
  width: min(230px, 100%);
  padding: 4px 6px 5px;
  border: 2px solid rgba(245, 201, 58, 0.75);
  border-radius: 10px;
  background: rgba(31, 22, 36, 0.86);
  color: #fff;
}

.ffa-board-head {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--pvp-gold, #f5c93a);
  font-size: 12px;
  font-weight: 800;
}

.ffa-board-head .ffa-room {
  margin-left: auto;
  color: #d8c8de;
  font-size: 10px;
  font-weight: 600;
}

.ffa-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* (a long name is cut short, never the board wider) */
  gap: 1px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.ffa-rows li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 4px;
  padding: 0 3px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.45;
}

.ffa-rows li.mine {
  background: rgba(59, 184, 255, 0.28);
  outline: 1px solid rgba(59, 184, 255, 0.7);
}

.ffa-rows li.apart {
  margin-top: 3px;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
}

.ffa-rows li.down {
  opacity: 0.55;
}

.ffa-rows .rank-n {
  display: grid;
  place-items: center;
  height: 16px;
  border-radius: 4px;
  background: #4a3a52;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.ffa-rows li:nth-child(1):not(.apart) .rank-n { background: #e8b64a; color: #3a2408; }
.ffa-rows li:nth-child(2):not(.apart) .rank-n { background: #c8d0dc; color: #2b2f38; }
.ffa-rows li:nth-child(3):not(.apart) .rank-n { background: #d08a4a; color: #3a1a08; }

.ffa-rows .who {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.ffa-rows .who img {
  width: 14px;
  height: 14px;
  filter: sepia(1) saturate(5) hue-rotate(-12deg) brightness(1.15);
}

.ffa-rows .who .pvp-nm {
  max-width: 100%;
}

.ffa-rows .pts {
  color: var(--pvp-gold, #f5c93a);
  font-weight: 800;
}

.ffa-rows .kd {
  color: #d8c8de;
  font-size: 10px;
  text-align: right;
}

/* leaving (under my bar) */
.ffa-leave {
  position: fixed;
  top: calc(84px + var(--safe-t));
  left: calc(8px + var(--safe-l));
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px 2px 6px;
  border: 2px solid #c8b8cc;
  border-radius: 10px;
  background: rgba(31, 22, 36, 0.8);
  color: #f3e7f5;
  font-size: 12px;
  font-weight: 700;
}

.ffa-leave-ask {
  top: calc(112px + var(--safe-t));
}

.ffa-leave-ask small {
  display: block;
}

/* the kill feed: a few lines at the left, mine gold, my fall red */
.ffa-feed {
  position: fixed;
  top: calc(116px + var(--safe-t));
  left: calc(8px + var(--safe-l));
  z-index: 3;
  display: grid;
  justify-items: start;
  gap: 3px;
  max-width: min(46vw, 330px);
  pointer-events: none;
}

.ffa-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: 9px;
  background: rgba(31, 22, 36, 0.84);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  animation: ffa-line-in 0.25s ease-out;
  transition: opacity 0.5s;
}

.ffa-line .pvp-nm {
  max-width: 13em;
}

.ffa-line .killer {
  color: #ffd76a;
}

.ffa-line .victim {
  color: #ffb4a8;
}

.ffa-line.mine {
  background: rgba(120, 84, 10, 0.92);
  outline: 1px solid #f5c93a;
}

.ffa-line.fell {
  background: rgba(120, 22, 18, 0.92);
  outline: 1px solid #ff6a5a;
}

.ffa-line.left {
  color: #d8c8de;
  font-weight: 600;
}

.ffa-line small {
  color: #d8c8de;
  font-weight: 600;
}

.ffa-line.gone {
  opacity: 0;
}

.ffa-line .ko-ico {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.ffa-line .ko-ico img {
  width: 14px;
  height: 14px;
}

.ffa-line .ko-ico small {
  color: #ff8a7a;
  font-size: 10px;
  font-weight: 800;
}

/* the feed's helpers: in full, or as "+N" on a phone */
.ffa-line .helpers .short {
  display: none;
}

@keyframes ffa-line-in {
  from { opacity: 0; transform: translateX(-12px); }
}

/* a call-out under the bars: someone else's streak, a bounty begun or ended */
/* (as wide as its words, on one line: shrink-to-fit gave it half the screen and two lines) */
.ffa-callout {
  position: fixed;
  left: 50%;
  top: calc(86px + var(--safe-t));
  z-index: 3;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 440px);
  pointer-events: none;
}

.ffa-call {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border: 2px solid #c8b8cc;
  border-radius: 12px;
  background: rgba(31, 22, 36, 0.9);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  animation: pvp-bump 0.35s;
}

.ffa-call.gold {
  border-color: var(--pvp-gold, #f5c93a);
  background: rgba(96, 62, 8, 0.94);
  color: #fff3c4;
}

.ffa-call img {
  flex: none;
}

/* the lobby: how many more, who is in */
.ffa-lobby {
  position: fixed;
  left: 50%;
  top: 24%;
  z-index: 3;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(88vw, 360px);
  padding: 10px 14px 12px;
  border: 3px solid var(--pvp-gold, #f5c93a);
  border-radius: 16px;
  background: rgba(31, 22, 36, 0.9);
  color: #fff;
  text-align: center;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.ffa-lobby b {
  font: 600 24px/1.2 var(--pvp-word, 'Mitr', sans-serif);
  color: #ffd76a;
}

.ffa-lobby .ffa-lobby-room {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px 0 4px;
  border-radius: 9px;
  background: rgba(168, 26, 20, 0.85);
  color: #fff3c4;
  font-weight: 800;
}

.ffa-lobby-room img {
  width: 16px;
  height: 16px;
}

.ffa-lobby small {
  color: #e6dcea;
  font-size: 12px;
}

.ffa-lobby .ffa-hint {
  color: #ffb4a8;
}

/* the attack button pressed in a lobby: the box that already says "waiting for N more" nods (no toast over it) */
.ffa-lobby.nudge {
  animation: ffa-nudge 0.42s ease-out;
}

@keyframes ffa-nudge {
  0%, 100% { transform: translateX(-50%); }
  20% { transform: translateX(calc(-50% - 7px)); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 0 4px rgba(255, 215, 106, 0.6); }
  45% { transform: translateX(calc(-50% + 6px)); }
  70% { transform: translateX(calc(-50% - 3px)); }
}

.ffa-lobby-faces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.ffa-lobby-faces span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #8a7a92;
  border-radius: 8px;
  background: #2b1f2e;
  overflow: hidden;
}

/* my fall: the screen's edges in red; who did it and the count to my wave on a dark card (the killer, whom the camera
   watches, stays clear in the middle) */
.ffa-ko {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: start;
  justify-items: center;
  padding-top: max(15vh, calc(118px + var(--safe-t)));
  background: radial-gradient(ellipse 70% 64% at 50% 48%, rgba(70, 0, 0, 0) 52%, rgba(90, 6, 6, 0.55) 100%);
  color: #fff;
  text-align: center;
  pointer-events: none;
  animation: fade-in 0.3s;
}

.ffa-ko-card {
  display: grid;
  justify-items: center;
  gap: 2px;
  max-width: min(92vw, 380px);
  padding: 4px 18px 9px;
  border: 3px solid #ff6a5a;
  border-radius: 16px;
  background: linear-gradient(rgba(58, 16, 26, 0.9), rgba(31, 22, 36, 0.9));
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  animation: pvp-res-in 0.3s ease-out;
}

.ffa-ko b {
  font: 600 52px/1 var(--pvp-word, 'Mitr', sans-serif);
  color: #ff5a4a;
  text-shadow: 3px 0 0 #2a0606, -3px 0 0 #2a0606, 0 3px 0 #2a0606, 0 -3px 0 #2a0606, 0 6px 0 rgba(0, 0, 0, 0.4);
  animation: ffa-ko-stamp 0.45s ease-out both;
}

/* (the duel's pvp-stamp fades out at its end and is placed for a centred word: this one stays on the card) */
@keyframes ffa-ko-stamp {
  0% { opacity: 0; transform: scale(2.4); }
  30% { opacity: 1; transform: scale(0.92); }
  55% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

.ffa-ko span {
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}

.ffa-ko .pvp-nm {
  color: #ffd76a;
}

.ffa-ko-count {
  margin-top: 4px;
  padding: 2px 14px;
  border: 2px solid var(--pvp-gold, #f5c93a);
  border-radius: 12px;
  background: rgba(31, 22, 36, 0.86);
  color: #ffd76a;
  font: 600 20px/1.3 var(--pvp-word, 'Mitr', sans-serif);
}

.ffa-ko small {
  color: #f0dcd8;
  font-size: 12px;
  font-weight: 600;
}

/* the end: the podium (second, first, third), my place and what it paid, the day's cap */
.ffa-end {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(10px + var(--safe-b));
  z-index: 6;
  display: grid;
  justify-items: center;
  padding: 0 10px;
  pointer-events: none;
}

.ffa-res {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(96vw, 540px);
  max-height: calc(100vh - 110px - var(--safe-t) - var(--safe-b));
  overflow: auto;
  padding: 10px 14px 12px;
  border: 3px solid var(--pvp-gold, #f5c93a);
  border-radius: 18px;
  background: linear-gradient(rgba(44, 28, 52, 0.96), rgba(31, 22, 36, 0.96));
  color: #fff;
  text-align: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: pvp-res-in 0.35s ease-out;
}

.ffa-res-title {
  color: var(--pvp-gold, #f5c93a);
  font: 600 26px/1.2 var(--pvp-word, 'Mitr', sans-serif);
  text-shadow: 0 3px 0 #000;
}

.ffa-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.ffa-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 31%;
  min-width: 0;
}

.ffa-step .skill-avatar {
  width: 64px;
  height: 92px;
}

.ffa-step-block {
  display: grid;
  place-items: center;
  width: 100%;
  border: 2px solid #9a6b14;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(#e8b64a, #b8861a);
  color: #3a2408;
  font: 600 20px/1 var(--pvp-word, 'Mitr', sans-serif);
}

.ffa-step.p1 .ffa-step-block { height: 38px; }
.ffa-step.p2 .ffa-step-block { height: 26px; background: linear-gradient(#e6ebf2, #9aa4b2); border-color: #6a7280; }
.ffa-step.p3 .ffa-step-block { height: 18px; background: linear-gradient(#e2a066, #a8622a); border-color: #6a3a14; }

.ffa-step.mine .ffa-step-name {
  color: #8fd8ff;
}

.ffa-step-name {
  max-width: 100%;
  font-size: 13px;
}

.ffa-step-name .pvp-nm {
  max-width: 100%;
}

.ffa-step-block b {
  line-height: 1;
}

.ffa-step small {
  color: #e6dcea;
  font-size: 11px;
}

.ffa-you {
  display: grid;
  gap: 1px;
}

.ffa-you b {
  font: 600 18px/1.3 var(--pvp-word, 'Mitr', sans-serif);
  color: #fff;
}

.ffa-you small {
  color: #e6dcea;
  font-size: 12px;
}

.ffa-reward {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(245, 201, 58, 0.16);
  color: #ffe9a8;
  font-weight: 800;
}

.ffa-reward .token {
  color: #ffd76a;
}

.ffa-reward.none,
.ffa-reward.capped {
  background: rgba(255, 255, 255, 0.08);
  color: #e6dcea;
  font-size: 12px;
  font-weight: 700;
}

.ffa-reward.capped {
  color: #ffb4a8;
}

.ffa-today {
  color: #d8c8de;
  font-size: 11px;
}

.ffa-res-acts .btn {
  color: var(--ink);
}

/* (the duel's result bar, without its place in the duel's own sideways grid: css/pvp.css) */
.ffa-res .res-clock {
  grid-area: auto;
  width: 100%;
}

/* a wide screen: the result at the right, the podium at the altar beside it (game/world.js cameraAim); it starts under
   the live board (--ffa-end-top, ui/pvp-ffa.js onEnd: its top rows stay readable) */
@media (min-aspect-ratio: 1/1) {
  .ffa-end {
    top: max(calc(76px + var(--safe-t)), var(--ffa-end-top, 0px));
    left: auto;
    right: calc(8px + var(--safe-r));
    align-content: center;
    justify-items: end;
    padding: 0;
  }

  .ffa-res {
    width: min(46vw, 420px);
    max-height: calc(100vh - max(calc(76px + var(--safe-t)), var(--ffa-end-top, 0px)) - 12px - var(--safe-b));
  }
}

/* confetti over the podium */
.ffa-confetti {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.ffa-confetti i {
  position: absolute;
  top: -12px;
  width: 7px;
  height: 11px;
  border-radius: 1px;
  animation: ffa-fall linear forwards;
}

@keyframes ffa-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.85; }
}

/* the round's end on screen: the fight's buttons step aside */
body.ffa-end-on #skills,
body.ffa-end-on #joystick,
body.ffa-end-on .ffa-leave,
body.ffa-end-on .ffa-feed,
body.ffa-end-on .ffa-callout {
  visibility: hidden;
}

/* toasts in a room: at the bottom between the chat and the skills (no hotbar there), clear of the bars, the feed, the
   call-outs and the fall's card (a phone held upright has no room there: under the feed, below) */
body.in-ffa #toasts {
  top: auto !important;
  bottom: calc(14px + var(--safe-b));
}

/* ------------------------------------------------------------ the world's words and tags (game/ffafx.js, avatar.js) */
.float.pvpword.power {
  background: #6a3fa8;
}

.float.pvpword.power.potion { background: #b8322a; }
.float.pvpword.power.boots { background: #c2700e; }
.float.pvpword.power.armor { background: #a8820e; }
.float.pvpword.power.gauge { background: #6a3fa8; }
.float.pvpword.power.blade { background: #c2401a; }

.float.pvpword.power.mine {
  font-size: max(15px, calc(22px * var(--wz, 1)));
}

/* โหมดสู้: a flag just went up over that player's head (game/pvpfx.js flagUp) */
.float.pvpword.flagup {
  background: #c8281e;
  box-shadow: 0 0 0 2px #ffd76a;
}

.float.pvpword.flagup.mine {
  font-size: max(15px, calc(22px * var(--wz, 1)));
}

/* the podium's plates: the place in a dark disc, the name cut short so the second's and the third's never meet */
.placetag.podium {
  gap: 3px;
  max-width: 84px;
  padding: 0 7px 0 2px;
  font-size: 11px;
  text-decoration: none;
}

.placetag.podium b {
  flex: none;
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(43, 31, 46, 0.88);
  color: #fff3c4;
  font-size: 10px;
}

.placetag.podium span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  /* (room inside the clip for Thai marks over an upper vowel) */
  padding: 0.35em 0 0.15em;
  margin: -0.35em 0 -0.15em;
}

.placetag.podium.p1 { max-width: 112px; font-size: 12px; background: #ffd76a; border-color: #9a6b14; }
.placetag.podium.p2 { background: #e6ebf2; border-color: #6a7280; }
.placetag.podium.p3 { background: #e2a066; border-color: #6a3a14; }

/* ลานเดือด: a room's name tags compact, so a crowd's fit (a long name cut short: the board and the feed say it whole;
   game/pvpfx.js declutter steps up the ones that would still meet) */
body.in-ffa #labels .nametag {
  height: 17px;
  padding: 0 6px;
  font-size: 11px;
}

body.in-ffa #labels .nametag .name {
  max-width: 8.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.35em 0 0.15em;
  margin: -0.35em 0 -0.15em;
}

body.in-ffa #labels .nametag .job-badge {
  display: none;
}

/* a bounty's gold skull on a name tag */
.nametag .bounty {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px 0 1px;
  border-radius: 8px;
  background: #3a2408;
  color: #ffd76a;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.nametag .bounty img {
  width: 15px;
  height: 15px;
  filter: sepia(1) saturate(5) hue-rotate(-12deg) brightness(1.2) drop-shadow(0 0 2px rgba(255, 200, 60, 0.9));
}

/* โหมดสู้: a flagged player's name in red, crossed swords and the adventure level where the farm's level was */
.nametag.flagged {
  background: rgba(168, 26, 20, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 120, 100, 0.65);
}

/* (in a row: the HUD's .lv is a grid, which stacked the swords over the level and dropped the level under the tag; a
   foe's tag keeps it too, the level being what the gap rule is about: the duel's foe tag hides the farm's level) */
.nametag.flagged .lv,
.nametag.foe.flagged .lv {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px 0 2px;
  background: #ffe0d8;
  color: #8f1a14;
}

.nametag .lv-swords {
  width: 12px;
  height: 12px;
  image-rendering: pixelated;
}

/* the week's hunter title, under the name */
.nametag .hunter-title {
  position: absolute;
  left: 50%;
  top: calc(100% + 1px);
  transform: translateX(-50%);
  padding: 0 6px;
  border-radius: 7px;
  background: rgba(58, 36, 8, 0.88);
  color: #ffd76a;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.nametag .hunter-title.top {
  background: linear-gradient(#8a5a0e, #5a3608);
  color: #fff3b0;
  box-shadow: 0 0 0 1px #ffd76a;
}

/* whole Thai phrases (ui/pvp-flag.js): a line breaks only between them, never inside "ไม่เสียของ" */
.toast .nobr,
.flag-defeat-card .nobr,
.ffa-res .nobr,
.ffa-leave-ask .nobr {
  white-space: nowrap;
}

/* the kill feed of the wild, as small dark toasts */
.toast.feed {
  padding: 2px 10px;
  border-width: 2px;
  border-color: #6a4a5a;
  background: rgba(31, 22, 36, 0.9);
  color: #fff;
  font-size: 13px;
}

/* ------------------------------------------------------------ โหมดสู้'s button (above the skills, or the stick) */
.flag-btn {
  right: calc(var(--gap) + var(--safe-r) + 4px);
  bottom: calc(var(--gap) + var(--safe-b) + 214px);
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 3px solid #a8281e;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff4dc, #f0d8a8 70%);
  box-shadow: 0 4px 0 rgba(43, 31, 46, 0.4);
  touch-action: manipulation;
}

.flag-btn > img {
  width: 30px;
  height: 30px;
  margin-top: -10px;
}

/* (the words span the button, so the pill under it can be centred on it or put against its right edge) */
.flag-words {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  display: grid;
  justify-items: center;
  line-height: 1;
  white-space: nowrap;
}

.flag-label {
  color: #8f1a14;
  font-size: 11px;
  font-weight: 800;
}

.flag-sub {
  position: absolute;
  top: calc(100% + 7px);
  right: 50%;
  transform: translateX(50%);
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(31, 22, 36, 0.86);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* the pill's words: the short ones only where the button stands in a narrow place (a short phone held upright) */
.flag-sub .short {
  display: none;
}

/* the count: a gold ring filling up round the button */
.flag-ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  pointer-events: none;
}

/* (a thick bright gold arc on a dark track, outside the button's red border: a thin red one read as the border) */
.flag-btn.count .flag-ring {
  background: conic-gradient(#ffd76a calc(var(--k, 0) * 360deg), rgba(31, 22, 36, 0.8) 0);
  -webkit-mask: radial-gradient(circle, transparent 31px, #000 32px);
  mask: radial-gradient(circle, transparent 31px, #000 32px);
  filter: drop-shadow(0 0 3px rgba(255, 200, 80, 0.85));
}

.flag-btn.count {
  animation: callout 0.5s ease-in-out infinite alternate;
}

/* up: red and glowing; coming down: orange */
.flag-btn.on {
  border-color: #ffd76a;
  background: radial-gradient(circle at 35% 30%, #ff7a5a, #c8281e 70%);
  box-shadow: 0 4px 0 rgba(43, 31, 46, 0.4), 0 0 14px rgba(255, 70, 50, 0.85);
  animation: flag-glow 1.4s ease-in-out infinite alternate;
}

.flag-btn.on .flag-label,
.flag-btn.leaving .flag-label {
  color: #fff;
  text-shadow: 0 1px 0 #5a0a06;
}

.flag-btn.leaving {
  border-color: #ffd76a;
  background: radial-gradient(circle at 35% 30%, #ffb45a, #d0701e 70%);
}

.flag-btn.leaving .flag-label {
  font-size: 10px;
}

/* not here, not yet: grey (a tap says why) */
.flag-btn.safe,
.flag-btn.low,
.flag-btn.wound {
  border-color: #8a7a92;
  background: radial-gradient(circle at 35% 30%, #efe8f2, #c8bccc 70%);
}

.flag-btn.safe > img,
.flag-btn.low > img,
.flag-btn.wound > img {
  filter: grayscale(1);
  opacity: 0.7;
}

.flag-btn.safe .flag-label,
.flag-btn.low .flag-label,
.flag-btn.wound .flag-label {
  color: #5a4a62;
}

@keyframes flag-glow {
  to { box-shadow: 0 4px 0 rgba(43, 31, 46, 0.4), 0 0 22px rgba(255, 70, 50, 1); }
}

/* the fight's lock: no warp, travel or mount for a moment after a blow */
.flag-lock {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 6px;
  border: 2px solid #ffd76a;
  border-radius: 8px;
  background: #a8180e;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

/* the weekly board's way in, beside the button */
.flag-board {
  right: calc(var(--gap) + var(--safe-r) + 70px);
  bottom: calc(var(--gap) + var(--safe-b) + 228px);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid var(--wood, #7a4a2b);
  border-radius: 50%;
  background: var(--paper, #fdf3d8);
  box-shadow: 0 3px 0 rgba(43, 31, 46, 0.35);
}

/* riding on a PC (owner 15 Oct "ปุ่มมันทับกัน"): the mount's buttons (pets-v2.css, พุ่งทะยาน and ลงเดิน, bottom 202)
   stand above this button and its trophy instead of on them; phones place them apart already */
body:not(.touch) #hud:has(.flag-btn:not([hidden])) .pet-v2-controls {
  bottom: calc(var(--gap) + var(--safe-b) + 286px);
}

/* a phone: above the stick, on its side */
body.touch .flag-btn {
  bottom: calc(var(--safe-b) + 156px);
}

body.touch .flag-board {
  bottom: calc(var(--safe-b) + 168px);
}

body.touch:not(.stick-right) .flag-btn {
  right: auto;
  left: calc(var(--gap) + var(--safe-l) + 4px);
}

body.touch:not(.stick-right) .flag-board {
  right: auto;
  left: calc(var(--gap) + var(--safe-l) + 70px);
}

/* (on its side with the stick on the left the chat's button is there too: the button and its trophy step right of it,
   owner 15 Oct "ปุ่มมันทับกัน") */
body.touch:not(.stick-right):not(.upright) .flag-btn {
  left: calc(var(--gap) + var(--safe-l) + 54px);
}

body.touch:not(.stick-right):not(.upright) .flag-board {
  left: calc(var(--gap) + var(--safe-l) + 120px);
}

/* a phone held upright: on the right edge under the menu's column, whichever side the stick is on (the bottom is the
   stick's, the skills', the hotbar's (a full one is as wide as the screen) and the banners' chips) */
body.touch.upright .flag-btn,
body.touch.upright:not(.stick-right) .flag-btn {
  top: calc(var(--gap) + var(--safe-t) + 370px);
  bottom: auto;
  left: auto;
  right: calc(var(--gap) + var(--safe-r) + 4px); /* (the count ring, 9 px round it, stays on the screen) */
}

body.touch.upright .flag-board,
body.touch.upright:not(.stick-right) .flag-board {
  top: calc(var(--gap) + var(--safe-t) + 383px);
  bottom: auto;
  left: auto;
  right: calc(var(--gap) + var(--safe-r) + 71px);
}

/* (on the right edge the pill under the button keeps to its right side: centred, "เฉพาะแมพป่า" ran off the screen) */
body.touch.upright .flag-sub {
  right: -2px;
  transform: none;
}

/* a short phone held upright (360x640, 375x667): the bottom band is the chips', the monster's card's and the hotbar's
   and the menu's column reaches down to it, so the button stands at the top, left of the menu, under the clock (above
   the toasts, right of the quest); the pill says it in short; the trophy steps aside (the profile card and the village's
   board open the weekly board too) */
@media (max-height: 760px) {
  body.touch.upright .flag-btn,
  body.touch.upright:not(.stick-right) .flag-btn {
    top: calc(var(--gap) + var(--safe-t) + 98px);
    right: calc(var(--gap) + var(--safe-r) + 56px);
    width: 50px;
    height: 50px;
  }

  body.touch.upright .flag-btn > img {
    width: 26px;
    height: 26px;
    margin-top: -9px;
  }

  body.touch.upright .flag-btn.count .flag-ring {
    -webkit-mask: radial-gradient(circle, transparent 26px, #000 27px);
    mask: radial-gradient(circle, transparent 26px, #000 27px);
  }

  body.touch.upright .flag-sub {
    top: calc(100% + 3px);
  }

  body.touch.upright .flag-lock {
    top: -7px;
  }

  body.touch.upright .flag-sub .long {
    display: none;
  }

  body.touch.upright .flag-sub .short {
    display: inline;
  }

  body.touch.upright #hud .flag-board {
    display: none;
  }
}

/* ------------------------------------------------------------ the defeat: "แพ้การต่อสู้" */
.flag-defeat {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(40, 6, 6, 0.25), rgba(40, 6, 6, 0.6));
  animation: fade-in 0.3s;
}

.flag-defeat-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(90vw, 360px);
  padding: 14px 16px 12px;
  border: 3px solid #ff6a5a;
  border-radius: 18px;
  background: linear-gradient(rgba(58, 16, 26, 0.97), rgba(31, 22, 36, 0.97));
  color: #fff;
  text-align: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
  animation: pvp-res-in 0.35s ease-out;
}

.flag-defeat-title {
  color: #ff6a5a;
  font: 600 34px/1.15 var(--pvp-word, 'Mitr', sans-serif);
  text-shadow: 0 3px 0 #000;
}

.flag-defeat-card span {
  font-size: 15px;
  font-weight: 700;
}

.flag-defeat-card .pvp-nm {
  color: #ffd76a;
}

.flag-defeat-card small {
  color: #f0dcd8;
  font-size: 13px;
}

.flag-defeat-card .flag-wound {
  color: #ffd76a;
  font-weight: 700;
}

.flag-defeat-card .btn {
  margin-top: 6px;
  color: var(--ink);
}

/* the weekly board: the top three's places in gold, silver and bronze; my own row outlined (its class not the HUD's .me) */
.list.hunters .hunter-row.mine {
  outline: 2px solid var(--blue, #57a8e0);
}

.list.hunters .hunter-row .rank {
  height: 28px;
  border-radius: 50%;
  background: var(--paper-2, #f3e6c4);
  font-size: 13px;
}

.list.hunters .hunter-row .rank.p1 { background: #ffd76a; color: #5a3608; box-shadow: 0 0 0 2px #9a6b14; }
.list.hunters .hunter-row .rank.p2 { background: #e6ebf2; color: #2b2f38; box-shadow: 0 0 0 2px #6a7280; }
.list.hunters .hunter-row .rank.p3 { background: #e2a066; color: #3a1a08; box-shadow: 0 0 0 2px #6a3a14; }

.list.hunters .hunter-row .sub img {
  width: 16px;
  height: 16px;
}

.hunter-me {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--blue, #57a8e0);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}

.hunter-tag {
  padding: 1px 8px;
  border-radius: 8px;
  background: #5a3608;
  color: #ffd76a;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ------------------------------------------------------------ phones */
@media (max-width: 560px), (max-height: 420px) {
  .ffa-hud {
    gap: 5px;
    padding-bottom: 10px;
  }

  .ffa-face {
    display: none;
  }

  .ffa-name b {
    font-size: 13px;
  }

  .ffa-name small {
    display: none;
  }

  .ffa-bar {
    height: 16px;
  }

  .ffa-bar .num {
    font-size: 10px;
  }

  .ffa-mid {
    min-width: 56px;
    padding: 1px 6px 3px;
  }

  .ffa-time {
    font-size: 22px;
  }

  .ffa-board {
    width: min(170px, 100%);
    padding: 3px 5px 4px;
  }

  .ffa-board-head span {
    display: none;
  }

  .ffa-rows li {
    grid-template-columns: 16px minmax(0, 1fr) auto 28px;
    gap: 3px;
    font-size: 11px;
  }

  /* (the top three and me: the rest of the five on a computer) */
  .ffa-rows li:nth-child(n + 4):not(.mine):not(.apart) {
    display: none;
  }

  .ffa-leave {
    top: calc(64px + var(--safe-t));
    font-size: 11px;
  }

  .ffa-leave-ask {
    top: calc(90px + var(--safe-t));
  }

  .ffa-feed {
    top: calc(92px + var(--safe-t));
    max-width: 62vw;
  }

  .ffa-line {
    font-size: 11px;
  }


  .ffa-lobby b {
    font-size: 20px;
  }

  .ffa-ko b {
    font-size: 46px;
  }

  .ffa-step .skill-avatar {
    width: 50px;
    height: 72px;
  }

  .ffa-res-title {
    font-size: 21px;
  }

}

/* a phone held upright: the call-outs, the toasts and the fall's card under the feed's four lines, one below the other */
@media (max-width: 560px) {
  .ffa-callout {
    top: calc(188px + var(--safe-t));
  }

  body.in-ffa #toasts {
    top: calc(222px + var(--safe-t)) !important;
    bottom: auto;
  }

  /* (a lobby has no feed yet: its toasts stand where the feed will be, above the lobby's box, never over it) */
  body.in-ffa.ffa-lobby-on #toasts {
    top: calc(98px + var(--safe-t)) !important;
  }

  .ffa-lobby {
    top: max(30%, calc(204px + var(--safe-t)));
  }

  .ffa-ko {
    padding-top: calc(262px + var(--safe-t));
  }

  /* the board: names whole enough to tell apart (the KOs and falls are on the end's panel); the feed's names share the
     line fairly, helpers as "+N" */
  .ffa-rows li {
    grid-template-columns: 16px minmax(0, 1fr) auto;
  }

  .ffa-rows .kd {
    display: none;
  }

  .ffa-line .pvp-nm {
    flex: 0 1 auto;
    min-width: 2.5em;
    max-width: none;
  }

  .ffa-line .ko-ico,
  .ffa-line .helpers {
    flex: none;
  }

  .ffa-line .helpers .long {
    display: none;
  }

  .ffa-line .helpers .short {
    display: inline;
  }
}

/* the end's panel on a phone held upright: right of the chat button, which stays usable ("gg") */
@media (max-width: 560px) and (max-aspect-ratio: 1/1) {
  .ffa-end {
    padding: 0 8px 0 calc(56px + var(--safe-l));
  }

  .ffa-end .ffa-res {
    width: 100%;
  }
}

/* a short phone held upright (360x640, 375x667): my fall's card at the top, under the leave button, where the feed was (the
   killer the camera watches and my own body stay clear in the middle); its stamp smaller */
@media (max-width: 560px) and (max-height: 760px) {
  .ffa-ko {
    padding-top: calc(92px + var(--safe-t));
  }

  .ffa-ko-card {
    padding: 2px 14px 6px;
  }

  .ffa-ko b {
    font-size: 34px;
  }

  .ffa-ko-count {
    font-size: 16px;
  }

  body.ffa-down .ffa-feed {
    visibility: hidden;
  }

  /* (the end's panel without the portraits, as sideways: the three stand on the podium at the altar above it, their
     plates in view) */
  .ffa-step .skill-avatar {
    display: none;
  }

  .ffa-step.p1 .ffa-step-block { height: 26px; }
  .ffa-step.p2 .ffa-step-block { height: 18px; font-size: 15px; }
  .ffa-step.p3 .ffa-step-block { height: 15px; font-size: 13px; }
}

/* my combo in a room on a phone: at the right under the board (at the left it sat on the kill feed) */
body.touch.in-ffa .pvp-combo {
  left: auto;
  right: calc(12px + var(--safe-r));
  top: calc(112px + var(--safe-t)); /* (under a board of four rows: the top three and me) */
  justify-items: end;
  transform-origin: right center;
}

/* a phone held sideways: the end's panel at the right (above), smaller still; the lobby and the fall's words lower */
@media (max-height: 460px) {
  .ffa-end {
    top: max(calc(58px + var(--safe-t)), var(--ffa-end-top, 0px));
    bottom: calc(6px + var(--safe-b));
  }

  .ffa-res {
    gap: 2px;
    padding: 6px 10px 8px;
    max-height: calc(100vh - max(calc(58px + var(--safe-t)), var(--ffa-end-top, 0px)) - 8px - var(--safe-b));
  }

  /* (no room for the portraits: the three stand on the podium at the altar, beside the panel) */
  .ffa-step .skill-avatar {
    display: none;
  }

  /* (the steps' digits fit inside their steps: 20 px ones spilled onto the names) */
  .ffa-step.p1 .ffa-step-block { height: 26px; font-size: 15px; }
  .ffa-step.p2 .ffa-step-block { height: 18px; font-size: 13px; }
  .ffa-step.p3 .ffa-step-block { height: 15px; font-size: 12px; }

  /* (the leave button's ask beside the chat button and the ultimate's V, not over them) */
  .ffa-leave-ask {
    left: calc(84px + var(--safe-l));
  }

  .ffa-res-title {
    font-size: 18px;
  }

  .ffa-you b {
    font-size: 15px;
  }

  .ffa-lobby {
    top: 30%;
  }

  /* (the call-out under the clock, the fall's card a little smaller under it: the killer stays clear in the middle) */
  .ffa-callout {
    top: calc(56px + var(--safe-t));
  }

  .ffa-ko {
    padding-top: calc(90px + var(--safe-t));
  }

  .ffa-ko-card {
    padding: 2px 14px 6px;
  }

  .ffa-ko b {
    font-size: 34px;
  }

  .ffa-ko-count {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flag-btn.on,
  .flag-btn.count,
  .ffa-confetti i,
  .ffa-ko b,
  .ffa-ko-card {
    animation: none;
  }

  .ffa-confetti {
    display: none;
  }
}
