/* 羽毛球实时计分系统 - 横屏移动端适配 */
:root {
  --court-green: #2d8a4e;
  --court-line: #ffffff;
  --court-bg: #1a5c32;
  --team-a: #e74c3c;
  --team-b: #3498db;
  --gold: #f1c40f;
  --dark: #1a1a2e;
  --card-bg: #16213e;
  --text: #e8e8e8;
  --accent: #0f3460;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--dark);
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}

/* 强制横屏提示 */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--dark);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
  font-size: 18px;
  text-align: center;
  padding: 20px;
}

#rotate-hint .icon {
  font-size: 48px;
  animation: rotate-anim 2s ease-in-out infinite;
}

@keyframes rotate-anim {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

/* 横屏提示由JS控制显示 */

/* 主应用容器 */
#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部比分栏 */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 4px 12px;
  height: 52px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--accent);
}

.team-score {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.team-score.right {
  flex-direction: row-reverse;
}

.team-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-display {
  font-size: 32px;
  font-weight: 900;
  min-width: 40px;
  text-align: center;
  line-height: 1;
}

.team-a-color { color: var(--team-a); }
.team-b-color { color: var(--team-b); }

.score-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.game-info {
  font-size: 11px;
  color: #aaa;
}

.game-dots {
  display: flex;
  gap: 4px;
}

.game-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #555;
  background: transparent;
}

.game-dot.won-a { background: var(--team-a); border-color: var(--team-a); }
.game-dot.won-b { background: var(--team-b); border-color: var(--team-b); }
.game-dot.current { border-color: var(--gold); box-shadow: 0 0 4px var(--gold); }

.server-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--gold);
  color: #000;
  font-weight: 700;
  margin-left: 4px;
}

/* 球场区域 */
.court-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  min-height: 0;
}

.court-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 2 / 1;
  max-height: 100%;
}

/* SVG球场 */
.court-svg {
  width: 100%;
  height: 100%;
}

/* 发球区高亮 */
.server-zone {
  fill: rgba(241, 196, 15, 0.25);
  stroke: var(--gold);
  stroke-width: 2;
  stroke-dasharray: 6 3;
  animation: pulse-zone 1.5s ease-in-out infinite;
}

.receiver-zone {
  fill: rgba(255, 255, 255, 0.1);
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

@keyframes pulse-zone {
  0%, 100% { fill-opacity: 0.25; }
  50% { fill-opacity: 0.45; }
}

/* 球员标记 */
.player-marker {
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.player-dot {
  r: 12;
  stroke-width: 2;
}

/* 底部操作栏 */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--card-bg);
  height: 56px;
  flex-shrink: 0;
  border-top: 2px solid var(--accent);
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.95);
}

.btn-score-a {
  background: var(--team-a);
  color: #fff;
  min-width: 80px;
}

.btn-score-b {
  background: var(--team-b);
  color: #fff;
  min-width: 80px;
}

.btn-fault-a {
  background: #c0392b;
  color: #fff;
  font-size: 12px;
}

.btn-fault-b {
  background: #2980b9;
  color: #fff;
  font-size: 12px;
}

.btn-undo {
  background: #555;
  color: #fff;
  font-size: 12px;
}

.btn-action {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

/* 换边提示 */
.swap-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
}

.swap-overlay.show {
  display: flex;
}

.swap-overlay h2 {
  font-size: 28px;
  color: var(--gold);
}

.swap-overlay p {
  font-size: 16px;
  color: #ccc;
}

/* 比赛结束弹窗 */
.match-end-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 200;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
}

.match-end-overlay.show {
  display: flex;
}

.match-end-overlay h1 {
  font-size: 36px;
  color: var(--gold);
}

.match-end-overlay .final-score {
  font-size: 48px;
  font-weight: 900;
}

/* 创建比赛页面 */
.create-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
  gap: 16px;
}

.create-page h1 {
  font-size: 24px;
  color: var(--gold);
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-row label {
  min-width: 70px;
  font-size: 13px;
}

.form-row input, .form-row select {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #222;
  color: #fff;
  font-size: 14px;
}

.btn-create {
  background: var(--gold);
  color: #000;
  font-size: 16px;
  padding: 12px;
  margin-top: 8px;
}

/* 比赛列表 */
.match-list {
  width: 100%;
  max-width: 500px;
}

.match-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.match-item:hover {
  background: var(--accent);
}

.match-item .teams {
  font-size: 14px;
  font-weight: 600;
}

.match-item .status {
  font-size: 12px;
  color: #aaa;
}

/* 发球信息栏 */
.server-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 2px 0;
  font-size: 12px;
  color: #aaa;
  background: rgba(0,0,0,0.3);
  height: 22px;
  flex-shrink: 0;
}

.server-info .highlight {
  color: var(--gold);
  font-weight: 700;
}

/* Deuce提示 */
.deuce-badge {
  color: var(--gold);
  font-weight: 900;
  font-size: 14px;
  animation: deuce-flash 0.8s ease-in-out infinite;
}

@keyframes deuce-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
