:root {
  --bg-0: #050a16;
  --bg-1: #0a1326;
  --bg-2: #0e1b35;
  --bg-3: #16284c;

  --panel: rgba(255, 255, 255, 0.072);
  --panel-2: rgba(255, 255, 255, 0.05);
  --panel-3: rgba(255, 255, 255, 0.038);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.2);

  --text: #f4f7ff;
  --muted: #a9b7d6;
  --muted-2: #7f8fb1;

  --primary: #7b8cff;
  --primary-2: #9f6dff;
  --primary-soft: rgba(123, 140, 255, 0.18);

  --good: #67e8a5;
  --good-bg: rgba(34, 197, 94, 0.16);
  --good-line: rgba(103, 232, 165, 0.28);

  --warn: #ffd17a;
  --warn-bg: rgba(245, 158, 11, 0.16);
  --warn-line: rgba(245, 158, 11, 0.3);

  --danger: #ff8e98;
  --danger-bg: rgba(239, 68, 68, 0.16);
  --danger-line: rgba(239, 68, 68, 0.32);

  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.36);
  --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.18);

  --radius-xl: 26px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;

  --container: 1120px;
  --ease: 180ms ease;
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

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

body.player-body {
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(123, 140, 255, 0.16), transparent 24%),
    radial-gradient(circle at top right, rgba(159, 109, 255, 0.13), transparent 24%),
    radial-gradient(circle at 50% 20%, rgba(89, 217, 255, 0.08), transparent 24%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  position: relative;
  overflow-x: hidden;
}

body.player-body::before,
body.player-body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body.player-body::before {
  top: -160px;
  left: -120px;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(123, 140, 255, 0.14), transparent 68%);
  filter: blur(14px);
}

body.player-body::after {
  right: -140px;
  bottom: -160px;
  width: 460px;
  height: 460px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(159, 109, 255, 0.12), transparent 68%);
  filter: blur(16px);
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, var(--container));
  margin: 0 auto;
  padding: 14px;
  position: relative;
  z-index: 1;
}

.player-shell {
  padding-bottom: 84px;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.045)),
    rgba(10, 16, 30, 0.78);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
}

.topbar.compact h1 {
  margin: 6px 0 0;
  font-size: clamp(1.28rem, 2.2vw, 1.78rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions .btn {
  min-height: 42px;
  padding-inline: 12px;
}

.top-actions .btn span {
  display: inline-flex;
  align-items: center;
}

.top-actions .btn img {
  width: 17px;
  height: 17px;
  object-fit: contain;
  opacity: 0.95;
}

.pill,
.mini-pill,
.turn-chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  white-space: nowrap;
}

.pill {
  min-height: 42px;
  padding: 10px 13px;
  font-size: 0.92rem;
  font-weight: 700;
}

.mini-pill {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #dfe7ff;
}

.turn-chip {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.79rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge {
  min-height: 28px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.good,
.turn-chip.good {
  background: var(--good-bg);
  border-color: var(--good-line);
  color: #b8ffd5;
}

.badge.warn,
.turn-chip.warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
  color: #ffe3ab;
}

.badge.bad,
.turn-chip.bad {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: #ffc0c6;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #74829f;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
  flex: 0 0 auto;
}

.dot.good {
  background: var(--good);
  box-shadow:
    0 0 0 4px rgba(103, 232, 165, 0.1),
    0 0 18px rgba(103, 232, 165, 0.28);
}

.dot.bad {
  background: #ff707b;
  box-shadow:
    0 0 0 4px rgba(255, 112, 123, 0.1),
    0 0 18px rgba(255, 112, 123, 0.26);
}

/* ---------- layout ---------- */

.player-layout {
  display: grid;
  gap: 14px;
}

.panel {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.038)),
    rgba(11, 18, 34, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
  padding: 15px;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  pointer-events: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 4px 0 0;
  font-size: 1.02rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* ---------- forms ---------- */

.field-grid.single {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.032)),
    rgba(10, 15, 28, 0.7);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  transition:
    border-color var(--ease),
    background var(--ease),
    box-shadow var(--ease),
    transform var(--ease);
}

.field input::placeholder {
  color: var(--muted-2);
}

.field input:hover,
.field select:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.field input:focus,
.field select:focus {
  border-color: rgba(123, 140, 255, 0.68);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.062), rgba(255,255,255,0.04)),
    rgba(10, 15, 28, 0.86);
  box-shadow:
    0 0 0 4px rgba(123, 140, 255, 0.14),
    0 10px 24px rgba(0, 0, 0, 0.16);
}

.field select {
  appearance: none;
  cursor: pointer;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04)),
    rgba(255, 255, 255, 0.025);
  color: var(--text);
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition:
    transform var(--ease),
    border-color var(--ease),
    background var(--ease),
    box-shadow var(--ease),
    opacity var(--ease);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.05)),
    rgba(255, 255, 255, 0.04);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(123, 140, 255, 0.16),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.btn.primary {
  color: #ffffff;
  border-color: rgba(142, 122, 255, 0.26);
  background:
    linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow:
    0 12px 26px rgba(90, 84, 210, 0.28),
    inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn.primary:hover:not(:disabled) {
  box-shadow:
    0 16px 32px rgba(90, 84, 210, 0.36),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn.ghost {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.025)),
    rgba(255,255,255,0.015);
}

.btn.warn {
  color: #ffe7bb;
  border-color: var(--warn-line);
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.11)),
    rgba(245, 158, 11, 0.06);
}

.btn.danger {
  color: #ffd1d5;
  border-color: var(--danger-line);
  background:
    linear-gradient(180deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.11)),
    rgba(239, 68, 68, 0.06);
}

.btn.huge {
  min-height: 58px;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 900;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: saturate(0.72);
  transform: none !important;
  box-shadow: none !important;
}

/* ---------- info blocks ---------- */

.hint-box,
.info-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.024)),
    rgba(255, 255, 255, 0.018);
  padding: 13px;
}

.hint-box {
  margin-top: 14px;
  color: #dbe6ff;
  line-height: 1.5;
  font-size: 0.92rem;
  position: relative;
}

.hint-box::before {
  content: "TIP";
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(123, 140, 255, 0.24);
  background: rgba(123, 140, 255, 0.12);
  color: #dbe2ff;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.hint-box.auth-required {
  border-color: var(--warn-line);
  background:
    linear-gradient(180deg, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0.08)),
    rgba(255, 255, 255, 0.02);
  color: #ffe8bf;
}

.hint-box.auth-required::before {
  content: "АНХААРУУЛГА";
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.18);
  color: #fff0d0;
}

.hint-auth-title {
  font-size: 0.9rem;
  font-weight: 900;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
  color: #fff4db;
}

.hint-auth-body {
  font-size: 0.86rem;
  line-height: 1.45;
  color: #ffe3b4;
}

.hint-login-btn {
  margin-top: 10px;
  min-height: 38px;
}

.info-card {
  font-size: 0.93rem;
  line-height: 1.56;
}

.info-card .item-title {
  margin-bottom: 6px;
}

.room-meta-card {
  margin-top: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.024)),
    rgba(255, 255, 255, 0.018);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.room-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.room-meta-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.room-meta-row strong,
.room-meta-row span {
  word-break: break-all;
}

.room-meta-row-link {
  align-items: flex-start;
}

.room-meta-link {
  flex: 1 1 240px;
  min-width: 0;
  color: #d5e2ff;
  text-decoration: none;
  border-bottom: 1px dashed rgba(123, 140, 255, 0.34);
  padding-bottom: 2px;
}

.room-meta-link:hover {
  color: #ffffff;
  border-bottom-color: rgba(123, 140, 255, 0.68);
}

/* ---------- stats ---------- */

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

.stat-card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.018);
  padding: 12px;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.025);
}

.stat-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-size: clamp(1.02rem, 2.8vw, 1.28rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #ffffff;
}

/* ---------- action grid ---------- */

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

.action-grid.mobile .btn.huge {
  grid-column: 1 / -1;
}

#rollBtn {
  min-height: 62px;
}

#buyBtn,
#tradeOfferBtn,
#bidBtn {
  border-color: rgba(123, 140, 255, 0.22);
}

#sellPropBtn,
#tradeDeclineBtn,
#leaveBtn {
  border-color: var(--danger-line);
}

#startAuctionBtn {
  border-color: var(--warn-line);
}

/* ---------- stack / lists ---------- */

.stack-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.item {
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.042), rgba(255,255,255,0.028)),
    rgba(255,255,255,0.018);
  padding: 12px;
  transition:
    border-color var(--ease),
    background var(--ease),
    box-shadow var(--ease),
    transform var(--ease);
  min-width: 0;
}

.item:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.062), rgba(255,255,255,0.04)),
    rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.15);
}

.item.turn {
  border-color: rgba(123, 140, 255, 0.44);
  background:
    linear-gradient(180deg, rgba(123, 140, 255, 0.12), rgba(123, 140, 255, 0.06)),
    rgba(255,255,255,0.024);
  box-shadow:
    inset 0 0 0 1px rgba(123, 140, 255, 0.16),
    0 12px 26px rgba(28, 44, 92, 0.18);
}

#myPropsList .item {
  cursor: pointer;
}

.item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  word-break: break-word;
}

.item-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  word-break: break-word;
}

.empty {
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
  padding: 15px;
  text-align: center;
  color: var(--muted);
  line-height: 1.45;
}

/* ---------- specific panels ---------- */

#currentTileCard,
#auctionCard,
#tradeCard {
  min-height: 92px;
}

#chatList .item {
  padding: 12px 12px 11px;
}

#chatList .item.turn {
  border-color: rgba(103, 232, 165, 0.32);
  background:
    linear-gradient(180deg, rgba(103, 232, 165, 0.09), rgba(103, 232, 165, 0.04)),
    rgba(255,255,255,0.02);
}

#myPropsList .badge,
#chatList .badge,
#playersMiniList .badge {
  flex-shrink: 0;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  z-index: 80;
  max-width: min(92vw, 520px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background:
    linear-gradient(180deg, rgba(20, 27, 46, 0.96), rgba(10, 15, 28, 0.96));
  color: var(--text);
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--ease),
    transform var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- small utility compatibility ---------- */

.fade-up,
.delay-1 {
  animation: none !important;
}

/* ---------- responsive ---------- */

@media (min-width: 700px) {
  .shell {
    padding: 20px;
  }

  .panel {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 920px) {
  .player-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 12px;
  }

  .player-layout > .panel:nth-child(1) {
    grid-column: 1 / -1;
  }

  .player-layout > .panel:nth-child(2),
  .player-layout > .panel:nth-child(4),
  .player-layout > .panel:nth-child(5) {
    grid-column: 1;
  }

  .player-layout > .panel:nth-child(3),
  .player-layout > .panel:nth-child(6),
  .player-layout > .panel:nth-child(7),
  .player-layout > .panel:nth-child(8) {
    grid-column: 2;
  }

  .action-grid.mobile {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #rollBtn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 919px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .status-row {
    justify-content: flex-start;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }

  .player-shell {
    padding-bottom: 76px;
  }

  .topbar {
    padding: 14px;
    border-radius: 22px;
  }

  .topbar.compact h1 {
    font-size: 1.24rem;
  }

  .panel {
    padding: 13px;
    border-radius: 18px;
  }

  .panel-head {
    margin-bottom: 12px;
  }

  .panel-head h2 {
    font-size: 0.98rem;
  }

  .pill {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 0.88rem;
  }

  .btn {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.91rem;
  }

  .btn.huge {
    min-height: 56px;
  }

  .field input,
  .field select {
    min-height: 44px;
    padding: 11px 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-grid.mobile {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .action-grid.mobile {
    grid-template-columns: 1fr;
  }

  .action-grid.mobile .btn.huge,
  #rollBtn {
    grid-column: auto;
  }

  .btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn-row .btn:only-child {
    grid-column: 1 / -1;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-actions .btn {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .top-actions .btn span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
