:root {
  --bg: #0b1530;
  --card: #13224a;
  --card-edge: #1d3270;
  --text: #e3ebff;
  --muted: #9fb0d8;
  --accent: #3b82f6;
  --tag: #1f3366;
  --c1: #3b82f6;
  --c2: #06b6d4;
  --c3: #8b5cf6;
  --c4: #22c55e;
  --c5: #f59e0b;
  --c6: #ec4899;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.18), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(6, 182, 212, 0.12), transparent 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.7;
  /* 日本語を文節単位で折り返す（未対応のブラウザは通常の折り返し）。はみ出すときだけ途中で折る */
  word-break: auto-phrase;
  overflow-wrap: anywhere;
}

header {
  position: relative;
  overflow: hidden;
  padding: 56px 20px 44px;
  text-align: center;
  background: linear-gradient(120deg, #1d4ed8 0%, #2563eb 30%, #0891b2 60%, #7c3aed 100%);
}
header::before {
  content: "";
  position: absolute;
  inset: -20px;
  pointer-events: none;
  background:
    radial-gradient(circle, #fde047 0 5px, transparent 6px) 8% 30% / 120px 120px,
    radial-gradient(circle, #f472b6 0 4px, transparent 5px) 22% 75% / 150px 110px,
    radial-gradient(circle, #4ade80 0 6px, transparent 7px) 85% 25% / 170px 130px,
    radial-gradient(circle, #67e8f9 0 3px, transparent 4px) 65% 80% / 90px 100px,
    radial-gradient(circle, #fb923c 0 4px, transparent 5px) 45% 15% / 140px 90px,
    radial-gradient(circle, rgba(255, 255, 255, 0.5) 0 2px, transparent 3px) 0 0 / 60px 70px;
  opacity: 0.55;
  animation: confetti 18s linear infinite;
}
header > * { position: relative; }
@keyframes confetti {
  to { transform: translateY(40px) rotate(2deg); }
}

.bg-icons {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-icon {
  position: absolute;
  fill: currentColor;
  opacity: 0.22;
  filter: drop-shadow(0 0 6px currentColor);
  transform: rotate(var(--r));
  animation: drift ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate(0, 0) rotate(var(--r)); }
  to { transform: translate(var(--dx), var(--dy)) rotate(calc(var(--r) * -1)); }
}
header, main, footer { position: relative; z-index: 1; }

.logo { display: inline-block; margin-right: 0.3em; }
.logo-letter {
  display: inline-block;
  color: var(--letter);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  animation: bob 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.12s);
}
.logo-letter:nth-child(7n + 1) { --letter: #fde047; }
.logo-letter:nth-child(7n + 2) { --letter: #f472b6; }
.logo-letter:nth-child(7n + 3) { --letter: #4ade80; }
.logo-letter:nth-child(7n + 4) { --letter: #67e8f9; }
.logo-letter:nth-child(7n + 5) { --letter: #fb923c; }
.logo-letter:nth-child(7n + 6) { --letter: #c4b5fd; }
.logo-letter:nth-child(7n + 7) { --letter: #ffffff; }
.logo-letter:hover { animation: spin 0.6s ease; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes spin {
  to { transform: rotate(360deg) scale(1.2); }
}
header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--c1), var(--c2), var(--c4), var(--c5), var(--c6), var(--c3));
}
header h1 { margin: 0 0 8px; font-size: clamp(1.5rem, 4vw, 2.4rem); color: #fff; letter-spacing: 0.02em; }
header p { margin: 0; color: #e0ecff; }

.join {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 24px;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font-weight: bold;
  text-decoration: none;
}

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
h2 {
  border-left: 4px solid;
  border-image: linear-gradient(var(--c1), var(--c2)) 1;
  padding-left: 12px;
  margin-top: 40px;
}
h2 small { color: var(--muted); font-weight: normal; font-size: 0.8em; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 760px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; column-gap: 8px; }
  .stat-icon { font-size: 1.4rem; }
}
.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--card-edge);
  border-top: 3px solid var(--c, var(--c1));
  border-radius: 12px;
  background: var(--card);
}
.stat:nth-child(8n + 1) { --c: var(--c1); }
.stat:nth-child(8n + 2) { --c: var(--c6); }
.stat:nth-child(8n + 3) { --c: var(--c3); }
.stat:nth-child(8n + 4) { --c: var(--c2); }
.stat:nth-child(8n + 5) { --c: var(--c4); }
.stat:nth-child(8n + 6) { --c: var(--c5); }
.stat:nth-child(8n + 7) { --c: var(--c2); }
.stat:nth-child(8n + 8) { --c: var(--c3); }
.stat-icon { grid-row: span 2; font-size: 1.7rem; }
.stat-label { color: var(--muted); font-size: 0.85rem; line-height: 1.4; word-break: keep-all; }
.stat-value .stat-note { display: block; margin-left: 0; font-size: 0.75rem; font-weight: normal; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: bold; line-height: 1.2; color: #fff; }
.stat-value small { font-size: 0.85rem; font-weight: normal; color: var(--muted); margin-left: 3px; }

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.chart {
  padding: 14px 16px 10px;
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  background: var(--card);
}
.chart h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--muted); font-weight: normal; }
.bars {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 6px;
  height: 150px;
  align-items: end;
}
.bar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  text-align: center;
  font-size: 0.75rem;
}
.bar-value { color: var(--muted); }
.bar-fill {
  align-self: end;
  height: var(--h);
  min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(to top, var(--c1), var(--c2));
  opacity: 0.75;
}
.bar.top .bar-fill { background: linear-gradient(to top, var(--c3), var(--c6)); opacity: 1; }
.bar.top .bar-value { color: #fff; font-weight: bold; }
.bar-label { color: var(--muted); margin-top: 4px; white-space: nowrap; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select {
  padding: 10px 12px;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters input { flex: 1; min-width: 200px; }

.period { margin-bottom: 16px; transition: opacity 0.15s; }
.period.searching { opacity: 0.4; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tabs button {
  padding: 6px 14px;
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.tabs button small { color: var(--muted); margin-left: 2px; }
.tabs button:hover { border-color: var(--accent); }
.tabs button.active {
  background: linear-gradient(120deg, var(--c1), var(--c2));
  border-color: transparent;
  color: #fff;
  font-weight: bold;
}
.tabs button.active small { color: #e0ecff; }
#year-tabs button { font-size: 1rem; }
.kinds { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--card-edge); }
.kinds button { font-size: 1rem; padding: 7px 18px; }
.tag.club { background: color-mix(in srgb, var(--c6) 30%, transparent); box-shadow: inset 0 0 0 1px var(--c6); color: #fff; }
.months button { font-size: 0.85rem; padding: 4px 12px; }

@media (max-width: 640px) {
  #year-tabs, #month-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 2px;
    margin-left: -2px;
    margin-right: -2px;
  }
  #year-tabs::-webkit-scrollbar, #month-tabs::-webkit-scrollbar { display: none; }
  #year-tabs button, #month-tabs button { flex: 0 0 auto; white-space: nowrap; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.event {
  --color: var(--c1);
  --tilt: 0deg;
  position: relative;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--color) 22%, transparent), transparent 55%),
    var(--card);
  border: 1px solid var(--card-edge);
  border-top: 4px solid var(--color);
  border-radius: 14px;
  padding: 16px 20px 18px;
  overflow-wrap: anywhere;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.event:hover {
  transform: translateY(-5px) rotate(var(--tilt));
  box-shadow: 0 10px 26px color-mix(in srgb, var(--color) 40%, transparent);
}
.event:hover .title-row h3::after { animation: wiggle 0.5s ease; }
.title-row h3::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--color);
  vertical-align: middle;
}
@keyframes wiggle {
  25% { transform: scale(1.6); }
  50% { transform: scale(0.8); }
  75% { transform: scale(1.3); }
}
.event:nth-child(6n + 2) { --color: var(--c2); }
.event:nth-child(6n + 3) { --color: var(--c3); }
.event:nth-child(6n + 4) { --color: var(--c4); }
.event:nth-child(6n + 5) { --color: var(--c5); }
.event:nth-child(6n + 6) { --color: var(--c6); }
.event time { color: var(--muted); font-size: 0.9rem; }
.tag.session {
  background: color-mix(in srgb, var(--color) 25%, transparent);
  box-shadow: inset 0 0 0 1px var(--color);
  color: #fff;
  font-weight: bold;
}
.event h3 { margin: 4px 0 8px; font-size: 1.15rem; color: #fff; }
.title-row { display: flex; align-items: flex-start; gap: 8px; }
.title-row a.store { margin-top: 6px; }
.event p { margin: 8px 0 0; font-size: 0.95rem; }
.event a { color: #38bdf8; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--tag); border-radius: 6px; padding: 2px 8px; font-size: 0.8rem; }

.tag.accent { background: var(--color); color: #fff; }
.participants { color: var(--muted); font-size: 0.85rem; }

.games { margin-top: 12px; }
.games ul { list-style: none; margin: 0; padding: 0; }
.games li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--tag);
  font-size: 0.9rem;
}
.games li small { color: var(--muted); }
.game-name { font-weight: bold; }
.games-section { margin-top: 8px; color: var(--muted); font-size: 0.8rem; }

.event a.store {
  margin-left: auto;
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--tag);
  color: #fff;
  font-size: 0.8rem;
  text-decoration: none;
}
.event a.store:hover { background: var(--color); }

.spoiler { background: #050a18; color: transparent; border-radius: 4px; cursor: pointer; }
.spoiler:hover { color: inherit; }

.tag { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tag:hover { transform: translateY(-2px) rotate(-3deg); }
.tabs button { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s; }
.tabs button:active { transform: scale(0.92); }

@media (prefers-reduced-motion: reduce) {
  header::before, .logo-letter, .bg-icon { animation: none; }
  .event, .event:hover { transform: none; }
}

.empty { color: var(--muted); }
footer { text-align: center; color: var(--muted); padding: 24px; font-size: 0.85rem; }
