:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --panel: #141418;
  --border: #303036;
  --text: #e8e8ea;
  --muted: #9a9aa2;
  --red: #e03a2f;
  --yellow: #f2b632;
  --green: #35c46f;
}

* {
  box-sizing: border-box;
}

[hidden],
.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 0%, #341315 0%, transparent 50%),
    radial-gradient(ellipse at 90% 30%, #151c25 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

.container {
  max-width: 1050px;
  margin: 0 auto;
  padding: 44px 20px;
}

.eyebrow {
  color: var(--muted);
  font: 12px Consolas, monospace;
  letter-spacing: 3px;
}

.site-title {
  margin: 14px 0;
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 900;
  letter-spacing: 3px;
}

.site-title span span {
  color: var(--red);
}

.doom-title {
  display: block;
  max-width: min(100%, 650px);
  height: auto;
  image-rendering: pixelated;
}

.subtitle {
  margin: 12px 0 32px;
  color: var(--muted);
  line-height: 1.6;
}

.panel {
  margin-bottom: 24px;
  padding: 28px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--red);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 16px 48px #0005;
}

h2 {
  margin: 0 0 24px;
  font-size: 23px;
}

h3 {
  margin-top: 28px;
  font-size: 16px;
}

.field {
  display: block;
  margin-bottom: 24px;
}

.field > span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0c0c0f;
  color: var(--text);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0e0e12;
  color: var(--text);
  text-align: left;
  transition: border-color .15s, background .15s;
}

.mode-card:hover {
  border-color: #777;
}

.mode-card.selected {
  border-color: var(--red);
  background: #251416;
  box-shadow: inset 3px 0 var(--red);
}

.mode-card strong {
  display: block;
  font-size: 18px;
}

.mode-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.primary-button,
.secondary-button {
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: white;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  background: var(--red);
}

.primary-button:hover {
  background: #f04438;
}

.secondary-button {
  background: #29292f;
  border-color: var(--border);
}

button:disabled {
  opacity: .55;
}

.hint,
.site-footer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.hint {
  margin: 14px 0 0;
}

.site-footer {
  text-align: center;
  letter-spacing: 2px;
}

.session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.session-head h2 {
  margin-bottom: 8px;
}

#session-status {
  margin: 0;
  color: var(--yellow);
  line-height: 1.6;
}

.players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.player {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-wrap: anywhere;
}

.player.active {
  border-color: var(--yellow);
  background: #f2b63210;
}

.maps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.map-card {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 125px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: linear-gradient(145deg, #29292f, #111115);
  color: var(--text);
  font: 700 18px Consolas, monospace;
}

.map-card:hover:not(:disabled) {
  border-color: var(--red);
  background: linear-gradient(145deg, #422023, #171115);
}

.map-card.banned::after,
.map-card.picked::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 19px;
}

.map-card.banned::after {
  content: "BANNED";
  color: var(--red);
  background: #290505aa;
}

.map-card.picked::after {
  content: "PICKED";
  color: var(--green);
  background: #052913aa;
}

.draft-log {
  color: var(--muted);
  font: 14px/1.6 Consolas, monospace;
}

.draft-log > div {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.error-box {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--red);
  border-radius: 6px;
  background: #351516;
  color: #ffb4ad;
}

@media (max-width: 600px) {
  .container {
    padding: 24px 12px;
  }

  .panel {
    padding: 20px 16px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }
}

/* Фон только внутри Deathmatch-сессии. */

body.deathmatch-session {
  background-color: #0b0b0d;
  background-image:
    linear-gradient(
      rgba(5, 5, 8, .65),
      rgba(5, 5, 8, .82)
    ),
    url("/assets/deathmatch/background.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Слегка прозрачная панель, чтобы фон был заметен. */

body.deathmatch-session #session-screen {
  background: rgba(20, 20, 24, .90);
}

body.deathmatch-session .maps {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

/* Карточка: изображение сверху, полное название снизу. */

.map-card.dm-map-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-width: 0;
  min-height: 0;
  padding: 0;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #101014;
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  text-align: center;
}

.dm-map-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: linear-gradient(135deg, #303039, #141419);
}

/* Затемнение снизу для читаемости MAP01. */

.dm-map-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    transparent 40%,
    rgba(0, 0, 0, .85)
  );
}

.dm-map-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s ease;
}

/* Маленький номер внутри картинки снизу по центру. */

.dm-map-number {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  z-index: 2;
  color: #fff;
  font: 700 13px/1.2 Consolas, monospace;
  letter-spacing: 1px;
  text-align: center;
  text-shadow: 0 2px 5px #000;
}

/* Полное название под изображением. */

.dm-map-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  color: #ececef;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* Отключаем прежний оверлей на всю карточку.
   Теперь статус расположен только поверх изображения. */

.map-card.dm-map-card.banned::after,
.map-card.dm-map-card.picked::after {
  content: none;
}

.dm-map-badge {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font: 900 18px Consolas, monospace;
  letter-spacing: 1px;
}

.dm-map-card.banned .dm-map-badge {
  color: #ff655a;
  background: rgba(55, 0, 0, .55);
}

.dm-map-card.picked .dm-map-badge {
  color: var(--green);
  background: rgba(0, 45, 15, .55);
}

/* Сохраняем читаемость названий забаненных карт. */

.map-card.dm-map-card:disabled {
  opacity: 1;
}

.dm-map-card.banned .dm-map-image {
  filter: grayscale(1) brightness(.45);
}

.dm-map-card.banned .dm-map-caption {
  color: #92929c;
}

.map-card.dm-map-card:hover:not(:disabled) {
  border-color: var(--red);
  background: #211316;
}

.dm-map-card:hover:not(:disabled) .dm-map-image {
  transform: scale(1.04);
}

@media (max-width: 850px) {
  body.deathmatch-session .maps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  body.deathmatch-session .maps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dm-map-caption {
    font-size: 12px;
  }

  body.deathmatch-session {
    background-attachment: scroll;
  }
}

.mode-tournament {
  display: block;
  margin-top: 10px;
  color: var(--yellow);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

/* Фон главной и остальных страниц вне DM-сессии. */

body:not(.deathmatch-session) {
  background-color: #0b0b0d;
  background-image:
    linear-gradient(
      rgba(5, 5, 8, .55),
      rgba(5, 5, 8, .80)
    ),
    url("/assets/background.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* Небольшая прозрачность панели на главной. */

body:not(.deathmatch-session) .panel {
  background: rgba(20, 20, 24, .92);
}

@media (max-width: 520px) {
  body:not(.deathmatch-session) {
    background-attachment: scroll;
  }
}

/* Три оставшиеся карты после завершения банов. */

.map-card.dm-map-card.final-map {
  border-color: var(--green);
  box-shadow:
    0 0 0 1px rgba(53, 196, 111, .45),
    0 0 22px rgba(53, 196, 111, .22);
}

.dm-map-card.final-map .dm-map-preview::after {
  background:
    linear-gradient(
      rgba(15, 115, 55, .18),
      rgba(5, 55, 25, .48)
    );
}

.dm-map-card.final-map .dm-map-caption {
  color: #bfffd4;
  background: rgba(15, 85, 40, .35);
  border-top-color: rgba(53, 196, 111, .45);
}

/* Финальный экран появляется поверх страницы. */

.dm-results-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 32px 20px;
  background: rgba(5, 8, 7, .94);
  backdrop-filter: blur(12px);
  animation: dm-results-appear .45s ease both;
}

.dm-results-panel {
  width: min(1280px, 100%);
  margin: auto;
  text-align: center;
}

.dm-results-eyebrow {
  margin: 0 0 12px;
  color: var(--yellow);
  font-size: 14px;
  letter-spacing: 2px;
}

.dm-results-panel h2 {
  margin: 0 0 12px;
  color: #eaffef;
  font-size: clamp(28px, 4vw, 44px);
}

.dm-results-panel h2:focus {
  outline: none;
}

.dm-results-description {
  margin: 0 0 32px;
  color: #b5c2b9;
  line-height: 1.5;
}

.dm-results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.dm-result-card {
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--green);
  border-radius: 12px;
  background: #101a14;
  box-shadow: 0 12px 45px rgba(0, 0, 0, .4);
  animation: dm-card-appear .5s ease both;
}

.dm-result-card:nth-child(2) {
  animation-delay: .08s;
}

.dm-result-card:nth-child(3) {
  animation-delay: .16s;
}

.dm-result-order {
  padding: 14px;
  color: #bcffd0;
  background: #183e25;
  font-weight: 800;
  font-size: 18px;
}

.dm-result-preview {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #26392d, #101813);
}

.dm-result-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-result-caption {
  margin: 0;
  padding: 20px 12px;
  color: #ecfff2;
  font-size: clamp(15px, 1.6vw, 20px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.dm-results-session {
  margin: 26px 0 0;
  color: #8fa295;
  font: 13px Consolas, monospace;
}

/* Скрываем исходную страницу, включая забаненные карты.
   Она остаётся в DOM и продолжает получать обновления. */

body.dm-results-open {
  overflow: hidden;
}

body.dm-results-open > .container {
  visibility: hidden;
}

@keyframes dm-results-appear {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dm-card-appear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 700px) {
  .dm-results-screen {
    padding: 24px 16px;
  }

  .dm-results-grid {
    grid-template-columns: 1fr;
    max-width: 420px;
    margin: 0 auto;
    gap: 18px;
  }

  .dm-result-preview {
    aspect-ratio: 16 / 9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dm-results-screen,
  .dm-result-card {
    animation: none;
  }
}