/* Главная, мастер создания турнира и редактор тем. */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: clamp(24px, 4vw, 40px);
  /* Заголовок с переливом из белого в акцент — фирменная деталь. */
  background: linear-gradient(100deg, var(--text) 30%, color-mix(in srgb, var(--accent-2) 75%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Карточки и секции выплывают по очереди при загрузке страницы. */
.tournaments .tcard,
.setup-form .section:not(.hidden),
.preview .section {
  animation: page-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.tournaments .tcard:nth-child(2), .preview .section:nth-child(2) { animation-delay: 70ms; }
.tournaments .tcard:nth-child(3), .preview .section:nth-child(3) { animation-delay: 140ms; }
.tournaments .tcard:nth-child(4), .preview .section:nth-child(4) { animation-delay: 210ms; }
.tournaments .tcard:nth-child(5) { animation-delay: 280ms; }
.tournaments .tcard:nth-child(n+6) { animation-delay: 340ms; }

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

.page-head p {
  margin: 6px 0 0;
  max-width: 60ch;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
}

/* -- главная -------------------------------------------------------------- */

.net-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.net-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.net-item b {
  font-size: 1.05rem;
}

.net-item span {
  font-size: 0.78rem;
  color: var(--muted);
}

.tournaments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.tcard {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(170deg, color-mix(in srgb, var(--panel) 93%, white), var(--panel));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 22px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tcard:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 12px 34px rgba(0, 0, 0, 0.35);
}

.tcard-title {
  font-size: 1.12rem;
  font-weight: 800;
}

.tcard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tcard-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.tcard-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 9px 10px;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* Второстепенные действия уже основных — все кнопки умещаются в одну строку. */
.tcard-actions .btn-icon {
  flex: 0 1 auto;
  padding: 9px 11px;
  font-size: 0.8rem;
  color: var(--muted);
}

.tcard-actions .btn-icon.btn-danger {
  color: var(--bad);
}

/* -- мастер --------------------------------------------------------------- */

.setup {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .setup {
    grid-template-columns: 1fr;
  }
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* -- шаги мастера ---------------------------------------------------------- */

.stepper {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.stepper::-webkit-scrollbar {
  display: none;
}

.step {
  /* Шаги делят строку поровну и умеют сжиматься: пятый не должен уезжать
     за край на ноутбучных экранах. */
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step.is-active {
  border-color: var(--accent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}

.step.is-done {
  color: var(--good);
}

.step-num {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--panel-alt);
  font-size: 0.73rem;
  font-weight: 800;
}

/* На узком экране остаются только номера — подписи не нужны. */
@media (max-width: 720px) {
  .step {
    flex: 0 0 auto;
    padding: 9px 12px;
  }
}

.step.is-active .step-num {
  background: var(--accent);
  color: #fff;
}

.step.is-done .step-num {
  background: color-mix(in srgb, var(--good) 25%, var(--panel-alt));
  color: var(--good);
}

.step-nav {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.step-nav .btn {
  flex: 1;
}

.section {
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(170deg, color-mix(in srgb, var(--panel) 94%, white), var(--panel));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 22px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section > h3 {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.preview {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.pstat {
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
}

.pstat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.pstat-value {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scroll-table {
  max-height: 320px;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.ptable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ptable th {
  position: sticky;
  top: 0;
  background: var(--panel-alt);
  text-align: left;
  padding: 8px 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ptable td {
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.ptable tr.is-break td {
  color: var(--accent);
  font-weight: 700;
}

.ptable td.num {
  text-align: right;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.type-option {
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font: inherit;
  color: inherit;
}

.type-option.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel-alt));
}

.type-option b {
  font-size: 0.98rem;
}

.type-option span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

/* -- номиналы фишек ------------------------------------------------------- */

.chip-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
}

/* Кружок с номиналом — визуально это та самая фишка. */
.chip-face {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
}

.chip-count {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.warn-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.warn {
  font-size: 0.82rem;
  color: var(--warn);
  line-height: 1.4;
}

/* -- редактор тем --------------------------------------------------------- */

.editor {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  position: sticky;
  top: 20px;
  padding-right: 4px;
}

.editor-stage-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--page-bg);
}

/* Экран редактируется в том же соотношении, что и телевизор в зале. */
.editor-stage {
  aspect-ratio: 16 / 9;
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), 1fr);
  grid-template-rows: repeat(var(--rows, 12), 1fr);
  gap: var(--gap);
  padding: var(--gap);
  position: relative;
}

.editor-stage .cell {
  position: relative;
  container-type: size;
}

.editor-stage .cell.is-selected::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid var(--accent);
  border-radius: calc(var(--radius) + 3px);
  pointer-events: none;
}

.editor-stage .cell.is-dragging {
  opacity: 0.55;
}

.drag-handle {
  position: absolute;
  inset: 0;
  cursor: grab;
  z-index: 2;
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  z-index: 3;
  background:
    linear-gradient(135deg, transparent 48%, var(--accent) 50%, var(--accent) 62%, transparent 64%);
  border-bottom-right-radius: var(--radius);
}

.grid-ghost {
  position: absolute;
  inset: var(--gap);
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), 1fr);
  grid-template-rows: repeat(var(--rows, 12), 1fr);
  gap: var(--gap);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.grid-ghost.is-on {
  opacity: 0.35;
}

.grid-ghost i {
  border: 1px dashed var(--muted);
  border-radius: 4px;
}

.widget-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.widget-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
}

.widget-item.is-selected {
  border-color: var(--accent);
}

.widget-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
}
