/* Общие переменные, сброс и элементы управления для всех экранов. */

@import url('/css/fonts.css');

/* Палитра «сукно»: зелёный стол покерного клуба и латунный акцент.
   Цвета заданы в oklch — так же, как в макете, без пересчёта в hex. */
:root {
  --bg: oklch(0.145 0.008 150);
  --panel: oklch(0.23 0.035 158);
  --panel-alt: oklch(0.28 0.05 158);
  --border: oklch(0.42 0.05 150 / 0.5);
  --text: oklch(0.96 0.015 90);
  --muted: oklch(0.72 0.025 150);
  --accent: oklch(0.78 0.11 85);
  --accent-2: oklch(0.9 0.09 92);
  --good: oklch(0.7 0.09 140);
  --bad: oklch(0.72 0.19 25);
  --warn: oklch(0.84 0.13 82);
  --timer-color: oklch(0.97 0.02 92);
  --radius: 16px;
  --gap: 12px;
  --scale: 1;
  /* Три гарнитуры из макета: заголовки с засечками, интерфейс гротеском,
     все числа и таймер — моноширинным, чтобы цифры не прыгали. */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-ui: 'Manrope', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', ui-monospace, monospace;
  --page-bg: radial-gradient(130% 100% at 50% -25%, oklch(0.22 0.04 158) 0%, oklch(0.17 0.022 155) 55%, oklch(0.145 0.008 150) 100%);
  --banner: linear-gradient(160deg, oklch(0.9 0.09 92) 0%, oklch(0.76 0.12 84) 52%, oklch(0.66 0.11 78) 100%);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--page-bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent-2);
}

/* -- элементы управления -------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  /* Лёгкий вертикальный градиент и блик сверху — кнопка выглядит объёмной. */
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-alt) 88%, white), var(--panel-alt));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 16px rgba(0, 0, 0, 0.35);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(0.96);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 4px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}

.btn-primary:hover:not(:disabled) {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 6px 26px color-mix(in srgb, var(--accent) 60%, transparent);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  color: var(--bad);
}

.btn-lg {
  padding: 16px 22px;
  font-size: 1.05rem;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

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

.field > label,
.label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

input[type='text'],
input[type='number'],
input[type='search'],
input[type='password'],
select,
textarea {
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  width: 100%;
  min-width: 0;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

input[type='color'] {
  width: 46px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}

.card {
  background: linear-gradient(170deg, color-mix(in srgb, var(--panel) 94%, white), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 28px rgba(0, 0, 0, 0.28);
}

.muted {
  color: var(--muted);
}

.accent {
  color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
}

.chip-good {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 40%, transparent);
}

.chip-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}

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

.denoms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.denom {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.denom.is-on {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

/* -- редактор структуры --------------------------------------------------- */

.lvl-head,
.lvl-row {
  display: grid;
  grid-template-columns: 2.2rem repeat(4, minmax(0, 1fr)) 6.6rem;
  gap: 6px;
  align-items: center;
}

.lvl-head {
  padding: 0 2px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.lvl-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}

.lvl-row input {
  padding: 7px 8px;
  font-size: 0.9rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* У перерыва вместо блайндов одно широкое поле с названием. */
.lvl-row.is-break {
  grid-template-columns: 2.2rem minmax(0, 3fr) minmax(0, 1fr) 6.6rem;
}

.lvl-row.is-break .lvl-name {
  text-align: left;
  color: var(--accent);
  font-weight: 700;
}

.lvl-num {
  text-align: center;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.lvl-btns {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}

.lvl-btns .icon-btn {
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.lvl-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 12px;
}

.lvl-total {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 600;
}

/* На телефоне строка целиком не помещается, но ломать её на две хуже, чем
   прокручивать вбок: уровень остаётся одной строкой и читается как таблица. */
@media (max-width: 560px) {
  .lvl-rows,
  .lvl-head {
    overflow-x: auto;
  }

  .lvl-head,
  .lvl-row {
    min-width: 460px;
  }
}

/* Всплывающие уведомления об ошибках и подтверждениях. */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s ease-out;
  font-weight: 600;
}

.toast.is-error {
  border-color: var(--bad);
  color: var(--bad);
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
