/* app/css/style.css */
:root {
  --color-bg: #eeeeee;
  --color-surface: #ffffff;
  --color-text: #111111;
  --color-text-muted: #888888;
  --color-border: #dcdcdc;
  --color-accent: #111111;
  --color-accent-text: #ffffff;
  --color-ball: #2e9e5b;
  --color-strike: #d9a400;
  --color-out: #d1392b;
  --radius-md: 0px;
  --spacing-unit: 8px;

  --font-scoreboard: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  max-width: 420px;
  margin-inline: auto; /* mobile-first, centered with side margins on desktop — spec §1 */
  padding: 12px 12px 32px;
}

h1 { font-size: 20px; margin: 12px 0 20px; }

.btn {
  display: block;
  width: 100%;
  padding: calc(var(--spacing-unit) * 2);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  font-family: inherit;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-text);
  border-color: var(--color-accent);
}

.btn-primary:disabled {
  background: #ddd;
  color: #999;
  border-color: #ddd;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary.btn-primary,
.btn-secondary.on {
  background: var(--color-accent);
  color: var(--color-accent-text);
  border-color: var(--color-accent);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.view { display: none; }
.view.active { display: block; }

/* ---- team row ---- */
.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
}
.side { display: flex; align-items: center; gap: 6px; }
.side.attacking { color: var(--color-text); }
.vs { font-size: 10px; font-weight: 400; color: #bbb; }
.attack-tag {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: #111;
  padding: 1px 5px;
  letter-spacing: 0.02em;
}

/* ---- scoreboard ---- */
.scoreboard-panel {
  text-align: center;
}
.score-row {
  font-family: var(--font-scoreboard);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.score-colon { color: #bbb; margin: 0 8px; }
.inning-row { font-size: 11px; color: var(--color-text-muted); margin: 2px 0 8px; }

.field-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.base-diagram { position: relative; width: 44px; height: 44px; flex: none; }
.base-diagram .diamond {
  position: absolute; inset: 7px;
  border: 1.5px solid #ddd;
  transform: rotate(45deg);
}
.base-diagram .base {
  position: absolute; width: 8px; height: 8px;
  border: 1.5px solid #bbb; background: #fff;
  transform: rotate(45deg);
}
.base-diagram .base.on { background: #111; border-color: #111; }
.base-diagram .base.b1 { right: 0; top: 50%; margin-top: -4px; }
.base-diagram .base.b2 { top: 0; left: 50%; margin-left: -4px; }
.base-diagram .base.b3 { left: 0; top: 50%; margin-top: -4px; }

.bso-compact { display: flex; flex-direction: column; gap: 3px; }
.bso-row { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--color-text-muted); }
.bso-lbl { width: 10px; font-weight: 700; color: #888; text-align: left; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #e2e2e2;
}
.dot.dot-b.lit { background: var(--color-ball); }
.dot.dot-s.lit { background: var(--color-strike); }
.dot.dot-o.lit { background: var(--color-out); }

/* ---- ready row (준비상태) ---- */
.ready-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  background: #fafafa;
}
.ready-row .who { color: #555; }
.ready-row .status { font-weight: 700; margin-left: 3px; }
.ready-row .status.ready { color: #111; }
.ready-row .status.waiting { color: #bbb; }
.ready-row .divider { color: #ddd; }

/* ---- combined play row: 구종(좌) / 존(중앙) / 확정(우) ---- */
.play-row { display: flex; gap: 7px; align-items: stretch; }
.pitchtype-col { display: flex; flex-direction: column; gap: 6px; flex: 0 0 58px; margin: 0; }
.pitchtype-col .btn {
  flex: 1;
  margin: 0;
  padding: 6px 2px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.zone-diagram {
  position: relative;
  flex: 1;
  max-width: 160px;
  aspect-ratio: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-inline: auto;
}
.zone-outer-tag { position: absolute; top: 5px; left: 6px; font-size: 9px; color: #bbb; pointer-events: none; }
.zone-outer-click { position: absolute; inset: 0; z-index: 0; background: transparent; border: none; cursor: pointer; }
.zone-outer-click.btn-primary { background: rgba(17,17,17,0.08); }

.zone-strike {
  position: absolute; inset: 20%;
  border: 2px solid #111;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  background: #f6f6f6;
}
.zone-strike button {
  border: none; background: transparent; font-family: inherit;
  font-weight: 700; font-size: 12px; color: #555; cursor: pointer;
}
.zone-strike button:nth-child(1) { border-right: 1px dashed #ddd; border-bottom: 1px dashed #ddd; }
.zone-strike button:nth-child(2) { border-bottom: 1px dashed #ddd; }
.zone-strike button:nth-child(3) { border-right: 1px dashed #ddd; }
.zone-strike button.btn-primary { background: #111; color: #fff; }

.zone-center {
  position: absolute; inset: 40%;
  background: #eee; border: 1px solid #bbb;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #222;
  cursor: pointer; z-index: 2; font-family: inherit;
}
.zone-center.btn-primary { background: #111; border-color: #111; color: #fff; }

.confirm-col {
  flex: 0 0 58px;
  background: var(--color-accent);
  color: var(--color-accent-text);
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.confirm-col:disabled { background: #ddd; color: #999; cursor: not-allowed; }

/* ---- broadcast log ---- */
#broadcast-log { font-size: 12.5px; line-height: 1.6; }
#broadcast-log div { padding: 3px 0; border-bottom: 1px solid #f2f2f2; }
#broadcast-log div:nth-child(even) { background: #fafafa; }

/* ---- team name popup ---- */
.team-modal-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.team-modal-overlay[hidden] { display: none; }
.team-modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-top: 1px solid var(--color-border);
  padding: 18px 16px 20px;
}
.team-modal-title { font-size: 13.5px; font-weight: 700; color: #111; margin: 0 0 3px; }
.team-modal-sub { font-size: 11px; color: #888; margin: 0 0 12px; }
.team-modal-input {
  width: 100%; border: 1px solid #999; background: #fff;
  padding: 10px 11px; font-size: 14px; font-family: inherit; color: #111;
  margin-bottom: 10px;
}
.team-modal-input:focus { outline: none; border-color: #111; }
.team-modal-confirm {
  display: block; width: 100%; background: #111; color: #fff;
  border: none; font-family: inherit; font-weight: 700; font-size: 13.5px;
  padding: 12px; cursor: pointer;
}
