:root {
  --color-primary: #1f4e8c;
  --color-primary-dark: #163865;
  --color-accent: #d4a017;
  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-border: #e1e4e8;
  --color-text: #1f2328;
  --color-text-muted: #656d76;
  --color-success: #2da44e;
  --color-danger: #cf222e;
  --color-warning: #bf8700;

  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);

  --nav-height: 60px;
  --header-height: 56px;
  --max-width: 720px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ========== Header ========== */
.app-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.app-header h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .header-status {
  font-size: 0.8rem;
  opacity: 0.9;
}

/* ========== Main ========== */
.app-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 24px);
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-primary);
}

/* ========== Bottom Navigation ========== */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  z-index: 50;
}
.app-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  gap: 2px;
}
.app-nav a.active { color: var(--color-primary); font-weight: 600; }
.app-nav .nav-icon { font-size: 1.4rem; line-height: 1; }

/* ========== Cards ========== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 8px;
}
.card-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  min-height: 44px;
}
.btn:hover { background: #f3f4f6; }
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-accent {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-danger {
  background: var(--color-surface);
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; min-height: 32px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== Forms ========== */
.field {
  display: block;
  margin-bottom: 12px;
}
.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text);
}
.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}
.field-textarea { min-height: 80px; resize: vertical; }
.field-row {
  display: flex;
  gap: 8px;
}
.field-row .field { flex: 1; }

/* ========== Hero (top page) ========== */
.hero {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  padding: 32px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  text-align: center;
}
.hero h2 { margin: 0 0 8px; font-size: 1.4rem; }
.hero p { margin: 0; opacity: 0.95; font-size: 0.95rem; }

/* ========== Result Badge ========== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-win { background: #ddf4e2; color: var(--color-success); }
.badge-lose { background: #ffebe9; color: var(--color-danger); }
.badge-draw { background: #f0f0f0; color: var(--color-text-muted); }

/* ========== Score ========== */
.score-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.1rem;
  margin: 8px 0;
}
.score-line .vs { color: var(--color-text-muted); font-size: 0.85rem; }
.score-num {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ========== Modal ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  box-shadow: var(--shadow-md);
}
.modal h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions .btn { flex: 1; }

/* ========== Attendance ========== */
.attendance-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}
.attendance-grid .name { font-size: 0.95rem; }
.attendance-buttons {
  display: flex;
  gap: 4px;
}
.att-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.att-btn.active-yes { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.att-btn.active-maybe { background: var(--color-warning); color: #fff; border-color: var(--color-warning); }
.att-btn.active-no { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }

/* ========== Empty ========== */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ========== Stats Table ========== */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.stats-table th, .stats-table td {
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
}
.stats-table th:first-child, .stats-table td:first-child {
  text-align: left;
}
.stats-table th {
  background: #f6f8fa;
  font-weight: 600;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  max-width: 90%;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-success); }

/* ========== Loading ========== */
.loading {
  text-align: center;
  padding: 24px;
  color: var(--color-text-muted);
}

/* ========== Action bar ========== */
.action-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.tab {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ========== Photos ========== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 12px;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: #f0f0f0;
  cursor: pointer;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}
.photo-thumb:hover img { transform: scale(1.04); }

.photo-grid-edit {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.photo-grid-edit:empty { display: none; }
.photo-edit-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: #f0f0f0;
}
.photo-edit-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.photo-remove-btn:hover { background: var(--color-danger); }

/* ========== Lightbox ========== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.lightbox.open { display: flex; }
.lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lightbox-close { top: 16px; right: 16px; font-size: 28px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox-caption {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ========== Scoreboard (input) ========== */
.home-toggle {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 6px;
  flex-wrap: wrap;
}
.ht-btn {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}
.ht-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.scoreboard-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
}
table.scoreboard {
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  width: max-content;
  min-width: 100%;
}
table.scoreboard th, table.scoreboard td {
  border: 1px solid var(--color-border);
  text-align: center;
  padding: 0;
  min-width: 36px;
  height: 36px;
}
table.scoreboard th {
  background: #f6f8fa;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
table.scoreboard th:first-child, table.scoreboard td:first-child {
  text-align: center;
  background: #f6f8fa;
  font-weight: 700;
  font-size: 0.85rem;
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 56px;
}
table.scoreboard input.inning-cell {
  width: 100%;
  height: 100%;
  text-align: center;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  -moz-appearance: textfield;
}
table.scoreboard input.inning-cell::-webkit-outer-spin-button,
table.scoreboard input.inning-cell::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
table.scoreboard input.inning-cell:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
table.scoreboard .total {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  min-width: 44px;
}
table.scoreboard tr.us-row td:first-child {
  background: #dde9f6;
  color: var(--color-primary);
}

/* ========== Scoreboard (card display) ========== */
.scoreboard-display {
  margin: 10px -4px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.scoreboard-display table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.scoreboard-display th,
.scoreboard-display td {
  border: 1px solid var(--color-border);
  text-align: center;
  padding: 4px 6px;
  min-width: 26px;
}
.scoreboard-display th {
  background: #f6f8fa;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.scoreboard-display .team-name {
  text-align: left;
  font-weight: 600;
  background: #f6f8fa;
  white-space: nowrap;
  min-width: 56px;
  font-size: 0.8rem;
}
.scoreboard-display .total {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  min-width: 36px;
}
.scoreboard-display tr.us-row .team-name {
  background: #dde9f6;
  color: var(--color-primary);
}

/* ========== Stats Entry Modal ========== */
.stats-modal {
  max-width: 540px;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.stats-list {
  flex: 1;
  overflow: auto;
  margin: 0 -4px;
  padding: 0 4px;
}
.stats-member-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}
.stats-member-header {
  width: 100%;
  background: var(--color-surface);
  border: none;
  padding: 14px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  align-items: center;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}
.stats-member-header:hover { background: #f6f8fa; }
.stats-member-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-member-name .num-badge {
  background: var(--color-primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.stats-member-summary {
  grid-column: 1 / 2;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.stats-member-toggle {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  transition: transform 0.2s;
}
.stats-member-card.expanded .stats-member-toggle { transform: rotate(180deg); }
.stats-member-body {
  display: none;
  padding: 4px 12px 12px;
  background: #fafbfc;
  border-top: 1px solid var(--color-border);
}
.stats-member-card.expanded .stats-member-body { display: block; }
.stats-section h5 {
  margin: 12px 0 4px;
  font-size: 0.85rem;
  color: var(--color-primary);
  font-weight: 600;
}
.stat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 6px 0;
  gap: 8px;
}
.stat-label {
  font-size: 0.95rem;
}
.stat-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1.4rem;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.stat-btn:active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  transform: scale(0.95);
}
.stat-btn-plus:active {
  background: var(--color-success);
  border-color: var(--color-success);
}
.stat-value {
  min-width: 32px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.05rem;
}
.decision-buttons {
  display: flex;
  gap: 6px;
}
.dec-btn {
  min-width: 44px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0 10px;
}
.dec-btn:active { transform: scale(0.95); }
.dec-btn.active-win { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.dec-btn.active-loss { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.dec-btn.active-none { background: var(--color-text-muted); color: #fff; border-color: var(--color-text-muted); }

/* ========== Plays Modal: readonly (確定済み) ========== */
.play-readonly .play-entry,
.play-readonly .entry-toggle,
.play-readonly .lineup-actions,
.play-readonly .lineup-row-position,
.play-readonly .home-toggle,
.play-readonly .play-edit-btn,
.play-readonly .play-del-btn,
.play-readonly .member-pool,
.play-readonly .member-pool-btn,
.play-readonly #change-pitcher,
.play-readonly #add-yes-attendees,
.play-readonly #add-maybe-attendees,
.play-readonly [data-add-member] {
  display: none !important;
}
.play-readonly .lineup-row {
  cursor: default;
}

/* ========== Plays Modal (打席記録) ========== */
.plays-modal {
  max-width: 560px;
  width: 100%;
  max-height: 96vh;
  height: 96vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* override .modal の overflow:auto。中身でスクロール */
  padding: 14px;
}
.plays-modal > h3,
.plays-modal > .card-meta,
.plays-modal > .play-tabs,
.plays-modal > .modal-actions {
  flex-shrink: 0;
}
.play-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.play-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
}
.play-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.play-tab-content {
  flex: 1;
  min-height: 0;
}
#tab-lineup {
  overflow-y: auto;
}
#tab-offense,
#tab-defense {
  flex-direction: column; /* 表示時に display:flex のとき効く */
  overflow: hidden;
}
.play-entry {
  flex-shrink: 0;
}
.play-entry.collapsed {
  display: none;
}
.entry-toggle {
  width: 100%;
  background: #f6f8fa;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 8px;
  text-align: left;
  font-weight: 500;
  flex-shrink: 0;
}
.entry-toggle:hover {
  background: #eef4fb;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.entry-bottom-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.entry-bottom-bar .btn-primary {
  min-height: 48px;
  font-weight: 700;
  font-size: 1rem;
}
.entry-bottom-bar .btn-primary:disabled {
  opacity: 0.4;
}
.plays-list-title {
  flex-shrink: 0;
  margin: 10px 0 6px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.plays-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

/* 打順リスト */
.lineup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lineup-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px;
}
.lineup-row-main {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
}
.lineup-row-position {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-left: 40px;
}
.lineup-pos-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.lineup-pos-select {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  font-size: 0.85rem;
}
.lineup-pos {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 1rem;
  text-align: center;
  background: #eef4fb;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lineup-name {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.num-badge {
  background: var(--color-primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.lineup-actions {
  display: flex;
  gap: 4px;
}
.lineup-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lineup-icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.member-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.member-pool-btn {
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px dashed var(--color-border);
  background: var(--color-surface);
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.member-pool-btn:hover {
  background: #eef4fb;
  border-color: var(--color-primary);
}

/* 攻撃タブ */
.play-state {
  background: #eef4fb;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.play-state-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.play-state-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
}
.play-state-out {
  font-size: 0.9rem;
  color: var(--color-warning);
  font-weight: 600;
}
.play-state-runs {
  font-size: 0.9rem;
  color: var(--color-success);
  font-weight: 600;
}
.batter-info {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.batter-info strong {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.result-btn {
  padding: 10px 2px;
  border-radius: 6px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 42px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-btn:active { transform: scale(0.96); }
.result-btn.is-out {
  color: var(--color-text-muted);
}
.result-btn.is-onbase {
  color: var(--color-primary);
}
.result-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.result-btn.active.is-out {
  background: var(--color-text-muted);
  border-color: var(--color-text-muted);
}
.rbi-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 0;
  gap: 8px;
}
.plays-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.play-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #fafbfc;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
}
.play-inning {
  font-weight: 600;
  color: var(--color-primary);
}
.play-result {
  color: var(--color-text);
  font-size: 0.85rem;
}
.play-edit-btn,
.play-del-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.play-edit-btn:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.play-del-btn:hover { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }

.play-row {
  grid-template-columns: 36px 1fr auto auto auto !important;
}

/* 打席編集 / 投手選択ポップアップ */
.play-edit-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 16px;
}
.play-edit-popup {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-md);
}
.play-edit-popup h4 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--color-primary);
}
.member-pool-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  border-style: solid;
}

/* ========== Top-page Slideshow ========== */
.slideshow {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: #1a1a1a;
}
.slideshow:empty { display: none; }
.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.slide.active { opacity: 1; }
.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.slide-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  padding: 24px 16px 14px;
  font-size: 0.85rem;
  font-weight: 500;
}
.slide-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}
.slide-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  padding: 0;
  cursor: pointer;
}
.slide-dot.active { background: rgba(255, 255, 255, 0.9); }

/* ========== Desktop tweaks ========== */
@media (min-width: 720px) {
  .app-main { padding: 24px; }
  .hero { padding: 48px 32px; }
  .hero h2 { font-size: 1.8rem; }
}
