/* 全局样式：让画布与左右侧栏并排 */
html, body {
  margin: 0;
  padding: 0;
  background: #2b2b2b;
  min-height: 100vh;
  overflow: auto; /* 内容超出时显示滚动条，而不是居中裁切 */
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  display: flex;
  justify-content: center;     /* 水平居中 */
  align-items: center;         /* 垂直居中：内容在视口中整体上下左右居中 */
}

:root {
  --title-bar-h: 50px;   /* 顶部工具栏与左右侧栏标题栏统一高度 */
  --brand-bg: #1a1a2e;   /* 深蓝品牌背景 */
}

#app {
  display: flex;
  flex-direction: row;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  width: 100%;
  height: 100vh;
  min-height: 768px;
  max-width: 100%;
}

#game {
  line-height: 0; /* 消除 canvas 底部缝隙 */
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f4f1e8;
  position: relative; /* 让 #beginner-guide 等 absolute 子元素以游戏区为定位基准 */
}

/* 顶部工具栏（HTML 覆盖层：信息 + 控件） */
#game-toolbar {
  line-height: normal;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--title-bar-h);
  box-sizing: border-box;
  padding: 0 14px;
  background: var(--brand-bg);  /* 深蓝色，与左右标题栏一致 */
  color: #ffd54f;
  font-size: 14px;
}

#game-info {
  flex: 1 1 auto;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game-tools {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  color: #1a1a2e;
  background: #ffd54f;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.tool-btn:hover { background: #ffe08a; }

/* Phaser 画布容器（FIT 缩放，居中） */
#game-canvas {
  line-height: 0;
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f1e8;
}
#game-canvas canvas { display: block; }

/* 抽屉开关（默认隐藏，仅窄屏显示） */
.drawer-toggle {
  display: none;
  position: fixed;
  top: 8px;
  z-index: 1200;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: #1a1a2e;
  color: #ffd54f;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.drawer-toggle.left { left: 8px; }
.drawer-toggle.right { right: 8px; }

/* 窄屏：侧栏变为可收起抽屉 */
body.narrow #knowledge-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1150;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
}
body.narrow #knowledge-panel.open { transform: translateX(0); }

body.narrow #coach-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 1150;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}
body.narrow #coach-panel.open { transform: translateX(0); }

body.narrow .drawer-toggle { display: block; }

/* 窄屏：取消固定最小高度，改用动态视口高度，避免地址栏/工具栏导致 100vh 偏大、按钮被裁切 */
body.narrow {
  overflow: hidden;            /* 禁止页面滚动，由 Phaser FIT 自适应缩放 */
}
body.narrow #app {
  height: 100dvh;              /* 动态视口高度 */
  min-height: 0;               /* 取消 768px 最小高度 */
}

/* 教练边栏：最新一条讲解高亮 */
#coach-lines .line.latest {
  background: #fff8dd;
  border-left: 3px solid #b8860b;
  padding-left: 8px;
  border-radius: 3px;
}

/* 知识弹窗 z-index 提升，使「本局知识点回顾」能盖在结算弹框之上 */
#knowledge-modal { z-index: 1100; }

/* 本局知识点回顾页 */
.kb-review { padding: 4px 0; }
.kb-review p { margin: 0 0 14px; color: #555; }
.kb-review .kb-item {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 10px;
  padding: 10px 12px;
  font-size: 15px;
  color: #1a1a2e;
  background: #fff;
  border: 1px solid #d4c9a8;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.kb-review .kb-item:hover {
  background: #fff8dd;
  border-color: #b8860b;
}

/* 左侧知识侧栏 */
#knowledge-panel {
  width: 220px;
  background: #f8f5ec;
  border-right: 1px solid #d4c9a8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100%;
  max-height: none;
}

#knowledge-panel h3,
#coach-panel h3 {
  margin: 0;
  height: var(--title-bar-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--brand-bg);
  color: #ffd54f;
  font-size: 16px;
  font-weight: bold;
}

#knowledge-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.knowledge-btn {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 8px;
  font-size: 14px;
  color: #1a1a2e;
  background: #ffffff;
  border: 1px solid #d4c9a8;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.knowledge-btn:hover {
  background: #fff8dd;
  border-color: #b8860b;
}

/* 右侧教学提示边栏 */
#coach-panel {
  width: 280px;
  background: #f8f5ec;
  border-left: 1px solid #d4c9a8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100%;
  max-height: none;
}

/* 右侧教学提示标题栏样式见上方与左侧合并的规则 */

/* 教学提示区置顶声明条：固定置顶，不随讲解滚动 */
#coach-disclaimer {
  flex: 0 0 auto;
  margin: 10px 12px 0;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #6b5a2e;
  background: linear-gradient(180deg, #fff8dd 0%, #fdf0c9 100%);
  border: 1px solid #e3c878;
  border-left: 4px solid #b8860b;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#coach-disclaimer strong { color: #1a1a2e; }
#coach-disclaimer .cd-emoji { font-weight: bold; margin-right: 2px; }

#coach-lines {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #4a3b18;
}

#coach-lines .line {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #d4c9a8;
}

#coach-lines .line:last-child {
  border-bottom: none;
}

#coach-lines .line.system {
  color: #8c7b50;
}

#coach-lines .line.coach {
  color: #b8860b;
}

#coach-lines .line.error {
  color: #c0392b;
}

/* 知识点弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #ffffff;
  width: 900px;
  max-width: 95vw;
  max-height: 85vh;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #1a1a2e;
  color: #ffd54f;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

#modal-close {
  background: transparent;
  border: none;
  color: #ffd54f;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
}

#modal-close:hover {
  color: #ffffff;
}

#modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.8;
  color: #333;
}

#modal-body table {
  font-size: 14px;
}

#modal-body p,
#modal-body ul,
#modal-body ol {
  margin-top: 0;
  margin-bottom: 12px;
}

#modal-body li {
  margin-bottom: 8px;
}

#modal-body .formula {
  font-size: 18px;
  font-weight: bold;
  padding: 12px 16px;
  background: #f4f1e8;
  border-radius: 8px;
  margin: 12px 0;
  text-align: center;
  color: #1a1a2e;
}

/* 位积分计算器 */
#score-calc {
  margin-top: 8px;
}

.calc-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 14px 0;
  padding: 10px 14px;
  background: #f8f5ec;
  border-radius: 8px;
}

.calc-toolbar label {
  font-weight: bold;
  color: #1a1a2e;
}

.calc-toolbar select {
  margin-left: 8px;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #d4c9a8;
  border-radius: 6px;
  background: #fff;
}

.calc-error {
  color: #c0392b;
  font-size: 14px;
  font-weight: bold;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 8px;
}

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

.calc-table th {
  background: #1a1a2e;
  color: #ffd54f;
  font-weight: bold;
}

.calc-table input[type="number"] {
  width: 60px;
  padding: 6px 4px;
  font-size: 14px;
  text-align: center;
  border: 1px solid #d4c9a8;
  border-radius: 6px;
}

.calc-table select {
  padding: 6px 4px;
  font-size: 14px;
  border: 1px solid #d4c9a8;
  border-radius: 6px;
  background: #fff;
}

.calc-table td.calc-op {
  text-align: right;
  white-space: nowrap;
}

.calc-table td.calc-op .op {
  color: #c0392b;
  margin-left: 2px;
}

.calc-table td.calc-wi {
  text-align: left;
}

.calc-wi b {
  color: #1a1a2e;
  font-size: 16px;
}

#calc-team-scores {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding: 14px;
  background: #f4f1e8;
  border-radius: 8px;
  justify-content: center;
}

.team-score {
  font-size: 16px;
  font-weight: bold;
  color: #1a1a2e;
}

.team-score.ns {
  color: #2e8b57;
}

.team-score.ew {
  color: #c0392b;
}

/* 结算弹框底部按钮栏 */
.modal-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 16px 22px 22px;
}

.btn {
  padding: 12px 30px;
  font-size: 17px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: #1a1a2e;
  color: #ffd54f;
}

.btn-primary:hover {
  background: #16213e;
}

.btn-secondary {
  background: #f4f1e8;
  color: #1a1a2e;
  border: 1px solid #d4c9a8;
}

.btn-secondary:hover {
  background: #ece6d4;
}

