* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #261713;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
}

.wood-frame {
  width: 100vw;
  height: 100dvh;
  padding: 6px;
  background: linear-gradient(180deg, #4E342E 0%, #3E2723 50%, #261713 100%);
}

.felt-table {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  border: 1.5px solid rgba(201, 162, 77, 0.45);
  background: radial-gradient(circle at 50% 42%, #267358 0%, #1B4D3E 58%, #0D2B21 100%);
  overflow: hidden;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* === 首页 === */
.home-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
}

.home-stats, .home-right-badges {
  display: flex;
  gap: 12px;
  align-items: center;
}

.pill-badge {
  background: rgba(14, 41, 32, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  font-size: clamp(14px, 2.2vw, 19px);
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 18px;
}

.pill-badge.gold {
  color: #FFE082;
  border-color: rgba(255, 224, 130, 0.35);
}

.pill-badge.subtle {
  color: #C8E6C9;
  font-weight: 600;
}

.home-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.suits-deco {
  font-size: 20px;
  color: rgba(255, 224, 130, 0.45);
  letter-spacing: 6px;
}

.home-title {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  color: #FFFFFF;
  letter-spacing: 3px;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
}

.home-subtitle {
  margin: 0;
  font-size: clamp(14px, 2.1vw, 18px);
  color: #C8E6C9;
}

.home-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding-bottom: 28px;
}

.big-btn {
  border: none;
  color: #FFFFFF;
  font-weight: 700;
  cursor: pointer;
  padding: 0 28px;
  height: 58px;
  border-radius: 30px;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s;
}

.big-btn:active {
  transform: scale(0.96);
}

.big-btn.primary {
  background: #FF8F00;
  border: 2px solid #FFE082;
  min-width: 190px;
  font-size: 25px;
}

.big-btn.green {
  background: #2E7D32;
  border: 1.5px solid #81C784;
}

.big-btn.blue {
  background: #0277BD;
  border: 1.5px solid #81D4FA;
}

.big-btn.gray {
  background: #546E7A;
}

/* === 设置页 === */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 26px;
}

.settings-header h2 {
  margin: 0;
  color: #FFFFFF;
  font-size: 26px;
}

.nav-btn {
  border: none;
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 22px;
  cursor: pointer;
}

.nav-btn.green {
  background: #2E7D32;
}

.settings-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 0 24px 16px;
}

.setting-row {
  width: 90%;
  max-width: 820px;
  background: rgba(16, 48, 38, 0.72);
  border-radius: 14px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.setting-label {
  color: #FFFFFF;
  font-size: 20px;
  font-weight: 700;
  min-width: 96px;
}

.setting-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.opt-btn {
  border: none;
  background: #12382D;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 22px;
  cursor: pointer;
}

.opt-btn.selected {
  background: #FF8F00;
}

.toggle-group {
  margin-left: auto;
  display: flex;
  gap: 18px;
  align-items: center;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.toggle-item input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: #FF8F00;
}

/* === 牌桌界面 === */
.table-top {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 8px;
}

.small-pill {
  background: rgba(14, 41, 32, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 15px;
  cursor: pointer;
  white-space: nowrap;
}

.small-pill.gold {
  color: #FFE082;
  border-color: rgba(255, 224, 130, 0.35);
}

.small-pill.muted {
  color: #FF8A80;
}

.table-top-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

.counter-bar {
  display: flex;
  gap: 2px;
  background: #0F2E24;
  padding: 2px 4px;
  border-radius: 6px;
  overflow-x: auto;
}

.counter-cell {
  width: 25px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #143B2F;
  line-height: 1.05;
}

.counter-cell.zero {
  background: #0F2E24;
}

.counter-rank {
  font-size: 11px;
  font-weight: 700;
  color: #FFE082;
}

.counter-cell.zero .counter-rank {
  color: #78909C;
}

.counter-rem {
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
}

.counter-cell.zero .counter-rem {
  color: #546E7A;
}

.table-middle {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 4px 12px;
  gap: 8px;
}

.bot-seat {
  width: 126px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
}

.chibi-canvas {
  display: block;
}

.seat-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.char-name {
  color: #FFFFFF;
}

.mood-caption {
  color: #FFE082;
  font-size: 11px;
}

.mood-caption.angry {
  color: #FF8A80;
}

.mood-caption.sad {
  color: #90CAF9;
}

.seat-count-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-tag {
  font-size: 12px;
  font-weight: 700;
  color: #E0F2F1;
  background: rgba(14, 41, 32, 0.72);
  padding: 2px 7px;
  border-radius: 8px;
}

.role-tag.landlord {
  color: #FFCC80;
  background: #E65100;
}

.cards-left {
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
}

.cards-left.low {
  color: #FF5252;
}

.seat-status {
  font-size: 14px;
  font-weight: 700;
  color: #FFE082;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 10px;
  border-radius: 10px;
}

.center-felt {
  position: relative;
  flex: 1;
  height: 94%;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 224, 130, 0.18);
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 4px 12px;
}

.table-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.10);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
}

.bot-plays-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
  z-index: 1;
}

.mini-cards-group {
  display: flex;
  align-items: center;
}

.self-play-row {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 64px;
  z-index: 1;
}

.self-pass-badge {
  font-size: 20px;
  font-weight: 700;
  color: #FFE082;
  background: rgba(0, 0, 0, 0.42);
  padding: 4px 16px;
  border-radius: 14px;
}

/* 操作按钮行 */
.action-row {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.act-btn {
  border: none;
  height: 38px;
  min-width: 96px;
  padding: 0 18px;
  border-radius: 20px;
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.act-btn:disabled {
  background: #37474F !important;
  opacity: 0.65;
  cursor: default;
}

.act-btn.orange { background: #FF8F00; }
.act-btn.deeporange { background: #E65100; }
.act-btn.green { background: #2E7D32; }
.act-btn.teal { background: #00695C; }
.act-btn.blue { background: #0277BD; }
.act-btn.gray { background: #546E7A; }

.thinking-text {
  color: #C8E6C9;
  font-size: 19px;
  font-weight: 700;
}

/* 底部手牌区 */
.table-bottom {
  height: 112px;
  display: flex;
  align-items: center;
  padding: 0 20px 6px 16px;
  gap: 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.22) 55%, rgba(30,18,14,0.45) 100%);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.player-avatar-box {
  width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
}

.hand-container {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  touch-action: none;
  padding-bottom: 4px;
}

.hand-cards-strip {
  display: flex;
  align-items: flex-end;
}

/* 扑克牌 */
.poker-card {
  width: 56px;
  height: 84px;
  background: #FFFFFF;
  border: 1px solid #B0BEC5;
  border-radius: 8px;
  padding: 3px 5px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease-out, background-color 0.12s;
  cursor: pointer;
  flex-shrink: 0;
}

.poker-card.xl {
  width: 64px;
  height: 92px;
}

.poker-card.mini {
  width: 42px;
  height: 58px;
  border-radius: 6px;
  padding: 2px 4px;
  cursor: default;
}

.poker-card.selected {
  background: #FFF8E1;
  border: 2px solid #FF9800;
  transform: translateY(-18px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.card-rank {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.05;
  color: #111111;
}

.poker-card.xl .card-rank {
  font-size: 25px;
}

.poker-card.mini .card-rank {
  font-size: 14px;
}

.card-rank.joker {
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
  white-space: pre-line;
  margin-top: 2px;
}

.poker-card.xl .card-rank.joker {
  font-size: 17px;
}

.poker-card.mini .card-rank.joker {
  font-size: 10px;
}

.card-suit {
  font-size: 16px;
  line-height: 1;
  color: #111111;
}

.poker-card.xl .card-suit {
  font-size: 19px;
}

.poker-card.mini .card-suit {
  font-size: 12px;
}

.poker-card.red .card-rank,
.poker-card.red .card-suit {
  color: #D32F2F;
}

/* 弹窗与 Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 20px;
  z-index: 30;
  white-space: nowrap;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-card {
  background: #FFFFFF;
  border-radius: 18px;
  padding: 22px 26px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  text-align: center;
  max-width: 90%;
}

.rules-card {
  width: 540px;
  text-align: left;
}

.rules-card h3 {
  text-align: center;
  margin: 0 0 12px;
  color: #1B4D3E;
  font-size: 26px;
}

.rules-card p {
  margin: 8px 0;
  color: #263238;
  font-size: 17px;
  line-height: 1.45;
}

.settle-card {
  width: 450px;
  border: 3px solid #FFD54F;
  animation: settlePop 0.36s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes settlePop {
  from { opacity: 0; transform: scale(0.68); }
  to { opacity: 1; transform: scale(1); }
}

.settle-card h3 {
  margin: 0 0 8px;
  font-size: 27px;
  color: #E65100;
}

.settle-card.loss {
  border-color: #B0BEC5;
}

.settle-card.loss h3 {
  color: #37474F;
}

.settle-detail {
  color: #455A64;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.settle-delta {
  font-size: 28px;
  font-weight: 800;
  color: #2E7D32;
}

.settle-delta.neg {
  color: #D32F2F;
}

.settle-balance {
  color: #546E7A;
  font-size: 16px;
  margin: 4px 0 10px;
}

.settle-refill {
  color: #FF8F00;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.settle-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-item {
  position: absolute;
  left: 50%;
  top: 32%;
  font-size: 26px;
  animation: fallDown 1.6s ease-out infinite;
}

@keyframes fallDown {
  0% { opacity: 1; transform: translate(var(--tx), -90px) rotate(0deg); }
  100% { opacity: 0.15; transform: translate(var(--tx), 110px) rotate(180deg); }
}

/* 竖屏提示 */
.portrait-tip {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(13, 43, 33, 0.94);
  z-index: 60;
  align-items: center;
  justify-content: center;
}

.portrait-box {
  background: #FFFFFF;
  padding: 26px;
  border-radius: 18px;
  text-align: center;
  width: 82vw;
  max-width: 340px;
}

.portrait-box h3 {
  margin: 0 0 8px;
  color: #1B4D3E;
  font-size: 24px;
}

.portrait-box p {
  margin: 0 0 16px;
  color: #455A64;
  font-size: 16px;
}

@media (orientation: portrait) {
  #app.wood-frame {
    position: fixed;
    top: 0;
    left: 100vw;
    width: 100dvh;
    height: 100vw;
    transform-origin: top left;
    transform: rotate(90deg);
  }
  .portrait-tip.show-portrait {
    display: none;
  }
}
