:root {
  --bg-1: #fffaf0;
  --bg-2: #fceecf;
  --ink: #1f2937;
  --muted: #596275;
  --card: #ffffffcc;
  --line: #e6dcc3;
  --primary: #ff7f50;
  --primary-deep: #f05a28;
  --success: #2d9f72;
  --danger: #e45858;
  --shadow: 0 18px 40px rgba(123, 88, 35, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #fffef9 0%, #fffaf0 35%, #f9e3be 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(6px);
  pointer-events: none;
  z-index: 0;
}

.orb-a {
  width: 280px;
  height: 280px;
  background: rgba(255, 127, 80, 0.22);
  top: -70px;
  left: -50px;
}

.orb-b {
  width: 260px;
  height: 260px;
  background: rgba(239, 200, 118, 0.3);
  right: -60px;
  bottom: -80px;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(920px, 92vw);
  margin: 36px auto;
  display: grid;
  gap: 20px;
  animation: rise-in 420ms ease;
}

.topbar h1 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", cursive;
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: 1px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 1.18rem;
}

.board-card,
.knowledge-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(2px);
  text-align: center;
}

.board-card {
  padding: 20px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-direction: column;
}

.timer-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: center;
}

.label {
  font-size: 1.12rem;
  color: var(--muted);
}

#timer {
  font-size: 2.15rem;
}

.state-wrap {
  color: var(--muted);
  font-weight: 600;
  font-size: 1.12rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 14px;
  margin: 14px 0 18px;
  justify-items: center;
}

.poker {
  aspect-ratio: 3 / 4;
  width: min(100%, 152px);
  border-radius: 14px;
  border: 1px solid #eadbc4;
  background: linear-gradient(160deg, #ffffff 0%, #fff8ea 100%);
  box-shadow: 0 8px 20px rgba(55, 45, 26, 0.1);
  display: grid;
  padding: 12px;
  transform: translateY(8px);
  opacity: 0;
  animation: card-in 300ms ease forwards;
}

.poker .rank {
  font-weight: 800;
  font-size: 2.6rem;
  line-height: 1;
}

.poker .suit {
  align-self: end;
  justify-self: end;
  font-size: 1.8rem;
  font-weight: 700;
}

.poker.black .rank,
.poker.black .suit {
  color: #1f2937;
}

.poker.red .rank,
.poker.red .suit {
  color: #cf2d2d;
}

.input-area label {
  display: inline-block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 1.1rem;
}

.input-wrap {
  position: relative;
}

#exprInput {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #d8c6a7;
  padding: 14px 16px;
  font-size: 1.2rem;
  text-align: center;
  outline: none;
  background: #fffdf8;
}

#exprInput:focus {
  border-color: #f2a05a;
}

.bubble {
  position: absolute;
  right: 10px;
  top: -8px;
  transform: translateY(-100%);
  background: #242f40;
  color: #fff;
  font-size: 1rem;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  white-space: nowrap;
}

.bubble.show {
  opacity: 1;
}

.btn-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

#numberButtons {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.btn-grid.operator-basic,
.btn-grid.operator-extra {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.key-btn {
  background: #fff3dd;
  border: 1px solid #f0d7ab;
  color: #5a4530;
  min-height: 60px;
  font-size: 1.34rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.key-btn:hover {
  box-shadow: 0 8px 18px rgba(176, 133, 58, 0.18);
}

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

.primary {
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-deep) 100%);
  color: #fff;
}

.success {
  background: var(--success);
  color: #fff;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.ghost {
  background: #fff7e6;
  color: #60491f;
  border: 1px solid #ebd2a5;
}

.hidden {
  display: none !important;
}

.result-panel {
  margin-top: 14px;
  border-radius: 12px;
  border: 1px dashed #ceb889;
  padding: 12px;
  background: #fff8e9;
}

.result-panel h3 {
  margin: 0 0 8px;
  font-size: 1.28rem;
}

.answer-line {
  margin: 6px 0;
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all;
  font-size: 1.08rem;
}

.answer-more {
  margin-top: 8px;
}

.knowledge-card {
  padding: 16px 20px;
}

.know-panel {
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid #e7d5b3;
  background: #fffdf7;
  max-height: 0;
  overflow: hidden;
  transition: max-height 260ms ease;
}

.know-panel.open {
  max-height: 330px;
}

.know-content {
  padding: 10px 12px;
  max-height: 320px;
  overflow: auto;
  font-size: 1.05rem;
  line-height: 1.55;
}

.know-intro {
  margin-bottom: 10px;
  font-weight: 600;
}

.know-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed #f0e5ce;
}

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

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

@keyframes card-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .btn-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .key-btn {
    min-height: 56px;
    font-size: 1.22rem;
  }

  .btn-grid.operator-basic,
  .btn-grid.operator-extra {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .status-row {
    flex-direction: column;
    align-items: center;
  }

  .know-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
