/* マスターズ大会一覧 - Freakers */
:root {
  --bg: #f3f8fb;
  --panel: #ffffff;
  --ink: #14212b;
  --muted: #5d6b76;
  --line: #dde6ec;
  --accent: #0a9fc4;
  --accent-ink: #067a97;
  --accent-soft: #e3f5fa;
  --short: #2f6fdf;
  --short-soft: #e8f0fd;
  --long: #d9434a;
  --long-soft: #fdecec;
  --ok: #17895a;
  --ok-soft: #e4f5ec;
  --warn: #a8660a;
  --warn-soft: #fbf1df;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* ヘッダー */
.hero { margin-bottom: 18px; }
.eyebrow {
  margin: 0;
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
}
.hero h1 {
  margin: 2px 0 4px;
  font-size: 26px;
  line-height: 1.3;
}
.lead { margin: 0; color: var(--muted); }

/* 絞り込み */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.field.grow { flex: 1 1 200px; }
.field label, .field .label { font-size: 12px; font-weight: 700; color: var(--muted); }

select, input[type="search"] {
  height: 36px;
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
select:disabled { color: #a3adb5; background: #f6f8f9; }
select:focus, input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  background: #eef3f6;
  border-radius: 9px;
}
.seg button {
  height: 30px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button.on {
  color: var(--ink);
  font-weight: 700;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 33, 43, .15);
}

.reset {
  height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  color: var(--accent-ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.reset:hover { background: var(--accent-soft); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
}
.count { margin: 0; font-weight: 700; }
.count small { font-weight: 400; color: var(--muted); }

/* 読み込み */
.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 0;
}
.status .logo { width: 88px; animation: bob 2s ease-in-out infinite; }
.loading-text { margin: 0; color: var(--muted); }
.progress { width: 240px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* カード */
.month {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
  border-bottom: 2px solid var(--accent-soft);
  padding-bottom: 4px;
}
.month:first-child { margin-top: 4px; }

.card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 14px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card.is-past { background: #f7f9fa; }
.card.is-past .date { background: #eef1f3; }
.card.is-past .date .md { color: var(--muted); }
.card.is-cancelled { background: #fafafa; }
.card.is-cancelled .name { text-decoration: line-through; text-decoration-color: rgba(20,33,43,.35); }

.date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  text-align: center;
  background: var(--accent-soft);
  border-radius: 10px;
  line-height: 1.2;
}
.date .md { font-size: 20px; font-weight: 800; color: var(--accent-ink); }
.date .dow { font-size: 12px; color: var(--muted); margin-top: 2px; }
.date .to { font-size: 11px; color: var(--muted); margin-top: 4px; }

.body { min-width: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  white-space: nowrap;
}
.tag.short { color: var(--short); background: var(--short-soft); }
.tag.long { color: var(--long); background: var(--long-soft); }
.tag.open { color: var(--ok); background: var(--ok-soft); }
.tag.soon { color: var(--accent-ink); background: var(--accent-soft); }
.tag.closed { color: var(--muted); background: #eef1f3; }
.tag.alert { color: var(--warn); background: var(--warn-soft); }

.name { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.entry { margin: 6px 0 0; font-size: 13px; }
.entry b { font-weight: 700; color: var(--muted); margin-right: 6px; }

.events {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.events li {
  padding: 2px 8px;
  font-size: 12px;
  color: #33434f;
  background: #f1f5f7;
  border-radius: 6px;
}
.events li span { color: var(--muted); margin-left: 4px; }
.events li.hit { color: #fff; background: var(--accent); }
.events li.hit span { color: #e3f5fa; }

.doc {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-top: 10px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
}
.doc:hover { background: var(--accent-soft); }

.load-warning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius);
}
.load-warning p { margin: 0; }
.retry {
  height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--warn);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* 種目表 */
.table-wrap {
  overflow: auto;
  max-height: 75vh;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { border-collapse: separate; border-spacing: 0; font-size: 12px; }
th, td {
  padding: 6px 6px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 700;
  background: #f6fafc;
}
thead tr:nth-child(2) th { top: 31px; }
th.sticky, td.sticky { position: sticky; left: 0; z-index: 1; text-align: left; }
thead th.sticky { z-index: 3; }
td.sticky { min-width: 220px; max-width: 260px; white-space: normal; font-weight: 700; }
td.sticky small { display: block; font-weight: 400; color: var(--muted); }
.g { border-left: 2px solid var(--line); }
td.y { color: var(--accent-ink); font-weight: 800; }
td.n { color: #c8d1d7; }
td.c-short { color: var(--short); font-weight: 700; }
td.c-long { color: var(--long); font-weight: 700; }
tr.is-hit td { background: #f4fbfd; }

/* スマホの種目表（泳法切り替え） */
.stroke-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.stroke-tabs::-webkit-scrollbar { display: none; }
.stroke-tabs button {
  flex: none;
  height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.stroke-tabs button.on { color: #fff; font-weight: 700; background: var(--accent); border-color: var(--accent); }

.table-wrap:has(table.compact) { max-height: none; overflow: visible; }
table.compact { width: 100%; table-layout: fixed; font-size: 12px; }
table.compact thead th { top: 0; }
table.compact th.sticky, table.compact td.sticky { position: static; width: 46%; }
table.compact td.sticky { min-width: 0; max-width: none; padding: 8px 6px 8px 10px; line-height: 1.4; }
table.compact td.sticky .when { display: block; font-size: 11px; font-weight: 700; color: var(--accent-ink); }
table.compact td.sticky .when b { font-weight: 700; margin-left: 4px; }
table.compact td.sticky .when .c-short { color: var(--short); }
table.compact td.sticky .when .c-long { color: var(--long); }
table.compact th:not(.sticky) { font-size: 11px; padding: 6px 0; }
table.compact td.y { color: var(--accent); font-size: 13px; }
table.compact td.n { color: #d3dade; }
table.compact th.hit, table.compact td.hit { background: var(--accent-soft); }
table.compact tr.is-past td { background: #f7f9fa; }
table.compact tr.is-past td.sticky .when { color: var(--muted); }

.note { margin: 20px 0 0; font-size: 12px; color: var(--muted); }

/* スマホ */
@media (max-width: 600px) {
  .app { padding: 16px 12px 32px; }
  .hero h1 { font-size: 22px; }
  .filters { padding: 12px; gap: 10px; }
  .field { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .field.grow { flex-basis: 100%; }
  .field:has(.seg) { flex-basis: 100%; }
  .field .seg { display: flex; }
  .field .seg button { flex: 1; }
  .reset { width: 100%; height: 44px; }
  /* 入力しやすさ：iPhoneは16px未満の入力欄で画面が拡大されるため16pxに */
  select, input[type="search"] { height: 44px; font-size: 16px; }
  .field .seg button { height: 38px; font-size: 14px; }
  .doc { min-height: 44px; }
  /* 種目表：画面を占有しすぎないよう高さと固定列を小さく */
  .table-wrap { max-height: 60vh; }
  td.sticky { min-width: 120px; max-width: 130px; }
  .card { grid-template-columns: 62px 1fr; gap: 10px; padding: 12px; }
  .date .md { font-size: 17px; }
  .name { font-size: 15px; }
}
