/* Основные цвета */
:root {
  color-scheme: dark;

  --bg: #151719;
  --panel: #1d2023;
  --border: #353a40;
  --text: #f5f5f1;
  --muted: #a6adb5;
  --accent: #bbdd85;
}

/* Общие настройки */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(1.12);
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

:focus-visible {
  outline: 3px solid #a9ceff;
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 1168px;
  margin: auto;
  padding: 0 32px;
}

/* Верхняя панель */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 100px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  text-decoration: none;
}

.brand-icon {
  margin-right: 12px;
  color: var(--accent);
  font-size: 26px;
}

.brand-dot {
  color: var(--accent);
}

.subtle {
  border-color: var(--border);
  background: transparent;
  color: #c0c6cc;
  font-size: 14px;
}

/* Заголовок и счётчик */
.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 56px 0 48px;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

h1 {
  margin: 0 0 20px;
  font-size: clamp(32px, 4.5vw, 54px);
  font-weight: 750;
  line-height: 1.13;
  letter-spacing: -1.8px;
}

h1 span {
  color: #a8afb5;
}

.lead {
  margin: 0;
  color: #b5bcc2;
  line-height: 1.7;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding-left: 40px;
  border-left: 1px solid var(--border);
}

.stat strong {
  font-size: 64px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -3px;
}

.stat span {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

/* Заголовок тир-листа и кнопки */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h2 {
  margin: 0 0 3px;
  font-size: 21px;
  letter-spacing: -0.5px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.primary {
  background: var(--accent);
  color: #17200e;
}

.wide {
  width: 100%;
}

/* Строки тиров */
.board {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tier {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 132px;
  background: #1b1e21;
}

.tier + .tier {
  border-top: 1px solid var(--border);
}

.tier-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--tier);
  color: #191b1d;
}

.tier-label strong {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.1;
}

.tier-label small {
  max-width: 100%;
  padding: 0 4px;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  overflow-wrap: anywhere;
}

.tier-games {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 16px;
  min-width: 0;
  padding: 20px;
}

.empty {
  margin: 0;
  color: #969fa8;
  font-size: 14px;
}

/* Карточки игр */
.card {
  position: relative;
  width: 94px;
  min-width: 0;
  margin: 0;
}

.card button {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-weight: 400;
  text-align: left;
}

.card img,
.cover-fallback {
  display: block;
  width: 94px;
  height: 126px;
  border: 1px solid #464e56;
  border-radius: 6px;
  background: #2a3035;
  object-fit: cover;
}

.cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b4bcc5;
  font-size: 30px;
}

.card figcaption {
  margin-top: 7px;
  color: #cbd0d5;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.card .edit-mark {
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 2px 5px;
  border: 1px solid #626b74;
  border-radius: 4px;
  background: #151719ed;
  color: white;
  font-size: 12px;
}

/* Сообщения */
.notice {
  margin: 0 0 24px;
  padding: 14px 16px;
  border: 1px solid #4a5663;
  border-radius: 8px;
  background: #202831;
  color: #d0dfeb;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.error {
  color: #ffb6ad;
  font-size: 14px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.error:empty {
  display: none;
}

.notice.error {
  border-color: #965a54;
  background: #332321;
  color: #ffb6ad;
}

/* Нижняя часть сайта */
footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 0 32px;
  color: var(--muted);
  font-size: 14px;
}

/* Всплывающие окна */
dialog {
  width: min(460px, calc(100% - 32px));
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
  padding: 28px;
  border: 1px solid #4e5861;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: #080a0ccc;
}

.dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.icon {
  flex-shrink: 0;
  min-width: 44px;
  padding: 0;
  background: #2d3339;
  color: var(--text);
  font-size: 26px;
}

label {
  display: block;
  margin: 20px 0;
  font-size: 14px;
  font-weight: 600;
}

input,
select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 11px;
  border: 1px solid #56616b;
  border-radius: 6px;
  background: #151719;
  color: var(--text);
}

input[type="file"] {
  padding: 8px;
  font-size: 14px;
}

label .muted {
  display: block;
  margin-top: 8px;
  font-weight: 400;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.danger {
  margin-right: auto;
  background: #4b2a28;
  color: #ffbbb3;
}

.cover-preview {
  max-width: 100%;
  height: 145px;
  border-radius: 6px;
  object-fit: contain;
}

/* Версия для телефонов */
@media (max-width: 600px) {
  .wrap {
    padding: 0 16px;
  }

  header {
    min-height: 80px;
  }

  .brand {
    font-size: 15px;
    letter-spacing: 1px;
  }

  .brand-icon {
    margin-right: 6px;
  }

  .subtle {
    padding: 8px 10px;
    font-size: 14px;
  }

  .intro {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    padding: 36px 0 32px;
  }

  h1 {
    letter-spacing: -1px;
  }

  .eyebrow {
    font-size: 12px;
    letter-spacing: 1px;
  }

  .desktop-break {
    display: none;
  }

  .stat {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    padding: 0;
    border: 0;
  }

  .stat strong {
    font-size: 32px;
    letter-spacing: -1px;
  }

  .stat span {
    margin: 0;
  }

  .toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .tier {
    grid-template-columns: 60px minmax(0, 1fr);
    min-height: 114px;
  }

  .tier-label strong {
    font-size: 28px;
  }

  .tier-label small {
    display: none;
  }

  .tier-games {
    gap: 12px;
    padding: 16px;
  }

  .card,
  .card img,
  .cover-fallback {
    width: 80px;
  }

  .card img,
  .cover-fallback {
    height: 108px;
  }

  footer {
    flex-direction: column;
    gap: 4px;
  }

  dialog {
    padding: 20px;
  }
}