/* 全局样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #f59e0b;
  --bg: #f0f4f8;
  --text: #1e293b;
  --border: #cbd5e1;
  --success: #10b981;
  --danger: #ef4444;
  --card-bg: #ffffff;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 游戏容器 */
#game-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: auto;
}

/* 屏幕通用 */
.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
}

.hidden {
  display: none !important;
}

/* 开始界面 */
#start-screen {
  background: linear-gradient(135deg, #1e3a5f, #2563eb, #f59e0b);
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  color: white;
  z-index: 10;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#start-screen h1 {
  font-size: 4.5em;
  margin-bottom: 40px;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.1em;
}

.player-setup {
  background: rgba(255, 255, 255, 0.95);
  padding: 40px 50px;
  border-radius: 20px;
  text-align: center;
  color: var(--text);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.player-setup h2 {
  margin-bottom: 20px;
  font-size: 1.4em;
}

.hint {
  color: #64748b;
  font-size: 0.9em;
  margin: 10px 0 20px;
}

#player-count {
  padding: 10px 20px;
  font-size: 1.1em;
  border: 2px solid var(--border);
  border-radius: 10px;
  width: 200px;
  cursor: pointer;
  outline: none;
}

#player-count:focus {
  border-color: var(--primary);
}

/* 按钮基础 */
button {
  padding: 12px 28px;
  font-size: 1.05em;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  opacity: 0.6;
}

/* 游戏主界面 */
#game-screen {
  z-index: 5;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  overflow-y: auto;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* 棋盘区域 */
#board-area {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 60vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

#board-canvas {
  display: block;
}

/* 信息面板 */
#game-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* 玩家信息 */
#players-info {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.player-info {
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 10px;
  border-left: 5px solid #ccc;
  background: #f8fafc;
  transition: background 0.2s;
}

.player-info.active {
  background: #eff6ff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.player-info .player-name {
  font-weight: 700;
  font-size: 1em;
  margin-bottom: 4px;
}

.player-info .player-money {
  color: var(--success);
  font-weight: 600;
}

.player-info .player-detail {
  font-size: 0.85em;
  color: #64748b;
}

/* 骰子区域 */
#dice-area {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

#dice-container {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
}

.dice {
  width: 60px;
  height: 60px;
  background: white;
  border: 3px solid var(--primary);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.8em;
  color: var(--primary);
  transition: transform 0.15s;
  user-select: none;
}

.dice.rolling {
  animation: diceRoll 0.1s linear infinite;
}

@keyframes diceRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(10deg) scale(1.05); }
  50% { transform: rotate(0deg) scale(1); }
  75% { transform: rotate(-10deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

#roll-dice {
  width: 100%;
  padding: 10px;
  font-size: 1.1em;
  background: var(--secondary);
}

#roll-dice:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
}

/* 操作按钮 */
#action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-buy {
  background: var(--success);
}
.btn-buy:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-build {
  background: #8b5cf6;
}
.btn-build:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.3);
}

.btn-end {
  background: #64748b;
}

/* 消息框 */
#message-box {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 12px;
  flex: 1;
  min-height: 80px;
  max-height: 200px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  font-size: 0.88em;
  line-height: 1.6;
}

#message-box div {
  padding: 3px 0;
  border-bottom: 1px solid #f1f5f9;
}

#message-box div:last-child {
  border-bottom: none;
  color: var(--primary);
  font-weight: 600;
}

/* 卡牌弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#card-icon {
  font-size: 3em;
  margin-bottom: 12px;
}

#card-title {
  font-size: 1.3em;
  margin-bottom: 10px;
  color: var(--text);
}

#card-description {
  color: #64748b;
  margin-bottom: 24px;
  line-height: 1.6;
}

#card-ok {
  min-width: 120px;
}

/* 大屏幕：左右布局 */
@media (min-width: 900px) {
  #game-screen {
    flex-direction: row;
    overflow: hidden;
  }

  #board-area {
    flex: 1;
    aspect-ratio: auto;
    max-height: none;
    min-width: 0;
  }

  #game-info {
    width: 300px;
    min-width: 300px;
    overflow-y: auto;
  }
}

/* 小屏幕优化 */
@media (max-width: 500px) {
  #board-area {
    max-height: 50vh;
  }

  .dice {
    width: 50px;
    height: 50px;
    font-size: 2.2em;
  }

  button {
    padding: 10px 16px;
    font-size: 0.95em;
  }

  #start-screen h1 {
    font-size: 2.8em;
  }

  .player-setup {
    padding: 24px 20px;
  }
}
