/* 공통 초기화 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: sans-serif;
  background: #fff;
  color: #333;
  padding: 10px;
}

/* 모달 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #fafafa;
  padding: 20px;
  width: 90%;
  max-width: 320px;
  border-radius: 8px;
  text-align: center;
}
.modal-content h2 {
  margin-bottom: 16px;
}
.modal-content label {
  display: block;
  margin: 8px 0;
  text-align: left;
}
.modal-content select {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
}
.modal-content button {
  margin-top: 12px;
  padding: 8px 16px;
  font-size: 16px;
}

/* 모달 예측 스탯 */
.modal-stats {
  margin: 12px 0;
  text-align: left;
}
.modal-stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0;
}
.modal-stats label {
  width: 60px;
}
.modal-stats progress {
  flex: 1;
  margin: 0 8px;
  height: 12px;
}

/* 스코어보드 */
#scoreTable {
  width: 100%;
  max-width: 640px;
  margin: 0 auto 16px;
  border-collapse: collapse;
  text-align: center;
}
#scoreTable th,
#scoreTable td {
  border: 1px solid #aaa;
  padding: 6px;
}
#scoreTable th.current-inning,
#scoreTable td.current-inning {
  background-color: #ffeeba;
}

/* 필드 */
#field-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto 16px;
  aspect-ratio: 3 / 2;
}
#field {
  width: 100%;
  height: 100%;
  display: block;
  background: #2e8b57;
  border: 2px solid #155724;
}

/* 오버레이 */
.overlay {
  position: absolute;
  background: rgba(255,255,255,0.85);
  padding: 6px 10px;      /* 패딩 줄임 */
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 12px;        /* 폰트 더 작게 */
  z-index: 10;
  min-width: 88px;        /* 너무 줄어들지 않게 최소폭 */
}
.overlay.left { 
  top: 6px;               /* 위 여백 줄임 */
  left: 6px;              /* 왼쪽 여백 줄임 */
}
.overlay.right { 
  top: 6px;               /* 위 여백 줄임 */
  right: 6px;             /* 오른쪽 여백 줄임 */
}
.overlay progress {
  width: 68px;            /* 게이지 바도 작게 */
  vertical-align: middle;
  height: 8px;
}
.overlay span {
  width: 28px;
  font-size: 12px;
}


/* 애니메이션 텍스트 */
#animationText {
  position: absolute;
  bottom: 120px;
  right: 60px;
  font-size: 36px;
  font-weight: bold;
  color: #ff4444;
  opacity: 0;
  transform: scale(1);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9;
}
#animationText.active {
  opacity: 1;
  transform: scale(1.5);
}

/* 카운트 디스플레이 */
#countDisplay {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-size: 14px;
  text-align: right;
}
.count-row {
  margin: 4px 0;
}
.circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #333;
  background: #fff;
  display: inline-block;
  margin-left: 4px;
}
/* 기본 원형 공통 스타일 */
.circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #333;
  background: #fff;
  display: inline-block;
  margin-left: 4px;
}

/* 색상 분리 적용 */
.circle.ball.active    { background: #4da6ff; } /* 볼: 파랑 */
.circle.strike.active  { background: #f8d90f; } /* 스트라이크: 노랑 */
.circle.out.active     { background: #ef3232; } /* 아웃: 빨강 */

/* 로그 */
#log {
  width: 100%;
  max-width: 640px;
  height: 160px;
  margin: 0 auto 16px;
  padding: 8px;
  border: 1px solid #333;
  background: #fafafa;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.4;
}

/* 차트 */
#battingChart,
#runChart {
  display: block;
  width: 100%;
  max-width: 600px;
  margin: 0 auto 16px;
  border: 1px solid #333;
}

/* 반응형 */
@media (max-width:480px) {
  #log { height:120px; }
  .modal-content { padding:12px; }
  .modal-content h2 { font-size:18px; }
  .overlay progress { width:80px; }
.batter-order-modal h4 {
    font-size: 8px;
}
}

@media (max-width: 600px) {
  .overlay {
    font-size: 11px;
    padding: 5px 7px;
    min-width: 66px;
  }
  .overlay progress {
    width: 40px;
    height: 7px;
  }
  .overlay span {
    width: 18px;
    font-size: 11px;
  }
}

/* 경기결과 저장 오버레이(필드 중앙) */
#saveResultOverlay {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1100;
}
#saveResultBtn {
  display: none;
  pointer-events: all;
  padding: 24px 48px;
  font-size: 2rem;
  border: none;
  border-radius: 32px;
  background: linear-gradient(90deg,#f5f6fa,#d1d8e6 80%);
  color: #222;
  font-weight: bold;
  box-shadow: 0 6px 24px 0 #ccd2e2, 0 1.5px 8px #b0b8cf;
  transition: box-shadow 0.2s, background 0.2s;
  cursor: pointer;
}
#saveResultBtn:hover {
  background: linear-gradient(90deg,#e2e7ef,#bfc7db 80%);
  box-shadow: 0 12px 36px 0 #b8bed3, 0 3px 16px #a5adc3;
}

/* 경기결과 표 맥 스타일 */
.mac-table {
  width: 100%;
  max-width: 560px;
  margin: 32px auto;
  border-collapse: separate;
  border-spacing: 0;
  background: #f9fafb;
  border-radius: 18px;
  box-shadow: 0 4px 24px 0 #ccd2e2;
  overflow: hidden;
}
.mac-table th, .mac-table td {
  padding: 18px 14px;
  font-size: 1.09rem;
  font-family: "SF Pro Text", "Apple SD Gothic Neo", "맑은 고딕", "Malgun Gothic", "Segoe UI", Arial, sans-serif;
  text-align: center;
  border-bottom: 1px solid #e1e5eb;
  background: linear-gradient(90deg,#f7faff 80%,#f0f2f7);
}
.mac-table th {
  background: #e7ebf3;
  font-weight: 600;
  color: #31364d;
  border-bottom: 2px solid #dde3f0;
  letter-spacing: 0.01em;
}
.mac-table tr:last-child td {
  border-bottom: none;
}
.mac-table tbody tr:hover {
  background: #f0f3fa;
  transition: background 0.2s;
}

#effectMsg {
  position: absolute;
  left: 50%;
  top: 62%; /* 아래 JS에서 정확한 위치로 조정할 것! */
  transform: translate(-50%, -50%);
  font-size: 32px; /* 기존 48px → 32px로 줄임 */
  font-weight: bold;
  color: #f8d90f;
  text-shadow: 0 3px 12px #a77, 0 0 24px #fff, 0 0 8px #f8d90f;
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
}

.effect-fadeup {
  animation: fadeUp 1s cubic-bezier(.3,1.4,.7,1) both;
  opacity: 1 !important;
}
@keyframes fadeUp {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -56%) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -65%) scale(1.1);
  }
}

#attackStatus {
  position: absolute;
  bottom: 16px;     /* 하단 여백 */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  font-size: 1.05rem;       /* 기존보다 더 작게 */
  font-weight: bold;
  padding: 5px 18px;
  border-radius: 16px;
  background: linear-gradient(90deg, #f2fbfe 80%, #f3f4fa);
  color: #2577c3;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 10px #e2ecf8;
  border: 1.5px solid #bfdafd;
  pointer-events: none;
  user-select: none;
  transition: background 0.2s, color 0.2s;
}

.batter-order-modal {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #aaa;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 8.2px;
  line-height: 1.2;
  width: auto;
  max-width: 140px;
  z-index: 1000;
}

.batter-order-modal h4 {
  font-size: 9px;
  margin-bottom: 4px;
  text-align: center;
  font-weight: bold;
  color: #222;
  white-space: nowrap;
}

.batter-order-modal .batter-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 2px;
  margin-bottom: 1px;
  font-size: 8px;
}

.batter-order-modal .highlight {
  background-color: #fff4b4;
  font-weight: bold;
  color: #d35400;
  border-left: 2px solid #ffae00;
}
.restart-btn {
  margin-top: 20px;
  padding: 8px 16px;
  font-size: 14px;
  background-color: #2c8be7;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.restart-btn:hover {
  background-color: #166ab4;
}