:root {
  --bg-wood: #5c3a21;
  --bg-paper: #fdf3d7;
  --bg-paper-dark: #f2dfb3;
  --border-gold: #d49b27;
  --border-brown: #4a2810;
  --red-main: #d93829;
  --red-dark: #9e1f14;
  --blue-main: #2b6cb0;
  --green-main: #2f855a;
  --purple-main: #6b46c1;
  --gold-bright: #ffd54f;
  --text-dark: #3b2314;
  --shadow-retro: 0 4px 0 #3b2314;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Heiti SC", sans-serif;
  background: radial-gradient(circle at center, #7c4d2b 0%, #3d2210 100%);
  color: var(--text-dark);
  overflow: hidden;
}

/* 复古怀旧纹理背景 */
.wood-bg {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 2px, transparent 2px, transparent 12px),
    radial-gradient(circle at 50% 30%, #8c5832 0%, #422411 100%);
}

/* 顶部怀旧标题栏 */
.top-bar {
  height: 52px;
  background: linear-gradient(180deg, #6e1a12 0%, #4a100a 100%);
  border-bottom: 4px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: #fff8e7;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  z-index: 20;
  gap: 8px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-badge {
  background: var(--gold-bright);
  color: #5c130b;
  font-weight: 900;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 2px solid #3b2314;
  box-shadow: 0 2px 0 #3b2314;
  flex-shrink: 0;
}

.brand-title h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-shadow: 2px 2px 0 #2b0905;
  color: #ffe89e;
  white-space: nowrap;
}

.top-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.round-pill {
  background: rgba(0,0,0,0.4);
  border: 2px solid var(--border-gold);
  padding: 3px 10px;
  border-radius: 20px;
  color: #ffeba8;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

.retro-btn {
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
  border: 3px solid var(--border-brown);
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 14px;
  background: linear-gradient(180deg, #ffe58f 0%, #f5b82e 100%);
  color: #4a2508;
  box-shadow: 0 3px 0 #3b2314;
  transition: transform 0.1s, filter 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.retro-btn:hover:not(:disabled) {
  filter: brightness(1.07);
  transform: translateY(-1px);
}

.retro-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3b2314;
}

.retro-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.retro-btn.small {
  padding: 4px 10px;
  font-size: 12px;
  border-width: 2px;
}

.retro-btn.red {
  background: linear-gradient(180deg, #ff7866 0%, #d93829 100%);
  color: #fff;
  text-shadow: 1px 1px 0 #611109;
}

.retro-btn.green {
  background: linear-gradient(180deg, #68d391 0%, #2f855a 100%);
  color: #fff;
  text-shadow: 1px 1px 0 #14422a;
}

.retro-btn.blue {
  background: linear-gradient(180deg, #63b3ed 0%, #2b6cb0 100%);
  color: #fff;
  text-shadow: 1px 1px 0 #15385e;
}

/* 主游戏布局：左侧玩家1&3，中间巨幅11x9三国棋盘，右侧玩家2&4与日志 */
.main-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 235px 1fr 235px;
  gap: 10px;
  padding: 8px 10px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow: hidden;
}

/* 玩家信息卡片 */
.player-card {
  background: var(--bg-paper);
  border: 3px solid var(--border-brown);
  border-radius: 14px;
  padding: 10px;
  box-shadow: var(--shadow-retro);
  position: relative;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-card.active-turn {
  border-color: #ff3b1f;
  background: #fff9e6;
  box-shadow: 0 0 0 3px #ffd54f, 0 6px 14px rgba(0,0,0,0.45);
  transform: scale(1.01);
}

.player-card.bankrupt {
  filter: grayscale(0.95);
  opacity: 0.6;
}

.player-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-box {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  border: 3px solid var(--border-brown);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.player-turn-tag {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ff2e17;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 10px;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  animation: bounceTag 0.8s infinite alternate;
}

@keyframes bounceTag {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.player-meta {
  flex: 1;
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-name {
  font-size: 16px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: bold;
  color: #fff;
}

.player-skill {
  font-size: 11px;
  color: #6e4726;
  margin-top: 2px;
  line-height: 1.2;
}

.player-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  background: var(--bg-paper-dark);
  padding: 5px 6px;
  border-radius: 8px;
  border: 1.5px solid #c9ad79;
  font-size: 11.5px;
  font-weight: bold;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.stat-gold {
  color: #b85d00;
  font-size: 12.5px;
  font-weight: 900;
}

.player-cards-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}

.mini-card-pill {
  font-size: 11px;
  background: #fff;
  border: 1.5px solid #704214;
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: bold;
  transition: transform 0.1s, background 0.15s;
}

.mini-card-pill:hover {
  background: #ffe89e;
  transform: translateY(-1px);
}

.status-buffs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.buff-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #ffe0b2;
  border: 1px solid #b26a00;
  color: #663c00;
  font-weight: bold;
}

/* 棋盘容器（11列x9行，共36格巨幅三国版图） */
.board-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.board-grid {
  width: 100%;
  height: 100%;
  background: #422512;
  border: 4px solid var(--border-gold);
  border-radius: 16px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  gap: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.65), inset 0 0 15px rgba(0,0,0,0.6);
  position: relative;
}

/* 棋盘格子 */
.board-tile {
  background: var(--bg-paper);
  border: 2px solid var(--border-brown);
  border-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 3px;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.board-tile:hover {
  z-index: 5;
  transform: scale(1.03);
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}

.board-tile.tile-corner {
  background: linear-gradient(135deg, #fff5cc 0%, #f5d376 100%);
  border-width: 3px;
}

.board-tile.tile-event {
  background: linear-gradient(135deg, #fff0f5 0%, #ffd6e7 100%);
}

.board-tile.tile-card {
  background: linear-gradient(135deg, #e6fffa 0%, #b2f5ea 100%);
}

.board-tile.tile-tavern {
  background: linear-gradient(135deg, #fefcbf 0%, #fbd38d 100%);
}

.board-tile.tile-tax {
  background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
}

.board-tile.active-step {
  box-shadow: 0 0 0 3px #ff2e17, 0 0 16px #ffd54f !important;
  transform: scale(1.05);
  z-index: 6;
}

/* 城池所属主公颜色条 */
.tile-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 900;
  padding: 1px 2px;
  border-radius: 4px;
  background: rgba(0,0,0,0.08);
  white-space: nowrap;
  overflow: hidden;
}

.tile-region-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
  border: 1px solid rgba(0,0,0,0.45);
  flex-shrink: 0;
}

.tile-center-art {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.tile-icon {
  font-size: 16px;
  line-height: 1;
}

.tile-buildings {
  font-size: 9.5px;
  letter-spacing: -0.5px;
  margin-top: 1px;
  white-space: nowrap;
}

.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: bold;
  color: #5c3a21;
  background: rgba(255,255,255,0.65);
  border-radius: 4px;
  padding: 0 2px;
  white-space: nowrap;
}

/* 路障标记 */
.tile-roadblock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(217, 56, 41, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 8px;
  border: 2px solid #fff;
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* 站在格子上的Q版小棋子 */
.tile-tokens {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  display: flex;
  justify-content: center;
  gap: 2px;
  z-index: 10;
  pointer-events: none;
}

.board-token {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.6);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.board-token.current-token {
  transform: scale(1.22) translateY(-2px);
  border-color: #ffd54f;
  box-shadow: 0 0 0 2px #d93829, 0 4px 8px rgba(0,0,0,0.65);
  z-index: 12;
}

/* 棋盘中央控制台（9x7区域） */
.board-center {
  grid-column: 2 / 11;
  grid-row: 2 / 9;
  background: radial-gradient(circle at center, #fff8e1 0%, #f0d7a3 100%);
  border: 4px solid var(--border-gold);
  border-radius: 14px;
  box-shadow: inset 0 0 24px rgba(138, 82, 29, 0.35);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 16px;
  position: relative;
  overflow: hidden;
}

/* 中央四角中国风装饰纹 */
.center-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 130px;
  font-weight: 900;
  color: rgba(184, 122, 40, 0.08);
  pointer-events: none;
  z-index: 0;
}

.center-top-banner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(90deg, #781e14, #a82e1e, #781e14);
  color: #ffe89e;
  padding: 8px 12px;
  border-radius: 10px;
  border: 2.5px solid var(--border-gold);
  box-shadow: 0 3px 0 #3b2314;
}

.turn-hero-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.turn-hero-avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 50%;
  border: 2.5px solid var(--gold-bright);
  overflow: hidden;
}

.turn-hero-text h2 {
  margin: 0;
  font-size: 16px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.turn-hero-text p {
  margin: 2px 0 0 0;
  font-size: 11.5px;
  color: #ffd591;
}

/* 中央舞台：骰子与互动区 */
.center-stage-area {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.region-legend-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 8px;
  background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid #c9ad79;
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 11px;
  color: #4a2810;
  max-width: 98%;
}

.region-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: bold;
}

.region-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.4);
}

.dice-arena {
  display: flex;
  align-items: center;
   gap: 22px;
}

.dice-cube {
  width: 78px;
  height: 78px;
  background: linear-gradient(145deg, #ffffff, #e6dec8);
  border: 4px solid #3b2314;
  border-radius: 18px;
  box-shadow: 0 6px 0 #3b2314, 0 10px 20px rgba(0,0,0,0.35);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
  cursor: pointer;
  transition: transform 0.2s;
}

.dice-cube.rolling {
  animation: shakeDice 0.18s infinite;
}

@keyframes shakeDice {
  0% { transform: rotate(-12deg) scale(1.06); }
  50% { transform: rotate(12deg) scale(0.96); }
  100% { transform: rotate(-12deg) scale(1.06); }
}

.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: transparent;
  align-self: center;
  justify-self: center;
}

.pip.show {
  background: #2b180a;
  box-shadow: inset 0 2px 2px rgba(0,0,0,0.5);
}

.pip.show.red-pip {
  background: #d92b1c;
  width: 15px;
  height: 15px;
}

.roll-main-btn {
  font-size: 18px;
  padding: 12px 24px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ff6b52 0%, #c92512 100%);
  color: #fff;
  border: 3.5px solid #3b2314;
  box-shadow: 0 5px 0 #3b2314, 0 8px 16px rgba(0,0,0,0.35);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 1px 2px 0 #590d05;
  white-space: nowrap;
}

.roll-main-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.roll-main-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #3b2314;
}

.roll-main-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.speech-bubble {
  background: #fff;
  border: 2.5px solid #3b2314;
  border-radius: 14px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: bold;
  color: #3b2314;
  box-shadow: 0 3px 0 rgba(0,0,0,0.2);
  max-width: 92%;
  text-align: center;
}

/* 中央底部锦囊手牌栏 */
.center-hand-bar {
  position: relative;
  z-index: 2;
  background: rgba(92, 58, 33, 0.12);
  border: 2px dashed #8c5a2b;
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hand-cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.strategy-card-btn {
  background: linear-gradient(180deg, #fffdf7 0%, #ffeaba 100%);
  border: 2px solid #5c3a21;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 900;
  color: #3b2314;
  box-shadow: 0 2px 0 #3b2314;
  white-space: nowrap;
  transition: transform 0.12s;
}

.strategy-card-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  background: #fff3c4;
}

.strategy-card-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 战报日志框 */
.log-panel {
  flex: 1;
  background: var(--bg-paper);
  border: 3px solid var(--border-brown);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: var(--shadow-retro);
  display: flex;
  flex-direction: column;
  min-height: 110px;
  overflow: hidden;
}

.log-title {
  font-size: 13px;
  font-weight: 900;
  color: #6e1a12;
  border-bottom: 2px solid #d4b483;
  padding-bottom: 4px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.log-entries {
  flex: 1;
  overflow-y: auto;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}

.log-item {
  line-height: 1.35;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.6);
  border-left: 3px solid #8c5a2b;
}

/* 弹窗遮罩 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 4, 0.72);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg-paper);
  border: 4px solid var(--border-brown);
  border-radius: 20px;
  box-shadow: 0 10px 0 #2b1608, 0 18px 40px rgba(0,0,0,0.65);
  max-width: 680px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 24px;
  position: relative;
  animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  text-align: center;
  border-bottom: 3px dashed #c9ad79;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  color: #781e14;
  text-shadow: 1px 1px 0 #ffd54f;
}

/* 选人开局界面 */
.setup-slots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.setup-slot-card {
  background: #fff9eb;
  border: 2.5px solid #6e4726;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.hero-option {
  border: 2px solid #cbb186;
  border-radius: 8px;
  padding: 4px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  font-weight: bold;
  transition: all 0.12s;
}

.hero-option.selected {
  border-color: #d93829;
  background: #ffe8cc;
  box-shadow: 0 0 0 2px #d93829;
}

/* 单挑弹窗 */
.duel-stage {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: linear-gradient(180deg, #ffe8cc 0%, #f5cfa0 100%);
  border: 3px solid #6e4726;
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
}

.duel-fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 40%;
  text-align: center;
}

.duel-vs {
  font-size: 32px;
  font-weight: 900;
  color: #d93829;
  text-shadow: 2px 2px 0 #fff;
}

.rps-choices {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

/* 浮动金币/提示文字特效 */
.floating-toast {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: #3b2314;
  color: #ffe89e;
  border: 2.5px solid #ffd54f;
  padding: 8px 20px;
  border-radius: 30px;
  font-weight: 900;
  font-size: 15px;
  z-index: 200;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.floating-toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

/* 响应式适配小屏幕 */
@media (max-width: 1100px) {
  .main-stage {
    grid-template-columns: 220px 1fr 220px;
  }
}
