:root {
  color-scheme: light;
  --felt: #0e6a54;
  --felt-dark: #0b4e41;
  --ink: #17211f;
  --muted: #6a756f;
  --paper: #fffaf0;
  --line: rgba(23, 33, 31, 0.12);
  --accent: #c9382d;
  --gold: #d9a441;
  --tile: #fffdf5;
  --shadow: 0 18px 60px rgba(4, 25, 20, 0.18);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: linear-gradient(135deg, #f6f0e4 0%, #e8efe8 45%, #e7eef2 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

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

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.join-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.join-panel {
  display: grid;
  width: min(440px, 100%);
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 8vw, 56px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: #fffef8;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--felt);
  box-shadow: 0 0 0 3px rgba(14, 106, 84, 0.16);
}

.primary-button {
  border-color: transparent;
  background: var(--felt);
  color: white;
}

.table-view {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
}

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

.top-actions button {
  min-width: 76px;
}

.table-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: 230px minmax(0, 1fr) 260px;
  gap: 14px;
}

.players-panel,
.log-panel,
.board-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.9);
}

.players-panel,
.log-panel {
  overflow: auto;
  padding: 14px;
}

.board-panel {
  display: grid;
  min-height: 680px;
  grid-template-rows: auto auto minmax(130px, 1fr) auto auto;
  gap: 12px;
  padding: 14px;
  background:
    linear-gradient(rgba(14, 106, 84, 0.9), rgba(11, 78, 65, 0.92)),
    radial-gradient(circle at 50% 25%, rgba(255, 255, 255, 0.24), transparent 42%);
  color: white;
}

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

.status-row > div {
  display: grid;
  gap: 2px;
  min-height: 58px;
  align-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 10px;
  background: rgba(1, 25, 20, 0.2);
}

.status-row span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 700;
}

.status-row strong {
  font-size: 18px;
}

.players-list,
.log-list {
  display: grid;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.56);
}

.seat-badge {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--felt);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.opponent {
  min-height: 80px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 10px;
  background: rgba(1, 25, 20, 0.2);
}

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

.mini-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 9px;
}

.mini-tile {
  width: 12px;
  height: 18px;
  border-radius: 3px;
  background: #e9d6a5;
}

.center-pile {
  align-content: start;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 7px;
  overflow: auto;
  min-height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 10px;
  background: rgba(1, 25, 20, 0.24);
}

.melds {
  display: flex;
  min-height: 52px;
  gap: 8px;
  overflow-x: auto;
}

.meld {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 6px;
  background: rgba(1, 25, 20, 0.25);
}

.claim-panel,
.hand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.claim-panel button,
.hand-actions button {
  border-color: rgba(255, 255, 255, 0.3);
  background: #fffef8;
}

.hand-section {
  display: grid;
  gap: 10px;
}

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

.tile {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 62px;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  background: var(--tile);
  box-shadow: 0 4px 0 #d7c99d;
  color: var(--ink);
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.tile.small {
  flex-basis: 35px;
  width: 35px;
  height: 48px;
  font-size: 12px;
}

.tile.discard {
  cursor: default;
}

.tile.selectable:hover {
  transform: translateY(-8px);
}

.tile.red {
  color: var(--accent);
}

.tile.green {
  color: #087449;
}

.log-item {
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(380px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #17211f;
  color: white;
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (max-width: 1050px) {
  .table-grid {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .log-panel {
    grid-column: 1 / -1;
    max-height: 180px;
  }
}

@media (max-width: 760px) {
  .table-view {
    padding: 8px;
  }

  .top-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1 1 80px;
  }

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

  .players-panel {
    max-height: 190px;
  }

  .board-panel {
    min-height: 610px;
  }

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

  .opponent {
    min-height: 62px;
  }

  .tile {
    flex-basis: 40px;
    width: 40px;
    height: 58px;
  }
}
