:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --felt: #0f4d3a;
  --felt-dark: #0a3328;
  --felt-line: rgba(230, 255, 243, 0.18);
  --ink: #f6fbf7;
  --muted: #a7beb4;
  --panel: rgba(10, 26, 23, 0.92);
  --panel-strong: #102d27;
  --card: #fffaf0;
  --card-ink: #1b1e1b;
  --red: #bd2738;
  --gold: #e1b951;
  --button: #f3f0df;
  --button-ink: #14211d;
  --danger: #e86161;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    var(--felt-dark);
  background-size: 34px 34px;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  min-height: 100svh;
  padding: 18px;
}

.language-shell {
  width: min(1180px, 100%);
  margin: 0 auto 12px;
  display: flex;
  justify-content: flex-end;
}

.language-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.language-field select {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.welcome-view {
  width: min(460px, 100%);
  margin: 8vh auto 0;
  padding: 24px;
  border: 1px solid var(--felt-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 68px;
  height: 68px;
  margin-bottom: 14px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
}

.entry-grid {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.inline-actions,
.room-tools {
  display: grid;
  gap: 10px;
}

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

.room-tools {
  margin-top: 16px;
}

.profile-panel {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.profile-name {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

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

.stat-item {
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.stat-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.toggle-field {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.toggle-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

.field span,
.section-title,
.eyebrow,
.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(225, 185, 81, 0.18);
}

.primary-action,
.secondary-action,
.link-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-action {
  background: var(--gold);
  color: #221b09;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.compact {
  min-height: 38px;
  padding: 0 12px;
}

.link-button {
  min-height: 28px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
}

.game-view {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.top-bar,
.admin-panel,
.hand-panel,
.minigame-panel,
.log-panel {
  border: 1px solid var(--felt-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

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

.profile-mini {
  min-height: 38px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.admin-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr)) minmax(120px, auto) auto auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
}

.compact-field input {
  min-height: 38px;
}

.table-band {
  min-height: 620px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.07), transparent 62%),
    var(--felt);
  box-shadow: inset 0 0 0 10px rgba(16, 69, 51, 0.72), var(--shadow);
  overflow: hidden;
}

.table-surface {
  position: relative;
  min-height: 620px;
  padding: 18px;
}

.felt-oval {
  position: absolute;
  inset: 86px 140px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.12), transparent 62%),
    linear-gradient(145deg, rgba(9, 78, 58, 0.88), rgba(6, 48, 37, 0.94));
  border: 10px solid rgba(9, 42, 32, 0.84);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    inset 0 26px 70px rgba(255, 255, 255, 0.04),
    0 18px 44px rgba(0, 0, 0, 0.26);
}

.players-grid {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

.player-seat {
  position: absolute;
  width: min(218px, 25vw);
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 10px;
  background: rgba(2, 22, 16, 0.62);
  display: grid;
  align-content: start;
  gap: 8px;
  pointer-events: auto;
  z-index: 2;
  cursor: pointer;
}

.player-seat:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.seat-0 {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
}

.seat-1 {
  right: 28px;
  bottom: 122px;
}

.seat-2 {
  right: 92px;
  top: 40px;
}

.seat-3 {
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
}

.seat-4 {
  left: 92px;
  top: 40px;
}

.seat-5 {
  left: 28px;
  bottom: 122px;
}

.player-seat.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(225, 185, 81, 0.18);
}

.player-seat.you {
  background: rgba(8, 46, 33, 0.86);
}

.player-seat.eliminated {
  opacity: 0.58;
}

.player-name {
  min-width: 0;
  color: var(--ink);
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.card-back-strip {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 2px;
  max-height: 64px;
  overflow-y: auto;
  padding: 2px 0;
}

.mini-card-back {
  flex: 0 0 auto;
  width: 16px;
  height: 23px;
  border-radius: 3px;
  background: url("/assets/card_back.png") center / cover no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.empty-hand-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge {
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.badge.gold {
  background: rgba(225, 185, 81, 0.18);
  color: #ffe29a;
}

.badge.danger {
  background: rgba(232, 97, 97, 0.16);
  color: #ffb1b1;
}

.center-stack {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(2, 82px);
  gap: 16px;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 3;
}

.pile-card,
.playing-card {
  width: 82px;
  aspect-ratio: 0.68;
  border-radius: 8px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.22);
  background: var(--card);
  color: var(--card-ink);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  font-weight: 900;
  letter-spacing: 0;
  overflow: hidden;
}

.pile-back {
  position: relative;
  background: url("/assets/card_back.png") center / cover no-repeat;
  color: white;
}

.pile-back::after {
  content: attr(data-count);
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 26px;
  min-height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  background: rgba(0, 0, 0, 0.62);
  color: white;
  font-size: 13px;
}

.pile-card.clickable {
  cursor: pointer;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.22),
    0 0 0 3px rgba(225, 185, 81, 0.2);
}

.discard-target {
  outline: 2px dashed transparent;
  outline-offset: 6px;
}

.discard-target.ready-to-play,
.discard-target.drag-over {
  outline-color: var(--gold);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.22),
    0 0 0 4px rgba(225, 185, 81, 0.2);
}

.turn-info {
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.table-pot {
  grid-column: 1 / -1;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  padding: 4px 10px;
  border: 1px solid rgba(225, 185, 81, 0.42);
  border-radius: 999px;
  background: rgba(225, 185, 81, 0.14);
  color: #ffe9a6;
  font-size: 13px;
  font-weight: 900;
}

.hand-panel,
.minigame-panel,
.log-panel {
  padding: 14px;
}

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

.hand-sort-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-field {
  display: grid;
  gap: 4px;
}

.mini-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-field select {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.mini-card-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 2px 4px;
}

.hand-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 76px));
  justify-content: center;
  align-items: start;
  gap: 10px;
  max-height: 270px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 2px 4px;
}

.playing-card {
  flex: 0 0 74px;
  width: 74px;
  min-height: 108px;
  position: relative;
  transition:
    transform 130ms ease,
    border-color 130ms ease,
    box-shadow 130ms ease;
}

.pile-card img,
.playing-card img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
}

button.playing-card {
  padding: 0;
  cursor: grab;
  touch-action: manipulation;
}

button.playing-card:active {
  cursor: grabbing;
}

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

.playing-card.legal {
  border-color: var(--gold);
}

.playing-card.selected {
  transform: translateY(-9px);
  box-shadow: 0 14px 28px rgba(225, 185, 81, 0.24);
}

.playing-card.swipe-ready {
  transform: translateY(-18px);
  border-color: var(--gold);
  box-shadow: 0 18px 32px rgba(225, 185, 81, 0.3);
}

.playing-card.dim {
  opacity: 0.54;
}

.suit-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
}

.suit-picker button {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 800;
}

.suit-picker button.active {
  background: var(--gold);
  color: #221b09;
}

.suit-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.suit-choice-grid button {
  min-height: 54px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 900;
}

.suit-choice-grid button:hover {
  border-color: var(--gold);
  box-shadow: 0 12px 24px rgba(225, 185, 81, 0.14);
}

.log-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  color: #d8e6df;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #211512;
  color: #ffe4d7;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.modal-panel {
  width: min(520px, 100%);
  max-height: calc(100svh - 36px);
  overflow-y: auto;
  border: 1px solid var(--felt-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.wide-modal {
  width: min(820px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.modal-copy {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.45;
}

.reset-vote-status {
  color: #ffe9a6;
}

.afk-warning-time {
  color: var(--danger);
  font-size: 22px;
}

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

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

.rules-preview {
  display: grid;
  gap: 10px;
}

.rules-list,
.history-list {
  display: grid;
  gap: 8px;
}

.rule-item,
.history-row {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d8e6df;
  font-size: 13px;
  font-weight: 800;
}

.history-row {
  grid-template-columns: minmax(86px, auto) 1fr;
  align-items: center;
}

.history-row strong {
  color: var(--ink);
}

.history-row.win strong {
  color: var(--gold);
}

.history-row.loss strong {
  color: var(--danger);
}

.history-row span {
  min-width: 0;
  color: var(--muted);
}

.match-history {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-title {
  font-size: 13px;
}

.danger-action {
  border-color: rgba(255, 109, 84, 0.44);
  color: #ffd6ce;
}

.profile-modal-actions {
  margin-top: 14px;
}

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

.table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(120px, 0.7fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
}

.table-row.locked {
  opacity: 0.76;
}

.table-row.participant {
  opacity: 1;
  border-color: rgba(225, 185, 81, 0.42);
}

.table-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.table-main strong,
.table-main span,
.table-player-list {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-main strong {
  color: var(--ink);
}

.table-main span,
.table-player-list,
.empty-list {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .top-bar,
  .hand-topline {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .admin-panel button {
    grid-column: span 2;
  }

  .table-band,
  .table-surface {
    min-height: 640px;
  }

  .felt-oval {
    inset: 146px 18px 116px;
  }

  .players-grid {
    position: absolute;
    inset: 0;
    display: block;
  }

  .player-seat {
    width: min(172px, calc(50vw - 18px));
    padding: 8px;
  }

  .seat-0 {
    left: 50%;
    bottom: 10px;
  }

  .seat-1 {
    right: 10px;
    bottom: 130px;
  }

  .seat-2 {
    right: 10px;
    top: 82px;
  }

  .seat-3 {
    left: 50%;
    top: 8px;
  }

  .seat-4 {
    left: 10px;
    top: 82px;
  }

  .seat-5 {
    left: 10px;
    bottom: 130px;
  }

  .center-stack {
    top: 52%;
    bottom: auto;
  }

  .playing-card {
    flex-basis: 68px;
    min-height: 100px;
  }

  .hand-cards {
    grid-template-columns: repeat(auto-fill, minmax(58px, 68px));
    max-height: 238px;
  }

  .modal-header,
  .table-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .modal-header {
    flex-direction: column;
  }

  .modal-actions,
  .table-details {
    justify-content: flex-start;
  }

  .modal-stat-grid {
    grid-template-columns: 1fr;
  }

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

  .hand-sort-controls {
    justify-content: flex-start;
  }
}
