/* ============================================================
   ShareGolfScore — グローバルスタイル
   ============================================================ */

/* ─── リセット・ベース ─────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Noto Sans JP', 'Yu Gothic', sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
  line-height: 1.6;
}

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  transition: background 0.15s, opacity 0.15s;
}

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

input[type="text"],
input[type="number"] {
  font-family: inherit;
  font-size: 1rem;
  border: 1.5px solid #cbd5e0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: #4299e1;
}

/* ─── 画面（screen）─────────────────────────────────────────── */

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
}

/* ─── トップ画面 ────────────────────────────────────────────── */

.top-inner {
  padding-top: 2rem;
}

.app-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: #2d6a4f;
}

.divider {
  text-align: center;
  color: #718096;
  margin: 1rem 0;
  position: relative;
}

.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #cbd5e0;
}

.divider::before { left: 0; }
.divider::after  { right: 0; }

/* ─── カード ────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #2d3748;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── フォーム ─────────────────────────────────────────────── */

.form-group {
  margin-bottom: 0.75rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0.25rem;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.form-row input {
  flex: 1;
}

.radio-group {
  display: flex;
  gap: 1.5rem;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  color: #2d3748;
}

.field-error {
  font-size: 0.8rem;
  color: #e53e3e;
  margin-top: 0.25rem;
  min-height: 1.2em;
}

/* ─── ボタン ────────────────────────────────────────────────── */

.btn {
  padding: 0.5rem 1rem;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: #2d6a4f;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1b4332;
}

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e0;
}

.btn-danger {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #feb2b2;
}

.btn-danger:hover:not(:disabled) {
  background: #fed7d7;
}

.btn-block {
  width: 100%;
  padding: 0.75rem;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.875rem;
}

.btn-icon {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  font-size: 1.1rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}

.btn-icon:hover:not(:disabled) {
  background: #e2e8f0;
}

/* ─── 画面ヘッダー ──────────────────────────────────────────── */

.screen-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
  margin: -1rem -1rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.header-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2d6a4f;
}

.header-actions {
  display: flex;
  gap: 0.4rem;
}

.header-url {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.url-text {
  color: #4299e1;
  font-size: 0.75rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 画面本体 ─────────────────────────────────────────────── */

.screen-body {
  padding-top: 0.25rem;
}

.bottom-action {
  padding: 1rem 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ─── プレイヤーリスト ───────────────────────────────────────── */

.player-list {
  list-style: none;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f4f8;
}

.player-item:last-child {
  border-bottom: none;
}

.player-name {
  font-weight: 500;
}

.count-badge {
  font-size: 0.8rem;
  background: #ebf8ff;
  color: #2b6cb0;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  font-weight: 400;
}

.empty-message {
  color: #a0aec0;
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

/* ─── OUT/IN タブ ────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
  padding: 0.5rem 1.5rem;
  background: transparent;
  color: #718096;
  border-radius: 0;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: #2d6a4f;
  border-bottom-color: #2d6a4f;
}

.tab-btn:hover:not(:disabled):not(.active) {
  color: #4a5568;
  background: transparent;
}

/* ─── スコアボードテーブル ───────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.score-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
  background: #fff;
  font-size: 0.875rem;
}

.score-table th,
.score-table td {
  padding: 0.5rem 0.6rem;
  text-align: center;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.score-table thead th {
  background: #f7fafc;
  font-weight: 700;
  color: #4a5568;
}

.score-table .par-row td {
  background: #f0fff4;
  font-weight: 600;
  color: #276749;
}

.score-table .player-col {
  text-align: left;
  font-weight: 600;
  min-width: 5em;
  background: #fafafa;
}

.score-table .total-col {
  font-weight: 700;
  background: #fff5e0;
}

.score-table .score-empty {
  color: #a0aec0;
}

/* ─── スコア入力 ────────────────────────────────────────────── */

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.player-chip {
  padding: 0.4rem 1rem;
  background: #edf2f7;
  color: #2d3748;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

.player-chip.active {
  background: #2d6a4f;
  color: #fff;
}

.player-chip:hover:not(:disabled):not(.active) {
  background: #e2e8f0;
}

.selected-name {
  font-size: 0.9rem;
  color: #2d6a4f;
  font-weight: 400;
}

.holes-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.holes-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
}

.holes-table th,
.holes-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  text-align: center;
}

.holes-table thead th {
  background: #f7fafc;
  font-weight: 700;
  color: #4a5568;
}

.holes-table tr:nth-child(even) td {
  background: #f9fafb;
}

.par-note {
  font-size: 0.78rem;
  color: #718096;
  margin-top: 0.5rem;
}

/* ─── +/- スピナー ─────────────────────────────────────────── */

.spinner {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.spinner-btn {
  width: 2rem;
  height: 2rem;
  background: #edf2f7;
  color: #2d3748;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-btn:hover:not(:disabled) {
  background: #e2e8f0;
}

.spinner-value {
  min-width: 2rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
}

/* ─── エラー画面 ────────────────────────────────────────────── */

.error-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: 1rem;
}

.error-icon {
  font-size: 3rem;
}

.error-inner h2 {
  font-size: 1.4rem;
  color: #c53030;
}

.error-desc {
  color: #718096;
  font-size: 0.9rem;
  max-width: 320px;
}

/* ─── トースト ──────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(4rem);
  background: rgba(26, 32, 44, 0.9);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 24px;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── 合計スコア モーダル ────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;        /* スマホ: 下から出現 */
  justify-content: center;
  z-index: 200;
}

.modal-sheet {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 860px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.modal-sheet-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2d3748;
}

.modal-sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 0 1rem;
}

.modal-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0.75rem;
}

.total-modal-table {
  min-width: 560px;
}

.grand-total-col {
  background: #ebf8ff !important;
  font-weight: 800;
  color: #2b6cb0;
}

/* ─── PC レイアウト（640px 以上）────────────────────────────── */

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;  /* PC: 中央表示 */
  }

  .modal-sheet {
    border-radius: 16px;
    max-height: 80vh;
    width: 90%;
  }

  .screen {
    padding: 1.5rem;
  }

  .score-table {
    font-size: 0.9rem;
  }

  .score-table th,
  .score-table td {
    padding: 0.6rem 0.75rem;
  }

  .card {
    padding: 1.5rem;
  }
}
