* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a2a3a; color: #fff;
  touch-action: manipulation;
  user-select: none;
}

#app {
  width: 100vw; height: 100vh;
  display: flex; flex-direction: column;
  background: #1a2a3a;
  max-width: 500px; margin: 0 auto; /* 手机居中 */
}

/* ===== 大厅 ===== */
#lobby {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 20px;
}
#lobby h1 { font-size: 2rem; margin-bottom: 20px; color: #f1c40f; }
.lobby-box {
  background: #2c3e50; padding: 25px; border-radius: 16px;
  display: flex; flex-direction: column; gap: 12px; width: 100%;
}
.lobby-box input, .lobby-box button {
  padding: 14px; font-size: 16px; border-radius: 10px; border: none;
  width: 100%;
}
.lobby-box button { background: #f1c40f; color: #000; font-weight: bold; cursor: pointer; }
.lobby-box button:active { transform: scale(0.97); }

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

/* 顶栏 */
#top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; background: #2c3e50;
  border-bottom: 2px solid #f1c40f;
  flex-shrink: 0; font-size: 13px; min-height: 40px;
}
#top-bar button {
  background: #e74c3c; color: #fff; border: none;
  padding: 4px 12px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
#turnInfo { color: #f1c40f; font-weight: bold; }

/* ===== 环绕式棋盘 ===== */
#board-wrapper {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 6px;
  background: #1a2a3a;
}

#boardContainer {
  width: 100%; height: 100%;
  max-width: 460px; max-height: 460px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  background: #2c3e50;
  border-radius: 8px;
  padding: 2px;
}

/* 30个格子的位置（环绕式：外圈顺时针） */
.cell {
  background: #3d566e; border-radius: 4px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  font-size: 8px; text-align: center;
  cursor: pointer; position: relative;
  overflow: hidden;
  padding: 1px;
  transition: 0.15s;
  min-height: 0;
  line-height: 1.2;
}
.cell:active { transform: scale(0.95); }

/* 格子类型颜色 */
.cell.start { background: #27ae60; }
.cell.property { background: #2980b9; }
.cell.fate { background: #8e44ad; }
.cell.chance { background: #d35400; }
.cell.tax { background: #c0392b; }
.cell.jail { background: #7f8c8d; }
.cell.parking { background: #2ecc71; }

.cell .cell-name { font-weight: bold; font-size: 9px; }
.cell .cell-price { font-size: 7px; color: #f1c40f; }
.cell .owner-info { font-size: 6px; color: #2ecc71; }
.cell .players-on {
  position: absolute; top: 1px; right: 1px;
  font-size: 7px; background: rgba(0,0,0,0.6);
  border-radius: 8px; padding: 0 3px;
}

/* 每个格子放在网格的哪一行哪一列（8x8网格，外圈顺时针） */
/* 0:起点(顶部中间) */ .cell[data-index="0"] { grid-column: 4 / 6; grid-row: 1 / 2; }
/* 顶部行（左→右） */ 
.cell[data-index="1"] { grid-column: 6 / 7; grid-row: 1 / 2; }
.cell[data-index="2"] { grid-column: 7 / 8; grid-row: 1 / 2; }
.cell[data-index="3"] { grid-column: 8 / 9; grid-row: 1 / 2; }
.cell[data-index="4"] { grid-column: 8 / 9; grid-row: 2 / 3; }
/* 右侧列（上→下） */
.cell[data-index="5"] { grid-column: 8 / 9; grid-row: 3 / 4; }
.cell[data-index="6"] { grid-column: 8 / 9; grid-row: 4 / 5; }
.cell[data-index="7"] { grid-column: 8 / 9; grid-row: 5 / 6; }
.cell[data-index="8"] { grid-column: 8 / 9; grid-row: 6 / 7; }
.cell[data-index="9"] { grid-column: 8 / 9; grid-row: 7 / 8; }
/* 底部行（右→左） */
.cell[data-index="10"] { grid-column: 7 / 8; grid-row: 8 / 9; }
.cell[data-index="11"] { grid-column: 6 / 7; grid-row: 8 / 9; }
.cell[data-index="12"] { grid-column: 5 / 6; grid-row: 8 / 9; }
.cell[data-index="13"] { grid-column: 4 / 5; grid-row: 8 / 9; }
.cell[data-index="14"] { grid-column: 3 / 4; grid-row: 8 / 9; }
.cell[data-index="15"] { grid-column: 2 / 3; grid-row: 8 / 9; }
.cell[data-index="16"] { grid-column: 1 / 2; grid-row: 8 / 9; }
/* 左侧列（下→上） */
.cell[data-index="17"] { grid-column: 1 / 2; grid-row: 7 / 8; }
.cell[data-index="18"] { grid-column: 1 / 2; grid-row: 6 / 7; }
.cell[data-index="19"] { grid-column: 1 / 2; grid-row: 5 / 6; }
.cell[data-index="20"] { grid-column: 1 / 2; grid-row: 4 / 5; }
.cell[data-index="21"] { grid-column: 1 / 2; grid-row: 3 / 4; }
.cell[data-index="22"] { grid-column: 1 / 2; grid-row: 2 / 3; }
/* 顶部行继续（左→右） */
.cell[data-index="23"] { grid-column: 2 / 3; grid-row: 1 / 2; }
.cell[data-index="24"] { grid-column: 3 / 4; grid-row: 1 / 2; }
/* 中间剩余格子放在内部区域（4x4中心） */
.cell[data-index="25"] { grid-column: 3 / 4; grid-row: 3 / 4; }
.cell[data-index="26"] { grid-column: 4 / 5; grid-row: 3 / 4; }
.cell[data-index="27"] { grid-column: 5 / 6; grid-row: 3 / 4; }
.cell[data-index="28"] { grid-column: 6 / 7; grid-row: 3 / 4; }
.cell[data-index="29"] { grid-column: 3 / 4; grid-row: 4 / 5; }

/* ===== 底部面板 ===== */
#bottom-panel {
  flex-shrink: 0;
  background: #2c3e50;
  padding: 6px 10px 10px 10px;
  display: flex; flex-direction: column;
  gap: 6px;
  border-top: 2px solid #f1c40f;
  max-height: 45vh;
}

/* 玩家信息 */
#playersInfo {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px 0;
}
.player-card {
  background: #3d566e; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; display: flex; align-items: center; gap: 6px;
}
.player-card .name { font-weight: bold; }
.player-card .money { color: #2ecc71; }
.player-card.bankrupt { opacity: 0.4; text-decoration: line-through; }

/* 操作按钮 */
#actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
#actions button {
  flex: 1; padding: 10px 8px; font-size: 15px;
  border: none; border-radius: 10px; cursor: pointer;
  font-weight: bold; min-height: 44px;
}
#rollBtn { background: #f1c40f; color: #000; }
#rollBtn:disabled { background: #7f8c8d; cursor: not-allowed; }
#addAIBtn { background: #2ecc71; color: #000; }
#startGameBtn { background: #e67e22; color: #fff; }
#voiceToggleBtn { background: #3498db; color: #fff; flex: 0.3; }
#voiceToggleBtn.on { background: #e74c3c; }

/* 聊天+日志 Tab */
#chatLogPanel {
  background: #1a2a3a; border-radius: 8px;
  display: flex; flex-direction: column;
  max-height: 160px;
}
.tab-bar {
  display: flex; gap: 0; flex-shrink: 0;
}
.tab-bar .tab {
  flex: 1; text-align: center; padding: 4px 0;
  font-size: 12px; cursor: pointer;
  background: #2c3e50; color: #8899aa;
  border-radius: 6px 6px 0 0;
}
.tab-bar .tab.active { background: #1a2a3a; color: #f1c40f; }
.tab-content { display: none; flex: 1; overflow-y: auto; padding: 4px 6px; font-size: 11px; max-height: 80px; }
.tab-content.active { display: block; }
.tab-content div { border-bottom: 1px solid #2c3e50; padding: 2px 0; }

#chatInputArea {
  display: flex; gap: 4px; flex-shrink: 0; padding: 4px 0;
}
#chatInput { flex: 1; padding: 6px 10px; font-size: 13px; border-radius: 6px; border: none; }
#emojiBtn, #sendChatBtn {
  padding: 6px 12px; font-size: 16px; border: none; border-radius: 6px;
  cursor: pointer; background: #f1c40f; color: #000;
}
#emojiPicker {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 4px; background: #2c3e50; border-radius: 6px;
}
#emojiPicker .emoji { cursor: pointer; font-size: 20px; padding: 2px; }

/* ===== 模态框 ===== */
.modal {
  display: none; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  justify-content: center; align-items: center;
  z-index: 1000;
}
.modal-content {
  background: #2c3e50; padding: 25px; border-radius: 16px;
  text-align: center; max-width: 90%; width: 360px;
}
.modal-content h2 { color: #f1c40f; margin-bottom: 12px; }
.modal-content p { font-size: 17px; margin: 12px 0; }
.modal-content button {
  padding: 10px 28px; margin: 4px; border: none; border-radius: 8px;
  font-size: 16px; cursor: pointer; min-height: 40px;
}
#cardConfirm, #actionYes { background: #2ecc71; color: #000; }
#actionNo, #cellDetailClose { background: #e74c3c; color: #fff; }