:root {
  --bg: #0a0a0d;
  --bg-deep: #060607;
  --surface: #16151c;
  --surface-raised: #1e1c26;
  --line: #2c2a36;
  --ink: #f2f0ea;
  --muted: #8f8b98;
  --side-a: #ff2e88;
  --side-a-glow: rgba(255, 46, 136, 0.35);
  --side-a-tint: rgba(255, 46, 136, 0.1);
  --side-b: #20e3e3;
  --side-b-glow: rgba(32, 227, 227, 0.35);
  --side-b-tint: rgba(32, 227, 227, 0.1);
  --gold: #f5c04e;
  --gold-glow: rgba(245, 192, 78, 0.35);
  --radius: 10px;
  --header-h: 60px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(255, 46, 136, 0.14), transparent 60%),
    radial-gradient(ellipse 900px 500px at 85% 0%, rgba(32, 227, 227, 0.12), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4,
.display {
  font-family: "Anton", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

a { color: inherit; }

/* ---------- Header ---------- */
header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  min-height: calc(var(--header-h) - 28px);
  background: var(--bg-deep);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  box-sizing: content-box;
}

header.app-header a { text-decoration: none; }

header.app-header .brand {
  min-width: 0;
  overflow: hidden;
}

header.app-header h1 {
  font-size: 1.3rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gold);
}

header.app-header .header-right {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-shrink: 0;
}

header.app-header .nav-link {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

header.app-header .nav-link:hover { color: var(--ink); }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 70px;
}

@media (max-width: 640px) {
  main { padding: 16px 12px 60px; }
  header.app-header { padding: 12px 14px; }
  header.app-header h1 { font-size: 1.05rem; }
}

/* ---------- Category filter ---------- */
.category-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  background: var(--bg);
  padding: 12px 0 10px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
}

.chip.active {
  color: var(--bg);
  font-weight: 700;
  background: var(--gold);
  border-color: var(--gold);
}

.chip:hover:not(.active) { color: var(--ink); border-color: var(--muted); }

.fav-toggle {
  font-size: 0.76rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  vertical-align: middle;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 999px;
}

.fav-toggle:hover { background: var(--gold); color: var(--bg); }

/* ---------- Card grid (top page) ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.theme-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.theme-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--side-a), var(--gold), var(--side-b));
  opacity: 0.7;
}

.theme-card:hover {
  border-color: var(--muted);
  transform: translateY(-2px);
}

.theme-card .badges {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.badge-cat {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: "Space Mono", monospace;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

.theme-card-title {
  margin: 0 0 14px;
  font-size: 1.15rem;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
}

.mini-pct {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: "Space Mono", monospace;
}

.mini-pct .a { color: var(--side-a); }
.mini-pct .b { color: var(--side-b); }
.mini-pct .vs {
  font-family: "Anton", sans-serif;
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}

/* Status tag: pulsing dot for live */
.stamp {
  font-family: "Space Mono", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 4px 10px 4px 8px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid currentColor;
}

.stamp::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.stamp.status-live { color: var(--side-a); box-shadow: 0 0 10px var(--side-a-glow); }
.stamp.status-live::before { animation: pulse-dot 1.4s ease-in-out infinite; }
.stamp.status-scheduled { color: var(--muted); }
.stamp.status-judging { color: var(--gold); box-shadow: 0 0 10px var(--gold-glow); }
.stamp.status-finished { color: var(--muted); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

/* ---------- Battle detail page ---------- */
.sticky-top {
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  margin: 0 -16px 20px;
}

.sticky-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.sticky-top h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  text-transform: none;
  letter-spacing: 0;
}

.score-mini {
  margin-top: 10px;
}

.score-bar.mini {
  height: 20px;
  border-radius: 999px;
}

.score-bar.mini .a,
.score-bar.mini .b {
  font-size: 0.72rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
}

@media (max-width: 640px) {
  .sticky-top h2 { font-size: 1.05rem; }
  .sticky-top { margin: 0 -12px 16px; }
}

.battle-desc {
  font-size: 0.92rem;
  color: var(--muted);
  margin: -8px 0 18px;
}

/* Verdict panel: versus-screen hype meter */
.score-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  margin: 0 0 16px;
}

.score-eyebrow {
  font-family: "Anton", sans-serif;
  font-size: 0.78rem;
  color: var(--gold);
  margin-bottom: 10px;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.score-deadline {
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0;
}

.score-bar {
  display: flex;
  height: 40px;
  overflow: hidden;
  background: #000;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.score-bar .a,
.score-bar .b {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  justify-content: center;
  font-family: "Anton", sans-serif;
  font-size: 1.05rem;
  color: var(--bg);
  transition: width 0.5s ease;
  white-space: nowrap;
}

.score-bar .a { background: var(--side-a); box-shadow: 0 0 18px var(--side-a-glow) inset; }
.score-bar .b { background: var(--side-b); box-shadow: 0 0 18px var(--side-b-glow) inset; }

.score-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.86rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.score-labels .a-label { color: var(--side-a); }
.score-labels .b-label { color: var(--side-b); }

.score-labels.mini {
  margin-top: 5px;
  font-size: 0.72rem;
}

.score-rationale {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.result-banner {
  padding: 16px 18px;
  margin-bottom: 14px;
  border: 1px solid;
  border-radius: var(--radius);
  font-family: "Anton", sans-serif;
  font-size: 1.05rem;
}

.result-banner.win-a { background: var(--side-a-tint); color: var(--side-a); border-color: var(--side-a); box-shadow: 0 0 24px var(--side-a-glow); }
.result-banner.win-b { background: var(--side-b-tint); color: var(--side-b); border-color: var(--side-b); box-shadow: 0 0 24px var(--side-b-glow); }
.result-banner.draw { background: var(--surface); color: var(--gold); border-color: var(--gold); }

.result-banner p {
  font-weight: 400;
  margin: 8px 0 0;
  font-size: 0.86rem;
  font-family: "Space Grotesk", sans-serif;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.thread-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.post-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  height: 460px;
  overflow-y: auto;
  padding: 8px 18px;
}

.post-list:empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-list:empty::after {
  content: "まだ発言がありません。最初の一言を投げてみよう";
  color: var(--muted);
  font-size: 0.85rem;
}

.post-item {
  padding: 13px 0;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--line);
}

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

.post-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.post-tag {
  font-family: "Space Mono", monospace;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.post-tag.a { background: var(--side-a-tint); color: var(--side-a); }
.post-tag.b { background: var(--side-b-tint); color: var(--side-b); }

.post-item .author {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: "Space Mono", monospace;
}

.post-form { padding: 16px 18px 20px; border-top: 1px solid var(--line); }

.post-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--ink);
  padding: 9px 10px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 60px;
}

.post-form input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--ink);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  margin-top: 6px;
}

.post-form textarea::placeholder,
.post-form input::placeholder { color: var(--muted); }

.post-form textarea:focus,
.post-form input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.post-form button {
  margin-top: 10px;
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 700;
  color: var(--bg);
  cursor: pointer;
  width: 100%;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.02em;
}

.post-form button {
  background: var(--gold);
}

.post-form button:hover { filter: brightness(1.08); }

.post-form button:disabled { background: var(--muted); box-shadow: none; cursor: not-allowed; }

.form-error {
  color: var(--side-a);
  font-size: 0.8rem;
  margin-top: 6px;
  min-height: 1em;
}

/* ---------- Admin / auth pages ---------- */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  max-width: 420px;
  margin: 40px auto;
}

.admin-card h2 {
  margin-top: 0;
  font-size: 1.4rem;
}

.admin-card label,
.admin-section label {
  display: block;
  font-size: 0.82rem;
  margin: 14px 0 6px;
  color: var(--muted);
}

.admin-card input,
.admin-card textarea,
.admin-card select,
.admin-section input,
.admin-section textarea,
.admin-section select {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
}

.admin-card input:focus,
.admin-card textarea:focus,
.admin-card select:focus,
.admin-section input:focus,
.admin-section textarea:focus,
.admin-section select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.admin-section textarea {
  min-height: 70px;
  resize: vertical;
}

.admin-card button,
.admin-section button {
  margin-top: 18px;
  padding: 11px 20px;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--bg);
  font-weight: 700;
  cursor: pointer;
}

.admin-card button:hover,
.admin-section button:hover { filter: brightness(1.1); }

.admin-card button { width: 100%; }

.admin-section .category-inline-form,
.admin-section form.inline {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.admin-section .category-inline-form input,
.admin-section form.inline input { flex: 1; }

.admin-section .category-inline-form button,
.admin-section form.inline button { margin-top: 0; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 560px) {
  .form-row-2 { grid-template-columns: 1fr; }
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.admin-section h3 {
  margin-top: 0;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

table.admin-table th, table.admin-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}

table.admin-table th {
  font-family: "Space Mono", monospace;
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--muted);
}

.notice {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 8px;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--gold);
}

.countdown.urgent {
  color: var(--side-a);
  font-weight: 700;
  animation: pulse-dot 0.9s ease-in-out infinite;
}

/* ---------- Mobile fine-tuning ---------- */
@media (max-width: 480px) {
  .score-bar { height: 46px; }
  .score-bar .a, .score-bar .b { font-size: 0.95rem; }
  .post-list { height: 260px; }
}

@media (prefers-reduced-motion: reduce) {
  .score-bar .a, .score-bar .b { transition: none; }
  .stamp.status-live::before { animation: none; }
}

.site-footer {
  max-width: 960px;
  margin: 40px auto 0;
  padding: 18px 16px 28px;
  text-align: center;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: "Space Mono", monospace;
}

.site-footer a { color: var(--gold); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.legal-page {
  max-width: 720px;
}

.legal-page h2 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.legal-updated {
  color: var(--muted);
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  margin-bottom: 28px;
}

.legal-page h3 {
  font-size: 1.02rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gold);
  margin: 28px 0 8px;
}

.legal-page p,
.legal-page li {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.8;
}

.legal-page ul { padding-left: 1.2em; margin: 8px 0; }
.legal-page li { margin-bottom: 4px; }
.legal-page a { color: var(--gold); }

#turnstile-post {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
