/* 河南斗地主 —— 样式 */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: radial-gradient(ellipse at 50% 30%, #1e6b32 0%, #12451f 55%, #0a2b13 100%);
  color: #fff;
  min-height: 100vh;
}

#app {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 12px 24px;
}

/* ===== 顶栏 ===== */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  margin-bottom: 10px;
}
#topbar h1 {
  margin: 0;
  font-size: 22px;
  color: #ffd76a;
  letter-spacing: 2px;
}
#scoreboard {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
}
#scoreboard b { color: #ffd76a; font-size: 15px; }
#scoreboard button {
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid #b0893a;
  background: #fff8e7;
  color: #5a3b00;
  cursor: pointer;
}
#scoreboard button:hover { background: #ffe9b8; }

/* ===== 牌桌 ===== */
#table {
  position: relative;
  height: 620px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.06), transparent 60%),
    linear-gradient(160deg, #1c5c2e, #144a24 60%, #0f3d1d);
  border: 10px solid #6b4a2a;
  border-radius: 26px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(0,0,0,0.35);
  overflow: hidden;
}

/* ===== 座位 ===== */
.seat {
  position: absolute;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.seat.north { top: 8px; left: 50%; transform: translateX(-50%); }
.seat.west  { left: 8px;  top: 50%; transform: translateY(-50%); }
.seat.east  { right: 8px; top: 50%; transform: translateY(-50%); }
.seat.south { bottom: 8px; left: 50%; transform: translateX(-50%); }

.seat-head {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 15px;
  white-space: nowrap;
}
.seat .name { font-weight: 600; font-size: 15px; }
.seat.landlord-seat .name { color: #ffd76a; }
.seat .role {
  background: #f0c75e;
  color: #5a3b00;
  font-size: 12px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 8px;
}
.seat.turn .seat-head {
  box-shadow: 0 0 0 3px #ffd76a, 0 0 16px 5px rgba(255, 215, 106, 0.65);
  background: rgba(20, 40, 10, 0.75);
}
.seat .count {
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 1px 9px;
}
.backs { display: flex; }
.backs .card.mini { margin-left: -16px; }
.backs .card.mini:first-child { margin-left: 0; }

.action-bubble {
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  padding: 3px 12px;
  border-radius: 11px;
  font-size: 13px;
}

/* 手牌区 */
.hand {
  position: relative;
  height: 130px;
  margin: 0 auto;
}
.hand .card {
  position: absolute;
  top: 0;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.hand .card:hover { transform: translateY(-6px); }
.hand .card.selected {
  transform: translateY(-22px);
  border-color: #e8a33d;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45), 0 0 0 2px #ffd76a;
}

/* ===== 中央区域 ===== */
#center {
  position: absolute;
  z-index: 8;
  left: 205px;
  right: 205px;
  top: 64px;
  bottom: 128px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  align-items: center;
  justify-items: center;
  gap: 4px;
}
#play-north { grid-column: 2; grid-row: 1; }
#play-west  { grid-column: 1; grid-row: 2; }
#middle     { grid-column: 2; grid-row: 2; }
#play-east  { grid-column: 3; grid-row: 2; }
#play-south { grid-column: 2; grid-row: 3; }

.play-cell {
  position: relative;
  z-index: 2;
  min-height: 56px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.play-cell .card {
  width: 54px;
  height: 78px;
  padding: 3px 4px;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}
.play-cell .card .rank { font-size: 14px; }
.play-cell .card .suit { font-size: 13px; }

#middle { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
#bottom-area .label {
  font-size: 12px;
  color: #cfe8c6;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 1px 10px;
  display: inline-block;
}
#bottom-cards { display: flex; justify-content: center; gap: 5px; margin-top: 4px; }
#bottom-cards .card {
  width: 42px;
  height: 60px;
  padding: 3px 4px;
  border-radius: 5px;
}
#bottom-cards .card .rank { font-size: 13px; }
#bottom-cards .card .suit { font-size: 12px; }

#message {
  min-height: 24px;
  font-size: 16px;
  color: #f2f7ee;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
#message.winner { color: #ffd76a; font-weight: 700; font-size: 19px; }
#message.flash { color: #ffb0b0; animation: shake 0.3s; }

@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ===== 扑克牌 ===== */
.card {
  position: relative;
  width: 74px;
  height: 104px;
  background: linear-gradient(160deg, #ffffff, #f0f0ee);
  border: 1px solid #999;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 6px;
  user-select: none;
}
.card .rank {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.card .suit {
  font-size: 19px;
  line-height: 1;
  align-self: flex-end;
}
.card.red { color: #d03a2e; }
.card.black { color: #232323; }

.card.back {
  background: repeating-linear-gradient(45deg, #2b5fbf 0px, #2b5fbf 6px, #2452a6 6px, #2452a6 12px);
  border: 2px solid #eef;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22), 0 2px 4px rgba(0, 0, 0, 0.4);
}
.card.mini {
  width: 30px;
  height: 42px;
  border-radius: 4px;
  border-width: 1px;
}

/* ===== 控制区 ===== */
#controls {
  margin-top: 16px;
  text-align: center;
  min-height: 96px;
}
#controls button {
  font-size: 16px;
  padding: 9px 24px;
  margin: 0 6px;
  border-radius: 10px;
  border: 1px solid #b0893a;
  background: #fff8e7;
  color: #5a3b00;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#controls button:hover { background: #ffe9b8; }
#controls button.primary {
  background: #e8a33d;
  color: #3a2400;
  border-color: #b07a1f;
  font-weight: 700;
}
#controls button.primary:hover { background: #f2b453; }
#controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.hidden { display: none !important; }

#hint {
  margin-top: 12px;
  min-height: 20px;
  font-size: 14px;
  color: #ffe9b8;
}
#hint.warn { color: #ff9b9b; }

/* 小屏适配 */
@media (max-width: 760px) {
  #table { height: 560px; }
  #center { left: 140px; right: 140px; top: 70px; bottom: 110px; }
  .seat.south .card { width: 60px; height: 84px; }
}
/* 最新出的牌置顶显示，避免被其他元素遮挡 */
.play-cell.latest {
  position: relative;
  z-index: 4;
  background: rgba(255, 215, 106, 0.12);
  border-radius: 12px;
}
.play-cell.latest .card {
  box-shadow: 0 0 0 2px #ffd76a, 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* 局末亮出所有玩家剩余手牌 */
.card.tiny {
  width: 30px;
  height: 42px;
  padding: 2px 3px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.card.tiny .rank { font-size: 12px; }
.card.tiny .suit { font-size: 11px; }
.reveal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 250px;
}
.seat.west .reveal,
.seat.east .reveal { max-width: 170px; }

/* 声音开关按钮 */
#btn-sound { font-size: 15px; padding: 5px 12px; }
/* ===== 特效层：炸弹 / 飞机动画 ===== */
#fx-layer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}
.bomb-fx {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 110px;
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.3);
  animation: bomb-pop 1.1s ease-out forwards;
  text-shadow: 0 0 34px rgba(255, 180, 40, 0.95);
}
@keyframes bomb-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-14deg); }
  22%  { opacity: 1; transform: translate(-50%, -50%) scale(1.7) rotate(10deg); }
  55%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(-4deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.4) rotate(4deg); }
}
.plane-fx {
  position: absolute;
  top: 42%;
  left: -12%;
  font-size: 84px;
  line-height: 1;
  opacity: 0;
  animation: plane-fly 1.5s ease-in forwards;
  filter: drop-shadow(0 0 14px rgba(255, 200, 80, 0.85));
}
@keyframes plane-fly {
  0%   { left: -12%; transform: translateY(0) rotate(-10deg); opacity: 0; }
  15%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { left: 112%; transform: translateY(-36px) rotate(-10deg); opacity: 0; }
}

/* ===== 座位分数徽章 ===== */
.seat-score {
  background: rgba(0, 0, 0, 0.45);
  color: #ffe9b8;
  font-size: 12px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}
.seat.landlord-seat .seat-score { background: #7a4b00; color: #ffd76a; }

/* 叫分按钮 */
#bid-controls button { min-width: 56px; }