:root {
  color-scheme: light;
  --bg: #f3efe2;
  --bg-2: #e4d6b8;
  --panel: rgba(255, 250, 240, 0.92);
  --ink: #221812;
  --muted: #6e5a4f;
  --accent: #9b2226;
  --accent-2: #d97706;
  --line: rgba(34, 24, 18, 0.12);
  --coin: #d4a017;
  --drink: #8b5a2b;
  --danger: #a83232;
  --shadow: 0 18px 40px rgba(53, 37, 24, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 248, 220, 0.9), transparent 35%),
    radial-gradient(circle at bottom right, rgba(210, 180, 140, 0.5), transparent 40%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
}

.page {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto 48px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(6px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}

.hero h1,
.toolbar h2,
.panel h2,
.panel h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--muted);
}

.lead {
  max-width: 60ch;
  color: var(--muted);
}

.hero-meta {
  display: flex;
  gap: 20px;
}

.meta-label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.split,
.layout,
.private-grid {
  display: grid;
  gap: 16px;
}

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

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

.stack {
  display: grid;
  gap: 12px;
}

.auth-form {
  max-width: 420px;
}

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

.profile-grid {
  align-items: center;
}

.profile-preview {
  display: grid;
  gap: 10px;
  justify-items: center;
  align-content: center;
}

.profile-photo,
.admin-photo {
  width: min(180px, 100%);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 24px rgba(34, 24, 18, 0.12);
}

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

.admin-user-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}

.admin-user-photo,
.admin-user-form {
  display: grid;
  gap: 12px;
}

.admin-user-photo {
  align-content: start;
  justify-items: center;
}

.admin-photo-fallback {
  width: min(180px, 100%);
}

.admin-user-actions,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.danger {
  color: #fff8f0;
  background: linear-gradient(135deg, var(--danger), #7c1d1d);
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: rgba(255, 255, 255, 0.75);
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  color: #fff8f0;
  background: linear-gradient(135deg, var(--accent), #7c1d1d);
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button.secondary {
  color: var(--ink);
  background: linear-gradient(135deg, #f9d976, #eac54f);
}

button.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
}

.toolbar,
.section-header,
.table-meta,
.toolbar-actions,
.lobby-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  background: rgba(155, 34, 38, 0.14);
}

.badge.subtle {
  background: rgba(34, 24, 18, 0.08);
}

.badge.accent {
  background: rgba(217, 119, 6, 0.18);
}

.log-list,
.options-list {
  display: grid;
  gap: 10px;
}

.log-entry,
.choice-row {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.55);
}

.mini-title {
  display: block;
}

.seat-meta,
.mini-copy {
  color: var(--muted);
  font-size: 0.92rem;
}

.message {
  min-height: 28px;
  color: var(--muted);
}

.turn-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 12px 18px;
  border-radius: 999px;
  color: #fff8f0;
  background: linear-gradient(135deg, rgba(34, 24, 18, 0.94), rgba(155, 34, 38, 0.9));
  box-shadow: 0 18px 36px rgba(34, 24, 18, 0.25);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.toast-region {
  position: fixed;
  top: 72px;
  right: 18px;
  z-index: 25;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
}

.toast {
  padding: 12px 14px;
  border-radius: 14px;
  color: #fff8f0;
  box-shadow: 0 18px 36px rgba(34, 24, 18, 0.22);
  background: rgba(34, 24, 18, 0.92);
  animation: toast-in 180ms ease;
}

.toast.accent {
  background: linear-gradient(135deg, rgba(155, 34, 38, 0.95), rgba(217, 119, 6, 0.9));
}

.toast.warning {
  background: linear-gradient(135deg, rgba(168, 50, 50, 0.95), rgba(124, 29, 29, 0.9));
}

.player-bubble {
  position: absolute;
  top: -12px;
  right: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff8f0;
  border: 1px solid rgba(155, 34, 38, 0.2);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(34, 24, 18, 0.16);
}

.player-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: #fff8f0;
  border-right: 1px solid rgba(155, 34, 38, 0.2);
  border-bottom: 1px solid rgba(155, 34, 38, 0.2);
  transform: rotate(45deg);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.table-grid {
  min-height: 128px;
}

.table-panel {
  padding-bottom: 28px;
}

.table-arena {
  position: relative;
  min-height: 900px;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(16, 10, 7, 0.08), rgba(16, 10, 7, 0.2)),
    url("/assets/cards/tavolo.png") center / cover no-repeat;
  box-shadow: inset 0 20px 40px rgba(0, 0, 0, 0.14);
}

.table-center {
  position: absolute;
  left: 19%;
  right: 19%;
  bottom: 19%;
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.table-felt {
  width: 100%;
  height: 100%;
  border-radius: 32px;
  padding: 10px 18px 24px;
  background: linear-gradient(180deg, rgba(48, 26, 15, 0.08), rgba(48, 26, 15, 0.2));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.table-center-header {
  display: flex;
  justify-content: center;
}

.table-cards {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  padding: 18px 22px;
  border-radius: 26px;
  background: rgba(255, 246, 232, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 14px 28px rgba(34, 18, 10, 0.18);
  backdrop-filter: blur(2px);
}

.seat {
  position: absolute;
  display: grid;
  gap: 10px;
  min-width: 0;
  z-index: 2;
}

.seat-top {
  top: 18px;
  left: 50%;
  width: min(360px, 38%);
  transform: translateX(-50%);
}

.seat-left {
  left: 22px;
  top: 34%;
  width: min(260px, 24%);
  transform: translateY(-50%);
}

.seat-right {
  right: 22px;
  top: 34%;
  width: min(260px, 24%);
  transform: translateY(-50%);
}

.seat-bottom {
  left: 50%;
  bottom: 18px;
  width: min(360px, 40%);
  transform: translateX(-50%);
}

.table-arena.players-3 .seat-left,
.table-arena.players-3 .seat-right {
  top: 27%;
  transform: none;
}

.table-arena.players-4 .seat-left,
.table-arena.players-4 .seat-right {
  top: 32%;
}

.seat-card {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 238, 0.9);
  box-shadow: 0 12px 26px rgba(34, 24, 18, 0.18);
  padding: 14px;
}

.my-hand-panel {
  margin-top: -4px;
}

.seat-card.current {
  border-color: rgba(217, 119, 6, 0.55);
  box-shadow: 0 16px 28px rgba(217, 119, 6, 0.2);
}

.seat-card.me {
  border-color: rgba(155, 34, 38, 0.42);
}

.seat-card.pending {
  outline: 3px solid rgba(155, 34, 38, 0.18);
}

.seat-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.seat-name {
  font-weight: 700;
}

.seat-role {
  color: var(--muted);
  font-size: 0.84rem;
}

.seat-hand {
  display: flex;
  align-items: flex-end;
  gap: 0;
  min-height: 92px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.seat-hand.opponent {
  justify-content: center;
}

.seat-hand.opponent.vertical {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.offer-pile {
  display: grid;
  gap: 6px;
}

.offer-pile-stack {
  display: flex;
  align-items: flex-end;
  gap: 0;
  min-height: 54px;
}

.offer-back {
  width: 34px;
  height: 50px;
  margin-right: -10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(34, 24, 18, 0.18);
  box-shadow: 0 6px 14px rgba(34, 24, 18, 0.14);
  background: rgba(255, 255, 255, 0.9);
}

.offer-back img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-back {
  flex: 0 0 50px;
  width: 50px;
  height: 74px;
  margin-right: -16px;
  border-radius: 12px;
  border: 1px solid rgba(34, 24, 18, 0.18);
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(34, 24, 18, 0.14);
}

.card-back img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.seat-hand.vertical .card-back {
  margin-right: -12px;
  margin-bottom: -8px;
}

.my-hand {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.my-hand .card {
  width: 118px;
  min-width: 118px;
}

.card {
  display: block;
  width: 92px;
  min-height: 112px;
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(34, 24, 18, 0.12);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 22px rgba(34, 24, 18, 0.14);
}

.card:disabled {
  opacity: 1;
}

.card.selected {
  outline: 3px solid rgba(155, 34, 38, 0.42);
}

.card.coin {
  border-color: rgba(212, 160, 23, 0.35);
}

.card.drink {
  border-color: rgba(139, 90, 43, 0.34);
}

.card.glutton,
.card.thief {
  border-color: rgba(168, 50, 50, 0.35);
}

.card-face {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  background: #f7efe2;
}

.table-cards .card {
  width: 102px;
  box-shadow: 0 14px 26px rgba(34, 24, 18, 0.26);
}

.compact-grid .card {
  width: 86px;
}

.empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .hero,
  .layout,
  .split,
  .private-grid,
  .toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-meta,
  .toolbar-actions,
  .table-meta,
  .lobby-actions,
  .section-header {
    flex-wrap: wrap;
  }

  .room-grid,
  .profile-grid,
  .admin-user-card {
    grid-template-columns: 1fr;
  }

  .table-arena {
    min-height: 1080px;
  }

  .table-center {
    left: 7%;
    right: 7%;
    bottom: 30%;
    height: 240px;
  }

  .seat-top,
  .seat-left,
  .seat-right,
  .seat-bottom {
    left: 50%;
    right: auto;
    width: min(620px, 96%);
    transform: translateX(-50%);
  }

  .seat-top {
    top: 8px;
  }

  .seat-left {
    top: 170px;
  }

  .seat-right {
    top: 340px;
  }

  .table-arena.players-3 .seat-left,
  .table-arena.players-3 .seat-right,
  .table-arena.players-4 .seat-left,
  .table-arena.players-4 .seat-right {
    transform: translateX(-50%);
  }

  .seat-bottom {
    bottom: 18px;
    width: min(560px, 94%);
  }
}
