:root {
  --paper: #f7f2e8;
  --ink: #163329;
  --green: #24995a;
  --green-deep: #11633e;
  --gold: #d6a13e;
  --red: #c94d43;
  --blue: #345d86;
  --felt: #246f50;
  --felt-dark: #124733;
  --line: rgba(22, 51, 41, 0.22);
  --shadow: 0 22px 60px rgba(22, 51, 41, 0.18);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(36, 153, 90, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(36, 153, 90, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

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

.home-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 24% 30%, rgba(214, 161, 62, 0.16), transparent 24rem),
    radial-gradient(circle at 78% 70%, rgba(52, 93, 134, 0.15), transparent 28rem);
}

.home-panel {
  width: min(560px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.82);
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
}

.home-panel::before,
.home-panel::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(22, 51, 41, 0.24);
  pointer-events: none;
}

.home-panel::after {
  inset: 20px;
  border-color: rgba(36, 153, 90, 0.28);
}

.brand-mark {
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0;
}

.home-panel h1 {
  margin: 0;
  font-size: clamp(46px, 12vw, 86px);
  line-height: 1;
  color: var(--green);
}

.home-copy {
  margin: 22px auto;
  max-width: 380px;
  line-height: 1.7;
  color: rgba(22, 51, 41, 0.76);
}

.home-balance {
  width: min(280px, 100%);
  margin: 0 auto 28px;
  padding: 14px 18px;
  border: 1px solid rgba(22, 51, 41, 0.18);
  border-radius: 8px;
  background: #fffaf0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-balance strong {
  color: var(--green-deep);
  font-size: 26px;
}

.home-actions {
  display: grid;
  gap: 16px;
  width: min(270px, 100%);
  margin: 0 auto;
}

.ink-button,
.ghost-button,
.action-button {
  border: 1px solid rgba(22, 51, 41, 0.3);
  border-radius: 8px;
  min-height: 48px;
  padding: 0 22px;
  color: var(--green-deep);
  background: #fffdf8;
  box-shadow: 0 8px 0 rgba(22, 51, 41, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ink-button:hover,
.ghost-button:hover,
.action-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 0 rgba(22, 51, 41, 0.08);
}

.ink-button.primary,
.action-button.accent {
  background: var(--green);
  color: #fff;
  border-color: var(--green-deep);
}

.game-screen {
  height: 100vh;
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}

.top-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.round-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.round-stats span {
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid rgba(22, 51, 41, 0.18);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.82);
  text-align: center;
}

.table-wrap {
  min-height: 0;
}

.felt-table {
  position: relative;
  min-height: 0;
  height: 100%;
  max-height: none;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), transparent 38%),
    radial-gradient(ellipse at center, #318b64 0%, var(--felt) 45%, var(--felt-dark) 100%);
  border: 8px solid #8b5b32;
  box-shadow: var(--shadow), inset 0 0 0 8px rgba(255, 244, 214, 0.18);
}

.felt-table::before {
  content: "";
  position: absolute;
  inset: 58px 76px;
  border: 2px dashed rgba(255, 244, 214, 0.36);
  border-radius: 48%;
}

.table-center {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  min-width: 170px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 244, 214, 0.42);
  border-radius: 8px;
  color: #fff9df;
  text-align: center;
  background: rgba(18, 71, 51, 0.7);
  box-shadow: inset 0 0 40px rgba(255, 244, 214, 0.08);
}

.table-center span,
.table-center small {
  display: block;
}

.table-center strong {
  display: block;
  margin: 6px 0;
  font-size: 34px;
  color: var(--gold);
}

.seat {
  position: absolute;
  width: min(250px, 28%);
  min-height: 136px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.92);
  border: 1px solid rgba(22, 51, 41, 0.18);
  box-shadow: 0 16px 32px rgba(15, 43, 31, 0.22);
}

.seat.active-turn {
  outline: 3px solid var(--gold);
  box-shadow: 0 16px 32px rgba(15, 43, 31, 0.22), 0 0 0 8px rgba(214, 161, 62, 0.22);
}

.seat.folded {
  filter: grayscale(0.8);
  opacity: 0.62;
}

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

.seat h2 {
  margin: 0;
  color: var(--green);
  font-size: clamp(20px, 2vw, 28px);
}

.seat p {
  margin: 8px 0;
  color: rgba(22, 51, 41, 0.74);
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
}

.seat-ai-3 {
  left: 8%;
  top: 6%;
}

.seat-ai-2 {
  right: 8%;
  top: 6%;
}

.seat-ai-4 {
  left: 8%;
  top: 47%;
}

.seat-ai-1 {
  right: 8%;
  top: 47%;
}

.seat-player {
  left: 50%;
  bottom: 14px;
  width: min(500px, 56%);
  transform: translateX(-50%);
}

.mini-cards,
.player-cards {
  display: flex;
  gap: 8px;
  min-height: 50px;
}

.card {
  width: 42px;
  height: 56px;
  border-radius: 7px;
  border: 1px solid rgba(22, 51, 41, 0.18);
  background: #fffdf8;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 8px 14px rgba(22, 51, 41, 0.16);
}

.player-cards .card {
  width: 72px;
  height: 94px;
  font-size: 24px;
}

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

.card.back {
  color: rgba(255, 255, 255, 0.85);
  background:
    linear-gradient(135deg, transparent 42%, rgba(255, 255, 255, 0.32) 43%, transparent 55%),
    repeating-linear-gradient(45deg, #5e48b8 0, #5e48b8 8px, #745fca 8px, #745fca 16px);
}

.side-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.panel-section {
  min-height: 0;
  padding: 14px;
  border: 1px solid rgba(22, 51, 41, 0.18);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.88);
  box-shadow: 0 12px 30px rgba(22, 51, 41, 0.11);
}

.side-panel .panel-section:last-child {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.panel-section label,
.panel-section h3 {
  display: block;
  margin: 0 0 12px;
  color: var(--green-deep);
  font-size: 18px;
}

.level-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-row input {
  width: 100%;
  accent-color: var(--green);
}

.log-list {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.log-list li {
  padding: 9px 10px;
  border-left: 4px solid rgba(36, 153, 90, 0.5);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  line-height: 1.45;
}

.action-bar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.action-button {
  min-height: 50px;
  font-size: clamp(18px, 1.7vw, 24px);
  font-weight: 900;
}

.action-button.danger {
  color: #fff;
  background: var(--red);
  border-color: #91362f;
}

.action-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 34, 28, 0.5);
}

.modal-card {
  width: min(390px, 100%);
  padding: 30px;
  border: 1px solid rgba(22, 51, 41, 0.24);
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 800;
}

.modal-card h2 {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 32px;
}

.modal-card p {
  line-height: 1.7;
}

@media (max-width: 980px) {
  .game-screen {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .side-panel {
    grid-row: 3;
    grid-template-columns: 1fr;
  }

  .action-bar {
    grid-row: 4;
  }

  .log-list {
    height: 170px;
    min-height: 170px;
  }

  .seat {
    width: 230px;
  }
}

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

  .top-bar {
    align-items: stretch;
  }

  .round-stats span {
    min-width: auto;
    padding: 8px;
  }

  .table-wrap,
  .felt-table {
    min-height: 760px;
    height: 760px;
  }

  .felt-table {
    border-width: 6px;
  }

  .felt-table::before {
    inset: 138px 24px;
  }

  .seat {
    width: calc(50% - 18px);
    min-height: 140px;
    padding: 10px;
  }

  .seat-ai-3 {
    left: 10px;
    top: 12px;
  }

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

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

  .seat-ai-1 {
    right: 10px;
    top: 218px;
  }

  .table-center {
    top: 52%;
    min-width: 152px;
  }

  .seat-player {
    width: calc(100% - 24px);
    bottom: 12px;
  }

  .player-cards .card {
    width: 30%;
    max-width: 82px;
    height: 96px;
  }

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