:root {
  color-scheme: dark;
  --bg: #050611;
  --surface: #0b0c19;
  --surface-2: #111221;
  --surface-3: #171827;
  --line: #292a3b;
  --line-strong: #3a3b50;
  --text: #f6f4fb;
  --muted: #9b9aaa;
  --accent: #ed2b80;
  --accent-soft: #341329;
  --focus: #ff78b0;
  --page: min(1480px, calc(100vw - 48px));
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header { position: sticky; top: 0; z-index: 40; background: rgba(5, 6, 17, .96); border-bottom: 1px solid var(--accent); }
.site-header__inner {
  width: var(--page);
  min-height: 70px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(260px, 430px) 1fr auto;
  align-items: center;
  gap: 30px;
}
.brand { color: var(--text); font-size: 24px; font-weight: 900; letter-spacing: .04em; text-decoration: none; }
.search {
  height: 38px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
  background: #0c0d19;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}
.search:focus-within { border-color: var(--focus); }
.search input { min-width: 0; height: 100%; padding: 0 4px 0 16px; color: var(--text); background: transparent; border: 0; outline: 0; font-size: 13px; }
.search input::placeholder { color: #727181; }
.search button { height: 28px; margin-right: 5px; padding: 0 14px; background: var(--surface-3); border: 0; border-radius: 999px; color: #cbc9d3; font-size: 12px; cursor: pointer; }
.global-nav { justify-self: end; display: flex; align-items: center; gap: clamp(18px, 2.3vw, 40px); }
.global-nav button { position: relative; padding: 25px 0; background: transparent; border: 0; color: #dedce6; font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.global-nav button::after { content: ""; position: absolute; right: 0; bottom: 18px; left: 0; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: center; transition: transform .18s ease; }
.global-nav button:hover::after, .global-nav button.is-active::after { transform: scaleX(1); }
.age-badge { display: grid; place-items: center; min-width: 46px; height: 30px; border: 1px solid var(--accent); border-radius: 9px; color: #ff87b9; font-size: 12px; font-weight: 800; }

main { min-height: 70vh; }
.ranking-hero { width: var(--page); margin: 0 auto; padding: 34px 0 28px; text-align: center; }
.ranking-hero__eyebrow { margin: 0 0 10px; color: #7d7b8c; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.ranking-hero h1 { margin: 0; font-size: clamp(22px, 2vw, 30px); line-height: 1.35; letter-spacing: .03em; }
.filter-stack { width: min(380px, 100%); margin: 22px auto 0; display: grid; gap: 10px; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.segmented--period { grid-template-columns: repeat(3, 1fr); }
.segmented button { min-height: 36px; padding: 6px 12px; background: transparent; border: 0; border-radius: 999px; color: #b1afbc; font-size: 12px; font-weight: 800; cursor: pointer; }
.segmented button.is-active { background: var(--accent); color: #fff; }
.category-panel { width: min(740px, 100%); margin: 22px auto 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.category-panel[hidden] { display: none; }
.category-panel button { min-height: 36px; padding: 7px 18px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.category-panel button.is-active { background: var(--accent-soft); border-color: var(--accent); color: #ff91bd; }
.result-summary { min-height: 18px; margin: 18px 0 0; color: #797887; font-size: 11px; }

.ranking-content { width: var(--page); margin: 0 auto; padding: 0 0 70px; }
.video-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-flow: dense; grid-auto-rows: 8px; gap: 16px; }
.video-grid[hidden] { display: none; }
.video-card { position: relative; min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-align: left; box-shadow: 0 18px 38px rgba(0, 0, 0, .2); cursor: pointer; transition: border-color .18s ease, transform .18s ease; }
.video-card:hover { transform: translateY(-3px); border-color: #5b2944; }
.video-card__media { position: relative; overflow: hidden; background: #0c0d18; }
.video-card--portrait .video-card__media { aspect-ratio: 9 / 16; }
.video-card--landscape .video-card__media { aspect-ratio: 16 / 9; }
.video-card__media img { display: block; width: 100%; height: 100%; object-fit: cover; filter: saturate(.82) brightness(.82); transition: filter .2s ease, transform .24s ease; }
.video-card:hover .video-card__media img { filter: saturate(.95) brightness(.94); transform: scale(1.018); }
.video-card__rank, .video-card__duration, .video-card__format { position: absolute; z-index: 2; background: rgba(4, 5, 13, .88); border: 1px solid rgba(255, 255, 255, .12); color: #fff; font-size: 10px; font-weight: 800; line-height: 1; }
.video-card__rank { top: 9px; left: 9px; min-width: 38px; padding: 7px 8px; border-color: rgba(237, 43, 128, .56); color: #ff8fbd; border-radius: 7px; }
.video-card__duration { right: 9px; bottom: 9px; padding: 5px 6px; border-radius: 5px; }
.video-card__format { top: 9px; right: 9px; padding: 5px 6px; border-radius: 5px; color: #bcbac6; }
.video-card__body { padding: 13px 14px 15px; }
.video-card__title { display: -webkit-box; min-height: 42px; margin: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: #f1eff5; font-size: 14px; font-weight: 800; line-height: 1.48; }
.video-card__meta { margin: 8px 0 0; display: flex; justify-content: space-between; gap: 8px; color: #777685; font-size: 10px; }
.video-card__creator { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-card__views { flex: none; }

.empty-state { padding: 80px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state h2 { margin: 0; font-size: 20px; }
.empty-state p { margin: 10px 0 24px; color: var(--muted); font-size: 13px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); font-size: 13px; font-weight: 800; text-decoration: none; cursor: pointer; }
.button--primary { background: var(--accent); border-color: var(--accent); }
.button--quiet { background: transparent; }

.site-footer { padding: 42px 24px 48px; background: #03040b; border-top: 1px solid #1a1b29; color: #777684; text-align: center; font-size: 11px; line-height: 1.8; }
.site-footer__brand { margin: 0 0 18px; color: #e9e7ef; font-size: 20px; font-weight: 900; letter-spacing: .05em; }
.site-footer p { margin: 6px auto; max-width: 720px; }
.site-footer__note { color: #8d7180; }

.age-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(3, 4, 11, .96); }
.age-gate[hidden] { display: none; }
.age-gate__panel { width: min(480px, 100%); padding: 40px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; text-align: center; }
.age-gate__brand { margin: 0 0 26px; color: #fff; font-size: 22px; font-weight: 900; letter-spacing: .06em; }
.age-gate h1 { margin: 0; font-size: 25px; }
.age-gate__panel > p:not(.age-gate__brand) { margin: 16px auto 26px; max-width: 350px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.age-gate__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.sample-dialog { width: min(960px, calc(100vw - 36px)); max-height: min(820px, calc(100vh - 36px)); padding: 0; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; color: var(--text); box-shadow: 0 32px 90px rgba(0, 0, 0, .66); }
.sample-dialog::backdrop { background: rgba(3, 4, 12, .82); backdrop-filter: blur(14px); }
.dialog-close { position: absolute; z-index: 3; top: 14px; right: 14px; min-height: 36px; padding: 7px 14px; background: rgba(5, 6, 15, .9); border: 1px solid var(--line-strong); border-radius: 999px; color: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.sample-dialog__media { position: relative; min-height: 380px; display: grid; place-items: center; background: #03040a; }
.sample-dialog__media img { display: block; max-width: 100%; max-height: min(62vh, 610px); object-fit: contain; filter: brightness(.68) saturate(.78); }
.sample-dialog__play { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); min-height: 42px; padding: 8px 20px; background: rgba(5, 6, 15, .9); border: 1px solid #57586a; border-radius: 999px; color: #bbb9c5; font-size: 12px; font-weight: 800; }
.sample-dialog__body { padding: 24px 28px 30px; }
.sample-dialog__rank { margin: 0 0 7px; color: #ff76ad; font-size: 12px; font-weight: 900; }
.sample-dialog h2 { margin: 0; font-size: clamp(20px, 3vw, 30px); line-height: 1.45; }
.sample-dialog__creator { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.sample-dialog__tags { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 7px; }
.sample-dialog__tags span { padding: 6px 10px; background: var(--surface-3); border-radius: 999px; color: #aaa8b4; font-size: 10px; }
.sample-dialog__notice { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: #7e7c89; font-size: 11px; line-height: 1.8; }

@media (max-width: 1180px) {
  :root { --page: min(1120px, calc(100vw - 36px)); }
  .site-header__inner { grid-template-columns: auto minmax(230px, 360px) 1fr auto; gap: 18px; }
  .global-nav { gap: 17px; }
  .global-nav button { font-size: 12px; }
  .video-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .site-header__inner { min-height: auto; padding: 15px 0 12px; grid-template-columns: 1fr auto; gap: 12px 18px; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .global-nav { grid-column: 1 / -1; grid-row: 3; justify-self: stretch; overflow-x: auto; justify-content: space-between; scrollbar-width: none; }
  .global-nav::-webkit-scrollbar { display: none; }
  .global-nav button { padding: 7px 0 9px; }
  .global-nav button::after { bottom: 3px; }
  .age-badge { grid-column: 2; grid-row: 1; }
  .video-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 660px) {
  :root { --page: calc(100vw - 24px); }
  .brand { font-size: 21px; }
  .ranking-hero { padding: 28px 0 22px; }
  .ranking-hero__eyebrow { display: none; }
  .ranking-hero h1 { font-size: 21px; }
  .filter-stack { margin-top: 18px; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 6px; gap: 10px; }
  .video-card { border-radius: 9px; }
  .video-card__body { padding: 11px 10px 12px; }
  .video-card__title { min-height: 38px; font-size: 12px; }
  .video-card__meta { display: block; margin-top: 6px; }
  .video-card__views { display: block; margin-top: 3px; }
  .video-card__rank { top: 6px; left: 6px; }
  .video-card__format { top: 6px; right: 6px; }
  .video-card__duration { right: 6px; bottom: 6px; }
  .age-gate__panel { padding: 30px 20px; }
  .age-gate__actions { grid-template-columns: 1fr; }
  .sample-dialog__media { min-height: 300px; }
  .sample-dialog__body { padding: 20px 18px 24px; }
}

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