/* ========================================
  MCGS - 多人卡牌桌游系统 样式
  微信风格 - 明亮清爽浅色主题
  ======================================== */

/* ---------- CSS Variables ---------- */
:root {
  /* 微信主色系 - WeChat Green */
  --color-primary: #07C160;
  --color-primary-light: #09DE6E;
  --color-primary-dark: #06AE56;
  --color-primary-bg: rgba(7, 193, 96, 0.08);

  /* 强调色 */
  --color-accent: #FA9D3B;
  --color-accent-light: rgba(250, 157, 59, 0.1);

  /* 链接/信息色 */
  --color-cyan: #576B95;
  --color-cyan-light: rgba(87, 107, 149, 0.08);

  /* 背景色 - 微信明亮主题 */
  --color-bg: #EDEDED;
  --color-bg-white: #FFFFFF;
  --color-bg-gray: #F7F7F7;
  --color-bg-dark: #E8E8E8;
  --color-bg-surface: #FFFFFF;

  /* 文字色 - 微信灰阶 */
  --color-text-primary: #191919;
  --color-text-secondary: #666666;
  --color-text-muted: #999999;

  /* 功能色 */
  --color-success: #07C160;
  --color-warning: #FA9D3B;
  --color-error: #FA5151;
  --color-info: #576B95;

  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* 字体 */
  --font-family: "Noto Sans SC", -apple-system, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 17px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;

  /* 圆角 - 微信风格偏小 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* 阴影 - 微信轻柔阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);

  /* 卡片尺寸 */
  --card-width: 100px;
  --card-height: 140px;
  --card-width-sm: 70px;
  --card-height-sm: 98px;

  /* 动画 */
  --transition-fast: 200ms ease-out;
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  max-width: 100%;
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  -webkit-appearance: none;
}

button:active {
  opacity: 0.8;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ---------- Typography ---------- */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: bold; }

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

.text-center { text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--font-size-base);
}

/* 微信绿色主按钮 */
.btn-primary {
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-sm);
}

.btn-primary:hover {
  background: var(--color-primary-light);
}

.btn-primary:active {
  background: var(--color-primary-dark);
}

/* 次要按钮 - 微信风格白底 */
.btn-secondary {
  background: var(--color-bg-gray);
  color: var(--color-text-primary);
  border-radius: var(--radius-sm);
}

.btn-secondary:active {
  background: var(--color-bg-dark);
}

/* 边框按钮 */
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
}

/* 强调按钮（橙色） */
.btn-accent {
  background: var(--color-accent);
  color: white;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-accent:hover {
  opacity: 0.9;
}

.btn-accent:active {
  opacity: 0.8;
}

/* 危险按钮 */
.btn-danger {
  background: var(--color-error);
  color: white;
  border-radius: var(--radius-sm);
}

/* 危险文字按钮 */
.btn-danger-text {
  color: var(--color-error) !important;
}

/* 幽灵按钮 */
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:active {
  background: var(--color-bg-gray);
}

/* 图标按钮 */
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* 文字按钮 */
.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: var(--space-xs) var(--space-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card {
  margin-top: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid #ECECEC;
}

.card-header h3, .card-header h4 {
  font-weight: 500;
}

.card-body {
  padding: var(--space-sm);
}

.card-footer {
  padding: var(--space-sm);
  border-top: 1px solid #ECECEC;
}

/* ---------- Game Card ---------- */
.game-card {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  background: var(--color-bg-gray);
}

.game-card:active {
  transform: scale(0.95);
}

.game-card.selected {
  box-shadow: 0 0 0 3px var(--color-primary);
  transform: scale(1.02);
}

.game-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 卡牌回收按钮 */
.card-takeback-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.game-card:hover .card-takeback-btn {
  opacity: 1;
}

.card-takeback-btn:hover {
  background: var(--color-primary);
}

.game-card-sm {
  width: var(--card-width-sm);
  height: var(--card-height-sm);
}

.game-card.size-md {
  width: var(--card-width);
  height: var(--card-height);
}

.game-card.size-sm {
  width: var(--card-width-sm);
  height: var(--card-height-sm);
}

/* ---------- Input ---------- */
.input {
  width: 100%;
  padding: var(--space-md);
  font-size: var(--font-size-base);
  background: var(--color-bg-gray);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  color: var(--color-text-primary);
}

.input:focus {
  background: var(--color-bg-white);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.input::placeholder {
  color: var(--color-text-muted);
}

/* ---------- Select ---------- */
.select {
  width: 100%;
  padding: var(--space-md);
  font-size: var(--font-size-base);
  background: var(--color-bg-gray);
  border-radius: var(--radius-sm);
  cursor: pointer;
  appearance: none;
  color: var(--color-text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  font-size: var(--font-size-xs);
  background: var(--color-bg-gray);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
}

.badge-success {
  background: var(--color-primary-bg);
  color: var(--color-success);
}

/* ---------- Status Indicator ---------- */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
}

.status-indicator.online {
  background: var(--color-success);
}

.status-indicator.offline {
  background: var(--color-text-muted);
}

.status-indicator.connecting {
  background: var(--color-warning);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-xs);
  gap: var(--space-xs);
}

.tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: transparent;
  border-radius: var(--radius-sm);
  text-align: center;
}

.tab:active {
  background: var(--color-bg-gray);
}

.tab.active {
  background: var(--color-primary);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Folder Tab (卡池Tab) */
.folder-tab.active {
  background: var(--color-primary);
  color: white;
}

/* ---------- Avatar ---------- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar svg {
  width: 20px;
  height: 20px;
  color: var(--color-text-secondary);
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

/* ---------- Layout ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-white);
  border-bottom: 1px solid #ECECEC;
}

.page-footer {
  padding: var(--space-lg);
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Host Layout */
.host-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg);
}

@media (max-width: 768px) {
  .host-layout {
    grid-template-columns: 1fr;
    padding: var(--space-sm);
  }
}

.host-sidebar {
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .host-sidebar {
    grid-row: auto;
  }
}

.host-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}

.host-footer {
  grid-column: 2;
}

@media (max-width: 768px) {
  .host-footer {
    grid-column: 1;
  }
}

/* Player Layout */
.player-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--color-bg);
}

.player-header {
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-white);
  border-bottom: 1px solid #ECECEC;
}

.player-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  gap: var(--space-md);
}

.hand-area {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.hand-scroll {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm);
  margin: calc(-1 * var(--space-sm));
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
}

.hand-scroll .game-card {
  scroll-snap-align: start;
}

.actions-area {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.actions-area .btn {
  flex: 1;
  min-width: 70px;
}

.preview-area {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

/* ---------- Battle Grid ---------- */
.battle-grid {
  display: grid;
  gap: 2px;
  background: #E0E0E0;
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: none;
}

.battle-cell {
  aspect-ratio: 1;
  background: var(--color-bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.battle-cell:active {
  background: var(--color-primary-bg);
}

.battle-cell.drag-over {
  background: var(--color-primary-bg);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.battle-token {
  width: 90%;
  height: 90%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: grab;
  box-shadow: var(--shadow-sm);
}

.battle-token:active {
  cursor: grabbing;
}

.battle-token img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Pool Folder (选择夹形式) ---------- */
.pool-folder {
  margin-bottom: 12px;
}

.pool-folder .card-header {
  padding: 10px 12px;
}

.folder-tabs {
  padding: 0;
}

.folder-tab-list {
  display: flex;
  gap: 2px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid #ECECEC;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.folder-tab-list::-webkit-scrollbar {
  display: none;
}

.folder-tab {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--color-bg-gray);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  white-space: nowrap;
  transition: all 0.2s;
}

.folder-tab:active {
  background: var(--color-bg-dark);
}

.folder-tab.active {
  background: var(--color-primary);
  color: white;
}

.folder-tab-content {
  padding: 8px;
}

.folder-tab-panel {
  display: none;
}

.folder-tab-panel.active {
  display: block;
}

.pool-cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 60px;
}

/* ---------- Discard Pile Card ---------- */
.discard-pile-card {
  margin-top: 0;
}

/* ---------- Grid Settings ---------- */
.grid-settings {
  display: flex;
  flex-direction: column;
}

/* ---------- Character List (Host) ---------- */
.char-management-card {
  flex: 0 0 auto;
}

.char-list-container {
  flex: 1;
  min-height: 40px;
}

.char-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ---------- Host Log Card ---------- */
.host-log-card {
  flex: 0 0 auto;
}

.char-list .char-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-bg-white);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.char-list .char-item:hover {
  background: var(--color-bg-gray);
}

.char-list .char-item.char-used {
  opacity: 0.6;
}

.char-list .char-item .char-icon {
  width: 32px;
  height: 32px;
  margin: 0;
  flex-shrink: 0;
}

.char-list .char-item .char-icon svg {
  width: 18px;
  height: 18px;
}

.char-list .char-item .char-info {
  flex: 1;
  min-width: 0;
}

.char-list .char-item .char-info .char-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.char-list .char-item .char-delete {
  flex-shrink: 0;
  opacity: 0.6;
}

.char-list .char-item .char-delete:hover {
  opacity: 1;
}

.char-list .char-item .char-delete:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---------- Character Grid ---------- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.char-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  background: var(--color-bg-white);
  border: 2px solid #ECECEC;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.char-item:active {
  background: var(--color-bg-gray);
}

.char-item.selected {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
}

.char-item.char-taken {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--color-bg-dark);
}

.char-item.char-taken:active {
  background: transparent;
}

.char-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-gray);
  border-radius: 50%;
  color: var(--color-text-secondary);
}

.char-item.selected .char-icon {
  background: var(--color-primary);
  color: white;
}

.char-icon svg {
  width: 24px;
  height: 24px;
}

.char-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.char-status {
  font-size: var(--font-size-xs);
  margin-top: var(--space-xs);
}

/* ---------- Waiting Panel (Player) ---------- */
.waiting-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-xl);
}

.waiting-content {
  max-width: 300px;
}

.waiting-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-bg);
  border-radius: 50%;
  color: var(--color-primary);
}

.waiting-icon svg {
  width: 40px;
  height: 40px;
}

.waiting-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--color-text-primary);
}

.waiting-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
}

/* ---------- Current Character Display ---------- */
.current-char-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-primary-bg);
  border-radius: var(--radius-full);
}

.current-char-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.current-char-icon svg {
  width: 14px;
  height: 14px;
}

.current-char-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-primary);
}

/* ---------- Player Log (Footer) ---------- */
.page-footer {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-bg-white);
  border-top: 1px solid #ECECEC;
}

.player-log {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
}

.player-log .log-time {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.player-log .log-message {
  color: var(--color-text-secondary);
  word-break: break-all;
}

/* ---------- Pool List ---------- */
.pool-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.pool-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.pool-item:active {
  background: var(--color-bg-gray);
}

.pool-item.active {
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary);
}

.pool-info {
  flex: 1;
}

.pool-name {
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.pool-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.pool-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  max-height: 250px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Player List ---------- */
.player-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.player-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.player-item:active {
  background: var(--color-bg-gray);
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-name {
  font-weight: 500;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.player-hand-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ---------- Table Area ---------- */
.table-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-width), 1fr));
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-bg-gray);
  border-radius: var(--radius-lg);
  min-height: 180px;
}

.table-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--color-text-muted);
}

.table-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* ---------- Discard Pile ---------- */
.discard-pile {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.discard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.discard-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.discard-card {
  position: relative;
}

.discard-card .game-card {
  opacity: 0.8;
}

.discard-card-checkbox {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: 10;
  width: 20px;
  height: 20px;
  background: var(--color-bg-white);
  border: 2px solid #CCCCCC;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.discard-card-checkbox.checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.discard-card-checkbox svg {
  width: 12px;
  height: 12px;
  color: white;
  opacity: 0;
}

.discard-card-checkbox.checked svg {
  opacity: 1;
}

/* ---------- Room ID ---------- */
.room-id-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-gray);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", "Consolas", monospace;
  font-size: var(--font-size-base);
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.room-id-copy {
  color: var(--color-text-muted);
  padding: var(--space-xs);
}

.room-id-copy:active {
  color: var(--color-primary);
}

/* ---------- Landing Page ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: linear-gradient(180deg, #F7F7F7 0%, #EDEDED 100%);
  text-align: center;
}

.landing-logo {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-xl);
  color: var(--color-primary);
}

.landing-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--color-text-primary);
}

.landing-subtitle {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2xl);
}

.role-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  width: 100%;
  max-width: 320px;
}

.role-card {
  padding: var(--space-xl);
  background: var(--color-bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  border: 2px solid transparent;
}

.role-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
}

.role-card:active {
  transform: scale(0.98);
}

.role-card-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-lg);
  background: var(--color-primary-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.role-card-icon svg {
  width: 28px;
  height: 28px;
}

.role-card-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.role-card-desc {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.landing-footer {
  margin-top: var(--space-2xl);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

/* ---------- Battle Log ---------- */
.battle-log {
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-sm);
  background: var(--color-bg-gray);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: 4px 0;
  color: var(--color-text-secondary);
  border-bottom: 1px solid #ECECEC;
  line-height: 1.4;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--color-text-muted);
  flex-shrink: 0;
  font-size: 11px;
}

.log-message {
  flex: 1;
  word-break: break-all;
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--font-size-sm);
}

/* ---------- Welcome Screen ---------- */
#welcomeScreen {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

#welcomeScreen .card {
  max-width: 320px;
  width: 100%;
  text-align: center;
  padding: var(--space-2xl);
}

#welcomeScreen .card svg {
  color: var(--color-primary);
  margin-bottom: var(--space-lg);
}

#welcomeScreen h1 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

#welcomeScreen p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-xl);
}

/* ---------- Token Menu ---------- */
.token-menu {
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.token-menu-item {
  display: block;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  background: transparent;
}

.token-menu-item:active {
  background: var(--color-bg-gray);
}

.token-menu-item + .token-menu-item {
  border-top: 1px solid #ECECEC;
}

/* ---------- Form Group ---------- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed #CCCCCC;
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:active {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-md);
  color: var(--color-text-muted);
}

.dropzone-text {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.dropzone-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 576px) {
  :root {
    --card-width: 80px;
    --card-height: 112px;
    --card-width-sm: 60px;
    --card-height-sm: 84px;
  }

  .page-header {
    padding: var(--space-sm) var(--space-md);
  }

  .actions-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-md);
    background: var(--color-bg-white);
    border-top: 1px solid #ECECEC;
    justify-content: space-around;
    z-index: 50;
    margin: 0;
    border-radius: 0;
  }

  .player-content {
    padding-bottom: 80px;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    min-width: max-content;
  }

  .role-cards {
    max-width: 100%;
  }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-lg);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--color-bg-white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid #ECECEC;
}

.modal-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--color-text-muted);
  border-radius: 50%;
}

.modal-close:active {
  background: var(--color-bg-gray);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-top: 1px solid #ECECEC;
}

.modal-footer .btn {
  flex: 1;
}

/* Pool/Player Options */
.pool-options,
.player-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.pool-option,
.player-option {
  padding: var(--space-md);
  background: var(--color-bg-white);
  border: 1px solid #ECECEC;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.pool-option:active,
.player-option:active {
  background: var(--color-bg-gray);
}

.pool-option.selected,
.player-option.selected {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
}

.pool-option-name,
.player-option-name {
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.pool-option-count,
.player-option-status {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ---------- Game Layout (Host) ---------- */
.game-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-bg-white);
  border-bottom: 1px solid #ECECEC;
  flex-shrink: 0;
}

.game-header-left,
.game-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.game-main {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  flex: 1;
  overflow: hidden;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-bg);
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow-y: auto;
}

.game-center {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-panels {
  flex: 1;
  overflow-y: auto;
}

.game-rightbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow-y: auto;
}

/* Card header compact */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid #ECECEC;
}

.card-header h3,
.card-header h4 {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.card-body {
  padding: var(--space-sm);
}

.card-footer {
  padding: var(--space-sm);
  border-top: 1px solid #ECECEC;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .game-main {
    grid-template-columns: 200px 1fr;
  }
  
  .game-rightbar {
    display: none;
  }
}

@media (max-width: 768px) {
  .game-main {
    grid-template-columns: 1fr;
  }
  
  .game-sidebar {
    display: none;
  }
}

/* Tabs compact */
.tabs {
  display: flex;
  gap: 2px;
  padding: var(--space-sm);
  background: var(--color-bg-white);
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-gray);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  transition: all 0.2s;
}

.tab.active {
  background: var(--color-primary);
  color: white;
}

/* Welcome screen adjustments */
#welcomeScreen {
  background: linear-gradient(180deg, #07C160 0%, #06AE56 100%);
}

#welcomeScreen .landing-logo {
  color: white;
}

#welcomeScreen .landing-title,
#welcomeScreen .landing-subtitle {
  color: white;
}

#welcomeScreen .landing-subtitle {
  opacity: 0.9;
}

/* Battle grid responsive */
.battle-grid {
  display: grid;
  gap: 2px;
  background: #E0E0E0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.battle-cell {
  aspect-ratio: 1;
  background: var(--color-bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
}

.battle-cell:active {
  background: var(--color-primary-bg);
}

.battle-cell.drag-over {
  background: var(--color-primary-bg);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.battle-token {
  width: 90%;
  height: 90%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: grab;
  box-shadow: var(--shadow-sm);
}

.battle-token:active {
  cursor: grabbing;
}

.battle-token img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
