/**
 * 🎮 聚会游戏大厅 · 公共基础与通用舞台样式 (Common Game Stylesheet)
 */

:root {
  --bg-gradient: radial-gradient(circle at center, #151d2a 0%, #080c14 100%);
  --panel-bg: rgba(22, 32, 48, 0.85);
  --card-bg: rgba(30, 41, 59, 0.7);
  --p1-color: #ff4757;
  --p1-glow: rgba(255, 71, 87, 0.5);
  --p2-color: #2ed573;
  --p2-glow: rgba(46, 213, 115, 0.5);
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --neon-cyan: #38bdf8;
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.5);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

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

body {
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  padding: 10px 12px 24px;
}

.container {
  width: 100%;
  max-width: 1080px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 游戏顶栏导航 (Universal Game Header) */
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  padding: 10px 18px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-back:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateX(-2px);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

.game-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

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

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* 模式切换选项卡 */
.mode-nav {
  display: flex;
  gap: 8px;
  background: var(--panel-bg);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  justify-content: center;
}

.mode-tab {
  flex: 1;
  max-width: 140px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* 联机房间面板 */
.online-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 10px 14px;
  border-radius: 8px;
  animation: fadeIn 0.3s ease;
}

.online-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.online-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: all 0.2s;
}

.btn-small:hover {
  background: var(--accent);
}

/* 计分与角色状态栏 */
.generic-scoreboard {
  display: flex;
  justify-content: space-around;
  gap: 12px;
  width: 100%;
}

.player-card {
  flex: 1;
  background: var(--panel-bg);
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-card.active-turn {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
}

.player-card.p1.active-turn {
  border-color: var(--p1-color);
  box-shadow: 0 0 15px var(--p1-glow);
}

.player-card.p2.active-turn {
  border-color: var(--p2-color);
  box-shadow: 0 0 15px var(--p2-glow);
}

.player-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.turn-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.2s;
}

.active-turn .turn-badge {
  opacity: 1;
  background: var(--accent);
  color: #fff;
}

/* 舞台容器 */
.stage-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

/* 2D Canvas 通用高分辨率样式 */
canvas.game-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* 底部工具栏与操作条 */
.toolbar {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

/* 桌面键盘按键提示条 */
.key-hint-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.key-hint-bar kbd {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 移动端专属虚拟手柄 */
.mobile-controls {
  display: none;
  width: 100%;
  max-width: 960px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  touch-action: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
}

.dpad-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dpad-btn:active {
  background: var(--accent);
}

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

.action-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.action-btn:active {
  background: var(--accent);
  transform: scale(0.95);
}

@media (pointer: coarse), (max-width: 768px) {
  .mobile-controls {
    display: flex;
  }
}

/* Toast 浮窗 */
#toast-msg {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
}

#toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 通用弹窗模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open .modal-box {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #cbd5e1;
  max-height: 65vh;
  overflow-y: auto;
}

.modal-body strong, .modal-body b {
  color: #fff;
}

.modal-body p {
  margin-bottom: 8px;
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .game-header {
    padding: 8px 12px;
  }
  .game-title {
    font-size: 1.05rem;
  }
  .nav-back {
    padding: 5px 10px;
    font-size: 0.82rem;
  }
}
