:root {
  color-scheme: dark;
  --bg-0: #090713;
  --bg-1: #120b24;
  --bg-2: #1b1236;
  --surface: rgba(28, 20, 58, 0.78);
  --surface-solid: #21183f;
  --surface-soft: rgba(255, 255, 255, 0.07);
  --surface-strong: rgba(255, 255, 255, 0.14);
  --gold: #ffd36b;
  --gold-2: #ffb84d;
  --accent: #7d5cff;
  --accent-2: #00e4b8;
  --danger: #ff5b7e;
  --success: #55f0a0;
  --text: #f8f2ff;
  --muted: #b8a9d9;
  --black-suit: #16101f;
  --red-suit: #e83e65;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --ring: 0 0 0 2px rgba(125, 92, 255, 0.44), 0 0 36px rgba(125, 92, 255, 0.28);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, rgba(125, 92, 255, 0.26), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(0, 228, 184, 0.14), transparent 26%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1) 48%, #080612);
  color: var(--text);
  overscroll-behavior: none;
  overflow-x: hidden;
  overflow-y: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body[data-route="room"],
body[data-route="room"] .app-shell,
body[data-route="room"] .screen,
body[data-route="room"] .content,
body[data-route="room"] .view,
body[data-route="room"] .room-screen,
body[data-route="room"] .game-table-wrap,
body[data-route="room"] .table-center,
body[data-route="room"] .play-zone,
body[data-route="room"] .hand-panel,
body[data-route="room"] .hand-frame,
body[data-route="room"] .hand,
body[data-route="room"] .players-panel,
body[data-route="room"] .room-card {
  touch-action: pan-y pinch-zoom;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.tab:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

.boot-screen {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  height: 100%;
  text-align: center;
}

.brand-orb {
  width: 96px;
  height: 96px;
  border-radius: 32px;
  background: linear-gradient(135deg, var(--gold), var(--accent), var(--accent-2));
  box-shadow: 0 18px 70px rgba(125, 92, 255, 0.45);
  position: relative;
  overflow: hidden;
}

.brand-orb::after {
  content: "Д";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #130b24;
  font-weight: 950;
  font-size: 56px;
}

.boot-screen h1,
.auth-card h1,
.view-title h1 {
  margin: 0;
  letter-spacing: -0.04em;
}

.boot-screen p,
.auth-card p,
.view-title p {
  margin: 0;
  color: var(--muted);
}

.screen {
  width: 100%;
  height: 100%;
  padding: clamp(14px, 2.6vw, 28px);
  overflow: hidden;
}

.auth-screen {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(18px, 4vw, 48px);
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

.auth-hero {
  min-height: 620px;
  display: grid;
  align-content: center;
  gap: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-xl);
  padding: clamp(24px, 5vw, 58px);
  background: linear-gradient(145deg, rgba(255, 211, 107, 0.15), rgba(125, 92, 255, 0.16) 48%, rgba(0, 228, 184, 0.09)),
    url("data:image/svg+xml,%3Csvg width='140' height='140' viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.12)' stroke-width='1'%3E%3Cpath d='M0 70h140M70 0v140'/%3E%3Ccircle cx='70' cy='70' r='52'/%3E%3C/g%3E%3C/svg%3E");
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.auth-hero::before {
  content: "";
  position: absolute;
  inset: auto -15% -25% 10%;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 211, 107, 0.28), transparent 66%);
  filter: blur(12px);
}

.hero-eyebrow,
.pill {
  width: max-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.auth-hero h2 {
  margin: 0;
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.94;
  letter-spacing: -0.07em;
}

.auth-hero p {
  max-width: 620px;
  color: #ddd5f2;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.55;
}

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

.feature-card,
.auth-card,
.panel,
.room-card,
.player-block,
.stat-card,
.market-item,
.admin-widget,
.toast {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.045));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.feature-card {
  border-radius: var(--radius-md);
  padding: 16px;
  color: #f4edff;
}

.feature-card strong {
  display: block;
  color: var(--gold);
  margin-bottom: 6px;
}

.auth-card {
  border-radius: var(--radius-xl);
  padding: clamp(22px, 4vw, 38px);
  display: grid;
  gap: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.segmented button,
.nav-button,
.action-button,
.icon-button,
.secondary-button,
.danger-button,
.buy-button,
.ghost-button {
  border: 0;
  color: var(--text);
  border-radius: 999px;
  padding: 11px 14px;
  font-weight: 850;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.segmented button[aria-pressed="true"],
.nav-button.active,
.action-button {
  background: linear-gradient(135deg, var(--accent), #a954ff 55%, #ff8f6b);
  box-shadow: 0 14px 38px rgba(125, 92, 255, 0.28);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:not(:disabled):active {
  transform: translateY(1px) scale(0.99);
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

.field label,
.setting-label {
  color: #e5dfff;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
.setting input,
.setting select,
.setting textarea {
  width: 100%;
  color: var(--text);
  background: rgba(7, 6, 18, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  min-height: 48px;
  user-select: text;
  -webkit-user-select: text;
}

.field textarea,
.setting textarea {
  min-height: 96px;
  resize: vertical;
}

.field small,
.validation-message,
.hint,
.mini-text {
  color: var(--muted);
  line-height: 1.4;
}

.validation-message.error {
  color: var(--danger);
}

.validation-message.ok {
  color: var(--success);
}

.auth-actions {
  display: grid;
  gap: 10px;
}

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

.secondary-button {
  background: rgba(255, 255, 255, 0.12);
}

.ghost-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.danger-button {
  background: rgba(255, 91, 126, 0.18);
  color: #ffd7df;
}

.app-layout {
  height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
}

.app-layout.is-narrow-layout {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 10px;
}

.sidebar {
  min-height: 0;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(14, 10, 29, 0.72);
  backdrop-filter: blur(20px);
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  box-shadow: var(--shadow);
}

.app-layout.is-narrow-layout .sidebar {
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto;
  align-items: center;
  padding: 10px;
  border-radius: 20px;
}

.logo-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: #140c24;
  font-weight: 950;
  font-size: 28px;
}

.logo-line h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.04em;
}

.logo-line span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding-right: 2px;
}

.app-layout.is-narrow-layout .nav-list {
  display: flex;
  overflow-x: auto;
  min-width: 0;
}

.nav-button {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  border-radius: 16px;
  min-height: 46px;
}

.app-layout.is-narrow-layout .nav-button {
  white-space: nowrap;
  width: auto;
}

.profile-chip {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.app-layout.is-narrow-layout .profile-chip {
  padding: 8px;
}

.app-layout.is-narrow-layout .profile-chip div:not(.avatar) {
  display: none;
}

.avatar {
  --avatar-a: #ffd36b;
  --avatar-b: #7d5cff;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 950;
  color: #160e26;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.72), transparent 22%), linear-gradient(135deg, var(--avatar-a), var(--avatar-b));
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.26);
}

.avatar.sm {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  font-size: 15px;
}

.profile-chip strong {
  display: block;
}

.profile-chip small {
  color: var(--muted);
}

.content {
  min-height: 0;
  overflow: hidden;
  display: grid;
}

.view {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.view-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 4px 4px 0;
}

.view-title h1 {
  font-size: clamp(27px, 4vw, 42px);
}

.scroll-area {
  min-height: 0;
  overflow: auto;
  padding: 2px 4px 14px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 16px;
}

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

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

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

.panel,
.room-card,
.stat-card,
.market-item,
.admin-widget {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.panel h2,
.room-card h2,
.stat-card h3,
.market-item h3,
.admin-widget h3 {
  margin: 0 0 12px;
  letter-spacing: -0.035em;
}

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

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

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

.range-row,
.inline-row,
.card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
}

.switch-row input {
  width: 22px;
  height: 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.badge.gold {
  color: #25170a;
  background: linear-gradient(135deg, var(--gold), #ff9f4f);
}

.badge.green {
  color: #061d19;
  background: linear-gradient(135deg, #73ffd6, #7cff9f);
}

.badge.red {
  color: #fff;
  background: rgba(255, 91, 126, 0.52);
}

.room-screen {
  height: auto;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 10px;
  padding: clamp(10px, 1.6vw, 18px);
}

.room-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-radius: 22px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255, 211, 107, 0.18), rgba(125, 92, 255, 0.22) 52%, rgba(0, 228, 184, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.26);
}

.room-header h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 32px);
  letter-spacing: -0.05em;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.32);
}

.room-header .participants-line {
  white-space: pre-line;
  color: #e5dfff;
  line-height: 1.35;
  font-weight: 700;
}

.table-info {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.info-cell {
  min-height: 56px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.info-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.game-table-wrap {
  min-height: 0;
  display: block;
}

.player-block {
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  position: relative;
  overflow: hidden;
}

.player-block.active-turn {
  border-color: rgba(255, 211, 107, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 211, 107, 0.2), 0 18px 60px rgba(255, 211, 107, 0.12);
}

.player-block.me {
  background: linear-gradient(145deg, rgba(125, 92, 255, 0.24), rgba(255, 255, 255, 0.04));
}

.player-head {
  display: flex;
  gap: 8px;
  align-items: center;
}

.player-head strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-head small {
  color: var(--muted);
  font-size: 12px;
}

.player-score {
  font-size: 20px;
  font-weight: 950;
  color: var(--gold);
}

.player-feature-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-flag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #f4edff;
  font-size: 12px;
  font-weight: 800;
}

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

.player-suit-row {
  display: flex;
  gap: 8px;
  font-size: 18px;
  align-items: center;
  padding-left: 14px;
}

.player-suit-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  margin-right: 4px;
  text-transform: uppercase;
}

.player-suit-row .active {
  text-shadow: 0 0 16px rgba(255, 211, 107, 0.35);
  transform: scale(1.1);
}

.player-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 12px;
}

.suit-red {
  color: var(--red-suit);
}

.suit-black {
  color: #d7d3e3;
}

.table-center {
  grid-column: 2;
  grid-row: 1 / span 3;
  min-height: 0;
  border-radius: var(--radius-xl);
  background: radial-gradient(circle at 50% 40%, rgba(255, 211, 107, 0.15), transparent 34%),
    linear-gradient(145deg, rgba(5, 63, 58, 0.85), rgba(18, 56, 69, 0.88) 45%, rgba(25, 19, 50, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.36), var(--shadow);
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 16px;
}

.table-center::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.11);
  pointer-events: none;
}

.table-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.trump-token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(8, 7, 18, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 900;
}

.play-zone {
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2vw, 18px);
  flex-wrap: wrap;
  min-height: 160px;
}

.card {
  width: clamp(54px, 8vw, 86px);
  aspect-ratio: 0.68;
  border-radius: 12px;
  background: linear-gradient(155deg, #fffdf8, #ece6d8);
  color: #1b1525;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(20, 10, 5, 0.1);
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  transform-origin: 50% 100%;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
  will-change: transform;
  touch-action: pan-y pinch-zoom;
}

.card.legal {
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28), 0 0 0 2px rgba(115, 255, 214, 0.55);
}

.card.illegal {
  filter: grayscale(0.8) brightness(0.76);
}

@media (hover: hover) and (pointer: fine) {
  .card:hover,
  .card.dragging {
    transform: translateY(-18px) rotate(0deg) scale(1.03) !important;
  }
}

.card-played {
  animation: cardDrop 0.28s ease both;
}

@keyframes cardDrop {
  from { transform: translateY(-18px) scale(1.08); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.card::before {
  content: attr(data-rank);
  position: absolute;
  left: 8px;
  top: 6px;
  font-weight: 950;
  font-size: clamp(14px, 2vw, 20px);
}

.card::after {
  content: attr(data-suit);
  position: absolute;
  left: 8px;
  top: 28px;
  font-size: clamp(15px, 2.2vw, 22px);
  line-height: 1;
}

.card .card-center {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
}

.card.red {
  color: var(--red-suit);
}

.card.black {
  color: var(--black-suit);
}

.card.back {
  background: linear-gradient(145deg, #30245e, #7d5cff 52%, #ffb84d);
  color: rgba(255, 255, 255, 0.55);
}

.card.back::before,
.card.back::after {
  content: "";
}

.card.back .card-center::before {
  content: "◆";
  font-size: 34px;
}

.table-hint {
  z-index: 1;
  font-size: 12px;
  color: #e8ddff;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(8, 7, 18, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hand-panel {
  min-height: 112px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding-bottom: var(--safe-bottom);
  position: relative;
  z-index: 2;
}

.hand-frame,
.players-panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(20, 16, 38, 0.92), rgba(15, 12, 28, 0.86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hand-frame {
  padding: 14px 14px 10px;
}

.hand-frame-head,
.players-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.hand-frame-head strong,
.players-panel-head h2 {
  display: block;
  margin: 0;
}

.hand-frame-head span {
  color: var(--muted);
  font-size: 12px;
}

.room-extra {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.room-roster-row {
  grid-template-columns: 1.1fr 0.75fr 0.7fr 0.8fr 0.9fr;
}

.room-log {
  max-height: 280px;
  overflow: auto;
}

.room-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.table-row.compact {
  grid-template-columns: 1.2fr 0.8fr 0.7fr 0.7fr;
}

.hand {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  min-height: 104px;
  padding: 8px 4px 6px;
  overflow: visible;
}

.hand .card {
  margin-left: 0;
}

.room-actions {
  display: grid;
  gap: 8px;
  min-width: 148px;
  align-content: start;
}

.players-panel {
  padding: 16px;
}

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

.player-room-block {
  min-height: 168px;
  align-content: start;
}

.chat-drawer {
  position: fixed;
  right: clamp(10px, 2vw, 20px);
  bottom: calc(10px + var(--safe-bottom));
  width: min(380px, calc(100vw - 20px));
  max-height: min(520px, calc(100dvh - 40px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(13, 10, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  z-index: 50;
}

.chat-drawer.hidden {
  display: none;
}

.chat-log {
  min-height: 150px;
  max-height: 310px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.chat-message {
  padding: 8px 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.07);
}

.chat-message strong {
  color: var(--gold);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

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

.market-preview {
  height: 122px;
  border-radius: 18px;
  background: var(--preview, linear-gradient(135deg, #0a574f, #35206d));
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  overflow: hidden;
}

.market-preview::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.market-item p,
.admin-widget p,
.stat-card p {
  color: var(--muted);
  line-height: 1.45;
}

.buy-button {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, var(--gold), #ff8f6b);
  color: #271607;
}

.stat-number {
  font-size: clamp(26px, 4vw, 44px);
  font-weight: 950;
  letter-spacing: -0.06em;
  color: var(--gold);
}

.table-list {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.6fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.replay-log {
  display: grid;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.log-line {
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #dfd6ff;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-list-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 99;
  width: min(420px, calc(100vw - 28px));
}

.toast {
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(20, 15, 42, 0.94);
  animation: toastIn 0.2s ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 4, 12, 0.72);
}

.modal-card {
  width: min(620px, 100%);
  max-height: min(780px, calc(100dvh - 36px));
  overflow: auto;
  padding: 20px;
  border-radius: 24px;
  background: #17102d;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

@media (max-width: 1060px) {
  .auth-screen {
    grid-template-columns: 1fr;
    align-content: start;
    overflow: auto;
  }

  .auth-hero {
    min-height: auto;
  }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 10px;
  }

  .sidebar {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    align-items: center;
    padding: 10px;
    border-radius: 20px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    min-width: 0;
  }

  .nav-button {
    white-space: nowrap;
    width: auto;
  }

  .profile-chip {
    padding: 8px;
  }

  .profile-chip div:not(.avatar) {
    display: none;
  }

  .grid-4,
  .grid-3,
  .grid-2,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .setting-grid,
  .setting-grid.compact {
    grid-template-columns: 1fr;
  }

  .game-table-wrap {
    display: block;
  }

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

  .room-extra {
    grid-template-columns: 1fr;
  }

  .players-grid {
    grid-template-columns: 1fr;
  }

  body[data-route="room"] .sidebar {
    position: static;
    top: auto;
    max-height: none;
  }

  body[data-route="room"] .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  body[data-route="room"] .content,
  body[data-route="room"] .room-screen,
  body[data-route="room"] .game-table-wrap,
  body[data-route="room"] .table-center,
  body[data-route="room"] .hand-panel,
  body[data-route="room"] .players-panel,
  body[data-route="room"] .room-extra {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 720px) {
  .screen {
    padding: 10px;
  }

  .auth-hero {
    padding: 22px;
    gap: 14px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .view-title {
    align-items: stretch;
    flex-direction: column;
  }

  .room-screen {
    gap: 8px;
    padding: 8px;
  }

  body[data-route="room"] .screen {
    padding: 8px;
  }

  .room-header {
    grid-template-columns: 1fr;
    padding: 10px;
  }

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

  .info-cell {
    min-height: 48px;
    padding: 8px;
  }

  .game-table-wrap {
    gap: 6px;
  }

  .player-block {
    padding: 7px;
    border-radius: 14px;
  }

  .player-head {
    gap: 6px;
  }

  .player-head small {
    display: block;
  }

  .player-score {
    font-size: 15px;
  }

  .avatar.sm {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .table-center {
    padding: 10px;
    border-radius: 22px;
    width: 100%;
  }

  .table-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .play-zone {
    min-height: 116px;
  }

  .hand-panel {
    grid-template-columns: 1fr;
    min-height: 108px;
  }

  .hand-frame,
  .players-panel,
  .room-card {
    width: 100%;
    max-width: 100%;
  }

  .room-actions {
    grid-template-columns: repeat(3, 1fr);
    min-width: 0;
  }

  .room-actions button {
    padding: 10px 8px;
    font-size: 12px;
  }

  .hand {
    justify-content: center;
    min-height: 96px;
    width: 100%;
  }

  .hand .card {
    width: 58px;
  }

  .card::before {
    left: 6px;
    top: 5px;
  }

  .card::after {
    left: 6px;
    top: 25px;
  }

  .card .card-center {
    font-size: 28px;
  }

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

  .table-row.compact {
    grid-template-columns: 1fr;
  }

  .room-roster-row {
    grid-template-columns: 1fr;
  }

  .players-panel {
    padding: 12px;
  }

  .players-panel-head,
  .hand-frame-head {
    flex-direction: column;
    align-items: stretch;
  }

  .player-feature-line,
  .player-meta-line {
    gap: 6px;
  }

  .player-suit-row {
    padding-left: 0;
  }

  .chat-drawer {
    right: 8px;
    bottom: calc(8px + var(--safe-bottom));
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .room-screen {
    grid-template-rows: auto auto auto auto;
  }

  .table-info {
    display: none;
  }

  .hand-panel {
    min-height: 88px;
  }

  .hand .card {
    width: 52px;
  }
}

body[data-route="room"] {
  min-height: 100dvh;
  overflow-y: auto;
}

body[data-route="room"] .app-shell {
  width: 100%;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

body[data-route="room"] .screen {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

body[data-route="room"] .app-layout {
  height: auto;
  min-height: 100dvh;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
}

body[data-route="room"] .app-layout.is-narrow-layout {
  grid-template-columns: 1fr !important;
  grid-template-rows: auto auto !important;
}

body[data-route="room"] .content {
  height: auto;
  min-height: 100dvh;
  min-width: 0;
  display: block;
  overflow: visible;
}

body[data-route="room"] .view {
  display: block;
  min-height: auto;
  overflow: visible;
}

body[data-route="room"] .sidebar {
  position: sticky;
  top: clamp(14px, 2.6vw, 28px);
  align-self: start;
  max-height: calc(100dvh - clamp(28px, 5vw, 56px));
}

body[data-route="room"] .app-layout.is-narrow-layout .sidebar {
  width: 100%;
  max-width: 100%;
  position: static;
  top: auto;
  max-height: none;
}

body[data-route="room"] .app-layout.is-narrow-layout .content {
  width: 100%;
  max-width: 100%;
}

body[data-route="room"] .room-screen {
  align-content: start;
  min-height: max-content;
  overflow: visible;
  padding-bottom: calc(32px + var(--safe-bottom));
}

@media (max-width: 1060px) {
  body[data-route="room"] .app-layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto !important;
  }

  body[data-route="room"] .sidebar {
    width: 100%;
    max-width: 100%;
  }

  body[data-route="room"] .content {
    width: 100%;
    max-width: 100%;
  }
}
