* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f1a14;
  color: #eee;
}
.app { max-width: 1100px; margin: 0 auto; padding: 20px; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
h1 { font-size: 22px; margin: 0; }
h1 .sub { font-size: 14px; color: #8fbf9a; font-weight: normal; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #2f9e63; color: white; font-weight: 600; }
.btn-primary:hover { background: #35b571; }
.btn-ghost {
  background: transparent;
  color: #cfe8d8;
  border: 1px solid #33513e;
}
.btn-ghost:hover { background: #1c2b22; border-color: #4a8f6a; }

.lang-select {
  background: #1c2b22;
  color: #cfe8d8;
  border: 1px solid #33513e;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  cursor: pointer;
}
.lang-select:hover { border-color: #4a8f6a; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-panel {
  background: #16241c;
  border: 1px solid #33513e;
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #263e30;
  position: sticky;
  top: 0;
  background: #16241c;
}
.modal-header h2 { margin: 0; font-size: 16px; color: #eafff2; }
.btn-close {
  background: transparent;
  border: none;
  color: #9db8a8;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.btn-close:hover { color: #eafff2; }
.modal-body { padding: 16px 20px; font-size: 13px; line-height: 1.7; color: #d7ecdd; }
.modal-body p { margin: 0 0 12px; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body strong { color: #7fd8a3; }
.btn-action {
  background: #1c2b22;
  color: #eee;
  border: 1px solid #33513e;
  margin: 4px;
  min-width: 110px;
}
.btn-action:hover:not(:disabled) { background: #274536; border-color: #4a8f6a; }
.btn-action:disabled { opacity: 0.3; cursor: not-allowed; }

.layout { display: flex; gap: 20px; align-items: flex-start; }
.table-wrap { flex: 1; min-width: 0; }
.side-panel { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }

.table {
  position: relative;
  background: radial-gradient(ellipse at center, #1d5c3a 0%, #123b26 70%, #0d2c1c 100%);
  border: 10px solid #3a2b1d;
  border-radius: 140px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  min-height: 360px;
  justify-content: space-between;
  overflow: visible;
}

.seat { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; border-radius: 16px; padding: 6px 10px; transition: box-shadow .3s ease; }
.seat-label { font-size: 13px; color: #cfe8d8; opacity: 0.85; }
.chip-count {
  background: #0d2c1c;
  border: 1px solid #33513e;
  border-radius: 12px;
  padding: 2px 12px;
  font-size: 13px;
  color: #ffd76a;
  transition: transform .2s ease, color .2s ease;
}
.chip-count.bump { transform: scale(1.25); color: #ffe89a; }

.seat-active {
  animation: seatGlow 1.1s ease-in-out infinite;
}
@keyframes seatGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(127, 216, 163, 0); }
  50% { box-shadow: 0 0 18px 4px rgba(127, 216, 163, 0.45); }
}
.seat-thinking {
  animation: seatGlowBlue 1.1s ease-in-out infinite;
}
@keyframes seatGlowBlue {
  0%, 100% { box-shadow: 0 0 0 rgba(143, 191, 224, 0); }
  50% { box-shadow: 0 0 18px 4px rgba(143, 191, 224, 0.45); }
}

/* flying chip travelling from a seat to the pot */
.flying-chip {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe89a, #d9a441 70%, #a9761d);
  border: 2px solid #7a5715;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 20;
  pointer-events: none;
  transition: left .55s cubic-bezier(.3,.6,.4,1), top .55s cubic-bezier(.3,.6,.4,1), opacity .55s ease .1s;
}

/* action toast bubble that pops above/below a seat */
.action-toast {
  position: absolute;
  transform: translate(-50%, -8px);
  background: #10201a;
  border: 1px solid #4a8f6a;
  color: #eafff2;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  z-index: 30;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.action-toast.show { opacity: 1; transform: translate(-50%, -22px); }
.action-toast.toast-fold { border-color: #c9705f; color: #ffd3c8; }
.action-toast.toast-raise { border-color: #ffd76a; color: #ffe89a; }
.action-toast.toast-call { border-color: #7fd8a3; }
.action-toast.toast-check { border-color: #8fbfe0; color: #d7ecff; }

/* fold: the card that gets mucked flips and slides away */
.card-fold-anim {
  animation: cardFold .6s ease forwards;
}
@keyframes cardFold {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  60% { transform: translateY(10px) rotate(-12deg) scale(0.96); opacity: 0.6; }
  100% { transform: translateY(28px) rotate(-18deg) scale(0.85); opacity: 0; }
}

.card-slot { display: flex; gap: 8px; min-height: 90px; align-items: center; }
.card {
  width: 60px;
  height: 84px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}
.card-back {
  background: repeating-linear-gradient(45deg, #23486b, #23486b 6px, #1a3652 6px, #1a3652 12px);
  border: 2px solid #3a5f85;
}
.card-empty {
  background: rgba(255,255,255,0.05);
  border: 2px dashed rgba(255,255,255,0.15);
}
.card-face {
  background: #fdfdf6;
  color: #222;
  border: 2px solid #ccc;
  flex-direction: column;
  line-height: 1;
  gap: 2px;
}
.card-face.red { color: #c62828; }

.center-row {
  display: flex;
  align-items: center;
  gap: 40px;
}
.public-card-area, .pot-area { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pot-label { font-size: 13px; color: #cfe8d8; opacity: 0.85; }
.pot-value { font-size: 22px; font-weight: 700; color: #ffd76a; transition: transform .2s ease; }
.pot-value.bump { transform: scale(1.3); }

.result-banner {
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #1c2b22;
  border: 1px solid #33513e;
  text-align: center;
  font-size: 15px;
}

.actions { display: flex; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
#nextHandBtn { display: block; margin: 16px auto 0; }
.status-line { text-align: center; color: #9db8a8; font-size: 13px; margin-top: 10px; min-height: 18px; }

.panel-block {
  background: #16241c;
  border: 1px solid #263e30;
  border-radius: 10px;
  padding: 14px 16px;
}
.panel-block h2 { font-size: 14px; margin: 0 0 10px; color: #cfe8d8; }

.leaderboard-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; margin-bottom: 10px; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
}
.leaderboard-row .rank { width: 20px; flex-shrink: 0; color: #7b9585; font-weight: 700; }
.leaderboard-row .name { flex: 1; min-width: 0; color: #d7ecdd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-row .score { flex-shrink: 0; color: #ffd76a; font-weight: 700; width: 44px; text-align: right; }
.leaderboard-row .hands { flex-shrink: 0; color: #7b9585; width: 54px; text-align: right; }
.leaderboard-row.top1 .rank { color: #ffd76a; }
.leaderboard-row.top2 .rank { color: #cfd8dc; }
.leaderboard-row.top3 .rank { color: #d9a441; }
.leaderboard-empty { font-size: 12px; color: #7b9585; }

.leaderboard-submit { display: flex; gap: 6px; }
.leaderboard-input {
  flex: 1;
  min-width: 0;
  background: #0d2c1c;
  border: 1px solid #33513e;
  border-radius: 8px;
  padding: 8px 10px;
  color: #eee;
  font-size: 13px;
}
.leaderboard-input:focus { outline: none; border-color: #4a8f6a; }
.leaderboard-save-btn { margin: 0; min-width: 0; white-space: nowrap; padding: 8px 12px; }
.leaderboard-msg { font-size: 12px; color: #7fd8a3; margin-top: 6px; min-height: 14px; }
.leaderboard-msg.error { color: #ffb0a0; }

.save-score-summary { font-size: 20px; font-weight: 700; color: #ffd76a; margin: 0 0 14px; }
.save-score-skip-btn { width: 100%; margin-top: 10px; }

.reveal-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cfe8d8;
  cursor: pointer;
  user-select: none;
}
.reveal-toggle input { accent-color: #2f9e63; width: 15px; height: 15px; cursor: pointer; }

.score { font-size: 30px; font-weight: 700; color: #ffd76a; }
.hands-played { font-size: 12px; color: #9db8a8; margin-top: 2px; }

.ai-policy { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #7fd8a3; }
.confidence-bar-wrap { margin-bottom: 10px; }
.confidence-bar {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: #0d2c1c;
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f9e63, #7fd8a3);
  transition: width .3s ease;
}
.confidence-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #ffd76a;
  left: 70%;
}
.confidence-text { font-size: 11px; color: #9db8a8; margin-top: 4px; }

.posterior-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.posterior-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.posterior-row .name { width: 84px; flex-shrink: 0; color: #cfe8d8; }
.posterior-row .bar-bg { flex: 1; height: 7px; background: #0d2c1c; border-radius: 4px; overflow: hidden; }
.posterior-row .bar-fill { height: 100%; background: #4a8f6a; }
.posterior-row .pct { width: 38px; text-align: right; color: #9db8a8; }

.hint { font-size: 11px; color: #7b9585; line-height: 1.5; margin: 4px 0 0; }

.action-log { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; font-size: 12px; }
.action-log .row { display: flex; justify-content: space-between; color: #b9d0c1; }
.action-log .row.agent { color: #8fbfe0; }
.action-log .row.human { color: #ffd76a; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side-panel { width: 100%; }
}
