/* main.css - 核心布局、组件与响应式结构 */

:root {
  --bg-color: #1a472a;
  --panel-bg: rgba(0, 0, 0, 0.4);
  --text-main: #ffffff;
  --text-muted: #e2e8f0;
  --card-bg: #ffffff;
  --card-border: #cbd5e1;
  --primary-color: #f59e0b;
  --primary-hover: #d97706;
  --danger-color: #ef4444;
  --accent-color: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background: var(--bg-color);
  color: var(--text-main);
}

/* 全屏容器 */
#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* 顶部导航与状态栏 */
header.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 48px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-multiplier {
  font-size: 0.95rem;
  padding: 2px 10px;
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid var(--primary-color);
  border-radius: 12px;
  color: #fef08a;
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 按钮基础样式 */
button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: #f59e0b;
  color: #1e293b;
}

.btn-primary:hover:not(:disabled) {
  background: #d97706;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

.btn-info {
  background: #0284c7;
  color: #ffffff;
}

.btn-info:hover:not(:disabled) {
  background: #0369a1;
}

.btn-eink-tool {
  background: #ffffff;
  color: #000000;
  border: 1px solid #000000;
}

/* 牌桌主体网格 */
main.game-table {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 240px 1fr 240px;
  grid-template-areas:
    "left top right"
    "left center right"
    "left bottom right";
  position: relative;
  overflow: hidden;
  padding: 8px;
  gap: 10px;
}

/* 顶部底牌区 */
.table-top {
  grid-area: top;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.bottom-cards-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.25);
}

.bottom-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fcd34d;
}

.bottom-cards {
  display: flex;
  gap: 6px;
}

/* 左侧 AI 1 玩家区 */
.table-left {
  grid-area: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px;
  position: relative;
}

/* 右侧 AI 2 玩家区 */
.table-right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px;
  position: relative;
}

/* 中央出牌对峙区 */
.table-center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: center;
  align-items: center;
}

.table-center-plays {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "ai1-play ai2-play"
    "human-play human-play";
  align-items: center;
  justify-items: center;
  padding: 10px;
}

.play-area {
  min-height: 80px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

#ai1-play { grid-area: ai1-play; }
#ai2-play { grid-area: ai2-play; }
#human-play { grid-area: human-play; }

.pass-tag {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f87171;
  padding: 4px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

/* 玩家信息卡片组件 */
.player-card-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.player-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.player-header.is-active-turn {
  color: #fef08a;
}

.turn-indicator {
  font-size: 0.75rem;
  background: #eab308;
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.player-avatar {
  font-size: 1.5rem;
}

.role-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.role-landlord {
  background: #ef4444;
  color: #ffffff;
}

.role-peasant {
  background: #3b82f6;
  color: #ffffff;
}

.player-card-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.speech-bubble {
  position: relative;
  background: #ffffff;
  color: #0f172a;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-top: 4px;
  max-width: 220px;
  word-break: break-all;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.speech-bubble::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #ffffff;
}

/* 底部人类玩家区 */
.table-bottom {
  grid-area: bottom;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.player-controls-container {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-buttons-group {
  display: flex;
  gap: 12px;
}

.btn-large {
  padding: 8px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

/* 人类手牌展示区 */
.human-hand-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding-bottom: 4px;
}

.human-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 120px;
  padding: 10px 20px;
  position: relative;
}

/* 扑克牌通用样式 */
.poker-card {
  width: 72px;
  height: 104px;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.12s ease, margin 0.1s ease;
  margin-left: -28px; /* 卡牌叠放 */
  flex-shrink: 0;
}

.poker-card:first-child {
  margin-left: 0;
}

.poker-card:hover {
  transform: translateY(-8px);
  z-index: 50;
}

.poker-card.selected {
  transform: translateY(-18px) !important;
  box-shadow: 0 8px 16px rgba(245, 158, 11, 0.4);
  border-color: #f59e0b;
  z-index: 60;
}

.poker-card.card-red {
  color: #dc2626;
}

.poker-card.card-black {
  color: #0f172a;
}

.poker-card.card-joker {
  background: #fffbeb;
  border-color: #fde68a;
}

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.top-left {
  align-self: flex-start;
}

.bottom-right {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-val {
  font-size: 1.1rem;
  font-weight: 800;
}

.card-suit-icon {
  font-size: 0.85rem;
}

.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.center-suit-icon {
  font-size: 1.8rem;
  opacity: 0.9;
}

.joker-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.joker-icon {
  font-size: 1.4rem;
}

.joker-name {
  font-size: 0.65rem;
  font-weight: 800;
}

.card-back {
  background: #1e3a8a;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #93c5fd;
  font-size: 2rem;
}

/* 记牌器侧边悬浮组件 */
.card-tracker-panel {
  position: absolute;
  top: 56px;
  right: 12px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  z-index: 80;
  backdrop-filter: blur(8px);
  width: 210px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.card-tracker-panel.collapsed .tracker-grid {
  display: none;
}

.tracker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tracker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.tracker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 3px 2px;
}

.tracker-item.tracker-zero {
  opacity: 0.25;
}

.tracker-rank {
  font-size: 0.75rem;
  font-weight: 700;
}

.tracker-count {
  font-size: 0.85rem;
  color: #facc15;
  font-weight: 800;
}

/* 游戏实时对局日志抽屉 (左下角可收起) */
.game-log-panel {
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 260px;
  max-height: 130px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.log-title {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 4px;
}

.log-box {
  flex: 1;
  overflow-y: auto;
  font-size: 0.75rem;
  line-height: 1.35;
  color: #cbd5e1;
}

.log-line {
  margin-bottom: 2px;
  word-break: break-all;
}

/* 提示 Toast */
.toast-container {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.95);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast-container.show {
  opacity: 1;
}

/* 模态框通用 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 900;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #1e293b;
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 840px;
  width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-sizing: border-box;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 6px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

.settings-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.settings-box h4 {
  font-size: 0.95rem;
  color: #facc15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
}

.field-group label {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 600;
}

.field-group input,
.field-group select,
.field-group textarea {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  color: #ffffff;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: #38bdf8;
}

.presets-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-preset:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 测试连接按钮与状态提示 */
.box-footer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.btn-test-conn {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid #3b82f6;
  color: #60a5fa;
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 4px;
}

.btn-test-conn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.3);
}

.test-result-box {
  font-size: 0.76rem;
  padding: 6px 10px;
  border-radius: 4px;
  display: none;
  line-height: 1.4;
  word-break: break-all;
}

.test-result-box.testing {
  display: block;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #eab308;
  color: #fde047;
}

.test-result-box.success {
  display: block;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  color: #86efac;
}

.test-result-box.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #fca5a5;
}

/* 牌桌开局准备横幅 (待机状态展示) */
.start-game-banner {
  position: absolute;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 2px solid rgba(245, 158, 11, 0.6);
  border-radius: var(--radius-lg);
  padding: 24px 36px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
  gap: 12px;
  max-width: 90%;
}

.start-game-banner.hidden {
  display: none;
}

.banner-icon {
  font-size: 3rem;
}

.banner-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fef08a;
}

.banner-desc {
  font-size: 0.88rem;
  color: #cbd5e1;
  max-width: 320px;
  line-height: 1.4;
}

.banner-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-banner {
  padding: 10px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

/* 发牌仪式感动画浮层 */
.dealing-anim-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 55;
  pointer-events: auto;
}

.dealing-card-deck {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fef08a;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 10px 24px;
  border-radius: 30px;
  border: 1px solid rgba(245, 158, 11, 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: pulse 0.6s infinite alternate;
}

/* 登录认证门禁卡片 */
.auth-card {
  max-width: 380px !important;
  text-align: center;
}

.auth-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  text-align: left;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #cbd5e1;
  cursor: pointer;
}

.auth-error {
  color: #f87171;
  font-size: 0.8rem;
  font-weight: 600;
  display: none;
  text-align: center;
}

.auth-error.show {
  display: block;
}

/* 结算弹窗 */
.settlement-card {
  text-align: center;
}

.settlement-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

.settlement-detail {
  font-size: 1.05rem;
  margin: 6px 0;
}

.spring-badge {
  display: inline-block;
  background: #ec4899;
  color: #fff;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 700;
  margin: 8px 0;
}

/* 墨水屏全反转刷屏全屏遮罩 */
#eink-flash-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
}
