/* 六博 · 界面样式（木色古风）
   布局：整页左右两栏——左「棋盘」尽量占满，右「标题+模式+信息+日志」侧栏。
   棋盘保持方形并按可用空间缩放；窄屏自动回退为上下布局。 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: linear-gradient(160deg, #b98d5a, #8a6a3b);
  height: 100dvh;
  overflow: hidden;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
  color: #3a2a12;
}

/* ===== 左右两栏骨架 ===== */
#wrap {
  width: 100%;
  max-width: 1500px;
  height: 100dvh;
  margin: 0 auto;
  padding: 10px 12px 14px;
  display: flex;
  gap: 12px;
}

/* 左：棋盘区 */
#board-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
canvas#board {
  background: #e8c98f; border: 5px solid #5a4020; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  /* 按可用宽高等比缩放（保持方形），永不超出容器、永不裁切 */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
}

/* 右：侧栏（标题 + 模式面板 + 信息栏 + 日志） */
#side-col {
  width: 320px;
  flex: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

header { text-align: center; flex: none; }
header h1 {
  font-size: 24px; color: #f7ecd8; text-shadow: 0 2px 6px rgba(0,0,0,.35);
  letter-spacing: 4px; line-height: 1.3;
}
header .sub { font-size: 11px; letter-spacing: 1px; color: #eed9b0; display: block; margin-top: 2px; }

#mode-panel {
  background: #f3e3c0; border: 3px solid #8a6a3b; border-radius: 12px;
  padding: 10px 12px; text-align: center; flex: none;
}
#mode-panel .intro { font-size: 13px; line-height: 1.55; margin-bottom: 10px; }
#mode-panel code { background: #e6d2a8; padding: 1px 5px; border-radius: 4px; }

#first-panel {
  background: #f3e3c0; border: 3px solid #8a6a3b; border-radius: 12px;
  padding: 10px 12px; text-align: center; font-size: 16px; flex: none;
}

aside#side {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}
#info {
  background: #f3e3c0; border: 3px solid #8a6a3b; border-radius: 10px;
  padding: 8px 12px; font-size: 14px; line-height: 1.5;
}
#turn { font-size: 18px; font-weight: bold; color: #5a2a12; }
#dice {
  background: #f3e3c0; border: 3px solid #8a6a3b; border-radius: 10px;
  padding: 8px 12px; min-height: 76px;
}
.dice-row { display: flex; gap: 8px; justify-content: center; }
.zhu {
  width: 24px; height: 42px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 16px; font-weight: bold;
}
.zhu.one { background: #f2ead8; color: #5a4020; border: 2px solid #8a6a3b; }
.zhu.zero { background: #8a6a3b; color: #f2ead8; border: 2px solid #5a4020; }
.points { text-align: center; margin-top: 6px; font-size: 14px; color: #5a2a12; min-height: 20px; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
button {
  font-family: inherit; font-size: 14px; cursor: pointer;
  background: #f7ecd8; color: #3a2a12;
  border: 2px solid #5a4020; border-radius: 8px;
  padding: 6px 12px; transition: background .15s, transform .05s;
}
button:hover:not(:disabled) { background: #e6d2a8; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.hist { background: #c0392b; color: #f7ecd8; border-color: #7a1f14; }
button.hist:hover { background: #a93226; }
button.flip { background: #7a1f14; color: #ffd9a0; border-color: #4a0d08; font-weight: bold; }
button.flip:hover:not(:disabled) { background: #5a120c; }

#log {
  background: rgba(58,42,18,.85); color: #f3e3c0; border-radius: 10px;
  padding: 10px 12px; font-size: 13px; line-height: 1.5;
  flex: 1; min-height: 80px; overflow-y: auto;
}
.log-line { border-bottom: 1px dashed rgba(243,227,192,.25); padding: 2px 0; }
.log-line.good { color: #9fe0b0; }
.log-line.boom { color: #ffb4a0; font-weight: bold; }
.log-line.info { color: #ffd97a; }
.log-line.dim { color: #cbb48a; }

#banner {
  position: fixed; inset: 0; background: rgba(30,20,5,.65);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
#banner[hidden] { display: none; }
#banner-box {
  background: #f3e3c0; border: 4px solid #c0392b; border-radius: 16px;
  max-width: 560px; padding: 30px 36px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#banner-box h2 { font-size: 30px; color: #7a1f14; margin-bottom: 12px; }
#banner-box p { font-size: 16px; color: #5a4020; margin-bottom: 18px; line-height: 1.6; }

#modal {
  position: fixed; inset: 0; background: rgba(30,20,5,.6);
  display: flex; align-items: center; justify-content: center; z-index: 30;
}
#modal[hidden] { display: none; }
#modal-box {
  background: #f3e3c0; border: 4px solid #8a6a3b; border-radius: 16px;
  max-width: 620px; max-height: 86vh; overflow-y: auto;
  padding: 24px 30px; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
#modal-box h2 { text-align: center; color: #5a2a12; margin-bottom: 12px; }
#modal-box p { font-size: 15px; line-height: 1.8; margin-bottom: 10px; }
#modal-box p.tail { color: #7a6a4a; font-size: 14px; }
#modal-box button { display: block; margin: 8px auto 0; }

/* 中等宽度：侧栏收窄，给棋盘让出更多空间 */
@media (max-width: 820px) {
  #side-col { width: 260px; }
}

/* 真·手机竖屏：才回退为上下布局 + 允许滚动 */
@media (max-width: 560px) {
  body { overflow: auto; height: auto; min-height: 100dvh; }
  #wrap { height: auto; flex-direction: column; }
  #board-col { flex: none; }
  canvas#board { max-width: 96vw; }
  #side-col { width: 100%; overflow: visible; }
  header h1 { font-size: 26px; letter-spacing: 6px; }
  #log { height: 180px; }
}
