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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a0a;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #eee;
}

#rotate-tip {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #111;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  text-align: center;
  padding: 30px;
}

@media (max-width: 768px) and (orientation: portrait) {
  #rotate-tip { display: flex; }
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* ===== 通用屏幕 ===== */
.screen {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* ===== 标题界面 ===== */
#screen-name {
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0a0a1e 100%);
}

.title-logo {
  text-align: center;
  margin-bottom: 50px;
}

.title-logo h1 {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: linear-gradient(180deg, #ff4444 0%, #ff8866 50%, #ffcc00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(255, 68, 68, 0.3);
  margin-bottom: 8px;
}

.subtitle {
  font-size: 16px;
  color: #666;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.name-input-area {
  text-align: center;
}

.prompt-text {
  font-size: 18px;
  color: #aaa;
  margin-bottom: 16px;
}

#player-name-input {
  display: block;
  margin: 0 auto 20px;
  padding: 14px 24px;
  width: 280px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  text-align: center;
  outline: none;
  transition: border-color 0.3s;
}

#player-name-input:focus {
  border-color: #ff4444;
  background: rgba(255, 255, 255, 0.12);
}

.primary-btn {
  padding: 12px 36px;
  background: linear-gradient(135deg, #e63946, #ff6b6b);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(230, 57, 70, 0.6);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled {
  background: #444;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

.error-msg {
  color: #ff4444;
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
}

/* ===== 大厅界面 ===== */
#screen-lobby {
  justify-content: flex-start;
  padding-top: 0;
}

.lobby-topbar {
  width: 100%;
  padding: 20px 30px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.player-meta {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
}

.player-id {
  font-size: 13px;
  color: #888;
  font-family: monospace;
}

.lobby-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.lobby-title {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 40px;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.lobby-modes {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-card {
  width: 220px;
  height: 280px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.3s;
  color: #eee;
}

.mode-card:hover {
  background: rgba(230, 57, 70, 0.15);
  border-color: #e63946;
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(230, 57, 70, 0.3);
}

.mode-icon {
  font-size: 56px;
}

.mode-name {
  font-size: 22px;
  font-weight: bold;
}

.mode-desc {
  font-size: 14px;
  color: #999;
  text-align: center;
}

/* ===== PVP搜索界面 ===== */
.screen-title {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 24px;
  color: #fff;
}

.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  width: 500px;
  max-width: 90%;
}

.search-bar input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  outline: none;
}

.search-bar input:focus {
  border-color: #e63946;
}

.online-label {
  font-size: 14px;
  color: #888;
  margin-bottom: 12px;
  width: 500px;
  max-width: 90%;
}

.player-list {
  width: 500px;
  max-width: 90%;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.player-list-item:hover {
  background: rgba(230, 57, 70, 0.15);
  border-color: #e63946;
}

.player-list-item .pl-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.player-list-item .pl-info {
  flex: 1;
}

.player-list-item .pl-name {
  font-size: 16px;
  font-weight: bold;
}

.player-list-item .pl-id {
  font-size: 12px;
  color: #888;
  font-family: monospace;
}

.player-list-item .pl-invite {
  padding: 6px 16px;
  background: #e63946;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.back-btn {
  margin-top: 20px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #ccc;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== 房间界面 ===== */
.room-id {
  font-size: 14px;
  color: #888;
  margin-bottom: 20px;
  font-family: monospace;
}

.room-players {
  display: flex;
  align-items: center;
  gap: 40px;
  margin-bottom: 30px;
}

.room-slot {
  width: 180px;
  height: 220px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.room-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.room-name {
  font-size: 18px;
  font-weight: bold;
}

.room-status {
  font-size: 13px;
  color: #888;
}

.room-vs {
  font-size: 36px;
  font-weight: 900;
  color: #e63946;
  text-shadow: 0 0 20px rgba(230, 57, 70, 0.5);
}

.room-actions {
  display: flex;
  gap: 16px;
}

/* ===== 角色选择界面 ===== */
#screen-select {
  justify-content: flex-start;
  padding: 20px;
}

.select-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 30px;
  margin-bottom: 20px;
}

.select-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 120px;
}

.select-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s;
}

.select-avatar.char-selected {
  border-color: #ffcc00;
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
}

.select-name {
  font-size: 15px;
  font-weight: bold;
}

.select-timer-wrap {
  text-align: center;
}

.select-timer-label {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 4px;
}

.select-timer {
  font-size: 48px;
  font-weight: 900;
  color: #ffcc00;
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
}

.select-timer.urgent {
  color: #ff4444;
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.char-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}

.char-card {
  width: 160px;
  height: 200px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.char-card:hover {
  transform: translateY(-6px) scale(1.03);
}

.char-card.selected-p1 {
  border-color: #4fc3f7;
  box-shadow: 0 0 25px rgba(79, 195, 247, 0.4);
}

.char-card.selected-p2 {
  border-color: #ff5252;
  box-shadow: 0 0 25px rgba(255, 82, 82, 0.4);
}

.char-card .char-portrait {
  width: 80px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.char-card .char-card-name {
  font-size: 16px;
  font-weight: bold;
  text-align: center;
}

.char-card .char-card-title {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-top: 4px;
}

.char-card .char-pick-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
  display: none;
}

.char-card.selected-p1 .char-pick-badge.p1 {
  display: block;
  background: #4fc3f7;
  color: #000;
}

.char-card.selected-p2 .char-pick-badge.p2 {
  display: block;
  background: #ff5252;
  color: #fff;
}

.char-detail {
  width: 600px;
  max-width: 95%;
  min-height: 100px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 16px;
}

.char-detail-name {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
}

.char-detail-skills {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-skill-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.char-skill-name {
  font-weight: bold;
  color: #ffcc00;
  white-space: nowrap;
  min-width: 100px;
}

/* ===== 战斗界面 ===== */
#screen-fight {
  padding: 0;
  background: #87CEEB;
  /* display 由 .screen/.screen.active 控制，不在这里设置 */
}

#fight-canvas {
  display: block;
  image-rendering: auto;
}

.pc-controls-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  pointer-events: none;
}

/* ===== 移动端控制 ===== */
.mobile-controls {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
}

.touch-device .mobile-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px 20px;
}

.joystick-zone {
  width: 140px;
  height: 140px;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.25);
  position: relative;
  margin: 10px;
}

.joystick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.1s;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  pointer-events: auto;
}

.action-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.atk-btn { background: rgba(255, 160, 60, 0.5); }
.skill1-btn { background: rgba(79, 195, 247, 0.5); }
.skill2-btn { background: rgba(102, 187, 106, 0.5); }
.ult-btn { background: rgba(255, 82, 82, 0.6); border-color: #ff5252; }

.action-btn:active {
  transform: scale(0.9);
  filter: brightness(1.4);
}

/* ===== 结果界面 ===== */
#screen-result {
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0a0a1e 100%);
}

.result-content {
  text-align: center;
}

#result-text {
  font-size: 60px;
  font-weight: 900;
  margin-bottom: 16px;
  letter-spacing: 0.1em;
}

#result-text.win {
  background: linear-gradient(180deg, #ffcc00, #ff8866);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#result-text.lose {
  color: #666;
}

#result-detail {
  font-size: 18px;
  color: #aaa;
  margin-bottom: 30px;
}

.result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* ===== 滚动条 ===== */
.player-list::-webkit-scrollbar {
  width: 6px;
}
.player-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
}
.player-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}
