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

:root {
  --felt-hi: #256b52;
  --felt: #17513d;
  --felt-lo: #0b2c20;
  --rail: #3c2317;
  --rail-hi: #6d4227;
  --brass: #d3ac66;
  --brass-hi: #f6e2b0;
  --brass-lo: #8a6a30;
  --cream: #fbf6ea;
  --ink: #23272e;
  --suit-red: #b32a20;
  --text: #ecead9;
  --muted: #94ab9e;
  --danger: #d4674f;
  --ok: #7fcf9a;

  --font-ui: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --font-display: "Georgia", "Iowan Old Style", "Times New Roman", serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* Базовый размер карты; контейнеры руки и сброса его переопределяют. */
  --card-w: 62px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: #0b2018;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app {
  height: 100dvh;
  width: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ── кнопки ─────────────────────────────────────────────────────────── */

.btn {
  --btn-face: linear-gradient(180deg, #37795f, #1f5642);
  --btn-edge: #0f3527;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 12px;
  background: var(--btn-face);
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 0 var(--btn-edge),
    0 10px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 var(--btn-edge),
    0 4px 10px rgba(0, 0, 0, 0.35);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 var(--btn-edge);
}

.btn--primary {
  --btn-face: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, #b8913f);
  --btn-edge: #6b4f1d;
  color: #3a2a0d;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn--danger {
  --btn-face: linear-gradient(180deg, #b8543f, #8d3626);
  --btn-edge: #5b2015;
}

.btn--ghost {
  --btn-face: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  --btn-edge: rgba(0, 0, 0, 0.35);
  color: var(--text);
}

.btn--lg {
  padding: 16px 40px;
  font-size: 19px;
  border-radius: 14px;
}

.btn--block {
  width: 100%;
}

/* ── сегментированный переключатель ─────────────────────────────────── */

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.32);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.seg__item {
  flex: 1;
  padding: 9px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.seg__item.is-active {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: #3a2a0d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ── поля ───────────────────────────────────────────────────────────── */

.field {
  display: block;
}

.field__label {
  display: block;
  margin-bottom: 8px;
  color: var(--brass);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.input:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

/* ── экран меню ─────────────────────────────────────────────────────── */

.menu {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-t)) 18px calc(20px + var(--safe-b));
  background:
    radial-gradient(120% 90% at 50% 8%, var(--felt-hi), var(--felt) 45%, var(--felt-lo) 100%),
    var(--felt-lo);
  overflow-y: auto;
}

.menu__inner {
  width: min(420px, 100%);
  display: grid;
  gap: 20px;
}

.menu__head {
  text-align: center;
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(40px, 12vw, 62px);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  background: linear-gradient(180deg, #fff3d0, var(--brass) 48%, var(--brass-lo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.55));
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel {
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(0, 0, 0, 0.18));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 18px 40px rgba(0, 0, 0, 0.45);
}

.menu__foot {
  display: grid;
  gap: 10px;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

/* ── модальное окно правил ──────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: rgba(4, 16, 11, 0.72);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease;
}

.modal__box {
  width: min(520px, 100%);
  max-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 22px;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 18px;
  background: linear-gradient(180deg, #1d5943, #123829);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--brass-hi);
}

.modal__body {
  /* min-height: 0 обязателен: у grid-элемента по умолчанию min-height: auto,
     из-за чего строка 1fr не даёт содержимому сжаться и overflow-y не
     включается — окно просто вырастает за экран. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 12px;
  font-size: 14px;
  line-height: 1.55;
  -webkit-overflow-scrolling: touch;
}

.modal__body b {
  color: var(--brass);
}

.rank-line {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-align: center;
}

.modal__para {
  margin: 0;
}

/* ── сообщения ──────────────────────────────────────────────────────── */

.notice {
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 13px;
  line-height: 1.45;
}

.notice--ok {
  background: rgba(90, 170, 120, 0.22);
  color: var(--ok);
}

.notice--warn {
  background: rgba(214, 175, 105, 0.18);
  color: var(--brass-hi);
}

.notice--bad {
  background: rgba(190, 80, 60, 0.22);
  color: var(--danger);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 90;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, #2a6b53, #17513d);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  font-size: 14px;
  text-align: center;
  transform: translate(-50%, 0);
  animation: toast-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.toast--bad {
  background: linear-gradient(180deg, #8d3d2c, #6b2a1d);
}

.toast.is-leaving {
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.28s, transform 0.28s;
}

.net-status {
  min-height: 1.2em;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.net-status.is-warn {
  color: var(--brass-hi);
}

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

.title--sm {
  font-size: clamp(26px, 7vw, 36px);
}

.menu__row {
  display: flex;
  gap: 10px;
}

.menu__row .btn {
  flex: 1;
}

/* ── настройки и профиль ────────────────────────────────────────────── */

.settings {
  gap: 18px;
}

.panel--tight {
  gap: 12px;
  padding: 16px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile__avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, #3d7f63, #1d5340);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-size: 26px;
}

.profile__id {
  display: grid;
  gap: 3px;
  font-size: 14px;
  min-width: 0;
}

.profile__id span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.chip--rank {
  justify-self: start;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: #3a2a0d;
}

.avatar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar-pick {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 20px;
}

.avatar-pick.is-active {
  border-color: var(--brass);
  background: rgba(214, 175, 105, 0.2);
}

.stats {
  display: grid;
  gap: 4px;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 13px;
}

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

.badge {
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  font-size: 11.5px;
  opacity: 0.55;
}

.badge.is-earned {
  border-color: rgba(214, 175, 105, 0.6);
  background: rgba(214, 175, 105, 0.18);
  color: var(--brass-hi);
  opacity: 1;
}

/* ── лобби комнаты ──────────────────────────────────────────────────── */

.lobby__seats {
  display: grid;
  gap: 8px;
}

.lobby__seat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.26);
}

.lobby__seat.is-offline {
  opacity: 0.5;
}

.lobby__seat--empty {
  justify-content: center;
  border: 2px dashed rgba(255, 255, 255, 0.14);
  background: none;
  color: var(--muted);
  font-size: 20px;
}

.lobby__seatInfo {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
}

.lobby__seatInfo span {
  font-size: 11.5px;
}

.lobby__actions {
  display: grid;
  gap: 8px;
}

.lobby__record {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(214, 175, 105, 0.16);
  color: var(--brass-hi);
  font-size: 12px;
  font-weight: 700;
}

.lobby__stats {
  display: grid;
  gap: 6px;
}

.icon-btn--sm {
  width: 30px;
  height: 30px;
  font-size: 15px;
}

.input--code {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 20px;
  font-family: var(--font-display);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
}
