/* ==========================================
   CSS Reset
   ========================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ==========================================
   CSS Variables
   ========================================== */
:root {
  /* Colors */
  --primary: #00B4CC;
  --secondary: #174a5c;
  --accent: #1DA1F2;
  --white0: #fff;
  --black0: #101010;
  --glay: #777777;

  /* Background */
  --bg-light: #f7f9fa;
  --bg-dark: #0f1419;
  --bc: rgb(255, 250, 250);

  /* Text */
  --text-primary: #0f1419;
  --text-secondary: #536471;

  /* Border */
  --border-color: #eff3f4;
  --bd: solid 1px rgb(218, 220, 224);

  /* Effects */
  --br: 16px;
  --bs: 0 8px 32px rgba(0, 0, 0, 0.08);
  --boxpad: 20px 1.5em;

  /* Transitions */
  --transition-base: all 0.3s ease;
}


/* ==========================================
   Base Layout
   ========================================== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, var(--bg-light) 0%, #ffffff 100%);
  word-break: break-all;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-container {
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  padding: 20px;
  flex: 1;
}

/* ==========================================
   Header
   ========================================== */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--white0);
  padding: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.5rem 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.site-title-link {
  text-decoration: none;
  color: var(--white0);
  transition: var(--transition-base);
}

.site-title-link:hover {
  opacity: 0.9;
}

.site-title {
  font-weight: 700;
  font-size: 1.5em;
  margin: 0;
  padding: 0;
}

.site-nav {
  font-weight: bold;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  font-weight: bold;
  color: var(--white0);
  text-decoration: none;
  font-size: 14px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: var(--transition-base);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================
   Footer
   ========================================== */
.site-footer {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: var(--white0);
  padding: 1rem 20px;
  width: 100%;
  margin-top: 4em;
}

.footer-container {
  max-width: 1000px;
  margin: 0 auto;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
  text-align: center;
}

.footer-content p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

.footer-nav {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-nav a {
  font-weight: bold;
  color: var(--white0);
  text-decoration: none;
  font-size: 14px;
  transition: var(--transition-base);
  opacity: 0.9;
}

.footer-nav a:hover {
  opacity: 1;
  text-decoration: underline;
}


/* ==========================================
   Typography
   ========================================== */
h1 {
  font-weight: bold;
  font-size: 2em;
  margin-bottom: 1em;
  padding: 10px 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-weight: bold;
  font-size: 1.3em;
  margin: 0.5em 0;
}

h3 {
  font-weight: bold;
  font-size: 1em;
  margin: 0.5em 0;
}

h3::before {
  content: "・";
}

p {
  margin: 0.5em 0;
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: var(--accent);
  transition: var(--transition-base);
}

a:hover {
  color: var(--primary);
  opacity: 0.8;
}

/* ==========================================
   Components
   ========================================== */
.block {
  background-color: var(--white0);
  border: var(--bd);
  border-radius: var(--br);
  box-shadow: var(--bs);
  padding: var(--boxpad);
  margin: 0 0 1em 0;
}

.portfolio-img {
  width: 100%;
  height: auto;
  border-radius: var(--br);
  box-shadow: var(--bs);
  margin-bottom: 1em;
}


/* ==========================================
   Video Container & Forms
   ========================================== */
.video-container {
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.input-section {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--white0);
  padding: 1.5em;
  border-radius: var(--br);
  box-shadow: var(--bs);
}

.input-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
}

#videoUrl {
  flex: 1;
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 25px;
  font-size: 16px;
  transition: var(--transition-base);
  background: var(--bg-light);
}

#videoUrl:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--white0);
  box-shadow: 0 0 0 4px rgba(29, 161, 242, 0.1);
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  transition: var(--transition-base);
}

.clear-btn:hover {
  color: var(--text-primary);
  font-size: 20px;
}

/* Buttons */
#fetchBtn,
.share-btn {
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  color: var(--white0);
  border: none;
  border-radius: 25px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-base);
  box-shadow: 0 4px 15px rgba(29, 161, 242, 0.3);
}

#fetchBtn:hover,
.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(29, 161, 242, 0.4);
}

#fetchBtn:active,
.share-btn:active {
  transform: translateY(0);
}

#fetchBtn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.share-btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
}

/* Messages */
.error-message {
  padding: 12px 16px;
  background: #fee;
  border-left: 4px solid #ff4444;
  border-radius: 6px;
  color: #c33;
  font-weight: 500;
  font-size: 14px;
}

.result-section {
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.share-container {
  margin: 3em;
  display: flex;
  justify-content: center;
  gap: 1em;
}

/* ==========================================
   Video Info & Items
   ========================================== */
.video-info {
  background: linear-gradient(135deg, rgba(0, 180, 204, 0.05) 0%, rgba(29, 161, 242, 0.05) 100%);
  padding: 1.5em;
  border-radius: var(--br);
  border-left: 4px solid var(--accent);
  box-shadow: var(--bs);
}

.video-info p {
  margin: 0.75em 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.video-info span {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1em;
}

.video-info a {
  word-break: break-all;
  font-weight: 500;
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 2em;
  align-items: center;
}

.video-item {
  width: 100%;
  max-width: 420px;
  background: var(--white0);
  border-radius: var(--br);
  overflow: hidden;
  box-shadow: var(--bs);
  transition: var(--transition-base);
  display: flex;
  flex-direction: column;
}

.video-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.video-item video {
  width: 100%;
  height: auto;
  padding: 1em;
  background: var(--bg-light);
}

.video-link {
  display: block;
  width: 100%;
  overflow: hidden;
  text-decoration: none;
  transition: var(--transition-base);
  position: relative;
}

.video-link:hover {
  opacity: 0.9;
}

.video-thumbnail {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  cursor: pointer;
}

.play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(64, 64, 64, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-base);
  cursor: pointer;
}

.play-button svg {
  width: 32px;
  height: 32px;
  margin-left: 4px;
}

.video-link:hover .play-button {
  background: rgb(149, 149, 149);
  transform: translate(-50%, -50%) scale(1.1);
}

.video-item .download-btn {
  margin: 0 1em 1em 1em;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  color: var(--white0) !important;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-base);
  text-align: center;
  display: inline-block;
}

.video-item .download-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(29, 161, 242, 0.3);
}

.description-container {
  background: var(--white0);
  padding: 1.5em;
  border-radius: var(--br);
  box-shadow: var(--bs);
  margin: 3em 0;
}



/* ==========================================
   Responsive Design
   ========================================== */
@media (max-width: 768px) {
  body {
    font-size: 0.9em;
  }

  h1 {
    font-size: 1.8em;
  }

  .header-container {
    flex-direction: column;
    gap: 1rem;
    padding: 0.3rem 15px;
  }

  .site-title {
    font-size: 1.2em;
  }

  .site-nav {
    width: 100%;
    justify-content: center;
    gap: 1rem;
  }

  .nav-link {
    font-size: 13px;
    padding: 0.4rem 0.8rem;
  }

  .footer-content {
    gap: 1rem;
  }

  .footer-nav {
    gap: 1.5rem;
  }

  .input-section {
    flex-direction: column;
    padding: 1em;
  }

  #videoUrl,
  #fetchBtn {
    width: 100%;
  }

  .video-item {
    max-width: 100%;
  }
}

/* ==========================================
   Ranking System
   ========================================== */
.ranking-description {
  background: linear-gradient(135deg, rgba(0, 180, 204, 0.05) 0%, rgba(29, 161, 242, 0.05) 100%);
  padding: 1.5em;
  border-radius: var(--br);
  margin-bottom: 2em;
  border-left: 4px solid var(--primary);
}

.ranking-description p {
  margin: 0.5em 0;
  color: var(--text-secondary);
}

.ranking-grid {
  width: 100%;
  margin: 0 auto;
  position: relative;
}

/* 各カラムパターンのコンテナ */
.ranking-grid>div[class^="ranking-grid-"] {
  display: none;
  gap: 1rem;
  align-items: flex-start;
}

.ranking-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Ranking Grid - Responsive Column Layouts */
@media (max-width: 640px) {
  .ranking-grid-col-2 {
    display: flex !important;
  }

  .ranking-grid>div[class^="ranking-grid-"]:not(.ranking-grid-col-2) {
    display: none !important;
  }

  .ranking-grid>div[class^="ranking-grid-"] {
    gap: 0.5rem;
  }

  .ranking-column {
    gap: 0.5rem;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .ranking-grid-col-3 {
    display: flex !important;
  }

  .ranking-grid>div[class^="ranking-grid-"]:not(.ranking-grid-col-3) {
    display: none !important;
  }

  .ranking-grid>div[class^="ranking-grid-"] {
    gap: 0.75rem;
  }

  .ranking-column {
    gap: 0.75rem;
  }
}

@media (min-width: 1025px) and (max-width: 1440px) {
  .ranking-grid-col-4 {
    display: flex !important;
  }

  .ranking-grid>div[class^="ranking-grid-"]:not(.ranking-grid-col-4) {
    display: none !important;
  }
}

@media (min-width: 1441px) {
  .ranking-grid-col-5 {
    display: flex !important;
  }

  .ranking-grid>div[class^="ranking-grid-"]:not(.ranking-grid-col-5) {
    display: none !important;
  }
}

/* Ranking Thumbnails */
.ranking-thumbnail {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 5px;
  overflow: hidden;
  text-decoration: none;
  transition: var(--transition-base);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ranking-thumbnail:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.thumbnail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--transition-base);
}

.ranking-thumbnail:hover .video-overlay {
  opacity: 1;
}

.play-icon {
  width: 50px;
  height: 50px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Ranking Navigation */
.ranking-nav {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
  width: 100%;
  margin: 1.5em 0;
  flex-wrap: wrap;
}

.ranking-nav-link {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 0.5rem 0.1rem;
  font-weight: bold;
  color: var(--text-primary);
  background: linear-gradient(135deg, rgba(0, 180, 204, 0.1) 0%, rgba(29, 161, 242, 0.1) 100%);
  border-radius: 8px;
  transition: var(--transition-base);
  text-decoration: none;
}

.ranking-nav-link:hover {
  background: linear-gradient(135deg, rgba(0, 180, 204, 0.2) 0%, rgba(29, 161, 242, 0.2) 100%);
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.ranking-nav-link.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: var(--white0);
}

/* Ranking Items */
.ranking-item {
  background: var(--white0);
  border-radius: var(--br);
  box-shadow: var(--bs);
  padding: 1.5em;
  display: flex;
  gap: 1.5em;
  transition: var(--transition-base);
}

.ranking-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.rank-badge {
  min-width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: var(--white0);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  flex-shrink: 0;
}

.tweet-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.tweet-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
}

.tweet-stats {
  display: flex;
  gap: 1.5em;
  font-size: 14px;
  color: var(--text-secondary);
}

.tweet-stats span {
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.tweet-videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1em;
  margin-top: 1em;
}

.video-thumb {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}