.duel-view {
  background: linear-gradient(135deg, #1a1a1a, #2c2c2c);
  color: #f0f0f0;
}

body.duel-view {
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

#duel-page {
  padding: 14px 12px 22px;
}

.duel-header {
  display: flex;
  justify-content: stretch;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 10px;
  position: relative;
}

.duel-share-pills {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 100%;
}

.duel-panel {
  padding: 12px;
  margin-bottom: 12px;
}

.duel-code-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  text-align: center;
}

#duel-code-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: clamp(1rem, 2.2vw, 1.18rem);
  text-align: center;
}

.duel-code-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
}

.duel-code-pill:active {
  transform: translateY(0);
}

.duel-copy-help {
  margin: 0;
  opacity: 0.88;
  font-size: 0.78rem;
  white-space: normal;
  font-style: italic;
  color: #bababa;
  text-align: center;
}

.duel-code-copied {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  font-size: 0.8rem;
  color: #9de09d;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.duel-code-copied.show {
  opacity: 1;
  transform: translateY(0);
}

.duel-options {
  margin: 8px 0 10px;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.duel-identity-gate h3 {
  margin: 0 0 6px;
  color: #eec566;
}

#duel-identity-status {
  margin: 0 0 10px;
  opacity: 0.9;
}

.duel-identity-hint {
  margin: 0 0 12px;
  font-size: 0.88rem;
  line-height: 1.35;
  opacity: 0.75;
}

.duel-identity-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.duel-identity-twitter-link {
  text-decoration: none;
}

.duel-identity-twitter-link button {
  width: 100%;
}

.duel-lobby-top {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.duel-player-list-wrap {
  min-width: 0;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  /* Allow color popovers/tooltips to escape the player list bounds. */
  overflow: visible;
}

.duel-player-list-wrap h3 {
  margin: 0 0 8px;
  color: #eec566;
  font-size: 0.98rem;
}

.duel-player-slots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  font-size: 0.82rem;
  color: rgba(255, 241, 216, 0.86);
  font-weight: 700;
}

.duel-slot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.62);
  background: transparent;
}

.duel-slot-dot.filled {
  background: rgba(var(--theme-gold-rgb), 0.92);
  box-shadow: 0 0 6px rgba(var(--theme-gold-rgb), 0.48);
}

.duel-options h3 {
  margin: 0 0 8px;
  color: #eec566;
  font-size: 0.98rem;
}

.duel-options-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: start;
}

.duel-options-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duel-options-main > label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
}

.duel-options-main > label:has(select),
.duel-options-main > label:has(.duel-difficulty-row) {
  flex-direction: column;
  align-items: flex-start;
}

.duel-options-main > label > select,
.duel-difficulty-row > select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--theme-gold-base);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(22, 24, 28, 0.96) 0%, rgba(13, 15, 18, 0.98) 100%);
  background-color: #14171c;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.1;
  padding: 8px 42px 8px 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.86) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.86) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(0, 0, 0, 0.22) inset,
    0 2px 8px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: filter 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.duel-options-main > label > select:hover,
.duel-difficulty-row > select:hover {
  filter: brightness(1.07) saturate(1.04);
  border-color: rgba(var(--theme-gold-rgb), 0.8);
}

.duel-options-main > label > select:focus-visible,
.duel-difficulty-row > select:focus-visible {
  outline: 2px solid rgba(var(--theme-gold-rgb), 0.96);
  outline-offset: 1px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 0 0 1px rgba(var(--theme-gold-rgb), 0.35),
    0 0 14px rgba(var(--theme-gold-rgb), 0.24);
}

.duel-options-main > label > select option,
.duel-difficulty-row > select option {
  background: #5a211f;
  color: #fff;
}

.duel-options-main > label > select option:checked,
.duel-difficulty-row > select option:checked {
  background: var(--theme-red-hover);
  color: #fff;
}

.duel-range-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.duel-range-row input[type="range"] {
  width: 100%;
  accent-color: var(--theme-gold-base);
  cursor: pointer;
}

.duel-range-value {
  min-width: 66px;
  text-align: right;
  color: var(--theme-gold-soft);
  font-weight: 700;
  font-size: 0.9rem;
}

.duel-options-groups {
  min-width: 0;
}

.duel-difficulty-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  width: 100%;
}

.duel-difficulty-desc {
  font-size: 0.82rem;
  color: rgba(255, 244, 220, 0.9);
  line-height: 1.25;
}

.duel-check-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
}

.duel-check-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  border: none;
  border-radius: 10px;
  padding: 4px 0;
  color: var(--theme-gold-muted);
  background: transparent;
}

.duel-options-main > label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 4px 0;
  color: var(--theme-gold-muted);
  background: transparent;
  width: 100%;
}

.duel-options-main input[type="checkbox"],
.duel-check-grid input[type="checkbox"] {
  accent-color: var(--theme-gold-base);
}

.duel-lobby-actions {
  display: grid;
  grid-template-columns: minmax(120px, 170px) 1fr minmax(120px, 170px);
  gap: 10px;
  align-items: stretch;
  margin-top: 10px;
}

#duel-ready-btn,
#duel-leave-btn,
#duel-start-btn {
  min-height: 46px;
}

#duel-leave-btn {
  background: transparent;
  border-color: var(--theme-gold-base);
  box-shadow: none;
}

#duel-leave-btn:hover:not(:disabled) {
  background: rgba(215, 191, 138, 0.08);
  box-shadow: none;
}

#duel-leave-btn:focus-visible {
  outline: 2px solid rgba(var(--theme-gold-rgb), 0.9);
  outline-offset: 1px;
}

#duel-start-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
}

#duel-confirm-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#duel-confirm-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--duel-next-ready-progress, 0%);
  background: linear-gradient(90deg, rgba(100, 194, 118, 0.35), rgba(130, 224, 146, 0.5));
  z-index: -1;
  transition: width 0.22s ease;
}

#duel-start-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--duel-ready-progress, 0%);
  background: linear-gradient(90deg, rgba(100, 194, 118, 0.35), rgba(130, 224, 146, 0.5));
  z-index: -1;
  transition: width 0.22s ease;
}

#duel-start-btn.duel-start-ready {
  box-shadow: 0 0 0 1px rgba(198, 253, 206, 0.35), 0 0 18px rgba(105, 221, 129, 0.44);
  animation: duelStartGlow 1.4s ease-in-out infinite alternate;
}

#duel-confirm-btn.duel-next-ready {
  box-shadow: 0 0 0 1px rgba(198, 253, 206, 0.35), 0 0 18px rgba(105, 221, 129, 0.44);
  animation: duelStartGlow 1.4s ease-in-out infinite alternate;
}

@keyframes duelStartGlow {
  from { box-shadow: 0 0 0 1px rgba(198, 253, 206, 0.25), 0 0 10px rgba(105, 221, 129, 0.28); }
  to { box-shadow: 0 0 0 1px rgba(198, 253, 206, 0.45), 0 0 22px rgba(105, 221, 129, 0.56); }
}

.duel-player-list {
  display: grid;
  gap: 6px;
}

.duel-player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: linear-gradient(
    180deg,
    rgba(var(--duel-player-color-rgb, 28, 28, 28), 0.36) 0%,
    rgba(var(--duel-player-color-rgb, 28, 28, 28), 0.24) 100%
  );
  border: 1px solid rgba(var(--theme-gold-rgb), 0.24);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.duel-player-item-host-can-kick {
  cursor: pointer;
}

@media (hover: hover) {
  .duel-player-item-host-can-kick:hover {
    border-color: rgba(var(--theme-gold-rgb), 0.4);
    filter: brightness(1.05);
  }
}

.duel-player-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  min-width: 0;
  flex: 1 1 auto;
}

.duel-player-name-trigger {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
}

.duel-player-name-trigger:hover {
  filter: brightness(1.06);
}

.duel-player-name-trigger:focus-visible {
  outline: 2px solid rgba(var(--theme-gold-rgb), 0.8);
  outline-offset: 2px;
  border-radius: 6px;
}

.duel-player-avatar-wrap {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.38);
  background: rgba(0, 0, 0, 0.2);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.duel-player-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.duel-player-avatar-host {
  transform: scale(1.35);
  transform-origin: center;
}

.duel-player-name > span {
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.15;
}

.duel-player-stats-badge {
  position: relative;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.32);
  background: rgba(0, 0, 0, 0.2);
  color: #e7dcc1;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-style: normal;
  cursor: pointer;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
}

.duel-player-stats-short {
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-stat-sep {
  margin: 0 4px;
  color: rgba(231, 220, 193, 0.65);
}

.duel-stat-g-num {
  color: #e7dcc1;
}

.duel-stat-w-num {
  color: #6bdd8a;
}

.duel-stat-l-num {
  color: #ee8a8a;
}

.duel-stat-d-num {
  color: #b6b6b6;
}

.duel-player-stats-tip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 6px);
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.24);
  background: rgba(14, 14, 14, 0.96);
  color: #bababa;
  font-size: 0.68rem;
  font-style: normal;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 6;
}

.duel-player-stats-badge:hover .duel-player-stats-tip,
.duel-player-stats-badge.open .duel-player-stats-tip {
  opacity: 1;
  visibility: visible;
}

.duel-ready-check {
  color: #6bdd8a;
  font-size: 0.9rem;
}

.duel-ready-check.off {
  color: rgba(255, 255, 255, 0.24);
}

.duel-host-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.45);
  border-radius: 999px;
  padding: 1px 0;
  width: 100%;
  font-size: 0.72rem;
  color: #ebd59f;
}

.duel-left-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(235, 95, 95, 0.75);
  background: rgba(235, 95, 95, 0.12);
  color: rgba(255, 212, 212, 0.95);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-left: 6px;
}

.duel-left-badge-hud {
  margin-left: 8px;
  padding: 0 6px;
  font-size: 0.66rem;
}

.duel-left-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 0.78rem;
  color: rgba(255, 212, 212, 0.9);
}

.duel-player-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  color: #c8cfbf;
  font-size: 0.85rem;
}

.duel-player-color-popover {
  position: absolute;
  left: 10px;
  bottom: calc(100% + 5px);
  top: auto;
  z-index: 9;
  display: none;
  grid-template-columns: repeat(4, 28px);
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.28);
  background: rgba(9, 10, 12, 0.97);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
}

.duel-player-item.duel-color-open {
  overflow: visible;
  z-index: 3;
}

.duel-player-item.duel-color-open-down .duel-player-color-popover {
  top: calc(100% + 5px);
  bottom: auto;
}

.duel-player-item.duel-color-open .duel-player-color-popover {
  display: grid;
}

.duel-player-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: var(--swatch-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.duel-player-color-swatch.selected {
  border-color: #fff5d0;
  box-shadow: 0 0 0 2px rgba(var(--theme-gold-rgb), 0.38);
}

.duel-player-color-swatch.taken,
.duel-player-color-swatch:disabled {
  cursor: not-allowed;
  filter: grayscale(0.9) brightness(0.75);
  opacity: 0.6;
}

@media (min-width: 900px) {
  .duel-player-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 56px;
    grid-template-areas:
      "name state"
      "stats state";
    row-gap: 4px;
    column-gap: 10px;
    align-items: center;
  }

  .duel-player-name {
    grid-area: name;
    min-width: 0;
    max-width: 100%;
  }

  .duel-player-stats-badge {
    grid-area: stats;
    justify-self: start;
  }

  .duel-player-state {
    grid-area: state;
    align-self: center;
  }
}

.duel-spectate-banner {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.45);
  background: rgba(40, 22, 12, 0.55);
  color: rgba(255, 244, 220, 0.95);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
}

.duel-match-spectating #map-container {
  pointer-events: none;
  opacity: 0.78;
  filter: grayscale(0.08);
}

.duel-scoreboard {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: clamp(14px, 2.2vh, 26px);
}

.duel-scoreboard-main {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.duel-scoreboard-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 92px;
}

.duel-enemies-hud {
  flex: 0 1 44%;
  max-width: min(340px, 46vw);
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: none;
  overflow: visible;
  overflow-x: hidden;
  padding-left: 4px;
  margin-left: auto;
}

.duel-enemies-hud::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.duel-enemies-hud {
  scrollbar-width: none;
}

.duel-enemy-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.duel-enemy-row.duel-enemy-eliminated .duel-enemy-name {
  opacity: 0.72;
}

.duel-enemy-row.duel-enemy-eliminated .duel-hp-track {
  opacity: 0.68;
}

.duel-enemy-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255, 244, 220, 0.9);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.duel-hp-track.duel-enemy-hp-track {
  height: 22px;
}

.duel-scoreboard.duel-scoreboard-impact-pin {
  position: fixed !important;
  left: var(--duel-scoreboard-pin-left, 0px) !important;
  top: var(--duel-scoreboard-pin-top, 0px) !important;
  width: var(--duel-scoreboard-pin-width, 100%) !important;
  margin: 0 !important;
  z-index: 30050 !important;
  pointer-events: none !important;
}

#duel-round-label {
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: left;
}

.duel-hp-name {
  font-size: 0.95rem;
  color: rgba(255, 244, 220, 0.92);
  font-weight: 700;
}

.duel-hp-name-you {
  text-align: left;
}

.duel-hp-track {
  position: relative;
  width: 100%;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.45);
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.duel-hp-track.duel-hp-hurt {
  animation: duel-hp-track-hurt 0.52s ease-out;
}

.duel-hp-fill {
  position: relative;
  width: 100%;
  height: 100%;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), background 0.28s ease;
  will-change: width, background, transform;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.33), rgba(255, 255, 255, 0.33)),
    rgba(var(--duel-hp-rgb, 255, 255, 255), 0.78);
}

.duel-hp-fill.duel-hp-hurt {
  animation: duel-hp-fill-hurt 0.52s ease-out;
}

.duel-hp-opp .duel-hp-fill {
  margin-left: auto;
}

.duel-hp-value {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  white-space: nowrap;
}

.duel-hp-fill.full { filter: brightness(1.03) saturate(0.78); }
.duel-hp-fill.safe { filter: brightness(1.0) saturate(0.76); }
.duel-hp-fill.intermediate { filter: brightness(0.93) saturate(0.74); }
.duel-hp-fill.warning { filter: brightness(0.87) saturate(0.78); }
.duel-hp-fill.caution { filter: brightness(0.82) saturate(0.82); }
.duel-hp-fill.danger-1 { filter: brightness(0.78) saturate(0.88); animation: vibrate-1 0.2s infinite; }
.duel-hp-fill.danger-2 { filter: brightness(0.74) saturate(0.92); animation: vibrate-2 0.1s infinite; }

#duel-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.4);
  background: rgba(0, 0, 0, 0.24);
  color: #e7dcc1;
  font-size: 1.02rem;
  font-weight: 700;
  text-align: center;
}

#duel-timer.duel-impact-callout {
  border-color: rgba(var(--theme-gold-rgb), 0.92);
  box-shadow:
    0 0 18px rgba(var(--theme-gold-rgb), 0.68),
    0 0 34px rgba(var(--theme-gold-rgb), 0.36);
  animation: duel-impact-pulse 0.85s ease-in-out infinite;
}

.duel-hp-track.duel-impact-target {
  border-color: rgba(var(--theme-gold-rgb), 0.95);
  box-shadow:
    0 0 18px rgba(var(--theme-gold-rgb), 0.72),
    0 0 28px rgba(var(--theme-gold-rgb), 0.38);
}

.duel-hp-track.duel-impact-track {
  border-color: rgba(var(--theme-gold-rgb), 0.82);
  box-shadow:
    0 0 12px rgba(var(--theme-gold-rgb), 0.5),
    0 0 24px rgba(var(--theme-gold-rgb), 0.28);
}

.duel-hp-fill.duel-impact-target-fill {
  animation:
    vibrate-1 0.16s infinite,
    duel-impact-gold-pulse 0.7s ease-in-out infinite;
}

.duel-hp-fill.duel-impact-fill {
  animation: duel-impact-gold-pulse 0.7s ease-in-out infinite;
}

/* Face strip: duel match + single-player game (same chrome) */
#duel-image-wrap,
#main-container.eg-solo-match-stage #face-container {
  width: 100%;
  height: 26vh;
  min-height: 200px;
  max-height: 360px;
  display: block;
  position: relative;
  perspective: 1600px;
  padding: 0;
  margin-top: clamp(6px, 1.1vh, 14px);
  margin-bottom: 8px;
  overflow: hidden;
}

.duel-face-flip-container {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.duel-face-flip-container.flip {
  transform: rotateY(180deg);
}

.duel-face-side {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.duel-face-front {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  padding: 0 10px;
}

.duel-face-front img,
#main-container.eg-solo-match-stage #face-front img {
  width: auto;
  max-width: 45%;
  height: 90%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 50%;
  border: 2px solid var(--theme-gold-base);
  background: rgba(0, 0, 0, 0.2);
}

.duel-face-back {
  transform: rotateY(180deg);
  overflow: visible;
  overflow-x: hidden;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  background: #ffffff;
  color: #111111;
}

.duel-face-back::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.duel-face-back {
  scrollbar-width: none;
}

/* Avoid horizontal scrollbar from long result text/blocks */
.duel-face-back pre,
.duel-face-back .full-info,
.duel-face-back .result-wrapper,
.duel-face-back .result-columns,
.duel-face-back .left-column,
.duel-face-back .right-column {
  max-width: 100%;
  overflow-x: hidden;
}

/* Map: legacy duel layout (no body.game-view) — fixed height strip */
body:not(.game-view) #duel-match #map-container {
  width: 100%;
  max-width: none;
  height: 360px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
  margin-left: 0;
  margin-right: 0;
  border: 1px solid var(--map-frame-border-soft);
}

/* --- Duel match: solo-style full map stage (game.php parity) --- */
body.game-view.duel-in-match #duel-page {
  padding: 0;
  min-height: 100dvh;
}

body.game-view.duel-in-match #duel-match {
  position: fixed;
  inset: 0;
  z-index: 60;
  margin: 0;
  max-width: none;
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border: none;
  background: transparent;
}

body.game-view.duel-in-match #duel-match.duel-panel {
  padding: 0;
}

body.game-view.duel-in-match #duel-match #game-container {
  flex: 1 1 0%;
  min-height: 0;
  width: 100%;
}

body.game-view.duel-in-match #duel-spectate-banner {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 0;
}

#duel-all-players-hud.duel-all-players-hud.duel-scoreboard {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 0;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-all-players-hud {
  position: absolute;
  top: var(--eg-map-overlay-padding);
  right: var(--eg-map-overlay-padding);
  left: auto;
  bottom: auto;
  z-index: 1202;
  width: min(44vw, 280px);
  max-width: min(44vw, 280px);
  pointer-events: none;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-all-players-hud .duel-hp-stack-row,
body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-enemies-hud .duel-enemy-row {
  pointer-events: auto;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-enemies-hud {
  flex: 0 1 auto;
  max-width: none;
  width: 100%;
  min-width: 0;
  margin-left: 0;
  padding-left: 0;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-all-players-hud .duel-hp-name,
body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-all-players-hud .duel-enemy-name {
  color: #000;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-all-players-hud .duel-hp-name-you {
  text-align: right;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-all-players-hud .duel-hp-value {
  color: #111;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-round-hud.duel-round-hud {
  position: absolute;
  bottom: var(--eg-map-overlay-padding);
  left: var(--eg-map-overlay-padding);
  right: auto;
  top: auto;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  pointer-events: none;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-round-hud #duel-round-label {
  color: #000;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-round-hud #duel-timer {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-confirm-btn {
  position: absolute;
  bottom: var(--eg-map-overlay-padding);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  z-index: 1201;
  width: min(92vw, 440px);
  max-width: 440px;
  margin: 0 !important;
  flex: none !important;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-confirm-btn:hover:not(:disabled) {
  transform: translateX(-50%) translateY(-1px) scale(1.01);
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage .eg-solo-float #duel-image-wrap {
  flex: 0 0 auto !important;
  width: min(92vw, 400px);
  height: min(32vh, 320px);
  min-height: 180px;
  max-height: 360px;
  margin: 0 !important;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-reveal {
  position: absolute;
  left: 50%;
  bottom: calc(var(--eg-map-overlay-padding) + 4.35rem);
  transform: translateX(-50%);
  z-index: 1250;
  margin: 0;
  max-width: min(94vw, 480px);
}

/*
 * Solo map frame: fixed height only when NOT on the full-screen game page.
 * game.php uses body.game-view — map frame is sized in style.css (fills stage with inset).
 * Without this guard, height: 360px here wins over inset-based sizing and leaves a huge empty band.
 */
body:not(.game-view) #main-container.eg-solo-match-stage .eg-solo-map-frame {
  width: 100%;
  max-width: none;
  height: 360px;
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
  margin-left: 0;
  margin-right: 0;
  border-radius: 10px;
  border: 1px solid var(--map-frame-border-soft);
  box-sizing: border-box;
}

body:not(.game-view) #main-container.eg-solo-match-stage .eg-solo-map-frame #map-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  border-radius: 0;
}

.duel-reveal {
  display: none;
  margin-top: 8px;
  padding: 8px 10px;
  min-height: 28px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(var(--theme-gold-rgb), 0.24);
}

#duel-round-result-content {
  width: 100%;
  height: 100%;
}

.duel-result-wrapper.result-wrapper {
  width: 100%;
  max-width: 100%;
  padding: 10px 8px 2px;
  background: #ffffff;
  color: #111111;
}

.duel-face-back .result-columns,
.duel-face-back .left-column,
.duel-face-back .right-column,
.duel-face-back .full-info,
.duel-face-back .phenotype-title,
.duel-face-back .result-stat,
.duel-face-back pre {
  color: #111111;
}

.duel-face-back .full-info {
  background: #ffffff;
  border: 1px solid #d8d8d8;
}

.duel-result-summary-text {
  text-align: center;
  color: #e7dcc1;
  font-size: 0.9rem;
  line-height: 1.35;
}


.duel-start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: start center;
  padding-top: clamp(36px, 11vh, 120px);
  z-index: 12000;
  pointer-events: auto;
}

.duel-start-overlay.duel-start-overlay-impact {
  background: rgba(0, 0, 0, 0.62);
  pointer-events: none;
}

.duel-start-countdown {
  font-size: clamp(78px, 15vw, 170px);
  font-weight: 800;
  color: #f3e3b7;
  text-shadow: 0 0 30px rgba(0, 0, 0, 0.75);
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.duel-start-overlay.duel-start-overlay-impact .duel-start-countdown::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(120px, 20vw, 210px);
  height: clamp(120px, 20vw, 210px);
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.duel-start-subtitle {
  margin-top: 6px;
  padding: 7px 14px;
  max-width: min(88vw, 900px);
  text-align: center;
  color: #f3e3b7;
  font-size: clamp(1rem, 2.8vw, 1.5rem);
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.65);
  background: rgba(0, 0, 0, 0.52);
  box-shadow: 0 0 18px rgba(var(--theme-gold-rgb), 0.34);
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.7);
  animation: duel-impact-pulse 0.95s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.duel-start-subtitle.duel-impact-subtitle {
  border-color: rgba(var(--theme-gold-rgb), 0.95);
  box-shadow:
    0 0 18px rgba(var(--theme-gold-rgb), 0.74),
    0 0 34px rgba(var(--theme-gold-rgb), 0.42);
  animation: duel-impact-gold-pulse 0.74s ease-in-out infinite;
}

body.duel-impact-foreground .duel-scoreboard,
body.duel-impact-foreground #duel-round-hud,
body.duel-impact-foreground .duel-hp-track,
body.duel-impact-foreground .duel-hp-name,
body.duel-impact-foreground #duel-timer {
  position: relative;
  z-index: 21050;
}

body.duel-impact-foreground .duel-start-overlay {
  z-index: 12000;
  background: rgba(0, 0, 0, 0.62) !important;
  pointer-events: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body.duel-impact-foreground .duel-start-countdown {
  opacity: 0.72;
}

@keyframes duel-impact-pulse {
  0%, 100% {
    filter: brightness(1);
    transform: translateY(0);
  }
  50% {
    filter: brightness(1.22);
    transform: translateY(-1px);
  }
}

@keyframes duel-impact-gold-pulse {
  0%, 100% {
    filter: brightness(1);
    transform: translateY(0);
  }
  50% {
    filter: brightness(1.35);
    transform: translateY(-1px);
  }
}

@keyframes duel-hp-track-hurt {
  0% {
    box-shadow:
      0 0 0 rgba(215, 56, 56, 0),
      inset 0 0 0 rgba(215, 56, 56, 0);
    border-color: rgba(var(--theme-gold-rgb), 0.45);
  }
  28% {
    box-shadow:
      0 0 18px rgba(215, 56, 56, 0.65),
      inset 0 0 20px rgba(215, 56, 56, 0.35);
    border-color: rgba(235, 95, 95, 0.95);
  }
  100% {
    box-shadow:
      0 0 0 rgba(215, 56, 56, 0),
      inset 0 0 0 rgba(215, 56, 56, 0);
    border-color: rgba(var(--theme-gold-rgb), 0.45);
  }
}

@keyframes duel-hp-fill-hurt {
  0% {
    filter: brightness(1);
    transform: translateX(0);
  }
  18% {
    filter: brightness(1.35) saturate(1.2);
    transform: translateX(1px);
  }
  40% {
    filter: brightness(1.18) saturate(1.08);
    transform: translateX(-1px);
  }
  100% {
    filter: brightness(1);
    transform: translateX(0);
  }
}


#duel-confirm-btn,
#duel-back-menu-btn,
#main-container.eg-solo-match-stage #confirm-guess {
  width: 100%;
  min-height: 44px;
}

.hidden {
  display: none !important;
}

@media (max-height: 900px) {
  .duel-face-front img,
  #main-container.eg-solo-match-stage #face-front img {
    max-height: 150px;
  }
  body:not(.game-view) #duel-match #map-container {
    height: 300px;
  }

  body:not(.game-view) #main-container.eg-solo-match-stage .eg-solo-map-frame {
    height: 300px;
  }
}

@media (max-height: 760px) {
  .duel-face-front img,
  #main-container.eg-solo-match-stage #face-front img {
    max-height: 120px;
  }
  body:not(.game-view) #duel-match #map-container {
    height: 240px;
  }

  body:not(.game-view) #main-container.eg-solo-match-stage .eg-solo-map-frame {
    height: 240px;
  }
}

@media (max-width: 780px) {
  .duel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .duel-share-pills {
    grid-template-columns: 1fr;
  }
  .duel-panel {
    padding: 10px;
  }
  .duel-player-item {
    align-items: flex-start;
    gap: 8px;
  }
  .duel-player-name {
    min-width: 0;
    max-width: 48%;
  }
  .duel-player-avatar-wrap {
    width: 22px;
    height: 22px;
  }
  .duel-player-stats-badge {
    align-self: center;
    margin-top: 1px;
  }
  .duel-player-stats-tip {
    white-space: normal;
    width: 170px;
    text-align: center;
  }
  .duel-player-state {
    margin-top: 1px;
  }
  .duel-identity-actions {
    grid-template-columns: 1fr;
  }
  .duel-lobby-top {
    grid-template-columns: 1fr;
  }
  .duel-lobby-actions {
    grid-template-columns: 1fr;
  }
  .duel-options-layout {
    grid-template-columns: 1fr;
  }
  .duel-difficulty-row {
    grid-template-columns: 1fr;
  }
  .duel-options-main {
    gap: 8px;
  }
  .duel-face-front {
    gap: 14px;
    padding: 0 6px;
  }
  .duel-face-front img,
  #main-container.eg-solo-match-stage #face-front img {
    max-width: 42%;
    height: 85%;
    max-height: 220px;
  }
  #duel-ready-btn,
  #duel-leave-btn,
  #duel-start-btn {
    min-height: 44px;
  }
}

@media (max-width: 980px) {
  .duel-options-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Single-player game.php: reuse duel match chrome (HUD + shell) --- */
/* Full width + stretch: avoids width jumping when confirm button text length changes
   (flex column + align-items:center was shrinking the panel to content width). */
#main-container.eg-page-shell {
  padding: 14px min(16px, 3vw) 22px;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  align-items: stretch;
}

#main-container.eg-solo-match-stage {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.eg-solo-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: clamp(10px, 1.8vh, 22px);
  text-align: center;
}

.eg-solo-hud-name {
  font-size: 0.95rem;
  color: rgba(255, 244, 220, 0.92);
  font-weight: 700;
}

#game-score-display.eg-solo-hud-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(var(--theme-gold-rgb), 0.45);
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  font-family: inherit;
  -webkit-text-stroke: 0;
  text-shadow: none;
  margin: 0;
  width: auto;
}

/* game.php: #back-to-menu is in #main-container.eg-solo-match-stage — position set in style.css (top-right over map) */
body.game-view #back-to-menu.eg-solo-end-game {
  margin-top: 0;
  padding: 6px 10px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  width: auto;
  max-width: min(96vw, 320px);
  text-align: right;
  color: #000;
  text-decoration: underline;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}

body.game-view #back-to-menu.eg-solo-end-game:hover {
  color: #222;
  transform: none;
  box-shadow: none;
  background: transparent;
  border: none;
}

#main-container.eg-solo-match-stage #confirm-guess.eg-primary-btn {
  border-radius: 12px;
  border: 1px solid var(--theme-gold-base);
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 8px;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  align-self: stretch;
}

#main-container.eg-solo-match-stage #confirm-guess.eg-primary-btn:not(.disabled) {
  animation: none;
}

#main-container.eg-solo-match-stage #confirm-guess.eg-primary-btn:hover:not(.disabled) {
  transform: translateY(-1px) scale(1.01);
}

#main-container.eg-solo-match-stage #face-front.duel-face-front {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Result flip-back: match original game (two columns, map.gif, full-info pre) */
#main-container.eg-solo-match-stage #result-popup #result-content {
  align-items: stretch;
}

@media (max-width: 768px) {
  #game-score-display.eg-solo-hud-total {
    font-size: 0.9rem;
  }

  body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage .eg-solo-float {
    top: calc(var(--eg-map-overlay-padding) + 2.85rem);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    align-items: center;
  }

  body.game-view:not(.reversed-mode) #duel-match #main-container.eg-solo-match-stage #duel-round-hud.duel-round-hud {
    bottom: calc(var(--eg-map-overlay-padding) + 4.75rem);
    left: var(--eg-map-overlay-padding);
    right: auto;
  }
}
