* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: #0a0a1a; color: #eee; overflow: hidden; height: 100vh; width: 100vw;
}
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: flex; align-items: center; justify-content: center; flex-direction: column; }

/* ====== 首页 - 双栏布局 ====== */
.home-layout { display: flex; width: 100%; height: 100%; }
.home-left {
  width: 380px; min-width: 380px; background: #111133;
  display: flex; flex-direction: column; align-items: center;
  padding: 20px; border-right: 2px solid #2a2a5e; overflow-y: auto;
}
.home-right { flex: 1; display: flex; flex-direction: column; padding: 16px; overflow-y: auto; min-height: 0; }

/* 角色预览场景 */
.char-preview-wrap { width: 100%; text-align: center; }
.char-preview-wrap h1 { font-size: 1.6em; color: #4ecdc4; margin-bottom: 4px; }
.char-preview-scene {
  width: 280px; height: 280px; margin: 10px auto;
  background: #0a0a20; border-radius: 16px; overflow: hidden;
  border: 2px solid #2a2a5e;
}
.char-preview-scene canvas { width: 100% !important; height: 100% !important; }

/* 角色选择 */
.char-select { width: 100%; margin: 8px 0; }
.char-grid { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.char-card {
  background: #0f3460; border: 2px solid transparent; border-radius: 10px;
  padding: 8px 6px; cursor: pointer; transition: all 0.3s; width: 64px; text-align: center;
}
.char-card:hover { border-color: #4ecdc4; background: #1a4a7a; transform: translateY(-2px); }
.char-card.active { border-color: #f7dc6f; background: #1a4a7a; box-shadow: 0 0 12px rgba(247,220,111,0.3); }
.char-emoji { font-size: 22px; margin-bottom: 2px; }
.char-name { font-size: 10px; color: #ccc; line-height: 1.1; }

/* 顶部图片区域 */
.banner-area {
  width: 100%; height: 0; overflow: hidden;
  border-radius: 10px; margin-bottom: 0;
  background: #0a0a20;
  transition: height 0.3s ease, margin 0.3s ease;
  flex-shrink: 0;
}
.banner-area.has-image {
  height: 160px; margin-bottom: 10px;
}
.banner-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 10px;
}
@media (max-width: 768px) {
  .home-layout { flex-direction: column; }
  .home-left { width: 100%; min-width: unset; border-right: none; border-bottom: 2px solid #2a2a5e; padding: 12px; }
  .char-preview-scene { width: 180px; height: 180px; }
  .char-card { width: 54px; }
  .banner-area.has-image { height: 120px; }
  .map-grid { grid-template-columns: 1fr; }
}

/* 地图网格 */
.map-grid-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.map-grid-header h2 { color: #4ecdc4; font-size: 1.2em; }
.online-count { color: #2ecc71; font-size: 13px; background: #0a2a1a; padding: 4px 12px; border-radius: 20px; }
.map-grid {
  flex: 1; overflow-y: auto; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; padding-right: 8px;
}

.map-card {
  background: #111133; border-radius: 12px; border: 1px solid #2a2a5e;
  overflow: hidden; transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex; flex-direction: column; cursor: pointer;
  position: relative;
  padding-bottom: 4px;
}
.map-card::before {
  content: ''; position: absolute; inset: 0; border-radius: 12px;
  background: linear-gradient(135deg, rgba(78,205,196,0.08), transparent 50%);
  opacity: 0; transition: opacity 0.35s ease; pointer-events: none;
}
.map-card:hover {
  border-color: #4ecdc4; transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 30px rgba(78,205,196,0.25), 0 0 60px rgba(78,205,196,0.05);
}
.map-card:hover::before { opacity: 1; }
.map-card:active { transform: translateY(-1px) scale(0.99); }
.map-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #0a0a30;
}
.map-card-name { color: #f7dc6f; font-weight: bold; font-size: 13px; }
.map-card-size { color: #888; font-size: 11px; }
.map-card-canvas { width: 100%; height: 100px; background: #0a0a20; display: block; }
.map-card-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 48, 0.92);
  backdrop-filter: blur(4px);
  border-top: 1px solid #2a2a5e;
  padding: 8px 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 5;
  max-height: 130px;
  overflow-y: auto;
}
.map-card:hover .map-card-body {
  opacity: 1;
  transform: translateY(0);
}
.map-card-players {
  font-size: 11px; color: #4ecdc4; margin-bottom: 4px;
  min-height: 18px;
}
.map-card-playcount {
  color: #555; font-size: 9px; margin-right: 4px;
}
.map-card-meta { display: flex; align-items: center; gap: 4px; }
.map-card-lb-title { color: #888; font-size: 10px; margin-bottom: 2px; }
.map-card-lb {
  font-size: 10px; color: #999; max-height: 60px; overflow-y: auto;
}
.map-card-lb-item {
  display: flex; justify-content: space-between; padding: 1px 0;
}
.map-card-lb-rank { color: #f7dc6f; width: 20px; }
.map-card-lb-name { flex: 1; color: #ddd; }
.map-card-lb-time { color: #4ecdc4; }

/* ====== 按钮 ====== */
button { padding: 12px 24px; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: all 0.2s; }
.btn-primary {
  background: #4ecdc4; color: #1a1a2e; font-weight: bold;
  width: 100%; font-size: 16px; letter-spacing: 1px; margin-top: 6px;
}
.btn-primary:hover { background: #3dbdb4; }
.btn-small { padding: 6px 12px; font-size: 12px; background: #333; color: #fff; border-radius: 6px; }
.btn-small:hover { background: #555; }
.hidden { display: none !important; }

/* ====== 通知浮层 ====== */
.notif-container {
  position: fixed; top: 16px; right: 16px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.notif-item {
  background: #111133; border: 1px solid #4ecdc4; border-radius: 10px;
  padding: 10px 16px; font-size: 13px; color: #eee;
  animation: notifIn 0.3s ease, notifOut 0.3s 2.7s ease forwards;
  pointer-events: auto;
}
@keyframes notifIn { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }
@keyframes notifOut { from { opacity:1; } to { opacity:0; transform:translateX(40px); } }

/* ====== 游戏界面 ====== */
#game-screen { padding: 0; position: relative; }
.game-layout { display: flex; width: 100vw; height: 100vh; }
.game-viewport { flex: 1; position: relative; background: #000; overflow: hidden; }
#three-canvas canvas { display: block; width: 100%; height: 100%; }

.game-overlay {
  position: absolute; top: 0; left: 0; right: 0; pointer-events: none; padding: 16px;
}
.round-info {
  display: flex; gap: 20px; font-size: 18px; font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
#round-display { color: #4ecdc4; }
#map-name { color: #f7dc6f; }
#timer-display { color: #e94560; }
.control-hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.4); font-size: 12px;
  background: rgba(0,0,0,0.5); padding: 6px 16px; border-radius: 20px;
}
.spectator-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 48px; color: #f7dc6f; text-shadow: 0 0 20px rgba(247,220,111,0.5);
  font-weight: bold; animation: pulse 2s ease-in-out infinite;
}

.countdown-overlay {
  position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.6); z-index:100; display:flex;
  align-items:center; justify-content:center; pointer-events:none;
}
.countdown-overlay #countdown-number {
  font-size: 120px; font-weight:bold; color:#4ecdc4; text-shadow:0 0 40px rgba(78,205,196,0.5);
}

/* 右侧面板 */
.game-panel {
  width: 340px; background: #16213e; display: flex;
  flex-direction: column; border-left: 2px solid #0f3460;
}
.panel-tabs { display: flex; border-bottom: 1px solid #0f3460; flex-shrink: 0; }
.tab-btn {
  flex: 1; padding: 8px; font-size: 16px; background: transparent;
  color: #555; border: none; cursor: pointer; transition: all 0.2s;
  border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: #aaa; background: #0f3460; }
.tab-btn.active { color: #4ecdc4; border-bottom-color: #4ecdc4; }
.tab-content { display: none; padding: 10px 14px; overflow-y: auto; }
.tab-content.active { display: block; flex: 1; }
.tab-content h3 { color: #4ecdc4; font-size: 13px; margin-bottom: 6px; }
.tab-content h4 { color: #4ecdc4; font-size: 12px; margin-bottom: 4px; }

.ranking-list { font-size: 12px; }
.ranking-item {
  display: flex; align-items: center; padding: 3px 6px;
  border-radius: 4px; margin-bottom: 2px; gap: 6px;
}
.ranking-item .rank-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ranking-item .rank-name { flex: 1; color: #ddd; }
.ranking-item .rank-status { font-size: 10px; color: #888; }
.ranking-item.eliminated { opacity: 0.4; text-decoration: line-through; }
.ranking-item.reached { background: rgba(46,204,113,0.15); }

.ai-doc { background: #0a0a1e; border-radius: 6px; padding: 8px; }
.ai-field { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #1a1a3e; }
.ai-label { color: #888; }
.ai-value { color: #f7dc6f; font-family: monospace; }
.ai-code-block {
  background: #0a0a1e; color: #96ceb4; border: 1px solid #1a1a3e;
  border-radius: 6px; padding: 8px; font-family: monospace;
  font-size: 10px; overflow: auto; white-space: pre-wrap;
  max-height: 140px; margin-bottom: 4px;
}
.btn-tiny {
  padding: 3px 8px; font-size: 11px; background: #0f3460;
  color: #4ecdc4; border: 1px solid #4ecdc4; border-radius: 4px; cursor: pointer;
}
.btn-tiny:hover { background: #1a4a7a; }

.cmd-row { display: flex; gap: 6px; }
.cmd-row input {
  flex: 1; padding: 8px 10px; border: 1px solid #0f3460; border-radius: 6px;
  background: #0f3460; color: #fff; font-size: 13px; outline: none;
}
.cmd-row input:focus { border-color: #4ecdc4; }
.log-list { font-size: 11px; color: #aaa; overflow-y: auto; height: calc(100% - 20px); }
.log-entry { padding: 2px 0; border-bottom: 1px solid #1a1a2e; }
.mini-info { display: flex; justify-content: space-between; font-size: 11px; color: #888; }

/* 结果 */
#result-screen .panel {
  background: #16213e; padding: 40px; border-radius: 16px;
  text-align: center; max-width: 600px; width: 90%;
}
#winner-display { margin: 24px 0; }
.winner-card { display: inline-block; margin: 8px; padding: 20px 30px; border-radius: 12px; background: #0f3460; }
.winner-card.gold { border: 2px solid #f7dc6f; }
.winner-card.silver { border: 2px solid #bdc3c7; }
.winner-card.bronze { border: 2px solid #e67e22; }
.winner-rank { font-size: 24px; font-weight: bold; }
.gold .winner-rank { color: #f7dc6f; }
.silver .winner-rank { color: #bdc3c7; }
.bronze .winner-rank { color: #e67e22; }
.winner-name { font-size: 18px; margin-top: 4px; }

/* 加载 */
.loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); z-index: 200; display: flex;
  align-items: center; justify-content: center; flex-direction: column;
}
.loading-spinner {
  width: 50px; height: 50px; border: 4px solid #333;
  border-top: 4px solid #4ecdc4; border-radius: 50%;
  animation: spin 1s linear infinite; margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }
#loading-text { color: #4ecdc4; font-size: 18px; }

.subtitle { color: #aaa; margin-bottom: 4px; font-size: 13px; }
