/* ================================
   IBCRecord — Global Design System
   ================================ */

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

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --card:     #21262d;
  --border:   #30363d;
  --orange:   #f97316;
  --orange-h: #ea6a0a;
  --blue:     #58a6ff;
  --blue-h:   #388bfd;
  --red:      #f85149;
  --red-h:    #da3633;
  --green:    #3fb950;
  --yellow:   #e3b341;
  --gray-btn: #6e7681;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --radius:   10px;
  --shadow:   0 8px 32px rgba(0, 0, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 1rem; /* 16px ベース */
}

/* ============================
   Auth Pages (home / login / register)
   ============================ */

.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-logo {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  display: block;
  text-align: center;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 32px;
  text-align: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 22px;
  color: var(--text);
}

/* ---- Form Fields ---- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.05rem;
  transition: border-color 0.15s;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--orange);
}

.field select option {
  background: var(--card);
  color: var(--text);
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 11px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
  text-align: center;
  width: 100%;
  text-decoration: none;
}

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

.btn-primary  { background: var(--orange); color: #fff; }
.btn-primary:hover  { background: var(--orange-h); }

.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: var(--blue-h); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-h); }

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Notices ---- */
.notice {
  padding: 11px 15px;
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 18px;
}

.notice-error {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.35);
  color: #ff7b72;
}

.notice-info {
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: #fdba74;
}

/* ---- Divider & Utility ---- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.text-muted { color: var(--muted); font-size: 1rem; }
.text-center { text-align: center; }

/* ============================
   App Layout (shot pages)
   ============================ */

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.tag {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 13px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.tag.guest {
  border-color: var(--gray-btn);
  color: var(--muted);
}

/* Main Content */
.app-main {
  flex: 1;
  padding: 24px 20px;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Guest Banner ---- */
.guest-banner {
  background: rgba(107, 114, 128, 0.1);
  border: 1px solid rgba(107, 114, 128, 0.28);
  border-radius: 8px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.guest-banner p {
  font-size: 1rem;
  color: var(--muted);
  text-align: left;
}

.guest-banner .btn {
  white-space: nowrap;
  width: auto;
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 1rem;
}

/* ---- Share Banner (analytics owner) ---- */
.share-banner {
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.22);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.share-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 4px;
}

.share-url {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.95rem;
  color: var(--blue);
  word-break: break-all;
}

.share-banner .btn {
  width: auto;
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 1rem;
}

/* ---- Viewer Banner (analytics non-owner) ---- */
.viewer-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 1rem;
  color: var(--muted);
}

.viewer-name {
  color: var(--text);
  font-weight: 600;
}

/* ---- Summary Cards ---- */
.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
}

.summary-card .label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 8px;
}

.summary-card .value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}

.summary-card .value .unit {
  font-size: 1.15rem;
  color: var(--muted);
  font-weight: 400;
}

/* ---- Court Overlay ---- */
.court-wrap {
  position: relative;
  max-width: 800px;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  /* overflow: hidden を外すことで、コーナーゾーンボタンのクリッピングを防ぐ */
  border: 1px solid var(--border);
}

.court {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: calc(var(--radius) - 1px);
}

/* Overlay positioning (calibrated to court image) */
.area  { position: absolute; display: flex; justify-content: space-around; width: 100%; top: 14%; left: 50%; transform: translate(-50%, -86%); }
.area2 { position: absolute; display: flex; justify-content: space-around; width: 100%; top: 26%; left: 50%; transform: translate(-50%, -78%); }
.area3 { position: absolute; display: flex; justify-content: space-around; width: 100%; top: 30%; left: 50%; transform: translate(-50%, -72%); }
.area4 { position: absolute; display: flex; justify-content: space-around; width: 100%; top: 38%; left: 50%; transform: translate(-50%, -68%); }
.area5 { position: absolute; display: flex; justify-content: space-around; width: 100%; top: 48%; left: 50%; transform: translate(-50%, -60%); }
.area6 { position: absolute; display: flex; justify-content: space-around; width: 100%; top: 58%; left: 50%; transform: translate(-50%, -50%); }

/* Zone colors — shared base */
.three_point,
.perimeter,
.free_throw,
.restricted_area {
  width: 18%;
  padding: 5px 6px;
  border: none;
  border-radius: 4px;
  /* clamp: 画面幅に比例してスケール (コート画像と同期) */
  font-size: clamp(0.75rem, 1.8vw, 0.95rem);
  font-weight: 700;
  text-align: center;
  box-sizing: border-box;
}

/* p tags (shot_table / analytics stats overlay) */
p.three_point,
p.perimeter,
p.free_throw,
p.restricted_area {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
  gap: 1px;
}

.three_point    { background: rgba(249, 115, 22, 0.82); color: #fff; }
.perimeter      { background: rgba(225, 180, 50, 0.88); color: #1a1200; }
.free_throw     { background: rgba(230, 230, 230, 0.92); color: #111; }
.restricted_area{ background: rgba(175, 72, 25, 0.88);  color: #fff; }

/* ---- スタンドアロン zone-pct / zone-sub (stats overlay 用) ---- */
.zone-pct {
  font-size: clamp(0.82rem, 2vw, 1rem);
  font-weight: 800;
  line-height: 1.2;
}

.zone-sub {
  font-size: clamp(0.6rem, 1.4vw, 0.75rem);
  font-weight: 500;
  opacity: 0.9;
  line-height: 1.2;
}

/* ---- Zone Buttons (shot_probability tap UI) ---- */
.zone-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 44px;
  line-height: 1.25;
  transition: transform 0.1s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  user-select: none;
}

.zone-btn:not(.filled) { filter: opacity(0.62); }
.zone-btn:not(.filled):hover { filter: opacity(0.85); }
.zone-btn:active { transform: scale(0.91); }

/* 空状態のラベル — clamp でコート幅に追随 */
.zone-btn .zone-label {
  font-size: clamp(0.68rem, 1.7vw, 0.88rem);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

/* 入力済み: パーセント表示 (zone-btn 内では上書きで少し大きく) */
.zone-btn.filled .zone-pct {
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
}

/* 入力済み: made/attempt サブテキスト */
.zone-btn.filled .zone-sub {
  font-size: clamp(0.65rem, 1.5vw, 0.8rem);
  opacity: 0.85;
}

/* ---- Popup ---- */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.popup-overlay.active { display: flex; }

.popup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px 22px;
  width: 320px;
  max-width: 92vw;
  box-shadow: var(--shadow);
}

.popup-zone-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  text-align: center;
}

.popup-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.popup-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
  text-align: center;
}

.popup-field input[type="number"] {
  width: 100%;
  padding: 10px 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

.popup-field input[type="number"]:focus {
  border-color: var(--orange);
}

.popup-field input[type="number"]::-webkit-inner-spin-button,
.popup-field input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.popup-error {
  font-size: 0.9rem;
  color: var(--red);
  text-align: center;
  min-height: 1.1em;
  margin-bottom: 14px;
}

.popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.popup-actions .btn { padding: 11px; }

/* ---- Action Bar ---- */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  margin-bottom: 28px;
}

.action-bar .btn,
.action-bar input.btn {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 220px;
  padding: 12px 16px;
  font-size: 1.05rem;
}

/* ---- History ---- */
.history-section {
  margin-top: 8px;
}

.history-section h3 {
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.data-card .card-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  gap: 8px;
}

.data-card .card-row:last-child { border-bottom: none; }

.data-card .card-row .val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

/* ================================
   Stats Page — Main Dashboard
   ================================ */

/* セクションタイトル */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 28px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* コート + ゾーンテーブル: デスクトップで横並び */
.court-stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 700px) {
  .court-stats-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ゾーンテーブル */
.zone-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.zone-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.zone-table thead th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  text-align: left;
}
.zone-table thead th.num,
.zone-table tbody td.num { text-align: right; }

.zone-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  color: var(--text);
}

.zone-table tbody tr.group-header td {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--orange);
  background: rgba(249, 115, 22, 0.06);
  padding: 7px 10px;
  border-bottom: none;
}

.zone-table tbody tr:last-child td { border-bottom: none; }

.pct-cell        { font-weight: 700; color: var(--orange) !important; }
.pct-cell.good   { color: var(--green) !important; }
.pct-cell.low    { color: var(--muted) !important; }
.no-data         { color: var(--muted) !important; }

.bar-col { width: 72px; padding: 8px 10px 8px 0 !important; }

/* 確率プログレスバー */
.pct-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.pct-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: calc(var(--pct, 0) * 1%);
  background: var(--orange);
  border-radius: 2px;
}

/* チャート */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  height: 240px;
  position: relative;
}

/* 記録履歴リスト */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.history-item:hover {
  border-color: var(--orange);
  background: rgba(249, 115, 22, 0.05);
}

.history-date {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.history-time {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 400;
}

.history-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-stat {
  font-size: 0.88rem;
  color: var(--muted);
}

.history-pct {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--orange);
  min-width: 58px;
  text-align: right;
}
.history-pct.good    { color: var(--green); }
.history-pct.low     { color: var(--muted); }
.history-pct.no-data { color: var(--muted); font-weight: 400; }

/* 空状態 */
.no-data-state {
  text-align: center;
  padding: 60px 16px 40px;
  color: var(--muted);
}
.no-data-icon {
  font-size: 3rem;
  margin-bottom: 14px;
}
.no-data-state p {
  font-size: 1.05rem;
  margin-bottom: 24px;
  color: var(--muted);
}

/* ================================
   Edit Page
   ================================ */

.edit-header { margin-bottom: 16px; }

.edit-date {
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 500;
}

/* ================================
   Memo Field
   ================================ */

.memo-field {
  margin: 12px 0 4px;
}

.memo-field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.memo-field textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.15s;
}

.memo-field textarea:focus { border-color: var(--orange); }

/* ================================
   Stats: History Memo & Main Layout
   ================================ */

.history-main {
  flex: 1;
  min-width: 0;
}

.history-memo {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================
   Stats: Chart Header & Zone Select
   ================================ */

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}

.zone-select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

.zone-select:focus { border-color: var(--orange); }

/* ================================
   Stats: Best Session Card
   ================================ */

.best-card { border-color: rgba(249, 115, 22, 0.35); }

.best-date {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ================================
   Profile Page
   ================================ */

.profile-info {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.profile-row:last-child { border-bottom: none; }

.profile-label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.profile-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
}

/* ================================
   Group Pages
   ================================ */

.group-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.group-card:hover { border-color: var(--orange); }

.group-name {
  font-size: 1rem;
  font-weight: 600;
}

.group-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.4px;
}

.group-badge.organizer {
  background: rgba(249, 115, 22, 0.18);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.group-badge.member {
  background: rgba(88, 166, 255, 0.15);
  color: var(--blue);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

.group-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.group-table thead th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.group-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.group-table tbody tr:last-child { border-bottom: none; }

.group-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.group-table tbody tr.current-user-row {
  background: rgba(249, 115, 22, 0.06);
}

.group-table td {
  padding: 11px 12px;
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

