/* ATR2 联机对战 - 共享样式 - 经典绿屏风格 */

@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

:root {
  /* 经典绿屏风格 */
  --bg: #001a00;
  --bg-light: #003300;
  --panel: #001a00;
  --panel2: #002600;
  --text: #00ff00;
  --muted: #00aa00;
  --line: #004400;
  --red: #ff4444;
  --blue: #44ccff;
  --amber: #ffdd00;
  --green: #00ff00;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: #001a00;
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.4;
  text-shadow: 0 0 3px rgba(0, 255, 0, 0.3);
}

button {
  font: inherit;
  min-height: 36px;
  border: 1px solid var(--green);
  border-radius: 2px;
  background: #002600;
  color: var(--text);
  cursor: pointer;
  padding: 0 16px;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.2) inset;
}

button:hover {
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 12px rgba(0, 255, 0, 0.4) inset, 0 0 8px rgba(255, 221, 0, 0.3);
}

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

button.primary {
  background: #003300;
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) inset;
}

button.primary:hover {
  background: #004400;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.5) inset, 0 0 10px rgba(0, 255, 0, 0.3);
}

/* 页面布局 */
.page {
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px;
}

.header {
  text-align: center;
  padding: 32px 16px;
  border-bottom: 1px solid var(--green);
  margin-bottom: 32px;
}

.header h1 {
  font-size: 32px;
  letter-spacing: 2px;
  color: var(--green);
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
  margin-bottom: 8px;
  font-family: 'Courier New', monospace;
}

.header p {
  color: var(--muted);
}

/* 模式选择卡片 */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 700px;
  margin: 0 auto;
}

.mode-card {
  background: #001a00;
  border: 1px solid var(--green);
  border-radius: 0;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.1) inset;
}

.mode-card:hover {
  border-color: var(--amber);
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.3) inset;
  transform: none;
}

.mode-card h2 {
  font-size: 20px;
  margin-bottom: 12px;
  color: var(--amber);
}

.mode-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.mode-card .icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--amber);
}

/* AI 卡片 */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .ai-grid {
    grid-template-columns: 1fr;
  }
}

.ai-card {
  background: var(--panel);
  border: 2px solid rgba(52, 199, 255, .3);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-card:hover {
  border-color: var(--amber);
}

.ai-card.selected {
  border-color: var(--green);
  background: linear-gradient(180deg, rgba(118, 255, 122, .15), rgba(5, 9, 11, .98));
}

.ai-card h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--amber);
}

.ai-card .difficulty {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 8px;
}

.ai-card .difficulty.简单 {
  background: rgba(118, 255, 122, .2);
  color: var(--green);
}

.ai-card .difficulty.中等 {
  background: rgba(255, 209, 102, .2);
  color: var(--amber);
}

.ai-card .difficulty.困难 {
  background: rgba(255, 77, 102, .2);
  color: var(--red);
}

.ai-card p {
  font-size: 12px;
  color: var(--muted);
}

/* 配置面板 */
.config-panel {
  background: #001a00;
  border: 1px solid var(--green);
  border-radius: 0;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.1) inset;
}

.config-panel h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--amber);
  border-bottom: 1px solid var(--green);
  padding-bottom: 8px;
}

/* 滑块 */
.sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.slider-group {
  background: #002600;
  padding: 12px;
  border-radius: 0;
  border: 1px solid var(--green);
}

.slider-group label {
  display: block;
  font-size: 12px;
  color: var(--green);
  margin-bottom: 6px;
}

.slider-group .value {
  float: right;
  color: var(--amber);
  font-weight: bold;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

/* 策略参数 */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.param-group {
  background: var(--panel2);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(52, 199, 255, .15);
}

.param-group label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.param-group select,
.param-group input[type="range"] {
  width: 100%;
  font-size: 12px;
}

.param-group select {
  padding: 4px;
  background: var(--bg);
  border: 1px solid rgba(52, 199, 255, .4);
  border-radius: 4px;
  color: var(--text);
}

/* 实战指标 */
.derived-stats {
  background: var(--panel2);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(52, 199, 255, .15);
  margin-top: 16px;
}

.derived-title {
  color: var(--amber);
  font-size: 11px;
  margin-bottom: 8px;
}

.derived-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stat-item {
  background: linear-gradient(180deg, rgba(10, 23, 29, .95), rgba(4, 10, 13, .98));
  padding: 6px;
  border: 1px solid rgba(52, 199, 255, .2);
  border-radius: 4px;
  text-align: center;
}

.stat-item span {
  display: block;
  font-size: 10px;
  color: var(--muted);
}

.stat-item b {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}

/* 按钮组 */
.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.btn-group button {
  flex: 1;
  min-width: 120px;
}

/* 房间面板 */
.room-panel {
  background: var(--panel);
  border: 1px solid rgba(52, 199, 255, .4);
  border-radius: 10px;
  padding: 24px;
  max-width: 480px;
  margin: 0 auto;
}

.room-panel h2 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--amber);
}

/* 等待大厅状态条 - 紧凑版 */
.room-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid rgba(52, 199, 255, .4);
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 16px;
  font-size: 14px;
}

.room-status-bar .status-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-status-bar .status-label {
  color: var(--muted);
}

.room-status-bar .room-code {
  font-family: monospace;
  font-size: 16px;
  font-weight: bold;
  color: var(--amber);
  letter-spacing: 2px;
}

.room-status-bar .status-divider {
  color: var(--border);
}

.room-status-bar .waiting-text {
  color: var(--green);
}

.room-status-bar .leave-btn {
  padding: 6px 16px;
  background: rgba(255, 69, 58, 0.2);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.room-status-bar .leave-btn:hover {
  background: rgba(255, 69, 58, 0.3);
}

/* 游戏布局 */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  width: 100%;
}

@media (max-width: 1000px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

.battle-panel {
  min-width: 0;
}

/* 可折叠面板 */
.collapsible {
  background: var(--panel);
  border: 1px solid rgba(52, 199, 255, .4);
  border-radius: 8px;
  overflow: hidden;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.collapsible-header:hover {
  background: rgba(52, 199, 255, 0.1);
}

.collapsible-header h3 {
  font-size: 14px;
  color: var(--amber);
  margin: 0;
}

.toggle-icon {
  transition: transform 0.3s;
  color: var(--muted);
}

.collapsible.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.collapsible-content {
  max-height: 5000px;
  overflow-y: auto;
  transition: max-height 0.3s ease;
}

.collapsible.collapsed .collapsible-content {
  max-height: 0;
}

.configs-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  height: 100%;
}

.configs-panel .collapsible:first-child {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.configs-panel .btn-group {
  flex-shrink: 0;
}

.configs-panel .collapsible {
  min-height: auto;
}

.room-input {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.room-input input {
  flex: 1;
  padding: 10px 14px;
  background: #001a00;
  border: 1px solid var(--green);
  border-radius: 0;
  color: var(--text);
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
  text-transform: uppercase;
  font-family: 'Courier New', monospace;
}

.room-input input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.2) inset;
}

/* 战斗区域 */
.battle-area {
  position: relative;
  margin-bottom: 16px;
}

#arena {
  display: block;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  background: #020506;
  border-radius: 8px;
  border: 1px solid rgba(52, 199, 255, .3);
}

/* HUD */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  max-width: 900px;
  margin: 0 auto 16px;
}

.meter {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  padding: 12px 16px;
}

.meter.red {
  border-color: rgba(255, 77, 102, .4);
}

.meter.blue {
  border-color: rgba(52, 199, 255, .4);
}

.score-display {
  font-size: 32px;
  font-weight: bold;
  text-align: center;
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid rgba(255, 221, 0, .3);
  border-radius: 8px;
  min-width: 80px;
}

.score-display .red {
  color: #ff4d66;
}

.score-display .blue {
  color: #34c7ff;
}

.meter .name {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 6px;
}

.meter.red .name {
  color: var(--red);
}

.meter.blue .name {
  color: var(--blue);
}

.meter .armor-bar {
  height: 8px;
  background: rgba(0, 0, 0, .5);
  border-radius: 4px;
  overflow: hidden;
}

.meter .armor-fill {
  height: 100%;
  transition: width 0.2s;
}

.meter.red .armor-fill {
  background: linear-gradient(90deg, var(--red), #ff8fa3);
}

.meter.blue .armor-fill {
  background: linear-gradient(90deg, var(--blue), #8adfff);
}

/* 状态栏 */
.status-bar {
  text-align: center;
  padding: 10px;
  background: var(--panel);
  border-radius: 6px;
  color: var(--amber);
  margin-bottom: 16px;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.hidden {
  display: none !important;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel);
  border: 1px solid rgba(52, 199, 255, .5);
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.modal-content h2 {
  font-size: 24px;
  margin-bottom: 16px;
}

.modal-content.victory h2 {
  color: var(--green);
}

.modal-content.defeat h2 {
  color: var(--red);
}

.modal-content p {
  color: var(--muted);
  margin-bottom: 24px;
}

.modal-content .btn-group {
  margin-top: 16px;
}

/* 导出导入按钮 */
.io-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.io-buttons input[type="file"] {
  display: none;
}

/* 历史战绩 */
.records-list {
  max-width: 600px;
  margin: 0 auto;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--panel);
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid rgba(52, 199, 255, .15);
}

.record-item .result {
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 4px;
}

.record-item .result.win {
  background: rgba(118, 255, 122, .2);
  color: var(--green);
}

.record-item .result.lose {
  background: rgba(255, 77, 102, .2);
  color: var(--red);
}

.record-item .info {
  flex: 1;
  padding: 0 16px;
}

.record-item .date {
  font-size: 12px;
  color: var(--muted);
}

/* 倒计时覆盖层 */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.countdown-overlay.hidden {
  display: none;
}

.countdown-number {
  font-size: 120px;
  font-weight: bold;
  color: var(--amber);
  text-shadow: 0 0 40px rgba(255, 209, 102, .5);
  animation: pulse 1s ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1.5); opacity: 0; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* 响应式 */
@media (max-width: 768px) {
  .header h1 {
    font-size: 24px;
  }

  .hud {
    grid-template-columns: 1fr;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }
}

/* 导航 */
.nav {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 12px 16px;
  background: #001a00;
  border-bottom: 1px solid var(--green);
  margin-bottom: 16px;
}

.nav a {
  color: var(--green);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 0;
  transition: all 0.2s;
  font-family: 'Courier New', monospace;
}

.nav a:hover {
  color: var(--amber);
  background: #003300;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.2);
}

/* 排行榜表格 */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(52, 199, 255, .1);
}

.leaderboard-table th {
  color: var(--amber);
  font-weight: normal;
  font-size: 12px;
}

.leaderboard-table tr:hover td {
  background: rgba(52, 199, 255, .05);
}

.leaderboard-table td:first-child {
  color: var(--muted);
  width: 40px;
}

.leaderboard-table tr:first-child td {
  color: #ffd700;
}

/* 等待动画 */
.waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.waiting::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--amber);
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* 预览配置 */
.config-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.preview-side {
  background: var(--panel2);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(52, 199, 255, .15);
}

.preview-side.red {
  border-color: rgba(255, 77, 102, .3);
}

.preview-side.blue {
  border-color: rgba(52, 199, 255, .3);
}

.preview-side h4 {
  font-size: 13px;
  margin-bottom: 8px;
}

.preview-side.red h4 {
  color: var(--red);
}

.preview-side.blue h4 {
  color: var(--blue);
}

.preview-side .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  font-size: 11px;
}

.preview-side .stat span {
  color: var(--muted);
}

/* 加载状态 */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--amber);
}

.loading::before {
  content: '加载中';
}

/* AI 教练 */
.coach-result {
  margin-top: 12px;
}

.coach-loading {
  text-align: center;
  padding: 16px;
  color: var(--amber);
  font-size: 13px;
}

.coach-error {
  padding: 12px;
  background: rgba(255, 69, 58, 0.15);
  border: 1px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  font-size: 13px;
}

.coach-analysis {
  padding: 12px;
  background: var(--panel2);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.coach-config {
  margin-top: 10px;
  padding: 12px;
  background: var(--panel2);
  border-radius: 6px;
}

.coach-config-title {
  font-size: 13px;
  color: var(--amber);
  margin-bottom: 8px;
}

.coach-config-line {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  word-break: break-all;
}

.coach-config-line b {
  color: var(--text);
}

.coach-apply-btn {
  margin-top: 8px;
  width: 100%;
}

/* 自定义对话框 */
.app-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: dialogFadeIn .2s ease;
}
@keyframes dialogFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.app-dialog {
  background: var(--panel);
  border: 1px solid rgba(52, 199, 255, .4);
  border-radius: 8px;
  padding: 24px;
  min-width: 320px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 0 30px rgba(0, 255, 0, .1);
}
.app-dialog .dialog-icon {
  font-size: 28px;
  margin-bottom: 12px;
}
.app-dialog .dialog-icon.info { color: var(--blue); }
.app-dialog .dialog-icon.warning { color: var(--amber); }
.app-dialog .dialog-icon.error { color: var(--red); }
.app-dialog .dialog-icon.success { color: var(--green); }
.app-dialog .dialog-message {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}
.app-dialog .dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.app-dialog .dialog-buttons button {
  min-width: 100px;
  padding: 8px 20px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
}
.app-dialog .btn-confirm {
  background: #002600;
  border: 1px solid var(--green);
  color: var(--green);
}
.app-dialog .btn-confirm:hover {
  background: #003300;
  box-shadow: 0 0 8px rgba(0, 255, 0, .2) inset;
}
.app-dialog .btn-cancel {
  background: #1a1a2e;
  border: 1px solid var(--muted);
  color: var(--muted);
}
.app-dialog .btn-cancel:hover {
  background: #252540;
  border-color: var(--text);
  color: var(--text);
}