* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  background: #2b2320;
  color: #f0e6d6;
  font-family: "KaiTi", "STKaiti", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #3a2f2a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  z-index: 5;
  flex-wrap: wrap;
}

h1 {
  font-size: 22px;
  letter-spacing: 4px;
  color: #f0d9a4;
}

.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: #555;
  white-space: nowrap;
}
.badge.r { background: #8c2f28; color: #ffe3d8; }
.badge.b { background: #3d3d3d; color: #e8e8e8; }

.you {
  font-size: 12px;
  color: #c9b89a;
  white-space: nowrap;
}

.clock {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: #4a3b32;
  color: #f0d9a4;
  white-space: nowrap;
}
.clock.danger {
  background: #8c2f28;
  color: #fff;
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: 0.55; } }

.btns { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: #b5893f;
  color: #2a1f14;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}
button:active { filter: brightness(0.9); }
button.big { width: 100%; padding: 12px; font-size: 17px; margin-top: 10px; }
button.ghost {
  background: transparent;
  color: #c9b89a;
  border: 1px solid #6b5335;
}
button.danger-btn { background: #8c2f28; color: #ffe3d8; }

/* ---------- 主区 ---------- */
main {
  position: relative;
  flex: 1;
  min-height: 0;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

#boardWrap { position: absolute; inset: 0; }
#board {
  position: absolute;
  inset: 0;
  touch-action: manipulation;
}

.home-card {
  background: #3a2f2a;
  border: 1px solid #6b5335;
  border-radius: 14px;
  padding: 26px 22px;
  width: 100%;
  max-width: 380px;
}

.home-card h2 {
  text-align: center;
  color: #f0d9a4;
  font-size: 22px;
  letter-spacing: 3px;
  margin-bottom: 10px;
}

.home-sub {
  text-align: center;
  font-size: 13px;
  color: #c9b89a;
  line-height: 1.7;
  margin-bottom: 8px;
}

.form-block {
  border-top: 1px solid #4a3b32;
  padding-top: 12px;
  margin-top: 12px;
}
.form-block h3 {
  font-size: 15px;
  color: #f0d9a4;
  margin-bottom: 8px;
}
.form-block label {
  display: block;
  font-size: 13px;
  color: #c9b89a;
  margin-bottom: 8px;
}
.form-block select,
.form-block input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #6b5335;
  background: #2b2320;
  color: #f0e6d6;
  font-family: inherit;
  font-size: 15px;
}
.form-block input { letter-spacing: 4px; text-transform: uppercase; }

.room-code {
  text-align: center;
  font-size: 44px;
  letter-spacing: 10px;
  color: #f0d9a4;
  font-weight: bold;
  margin: 18px 0;
  user-select: all;
}

#toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  max-width: 86%;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(20, 14, 10, 0.88);
  color: #ffe9b8;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 6;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 战利品 / 战报 ---------- */
#trays {
  padding: 6px 12px 8px;
  background: #3a2f2a;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tray-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}

.tray-label {
  flex: none;
  font-size: 13px;
  width: 72px;
}
.tray-label.r { color: #ff9d90; }
.tray-label.b { color: #d0d0d0; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow: hidden;
  max-height: 52px;
}

.chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: #f6e7c6;
  border: 1px solid #8a6a3a;
}
.chip.r { color: #b3211c; }
.chip.b { color: #1c1c1c; }

.empty { color: #8a7a68; font-size: 12px; }

#logPanel {
  background: #3a2f2a;
  border-top: 1px solid #4a3b32;
  padding: 4px 12px 8px;
  max-height: 120px;
  overflow-y: auto;
}
#logPanel summary {
  font-size: 13px;
  color: #c9b89a;
  cursor: pointer;
}
#logPanel ol {
  margin: 6px 0 0 20px;
  font-size: 12px;
  color: #d8cbb2;
  line-height: 1.7;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}
.modal.hidden { display: none; }

.card {
  background: #4a3b32;
  border: 1px solid #6b5335;
  border-radius: 12px;
  padding: 20px 22px;
  max-width: 420px;
  width: 100%;
  max-height: 84vh;
  overflow-y: auto;
}

.card h2 {
  font-size: 20px;
  color: #f0d9a4;
  margin-bottom: 12px;
  letter-spacing: 2px;
  text-align: center;
}

.card ol {
  margin: 0 0 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  line-height: 1.55;
}

.card .tip {
  font-size: 13px;
  color: #c9b89a;
  margin-bottom: 14px;
}

.card p { margin-bottom: 14px; font-size: 15px; line-height: 1.6; text-align: center; }

.card button { width: 100%; padding: 10px; font-size: 16px; }
