* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f0f0;
  color: #333;
}

/* ===== Header ===== */
header {
  background: #1a1a2e;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.site-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 3px;
}

/* ===== Main ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 16px;
}

.hero {
  text-align: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.subtitle {
  color: #888;
  font-size: 12px;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
}

.tab {
  background: none;
  border: none;
  padding: 10px 32px;
  font-size: 14px;
  cursor: pointer;
  color: #888;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: #444;
}

.tab.active {
  color: #c0392b;
  border-bottom-color: #c0392b;
  font-weight: 600;
}

/* ===== Grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 500px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Card ===== */
.card {
  background: #222;
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  display: block;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.card-thumb {
  position: relative;
  padding-top: 56.25%; /* 16:9 */
  background: #111;
  overflow: hidden;
}

.card-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

.card-thumb img.error {
  opacity: 0.3;
}

/* ランキングバッジ */
.rank-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.rank-1 { background: rgba(192, 57, 43, 0.85); }
.rank-2 { background: rgba(120, 60, 20, 0.85); }
.rank-3 { background: rgba(100, 100, 20, 0.85); }

/* Xリンク */
.x-link {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #000;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.15s;
  z-index: 10;
}

.x-link:hover {
  opacity: 1;
}

.x-link svg {
  width: 12px;
  height: 12px;
}

/* カード下部 */
.card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: #1a1a1a;
}

.like-count {
  color: #e74c3c;
  font-size: 11px;
  font-weight: 600;
}

.username {
  color: #999;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

/* ===== Modal ===== */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#modal-inner {
  background: #111;
  border-radius: 8px;
  padding: 16px;
  max-width: 640px;
  width: 100%;
  position: relative;
}

#modal-video {
  width: 100%;
  max-height: 70vh;
  border-radius: 4px;
  background: #000;
}

#modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

#modal-tweet-link {
  display: block;
  margin-top: 10px;
  color: #1d9bf0;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

#modal-tweet-link:hover {
  text-decoration: underline;
}

/* ===== States ===== */
.loading,
.error,
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: #999;
  font-size: 14px;
}
