* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Microsoft YaHei', sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}
button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  transition: all 0.2s;
}
button:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}
button:active {
  transform: scale(0.96);
}
input,
select {
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  background: #2a2a3e;
  color: #eee;
  outline: none;
  border: 1px solid #444;
}
input:focus,
select:focus {
  border-color: #6c63ff;
}

/* 桌面端：左右布局 */
.container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  padding: 12px;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
}

/* 地图区域 */
.map-section {
  background: #16213e;
  border-radius: 12px;
  padding: 12px;
}
.map-section h2 {
  text-align: center;
  margin-bottom: 8px;
  color: #6c63ff;
  font-size: 20px;
}

.board {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  max-width: 850px;
  margin: 0 auto;
}

.cell {
  background: #1e2a3a;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  position: relative;
  font-size: 9px;
  text-align: center;
  overflow: hidden;
  border: 1px solid #2a3a4a;
  min-height: 0;
}
.cell.start {
  background: #4a3500;
  border-color: #ffd700;
}
.cell.property {
  background: #1a2e3a;
}
.cell.chance {
  background: #2a4010;
  border-color: #4caf50;
}
.cell.fate {
  background: #3a1515;
  border-color: #f44336;
}
.cell .cell-name {
  font-size: 9px;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell .cell-price {
  font-size: 7px;
  color: #aaa;
}
.cell .cell-owner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}
.cell .cell-index {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 6px;
  color: #555;
}
.cell .player-dots {
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: absolute;
  top: 8px;
}
.cell .player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #fff;
}

/* 占位格子 */
.cell.empty {
  background: transparent;
  border: none;
}

/* 右侧面板 */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: #16213e;
  border-radius: 12px;
  padding: 14px;
}
.panel h3 {
  font-size: 15px;
  margin-bottom: 10px;
  color: #6c63ff;
  border-bottom: 1px solid #2a2a4a;
  padding-bottom: 6px;
}

/* 设置面板 */
.setup-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-setup-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.player-setup-row input {
  flex: 1;
  min-width: 0;
}
.player-setup-row input[type="color"] {
  width: 36px;
  padding: 2px;
  height: 32px;
}
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.btn-add {
  background: #4caf50;
  color: #fff;
}
.btn-remove {
  background: #f44336;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
}
.btn-start {
  background: #6c63ff;
  color: #fff;
  width: 100%;
  padding: 10px;
  font-size: 16px;
  margin-top: 6px;
}
.btn-custom-map {
  background: #ff9800;
  color: #fff;
  width: 100%;
  margin-top: 4px;
}

.custom-map-area {
  display: none;
  margin-top: 8px;
}
.custom-map-area textarea {
  width: 100%;
  height: 80px;
  background: #1a1a2e;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  resize: vertical;
}
.custom-map-area .btn-apply {
  background: #4caf50;
  color: #fff;
  width: 100%;
  margin-top: 4px;
}

/* 玩家信息卡 */
.player-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-card {
  background: #1e2a3a;
  border-radius: 8px;
  padding: 10px;
  border-left: 4px solid;
}
.player-card.active {
  background: #1a2540;
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.3);
}
.player-card .pc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.player-card .pc-name {
  font-weight: bold;
  font-size: 14px;
}
.player-card .pc-funds {
  font-size: 16px;
  color: #ffd700;
  font-weight: bold;
}
.player-card .pc-info {
  font-size: 11px;
  color: #aaa;
  margin-top: 4px;
}
.player-card .pc-props {
  font-size: 10px;
  color: #4caf50;
  margin-top: 2px;
  max-height: 40px;
  overflow-y: auto;
}

/* 操作面板 */
.action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.action-row label {
  font-size: 12px;
  white-space: nowrap;
  min-width: 40px;
  color: #aaa;
}
.action-row input,
.action-row select {
  flex: 1;
  min-width: 0;
}
.btn-move {
  background: #2196f3;
  color: #fff;
  min-width: 60px;
}
.btn-teleport {
  background: #9c27b0;
  color: #fff;
  min-width: 60px;
}
.btn-funds {
  background: #ff9800;
  color: #fff;
  min-width: 60px;
}
.btn-buy {
  background: #4caf50;
  color: #fff;
  width: 100%;
  padding: 10px;
}
.btn-buy:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-next {
  background: #6c63ff;
  color: #fff;
  width: 100%;
  padding: 10px;
  font-size: 16px;
}
.btn-undo {
  background: #f44336;
  color: #fff;
  width: 100%;
  padding: 8px;
  margin-top: 6px;
}

/* 日志 */
.log-panel {
  flex: 1;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}
.log-list {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  max-height: 250px;
}
.log-item {
  padding: 3px 6px;
  border-bottom: 1px solid #2a2a3a;
}
.log-item .log-time {
  color: #666;
  margin-right: 6px;
}
.log-item.move {
  color: #64b5f6;
}
.log-item.rent {
  color: #ef5350;
}
.log-item.buy {
  color: #66bb6a;
}
.log-item.funds {
  color: #ffa726;
}
.log-item.turn {
  color: #ce93d8;
}
.log-item.undo {
  color: #bdbdbd;
}
.log-item.event {
  color: #ffd54f;
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal.show {
  display: flex;
}
.modal-content {
  background: #1e2a3a;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  max-width: 400px;
  margin: 0 16px;
}
.modal-content h3 {
  margin-bottom: 12px;
}
.modal-content .modal-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}
.modal-content .btn-confirm {
  background: #4caf50;
  color: #fff;
}
.modal-content .btn-cancel {
  background: #f44336;
  color: #fff;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #1a1a2e;
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

/* 设置/游戏面板切换 */
.setup-panel {
}
.game-panel {
  display: none;
}
.game-active .setup-panel {
  display: none;
}
.game-active .game-panel {
  display: flex;
}

/* ==================== 移动端响应式（屏幕宽度 ≤ 768px） ==================== */
@media (max-width: 768px) {
  .container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px;
  }

  .map-section {
    padding: 8px;
  }
  .map-section h2 {
    font-size: 16px;
    margin-bottom: 4px;
  }

  .board {
    max-width: 100%;
  }

  .cell .cell-name {
    font-size: 7px;
  }
  .cell .cell-price {
    font-size: 6px;
  }
  .cell .cell-index {
    font-size: 5px;
  }
  .cell .player-dot {
    width: 6px;
    height: 6px;
  }

  .side-panel {
    gap: 8px;
  }

  .panel {
    padding: 10px;
  }
  .panel h3 {
    font-size: 14px;
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .player-setup-row input {
    font-size: 13px;
    padding: 6px 8px;
  }

  .action-row {
    gap: 6px;
    margin-bottom: 6px;
  }
  .action-row label {
    font-size: 11px;
    min-width: 32px;
  }
  .action-row input,
  .action-row select {
    font-size: 13px;
    padding: 6px 8px;
  }
  button {
    font-size: 13px;
    padding: 8px 12px;
  }

  .btn-start,
  .btn-next {
    font-size: 15px;
  }

  .log-list {
    max-height: 150px;
  }
  .log-item {
    font-size: 10px;
  }

  .player-card .pc-name {
    font-size: 13px;
  }
  .player-card .pc-funds {
    font-size: 14px;
  }

  .modal-content {
    padding: 20px;
    max-width: 320px;
  }

  /* 游戏面板移动端：使玩家卡片横向排列以节省垂直空间 */
  .player-cards {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .player-card {
    flex: 1 1 45%;
    min-width: 130px;
  }
}