/* ===== 财管帝国：资本博弈 - 样式表 ===== */
/* 深色调暗金主题，参考三国杀/炉石传说 */

:root {
  --bg-primary: #1a1410;
  --bg-secondary: #241d15;
  --bg-panel: #2a2218;
  --gold: #c9a84c;
  --gold-light: #f0d878;
  --gold-dark: #8b6914;
  --gold-glow: rgba(201, 168, 76, 0.4);
  --text-primary: #e8dcc8;
  --text-secondary: #b8a88c;
  --text-dim: #7a6e5a;
  --red: #c0392b;
  --red-light: #e74c3c;
  --green: #27ae60;
  --green-light: #2ecc71;
  --blue: #2980b9;
  --blue-light: #3498db;
  --orange: #e67e22;
  --purple: #8e44ad;
  --card-common: #6b8e6b;
  --card-rare: #4a7db5;
  --card-epic: #9b59b6;
  --card-legendary: #e67e22;
  --border-radius: 8px;
  --card-radius: 6px;
  --shadow: 0 4px 16px rgba(0,0,0,0.5);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', sans-serif;
  overflow: hidden;
  height: 100vh;
  user-select: none;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(201,168,76,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(201,168,76,0.05) 0%, transparent 40%);
}

/* ===== 游戏容器 ===== */
#game-container {
  display: grid;
  grid-template-rows: 56px 1fr 180px;
  grid-template-columns: 280px 1fr 280px;
  grid-template-areas:
    "topbar topbar topbar"
    "left board right"
    "bottom bottom bottom";
  height: 100vh;
  gap: 4px;
  padding: 4px;
}

/* ===== 顶部信息栏 ===== */
#topbar {
  grid-area: topbar;
  background: linear-gradient(180deg, rgba(42,34,24,0.98), rgba(30,24,14,0.95));
  border-bottom: 2px solid var(--gold-dark);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

#topbar .turn-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

#topbar .turn-info .label { color: var(--text-secondary); }
#topbar .turn-info .value {
  color: var(--gold-light);
  font-weight: bold;
  font-size: 18px;
}

#topbar .phase-indicator {
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  background: rgba(201,168,76,0.15);
  border: 1px solid var(--gold-dark);
  color: var(--gold-light);
}

.market-card-display {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.market-card-mini {
  width: 90px;
  height: 40px;
  background: linear-gradient(135deg, #3a1f0a, #5a3010);
  border: 2px solid var(--gold);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--gold-light);
  font-weight: bold;
  text-align: center;
  box-shadow: 0 0 10px var(--gold-glow);
}

/* ===== 左侧面板 ===== */
#left-panel {
  grid-area: left;
  background: var(--bg-panel);
  border-right: 1px solid rgba(201,168,76,0.2);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.opponent-compact {
  background: linear-gradient(135deg, rgba(30,24,14,0.9), rgba(42,34,24,0.7));
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: var(--border-radius);
  padding: 8px 10px;
  cursor: pointer;
  transition: var(--transition);
}

.opponent-compact:hover {
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
}

.opponent-compact .name {
  font-weight: bold;
  font-size: 13px;
  color: var(--gold-light);
}

.opponent-compact .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
  font-size: 11px;
  margin-top: 4px;
  color: var(--text-secondary);
}

.opponent-compact .stats span { color: var(--text-primary); }

/* ===== 右侧面板 ===== */
#right-panel {
  grid-area: right;
  background: var(--bg-panel);
  border-left: 1px solid rgba(201,168,76,0.2);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-status {
  background: linear-gradient(135deg, rgba(30,24,14,0.95), rgba(42,34,24,0.8));
  border: 2px solid var(--gold);
  border-radius: var(--border-radius);
  padding: 12px;
  box-shadow: 0 0 16px var(--gold-glow);
}

.player-status .player-name {
  font-size: 16px;
  font-weight: bold;
  color: var(--gold-light);
  text-align: center;
  margin-bottom: 8px;
  text-shadow: 0 0 8px var(--gold-glow);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.status-item {
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 6px 8px;
  text-align: center;
}

.status-item .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status-item .value {
  font-size: 17px;
  font-weight: bold;
  color: var(--gold-light);
}

.status-item.warning .value { color: var(--orange); }
.status-item.danger .value { color: var(--red-light); }
.status-item.good .value { color: var(--green-light); }

.debt-bar-container {
  margin-top: 8px;
}

.debt-bar-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.debt-bar {
  height: 8px;
  background: rgba(0,0,0,0.5);
  border-radius: 4px;
  overflow: hidden;
}

.debt-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease, background 0.6s ease;
}

.debt-bar-fill.safe { background: var(--green); }
.debt-bar-fill.warning { background: var(--orange); }
.debt-bar-fill.danger { background: var(--red); }

/* 行动按钮 */
#action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.action-btn {
  flex: 1;
  min-width: 60px;
  padding: 6px 10px;
  background: linear-gradient(180deg, rgba(201,168,76,0.2), rgba(139,105,20,0.2));
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  color: var(--gold-light);
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  transition: var(--transition);
  text-align: center;
}

.action-btn:hover {
  background: linear-gradient(180deg, rgba(201,168,76,0.4), rgba(139,105,20,0.4));
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

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

.action-btn.primary {
  background: linear-gradient(180deg, rgba(201,168,76,0.5), rgba(139,105,20,0.4));
  border-color: var(--gold-light);
  font-size: 13px;
}

/* ===== 中央游戏区 ===== */
#board-area {
  grid-area: board;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 对手打出的资产区 */
.played-assets-row {
  background: rgba(0,0,0,0.2);
  border-radius: var(--border-radius);
  padding: 6px;
  min-height: 80px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.played-assets-row .label {
  font-size: 9px;
  color: var(--text-dim);
  width: 100%;
  margin-bottom: 2px;
}

/* 中央主区域 - 玩家资产 */
#center-play-area {
  flex: 1;
  background: radial-gradient(ellipse at center, rgba(42,34,24,0.6), rgba(26,20,16,0.9));
  border: 2px solid rgba(201,168,76,0.3);
  border-radius: var(--border-radius);
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  min-height: 200px;
}

/* ===== 底部手牌区 ===== */
#hand-area {
  grid-area: bottom;
  background: linear-gradient(0deg, rgba(30,24,14,0.98), rgba(42,34,24,0.9));
  border-top: 2px solid var(--gold-dark);
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  perspective: 800px;
  overflow-x: auto;
  gap: 0;
}

/* ===== 卡牌基础样式 ===== */
.card {
  width: 100px;
  height: 140px;
  border-radius: var(--card-radius);
  position: relative;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-12px) scale(1.08);
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.card.played {
  width: 80px;
  height: 110px;
  cursor: default;
}

.card.played:hover {
  transform: translateY(-4px) scale(1.05);
}

/* 卡牌稀有度光效 */
.card.rarity-common {
  border: 2px solid #7a8a7a;
  box-shadow: 0 0 6px rgba(122,138,122,0.3);
}

.card.rarity-rare {
  border: 2px solid #4a8dc5;
  box-shadow: 0 0 10px rgba(74,141,197,0.4);
}

.card.rarity-epic {
  border: 2px solid #9b59b6;
  box-shadow: 0 0 14px rgba(155,89,182,0.5);
  animation: epicGlow 2s ease-in-out infinite;
}

.card.rarity-legendary {
  border: 2px solid var(--orange);
  box-shadow: 0 0 18px rgba(230,126,34,0.6);
  animation: legendaryGlow 1.5s ease-in-out infinite;
}

@keyframes epicGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(155,89,182,0.4); }
  50% { box-shadow: 0 0 20px rgba(155,89,182,0.7); }
}

@keyframes legendaryGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(230,126,34,0.5); }
  50% { box-shadow: 0 0 25px rgba(230,126,34,0.8); }
}

/* 卡牌颜色主题 */
.card.theme-market {
  background: linear-gradient(135deg, #2a1a0a, #4a2a10);
}

.card.theme-asset {
  background: linear-gradient(135deg, #1a2a1a, #1a3a1a);
}

.card.theme-finance {
  background: linear-gradient(135deg, #1a1a2a, #1a2a4a);
}

.card.theme-strategy {
  background: linear-gradient(135deg, #2a1a2a, #3a1a3a);
}

.card-inner {
  width: 100%;
  height: 100%;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.card-id {
  font-size: 9px;
  font-weight: bold;
  color: var(--gold-light);
  background: rgba(0,0,0,0.4);
  padding: 1px 4px;
  border-radius: 2px;
}

.card-type {
  font-size: 8px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.card-name {
  font-size: 11px;
  font-weight: bold;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
}

.card-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
  margin: 2px 0;
}

.card-effect {
  font-size: 9px;
  color: var(--text-secondary);
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
}

.card-cost {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 10px;
  font-weight: bold;
  color: var(--gold-light);
  background: rgba(0,0,0,0.6);
  padding: 1px 5px;
  border-radius: 3px;
}

.card-tag {
  display: inline-block;
  font-size: 7px;
  padding: 1px 4px;
  border-radius: 3px;
  margin: 1px;
}

.tag-green { background: rgba(39,174,96,0.3); color: var(--green-light); }
.tag-brown { background: rgba(192,57,43,0.3); color: var(--red-light); }
.tag-neutral { background: rgba(149,165,166,0.3); color: #bdc3c7; }
.tag-instant { background: rgba(231,76,60,0.4); color: #e74c3c; font-weight: bold; }

/* ===== 手牌扇形布局 ===== */
#hand-area .card {
  margin-left: -40px;
  transform-origin: bottom center;
}

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

#hand-area .card:hover {
  transform: translateY(-18px) scale(1.12);
  z-index: 200;
}

/* ===== 弹窗模态框 ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-secondary);
  border: 2px solid var(--gold);
  border-radius: var(--border-radius);
  padding: 20px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 24px var(--gold-glow);
}

.modal h3 {
  color: var(--gold-light);
  font-size: 18px;
  margin-bottom: 12px;
  text-align: center;
}

.modal .card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover { color: var(--gold-light); }

/* ===== 日志区 ===== */
#log-area {
  position: fixed;
  bottom: 190px;
  right: 8px;
  width: 250px;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  padding: 6px;
  font-size: 10px;
  color: var(--text-dim);
  z-index: 50;
  pointer-events: none;
}

#log-area .log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#log-area .log-entry.highlight {
  color: var(--gold-light);
}

/* ===== 动画效果 ===== */
@keyframes cardPlay {
  0% { transform: scale(1.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes cardDeal {
  0% { transform: translateY(-40px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px var(--gold-glow); }
  50% { box-shadow: 0 0 20px var(--gold-glow); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.card-playing {
  animation: cardPlay 0.4s ease-out;
}

.card-dealing {
  animation: cardDeal 0.3s ease-out;
}

.card-selected {
  transform: translateY(-15px) scale(1.1) !important;
  box-shadow: 0 0 16px var(--gold-glow) !important;
  border-color: var(--gold-light) !important;
  z-index: 101;
}

.pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ===== 消息提示 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  z-index: 2000;
  animation: toastIn 0.3s ease-out;
  pointer-events: none;
}

.toast.info {
  background: rgba(41,128,185,0.9);
  color: white;
}

.toast.success {
  background: rgba(39,174,96,0.9);
  color: white;
}

.toast.warning {
  background: rgba(230,126,34,0.9);
  color: white;
}

.toast.error {
  background: rgba(192,57,43,0.9);
  color: white;
}

@keyframes toastIn {
  0% { transform: translateX(-50%) translateY(-30px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ===== 结算动画面板 ===== */
.settlement-panel {
  background: rgba(0,0,0,0.85);
  border: 2px solid var(--gold);
  border-radius: var(--border-radius);
  padding: 16px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1500;
  min-width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}

.settlement-panel h3 {
  color: var(--gold-light);
  text-align: center;
  margin-bottom: 10px;
}

.settlement-panel .step {
  padding: 4px 0;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.settlement-panel .step .label { color: var(--text-secondary); }
.settlement-panel .step .val { color: var(--gold-light); font-weight: bold; }

/* ===== 游戏结束面板 ===== */
.game-over-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.game-over-panel h1 {
  font-size: 48px;
  color: var(--gold-light);
  text-shadow: 0 0 20px var(--gold-glow);
  margin-bottom: 20px;
}

.game-over-panel .rankings {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 24px;
  text-align: center;
  line-height: 2;
}

.game-over-panel button {
  padding: 12px 32px;
  font-size: 16px;
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  border: none;
  border-radius: 8px;
  color: var(--bg-primary);
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
}

.game-over-panel button:hover {
  box-shadow: 0 0 20px var(--gold-glow);
  transform: scale(1.05);
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
  #game-container {
    grid-template-columns: 220px 1fr 220px;
  }
  .card { width: 80px; height: 112px; }
  #hand-area .card { margin-left: -32px; }
  .card-name { font-size: 9px; }
  .card-effect { font-size: 7px; }
}
