:root {
  color-scheme: dark;
  --ink: #f6efe4;
  --muted: #bfb6a7;
  --quiet: #80786d;
  --bg: #171512;
  --panel: rgba(34, 31, 26, 0.82);
  --panel-strong: rgba(47, 42, 34, 0.95);
  --line: rgba(246, 239, 228, 0.15);
  --gold: #e5b85d;
  --mint: #79d3bd;
  --red: #e86f58;
  --blue: #7aa8df;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(229, 184, 93, 0.18), transparent 28rem),
    radial-gradient(circle at 78% 16%, rgba(121, 211, 189, 0.12), transparent 24rem),
    linear-gradient(135deg, #191612 0%, #242018 47%, #11100e 100%);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

textarea,
input.plain-number {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 11, 9, 0.52);
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  padding: 14px;
  line-height: 1.65;
}

input.plain-number {
  max-width: 100%;
  height: 48px;
  padding: 0 12px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
}

textarea:focus,
input.plain-number:focus {
  border-color: rgba(229, 184, 93, 0.7);
  box-shadow: 0 0 0 3px rgba(229, 184, 93, 0.13);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 7px 7px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand img {
  width: 58px;
  height: 58px;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.36));
}

.kicker,
.round-chip,
.section-head span,
.secret-top,
.field span,
.stepper span,
.lexicon-stats span,
.word-face span,
.inspect-result span {
  color: var(--muted);
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.9;
}

h2 {
  font-size: 1.18rem;
}

.round-chip {
  min-width: 72px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: rise 420ms ease both;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

.panel,
.table-card,
.result-panel,
.phone-card {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 18px;
}

.start-panel {
  grid-column: 1;
}

.settings-panel {
  grid-column: 2;
}

.category-panel {
  grid-column: 1 / 3;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.field.compact textarea {
  min-height: 142px;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.centered {
  justify-content: center;
}

.primary,
.secondary,
.ghost {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
  color: #18140d;
  transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease;
}

.primary {
  background: linear-gradient(135deg, var(--gold), #f3d68b);
  box-shadow: 0 12px 28px rgba(229, 184, 93, 0.22);
}

.secondary {
  background: linear-gradient(135deg, var(--mint), #b8ead8);
}

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

.small {
  min-height: 38px;
  padding: 0 13px;
  font-size: 0.9rem;
}

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

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

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

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

.big-stepper input {
  height: 92px;
  font-size: clamp(2.8rem, 9vw, 5.8rem);
  font-family: Georgia, "Songti SC", serif;
}

.seat-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.seat-preview span {
  min-width: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--gold);
  text-align: center;
  font-weight: 900;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.toggle-line:last-child {
  border-bottom: 0;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

.lexicon-stats {
  display: flex;
  align-items: end;
  gap: 9px;
  margin-bottom: 13px;
}

.lexicon-stats strong {
  font-size: 2.2rem;
  line-height: 1;
}

.category-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.category-toolbar span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.ghost.active,
.secondary.active {
  outline: 2px solid rgba(229, 184, 93, 0.48);
  outline-offset: 2px;
}

.category-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 9px;
}

.category-chip {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.category-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(229, 184, 93, 0.42);
}

.category-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.category-chip span {
  color: var(--ink);
  font-weight: 900;
}

.category-chip em {
  min-width: 34px;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(229, 184, 93, 0.14);
  color: var(--gold);
  font-style: normal;
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
}

.category-chip:has(input:checked) {
  border-color: rgba(121, 211, 189, 0.72);
  background: rgba(121, 211, 189, 0.11);
}

.table-card {
  grid-column: 3;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: end;
  min-height: 560px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(22, 20, 17, 0.16), rgba(22, 20, 17, 0.94)),
    radial-gradient(circle at 50% 38%, rgba(229, 184, 93, 0.15), transparent 18rem),
    var(--panel-strong);
}

.table-card img {
  position: absolute;
  inset: 36px 50% auto auto;
  width: min(76%, 340px);
  transform: translateX(50%);
  opacity: 0.92;
}

.table-copy {
  position: relative;
  margin-top: auto;
  padding-top: 280px;
}

.table-copy span {
  color: var(--gold);
  font-weight: 900;
}

.table-copy p {
  margin: 10px 0 18px;
  color: var(--muted);
}

.deal-layout {
  display: grid;
  place-items: center;
  gap: 18px;
  min-height: calc(100vh - 150px);
}

.phone-card {
  width: min(440px, 100%);
  min-height: 610px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    linear-gradient(160deg, rgba(50, 44, 35, 0.95), rgba(17, 16, 14, 0.96)),
    var(--panel-strong);
}

.secret-top {
  display: flex;
  justify-content: space-between;
}

.secret-button {
  align-self: center;
  justify-self: stretch;
  min-height: 300px;
  border: 1px dashed rgba(246, 239, 228, 0.28);
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, rgba(229, 184, 93, 0.08) 0 8px, transparent 8px 16px),
    rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.secret-button strong {
  display: block;
  margin-top: 16px;
  font-size: 1.4rem;
}

.lock-mark {
  display: inline-grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--gold);
  font-size: 1.6rem;
}

.word-face {
  align-self: end;
  min-height: 148px;
  border-radius: 8px;
  padding: 22px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  text-align: center;
}

.word-face.hidden {
  visibility: hidden;
}

.word-face strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(2.3rem, 10vw, 4.5rem);
  line-height: 1.08;
}

.deal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.play-grid {
  display: grid;
  grid-template-columns: minmax(280px, 720px);
  justify-content: center;
  gap: 16px;
}

.player-list,
.reveal-grid {
  display: grid;
  gap: 9px;
}

.player-pill,
.reveal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

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

.player-pill.out {
  opacity: 0.48;
  text-decoration: line-through;
}

.player-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(229, 184, 93, 0.15);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
}

.full-button {
  width: 100%;
  margin-top: 12px;
}

.inspect-result {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid rgba(229, 184, 93, 0.36);
  border-radius: 8px;
  padding: 16px;
  background:
    radial-gradient(circle at 100% 0%, rgba(232, 111, 88, 0.2), transparent 9rem),
    rgba(0, 0, 0, 0.25);
}

.inspect-result.hidden {
  display: none;
}

.inspect-result strong {
  color: var(--gold);
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.08;
}

.bottom-actions {
  width: min(720px, 100%);
  margin: 16px auto 0;
  display: flex;
  justify-content: center;
}

.bottom-actions button {
  min-width: min(220px, 100%);
}

.result-panel {
  width: min(780px, 100%);
  margin: 28px auto 0;
  padding: clamp(22px, 5vw, 42px);
  text-align: center;
}

.result-panel h2 {
  margin: 10px 0;
  font-size: clamp(2.4rem, 8vw, 5rem);
  font-family: Georgia, "Songti SC", serif;
}

.result-panel p {
  color: var(--muted);
  margin-bottom: 22px;
}

.reveal-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  text-align: left;
}

.reveal-card strong,
.reveal-card span {
  display: block;
}

.reveal-card span {
  color: var(--muted);
  margin-top: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  max-width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(20, 18, 15, 0.92);
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@media (max-width: 920px) {
  .setup-grid,
  .play-grid {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .setup-grid {
    display: flex;
    flex-direction: column;
  }

  .start-panel,
  .settings-panel,
  .category-panel,
  .table-card {
    grid-column: auto;
    min-width: 0;
  }

  .table-card {
    min-height: 380px;
  }

  .table-card img {
    width: min(72%, 260px);
  }

  .table-copy {
    padding-top: 220px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand img {
    width: 46px;
    height: 46px;
  }

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

  .category-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

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

  .phone-card {
    min-height: 560px;
  }
}
