:root {
  --bg: #0c0b10;
  --fg: #f3f1f7;
  --muted: #9b97a8;
  --line: rgba(255, 255, 255, .10);
  --panel: rgba(255, 255, 255, .04);
  --accent: #ff7a59;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(70% 40% at 15% 0%, rgba(255, 122, 89, .14), transparent 70%),
    radial-gradient(60% 40% at 100% 20%, rgba(120, 90, 255, .12), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--fg);
  font: 15px/1.5 "Inter", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---- header ---- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  background: rgba(12, 11, 16, .72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.tag { margin: 0; font-size: 12px; color: var(--muted); }
.logo { display: flex; align-items: flex-end; gap: 3px; height: 22px; }
.logo i { width: 4px; border-radius: 2px; background: var(--accent); animation: eq 1.1s ease-in-out infinite; }
.logo i:nth-child(1) { height: 40%; animation-delay: -.2s; }
.logo i:nth-child(2) { height: 100%; animation-delay: -.5s; }
.logo i:nth-child(3) { height: 60%; animation-delay: -.8s; }
.logo i:nth-child(4) { height: 30%; animation-delay: -.35s; }
@keyframes eq { 50% { transform: scaleY(.35); } }
.logo i { transform-origin: bottom; }

.stats { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--fg); font-variant-numeric: tabular-nums; font-weight: 700; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: #52525b; }
.conn.on { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .15); }
.join-link[hidden] { display: none; }
.join-link { border: 0; cursor: pointer; font: inherit; }
.join-link {
  text-decoration: none; color: var(--bg); background: var(--accent);
  padding: 5px 12px; border-radius: 99px; font-weight: 700; font-size: 13px;
}

main { width: min(1180px, 100%); margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 36px; }

/* ---- live grid ---- */
.grid {
  --tile: 200px;
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--tile), 44vw), 1fr));
}
/* 人数に応じてタイルを小さく */
.grid[data-density="m"] { --tile: 150px; gap: 14px; }
.grid[data-density="s"] { --tile: 112px; gap: 10px; }
.grid[data-density="m"] .info .t { font-size: 14px; }
.grid[data-density="s"] .info .t { font-size: 13px; }
.grid[data-density="s"] .info .a { font-size: 12px; }
.grid[data-density="s"] .since { display: none; }
@media (max-width: 560px) {
  .grid[data-density="m"] { grid-template-columns: repeat(3, 1fr); }
  .grid[data-density="s"] { grid-template-columns: repeat(4, 1fr); }
  .grid[data-density="s"] .info { display: none; }
}
.card a { display: grid; gap: 10px; text-decoration: none; }
.card .art {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg, #24212d, #17151d);
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, .8);
  transition: transform .25s ease;
}
.card a:hover .art { transform: translateY(-3px); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s; }
.card img.ok { opacity: 1; }
.card .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 42px; color: #3f3b4a; }
.card img.ok + .ph { display: none; }
.info { display: grid; min-width: 0; }
.info .t, .info .a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info .t { font-weight: 700; font-size: 15px; }
.info .a { color: var(--muted); font-size: 13px; }
.since { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--accent); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.eq i { width: 2px; height: 100%; background: currentColor; border-radius: 1px; transform-origin: bottom; animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; }
.eq i:nth-child(3) { animation-delay: -.6s; }

.card { animation: pop .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.card.out { animation: fade .4s ease forwards; }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(8px); } }
@keyframes fade { to { opacity: 0; transform: scale(.96); } }

.empty { margin: 60px 0; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 14px; }
.empty[hidden] { display: none; }
.empty p { margin: 0; }

/* ---- recent ---- */
.recent-sec h2, .join h2 { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.recent {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 4px 20px; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}
.recent a { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 6px 8px; border-radius: 10px; text-decoration: none; }
.recent a:hover { background: var(--panel); }
.recent img { border-radius: 6px; object-fit: cover; background: #1d1b24; }
.rm { display: grid; min-width: 0; }
.rm .t, .rm .a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rm .t { font-size: 14px; font-weight: 600; }
.rm .a { font-size: 12px; color: var(--muted); }
.recent time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- join ---- */
.join {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  padding: 22px; border: 1px solid var(--line); border-radius: 18px;
  background: #16141c; color: var(--fg);
}
.join:focus, .join:focus-visible { outline: none; }
.join::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
.join[open] { animation: pop .3s cubic-bezier(.2, .9, .3, 1.1); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dlg-head h2 { margin: 0 !important; }
.dlg-close { border: 0; background: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.dlg-close:hover { color: var(--fg); }
.steps { margin: 0 0 18px; padding-left: 1.3em; display: grid; gap: 6px; }
.steps a { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: 99px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--fg);
  font: inherit; font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.me { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-weight: 600; }
.me-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex: none; }
.me-dot.warn { background: #fbbf24; }
.token-form { display: flex; gap: 8px; flex-wrap: wrap; }
.token-form input {
  flex: 1 1 240px; min-width: 0; height: 40px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, .3); color: var(--fg); font: inherit; font-size: 14px;
}
.token-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-msg { margin: 8px 0 0; min-height: 1.4em; font-size: 13px; color: #fca5a5; }
#mbLogin[hidden] { display: none; }
.btn svg { width: 18px; height: 18px; fill: currentColor; margin-right: 8px; }
.btn.discord { background: #5865f2; color: #fff; }
.sub-link { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.sub-link a { color: var(--fg); }
.sub-link[hidden] { display: none; }
.alt { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.alt summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.alt[open] summary { margin-bottom: 12px; }
.alt .token-form { margin-bottom: 10px; }
.notes { margin: 18px 0 0; padding-left: 1.2em; color: var(--muted); font-size: 13px; display: grid; gap: 2px; }

.foot { text-align: center; font-size: 12px; color: var(--muted); }
.foot a { color: var(--muted); }

@media (max-width: 560px) {
  .stats { gap: 10px; }
  .grid { gap: 14px; }
  .join { padding: 16px; }
}
/* ---- 壁表示 (?wall) ---- */
.wall-badge { display: none; }
html.wall body { background: #000; overflow: hidden; cursor: none; }
html.wall body.pointer { cursor: default; }
html.wall .top, html.wall .foot, html.wall .info { display: none; }
html.wall main { width: 100vw; height: 100dvh; padding: 0; display: block; }
html.wall .grid { gap: 0; width: 100vw; height: 100dvh; align-content: center; justify-content: center;
  grid-template-columns: repeat(var(--cols, 1), var(--cell, 100vh)); }
html.wall .card .art { border-radius: 0; box-shadow: none; }
html.wall .card a:hover .art { transform: none; }
html.wall .empty { position: fixed; inset: 0; margin: 0; align-content: center; }
html.wall .empty .btn { display: none; }
html.wall .wall-badge {
  display: flex; align-items: center; gap: 8px; position: fixed; right: 16px; bottom: 14px;
  padding: 6px 12px; border-radius: 99px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 700; color: #fff;
}
html.wall .wall-badge .logo { height: 14px; gap: 2px; }
html.wall .wall-badge .logo i { width: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
