/* UNO 游戏全局样式 */

:root {
  --uno-red: #e53935;
  --uno-yellow: #fdd835;
  --uno-green: #43a047;
  --uno-blue: #1e88e5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: #f5f0ea;
}

.hidden {
  display: none !important;
}

.view {
  min-height: 100vh;
}

/* ============ 大厅 ============ */
#lobby-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lobby-panel {
  width: 380px;
  max-width: 100%;
  padding: 40px 36px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.lobby-logo {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--uno-red);
  line-height: 1;
}

.lobby-logo span {
  color: var(--uno-yellow);
  -webkit-text-stroke: 1px #333;
}

.lobby-subtitle {
  color: #666;
  margin: 8px 0 28px;
  font-size: 14px;
}

.lobby-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  align-items: center;
}

.lobby-row mdui-button {
  flex: 1;
}

.lobby-row mdui-button[hidden] {
  display: none;
}

.code-input {
  flex: 1;
}

.lobby-divider {
  margin-top: 18px;
  color: #999;
  font-size: 13px;
}

.room-code-label {
  color: #888;
  font-size: 13px;
  margin-bottom: 6px;
}

.room-code {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 12px;
  color: var(--uno-blue);
  margin-bottom: 20px;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 220px;
  overflow-y: auto;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: #f4f4f4;
  font-size: 14px;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.owner-tag {
  background: var(--uno-blue);
  color: #fff;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
}

.player-status {
  color: #888;
  font-size: 12px;
}

/* ============ 游戏桌 ============ */
#game-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 5;
}

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

.topbar-room {
  font-size: 14px;
  color: #555;
}

.topbar-room b {
  color: var(--uno-blue);
  letter-spacing: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #666;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #333;
}

.badge {
  font-size: 13px;
  color: var(--uno-blue);
  background: rgba(30, 136, 229, 0.12);
  border-radius: 12px;
  padding: 3px 12px;
}

/* 中央桌面 */
#table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 16px 300px 16px 16px;
  overflow: auto;
}

/* 内容不超高时垂直居中；超高（如页面缩放）时可滚动，避免摸牌区被挤出无法点击 */
#table > :first-child {
  margin-top: auto;
}

#table > :last-child {
  margin-bottom: auto;
}

#opponents {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 116px;
  padding: 12px 8px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s;
}

.seat.turn {
  box-shadow: 0 0 0 2px var(--uno-blue), 0 4px 12px rgba(30, 136, 229, 0.25);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #78909c, #455a64);
  margin-bottom: 6px;
}

.seat-name {
  font-size: 14px;
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hand-count {
  font-size: 12px;
  color: #777;
  margin-top: 2px;
}

.uno-badge {
  display: inline-block;
  background: var(--uno-red);
  color: #fff;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  margin-left: 4px;
}

.challenge-btn {
  margin-top: 8px;
  --shape-corner: 10px;
}

/* 中央牌区 */
#center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#turn-banner {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  min-height: 24px;
}

#center .row {
  display: flex;
  gap: 48px;
}

.pile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pile-count {
  font-size: 12px;
  color: #888;
}

#discard-pile .pile-count {
  opacity: 0;
}

.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  background: #ccc;
}

.color-dot.red {
  background: var(--uno-red);
}

.color-dot.yellow {
  background: var(--uno-yellow);
}

.color-dot.green {
  background: var(--uno-green);
}

.color-dot.blue {
  background: var(--uno-blue);
}

/* 我自己的面板 */
#me-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

#hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 132px;
  padding: 8px;
}

#hand .card {
  margin-left: -18px;
  transition: transform 0.15s;
}

#hand .card:first-child {
  margin-left: 0;
}

#hand .card:hover {
  transform: translateY(-16px) scale(1.06);
  z-index: 10;
}

/* ============ 卡牌动画 ============ */
/* 发牌：手牌从摸牌堆逐张飞入 */
#hand .card.deal-in {
  animation: card-deal-in 0.42s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

@keyframes card-deal-in {
  from {
    transform: translate(var(--fx-x, 0px), var(--fx-y, -40px)) rotate(-8deg) scale(0.8);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* 出牌/开局：弃牌堆顶牌入场 */
.card.play-drop {
  animation: card-drop 0.28s ease-out;
}

@keyframes card-drop {
  from {
    transform: translateY(-24px) scale(1.18) rotate(8deg);
    opacity: 0.3;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* 摸牌/被罚：手牌数增加的对手座位闪烁提示 */
.seat.hand-pulse {
  animation: seat-pulse 0.45s ease-out;
}

@keyframes seat-pulse {
  0% {
    transform: translateY(-8px) scale(1.07);
    box-shadow: 0 0 0 2px var(--uno-yellow), 0 4px 12px rgba(255, 193, 7, 0.4);
  }
  100% {
    transform: none;
  }
}

#actions {
  display: flex;
  gap: 12px;
}

#actions mdui-button[hidden] {
  display: none;
}

/* ============ 牌面 ============ */
.card {
  width: 76px;
  height: 112px;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.card-back {
  background: linear-gradient(135deg, #e53935 50%, #fdd835 50%);
  background-size: 12px 12px;
  cursor: default;
}

.card-back::after {
  content: "UNO";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  font-size: 18px;
  letter-spacing: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.card .card-inner {
  position: absolute;
  inset: 5px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card .card-corner {
  position: absolute;
  top: 7px;
  left: 9px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card .card-num {
  font-size: 44px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.28);
}

.card .card-plus {
  font-size: 34px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.28);
}

.card-icon {
  width: 56px;
  height: 56px;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.card.red {
  background: linear-gradient(145deg, #ef5350, #c62828);
}

.card.yellow {
  background: linear-gradient(145deg, #ffca28, #f9a825);
}

.card.green {
  background: linear-gradient(145deg, #66bb6a, #2e7d32);
}

.card.blue {
  background: linear-gradient(145deg, #42a5f5, #1565c0);
}

.card.wild {
  background: #fff;
  border: 2px solid #ddd;
}

.card.wild .card-inner {
  border-color: #f0f0f0;
}

/* 摸到的牌高亮 */
#hand .card.drawn {
  box-shadow: 0 0 0 3px var(--uno-yellow), 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 不可出的牌：与可出的牌视觉完全一致，不提示可出性（更有节目效果） */
#hand .card.disabled {
  opacity: 1;
}

/* ============ 消息面板 ============ */
#message-panel {
  position: fixed;
  right: 16px;
  top: 64px;
  bottom: 16px;
  width: 264px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
}

.message-title {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
  flex-shrink: 0;
}

#message-list {
  flex: 1;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}

.msg {
  padding: 4px 0;
  color: #444;
  border-bottom: 1px dashed #eee;
}

.msg.uno {
  color: var(--uno-red);
  font-weight: 600;
}

.msg.warn {
  color: #e65100;
}

.msg.win {
  color: var(--uno-green);
  font-weight: 700;
}

.msg.system {
  color: #999;
}

/* ============ 换色弹窗 ============ */
.color-options {
  display: flex;
  gap: 16px;
  padding: 8px 4px;
}

.color-option {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  border: 4px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.color-option:hover {
  transform: scale(1.12);
}

.color-option.red {
  background: var(--uno-red);
}

.color-option.yellow {
  background: var(--uno-yellow);
}

.color-option.green {
  background: var(--uno-green);
}

.color-option.blue {
  background: var(--uno-blue);
}

/* ============ 投票横幅 ============ */
.vote-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 2px solid var(--uno-blue);
  border-radius: 14px;
  padding: 10px 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 500;
}

.vote-banner .vote-done {
  color: var(--uno-green);
  font-weight: 600;
}

.vote-banner mdui-button {
  --shape-corner: 10px;
}

/* ============ 结算数据看板 ============ */
.stats-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.stats-panel {
  width: 560px;
  max-width: 92vw;
  background: #fff;
  border-radius: 18px;
  padding: 26px 30px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.stats-title {
  margin: 0 0 18px;
  font-size: 22px;
  text-align: center;
  color: #333;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.stats-table th,
.stats-table td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.stats-table th {
  color: #888;
  font-weight: 500;
  font-size: 13px;
}

.stats-table tr.winner-row {
  background: rgba(67, 160, 71, 0.1);
}

.stats-table tr.winner-row td {
  font-weight: 600;
}

.winner-badge {
  display: inline-block;
  background: var(--uno-green);
  color: #fff;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: 6px;
}

.rematch-area {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rematch-status {
  font-size: 13px;
  color: #777;
  min-height: 18px;
}

/* ============ 响应式 ============ */
@media (max-width: 960px) {
  #table {
    padding: 12px;
  }

  #message-panel {
    position: static;
    width: 100%;
    max-height: 180px;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid #eee;
    flex-shrink: 0;
  }

  #game-view {
    overflow-y: auto;
  }

  .card {
    width: 60px;
    height: 88px;
  }

  .card .card-num {
    font-size: 32px;
  }

  .card-icon {
    width: 44px;
    height: 44px;
  }
}
