:root {
  --bg: #f4f5fb;
  --bg-elevated: #ffffff;
  --text: #1c1e26;
  --text-muted: #6b6f7f;
  --border: #e3e5f0;
  --accent: #6c5ce7;
  --accent-soft: #efeaff;
  --star: #f5a623;
  --shadow: 0 4px 16px rgba(30, 30, 60, 0.08);
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #14151f;
  --bg-elevated: #1e202c;
  --text: #eceef5;
  --text-muted: #9a9db0;
  --border: #2b2d3d;
  --accent: #a78bfa;
  --accent-soft: #2a2440;
  --star: #ffc857;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-emoji { font-size: 1.4rem; }

.header-controls { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.icon-btn:hover { background: var(--accent-soft); transform: scale(1.06); }

/* ===== 統計ダッシュボード ===== */
.stat-dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-dashboard:empty { display: none; }
.stat-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-key {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}
@media (max-width: 560px) {
  .stat-dashboard { grid-template-columns: repeat(2, 1fr); }
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.today-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}
.today-date {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.today-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.today-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.today-chip.holiday {
  background: rgba(245, 166, 35, 0.16);
  color: var(--star);
}
.today-chip.intl {
  background: rgba(52, 199, 89, 0.14);
  color: #1e9e4f;
}
[data-theme="dark"] .today-chip.intl { color: #4ade80; }

.today-chips-more:not([hidden]) {
  display: contents;
}
.today-more-btn {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.today-more-btn:hover { border-color: var(--accent); color: var(--accent); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.search-input {
  flex: 1 1 220px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 100%;
  order: 3;
}

.tag-chip {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tag-mode-btn {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.tag-mode-btn:hover { background: var(--accent); color: #fff; }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.favorite-only-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.favorite-only-toggle input { accent-color: var(--star); width: 15px; height: 15px; }

.sort-select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.85rem;
}

.result-count {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 14px 2px 14px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.game-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: fadeIn 0.3s ease both;
}
.game-card:hover { transform: translateY(-3px); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.card-top-btns { display: flex; align-items: center; gap: 2px; }

.share-btn {
  background: none;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
  opacity: 0.6;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.share-btn:hover { transform: scale(1.15); opacity: 1; }

.play-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.card-emoji {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 14px;
  flex-shrink: 0;
}

.fav-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--border);
  line-height: 1;
  padding: 4px;
  transition: transform 0.15s ease;
}
.fav-btn:hover { transform: scale(1.15); }
.fav-btn.active { color: var(--star); }

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.card-tag {
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.vote-row {
  display: flex;
  gap: 8px;
}

.vote-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.vote-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.vote-btn:disabled { cursor: default; }
.vote-btn .vote-count { font-weight: 700; }

.vote-btn.like.active {
  background: #eafbf0;
  border-color: #34c759;
  color: #1e9e4f;
}
.vote-btn.dislike.active {
  background: #fdecec;
  border-color: #ff4d4f;
  color: #c0282a;
}
[data-theme="dark"] .vote-btn.like.active {
  background: rgba(52, 199, 89, 0.16);
  border-color: #34c759;
  color: #4ade80;
}
[data-theme="dark"] .vote-btn.dislike.active {
  background: rgba(255, 77, 79, 0.16);
  border-color: #ff4d4f;
  color: #f87171;
}

.play-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 10px;
  border-radius: 10px;
  margin-top: 4px;
  transition: opacity 0.15s ease;
}
.play-btn:hover { opacity: 0.85; }

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
  font-size: 0.95rem;
}

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 24px 20px 40px;
}
.footer-hint { margin-top: 6px; opacity: 0.8; }
.footer-hint kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

/* ===== レトロ訪問者カウンター ===== */
.visitor-counter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 auto 14px;
  padding: 8px 14px;
  background: #05070a;
  border: 2px outset #444;
  border-radius: 4px;
}
.visitor-counter .vc-label {
  color: #9aa;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}
.visitor-counter .vc-digit {
  font-family: ui-monospace, "Courier New", monospace;
  font-weight: 700;
  font-size: 1.05rem;
  color: #33ff88;
  background: #0a1410;
  border: 1px solid #1c3a2a;
  border-radius: 2px;
  padding: 1px 4px;
  text-shadow: 0 0 6px #33ff8899;
}

/* ===== トースト ===== */
.gl-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}
.gl-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 今日の1本 モーダル ===== */
.rp-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rp-modal.open { display: flex; }
.rp-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 25, 0.55);
  backdrop-filter: blur(2px);
}
.rp-dialog {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: min(380px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: rpPop 0.25s ease;
}
@keyframes rpPop {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.rp-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.rp-caption {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.rp-body { text-align: center; }
.rp-emoji {
  font-size: 3rem;
  width: 84px;
  height: 84px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 20px;
}
.rp-title { margin: 0 0 8px; font-size: 1.15rem; }
.rp-desc {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.rp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-bottom: 14px;
}
.rp-play { margin-top: 0; }
.rp-actions { margin-top: 12px; text-align: center; }
.rp-reroll {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  cursor: pointer;
}
.rp-reroll:hover { border-color: var(--accent); color: var(--accent); }

/* ===== コナミコマンド: パーティーモード & 紙吹雪 ===== */
:root.party body { animation: partyHue 7s linear infinite; }
@keyframes partyHue {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}
.confetti-box {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 300;
}
.confetti-box i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall 2.8s ease-in forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.2; }
}

@media (max-width: 480px) {
  .toolbar-right { width: 100%; justify-content: space-between; margin-left: 0; }
}
