/* Tsukiro 2.2.3 — mobile layout and player hotfix */

@media (max-width: 680px) {
  html {
    scroll-padding-top: 68px;
    overflow-x: hidden;
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  body.has-mobile-nav {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .navbar {
    width: 100%;
    height: 62px !important;
    min-height: 62px;
    padding: 8px 12px !important;
    grid-template-columns: minmax(42px, 1fr) auto !important;
    background: rgba(8, 8, 12, .94) !important;
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
  }

  .navbar .brand {
    width: 42px;
    min-width: 42px;
    gap: 0;
  }

  .navbar .brand img {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px;
    object-fit: contain;
  }

  .navbar .brand span,
  .navbar .nav-links {
    display: none !important;
  }

  .navbar .nav-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 7px;
    min-width: 0;
  }

  .navbar .icon-button {
    width: 42px !important;
    min-width: 42px;
    height: 42px !important;
    min-height: 42px;
    padding: 0 !important;
    border-radius: 13px !important;
  }

  .navbar .icon-button .ui-icon {
    width: 21px;
    height: 21px;
  }

  .search-shell.is-open .search-input {
    top: 66px !important;
  }

  .search-shell.is-open .search-results {
    top: 116px !important;
    max-height: calc(100dvh - 132px);
  }

  .tsukiro-mobile-nav {
    left: 12px !important;
    right: 12px !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    height: 58px !important;
    padding: 4px !important;
    border-radius: 18px !important;
  }

  .tsukiro-mobile-nav a {
    min-width: 0;
    gap: 1px !important;
    border-radius: 14px !important;
    font-size: 8px !important;
  }

  .tsukiro-mobile-nav .ui-icon {
    width: 17px !important;
    height: 17px !important;
  }

  .community-chat-fab {
    right: 12px !important;
    bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    width: 44px;
    min-width: 44px;
    height: 44px !important;
    padding: 0 !important;
    display: grid;
    place-items: center;
    border-radius: 14px !important;
  }

  .community-chat-fab span {
    display: none !important;
  }

  body[data-page="home"] .community-chat-fab,
  body[data-page="anime"] .community-chat-fab,
  body[data-page="watch"] .community-chat,
  body[data-page="watch"] .community-chat-fab {
    display: none !important;
  }

  .back-to-top {
    right: 12px !important;
    bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    width: 42px;
    height: 42px;
  }

  /* Home hero */
  .hero-v8,
  .hero-v8.has-long-title,
  .hero-v8.has-extra-long-title {
    width: 100%;
    height: auto !important;
    min-height: max(660px, 100svh) !important;
    max-height: none !important;
  }

  .hero-v8 .hero-video-layer {
    display: none !important;
  }

  .hero-v8 .hero-media {
    inset: 0;
    background-position: center 24% !important;
  }

  .hero-v8 .hero-overlay {
    background:
      linear-gradient(180deg, rgba(7,7,10,.35) 0%, rgba(7,7,10,.2) 20%, rgba(7,7,10,.83) 68%, #07070a 100%),
      linear-gradient(90deg, rgba(7,7,10,.82), rgba(7,7,10,.12)) !important;
  }

  .hero-v8 .hero-content-v8,
  .hero-v8.has-long-title .hero-content-v8,
  .hero-v8.has-extra-long-title .hero-content-v8 {
    width: calc(100% - 28px);
    min-height: max(660px, 100svh) !important;
    height: auto !important;
    justify-content: flex-end !important;
    align-items: flex-start;
    padding: 90px 0 112px !important;
  }

  .hero-v8 .hero-content-v8 h1,
  .hero-v8.has-long-title .hero-content-v8 h1,
  .hero-v8.has-extra-long-title .hero-content-v8 h1 {
    width: 100%;
    max-width: 100% !important;
    margin: 10px 0 9px;
    font-size: clamp(30px, 9.4vw, 42px) !important;
    line-height: 1.01 !important;
    letter-spacing: -.045em;
    text-wrap: pretty;
    overflow-wrap: anywhere;
  }

  .hero-content-v8 .hero-kicker {
    font-size: 9px;
  }

  .hero-content-v8 .hero-alt-title {
    min-height: 0;
    margin: 0 0 10px;
    font-size: 11px !important;
  }

  .hero-content-v8 .hero-meta {
    gap: 5px 8px;
    font-size: 10px !important;
  }

  .hero-content-v8 .hero-genres {
    gap: 6px;
    margin-block: 10px;
  }

  .hero-content-v8 .hero-genres .chip,
  .hero-content-v8 .hero-genres span {
    padding: 6px 9px;
    font-size: 9px;
  }

  .hero-content-v8 .hero-description {
    margin: 0 0 14px;
    font-size: 12px !important;
    line-height: 1.48;
    -webkit-line-clamp: 2 !important;
  }

  .hero-content-v8 .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .hero-content-v8 .hero-actions .button {
    width: 100%;
    min-width: 0;
    height: 44px !important;
    padding: 0 10px !important;
    font-size: 12px;
    white-space: nowrap;
  }

  .quick-start {
    width: calc(100% - 24px) !important;
    margin: -76px auto 0 !important;
  }

  .quick-start-grid {
    gap: 8px !important;
  }

  .quick-start-card {
    min-height: 72px !important;
    grid-template-columns: 38px minmax(0, 1fr) 16px !important;
    gap: 10px !important;
    padding: 12px !important;
  }

  .quick-start-icon {
    width: 38px !important;
    height: 38px !important;
  }

  .quick-start-card strong {
    font-size: 12px;
  }

  .quick-start-card small {
    font-size: 9px;
  }

  /* Anime detail */
  .anime-hero {
    min-height: 0 !important;
    padding-top: 84px;
  }

  .anime-hero-content {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
    align-items: end;
    padding-bottom: 26px !important;
  }

  .detail-poster {
    display: none !important;
  }

  .detail-copy {
    min-width: 0;
  }

  .detail-copy h1,
  .detail-title-row h1 {
    max-width: 100%;
    font-size: clamp(28px, 8.8vw, 39px) !important;
    line-height: 1.02 !important;
    overflow-wrap: anywhere;
  }

  .detail-copy h2 {
    margin-bottom: 10px;
    font-size: 12px !important;
  }

  .detail-copy > p {
    grid-column: 1 / -1;
    margin-top: 12px;
    font-size: 12px !important;
    line-height: 1.5;
    -webkit-line-clamp: 3 !important;
  }

  .anime-primary-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    margin-top: 14px;
  }

  .anime-primary-actions .button {
    width: 100%;
    min-width: 0 !important;
    height: 43px !important;
    padding: 0 8px !important;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .anime-primary-actions #watchNow {
    grid-column: 1 / -1;
    font-size: 13px;
  }

  .anime-primary-actions .hidden {
    display: none !important;
  }

  .anime-detail-layout {
    padding-top: 10px;
  }

  .info-card,
  .fold-card {
    border-radius: 17px;
  }

  /* Watch page: no floating bars over playback. */
  body.watch-page {
    padding-bottom: env(safe-area-inset-bottom) !important;
  }

  .watch-page .tsukiro-mobile-nav,
  .watch-page .back-to-top {
    display: none !important;
  }

  .watch-navbar {
    height: 58px !important;
    min-height: 58px;
  }

  .watch-navbar .brand img {
    width: 38px !important;
    height: 38px !important;
  }

  .watch-main {
    width: 100%;
    padding: 66px 0 36px !important;
  }

  .watch-container {
    width: 100% !important;
    max-width: none !important;
    padding-inline: 8px !important;
  }

  .watch-titlebar {
    min-width: 0;
    margin: 0 4px 10px;
  }

  .watch-title-copy {
    min-width: 0;
  }

  .watch-title-copy h1 {
    margin: 4px 0 2px !important;
    overflow: hidden;
    font-size: 18px !important;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .watch-title-copy p {
    margin: 0;
    overflow: hidden;
    font-size: 10px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .watch-back {
    font-size: 10px !important;
  }

  .watch-player-shell {
    width: calc(100% + 16px) !important;
    max-width: none !important;
    max-height: none !important;
    margin-left: -8px !important;
    margin-right: -8px !important;
    border-inline: 0 !important;
    border-radius: 0 !important;
    aspect-ratio: 16 / 9 !important;
  }

  .watch-player-shell video,
  .watch-external-player,
  .watch-external-frame {
    width: 100% !important;
    height: 100% !important;
  }

  .watch-player-top-controls {
    top: 6px !important;
    right: 6px !important;
    left: 6px;
    justify-content: flex-end;
    gap: 5px !important;
    max-width: none !important;
  }

  .watch-player-top-controls .watch-franchise-button,
  .watch-player-top-controls .watch-source-button {
    max-width: 116px;
    height: 31px !important;
    min-height: 31px;
    padding: 0 8px !important;
    border-radius: 9px;
    font-size: 9px !important;
  }

  .watch-player-top-controls .watch-source-button strong {
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .watch-source-button__caption {
    display: none !important;
  }

  .watch-franchise-menu,
  .watch-source-menu {
    position: fixed !important;
    z-index: 4100 !important;
    top: 68px !important;
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    min-width: 0 !important;
    max-height: calc(100dvh - 86px) !important;
    overflow: auto;
    border-radius: 14px !important;
  }

  .watch-franchise-item {
    grid-template-columns: 38px minmax(0, 1fr) auto !important;
  }

  .watch-player-top {
    display: none !important;
  }

  .watch-center-play {
    width: 54px !important;
    height: 48px !important;
    border-radius: 14px !important;
    font-size: 19px !important;
  }

  .watch-controls {
    padding: 40px 8px 5px !important;
  }

  .watch-controls-row {
    gap: 4px !important;
  }

  .watch-controls-left,
  .watch-controls-right {
    gap: 1px !important;
  }

  .watch-control-button {
    width: 31px;
    min-width: 31px !important;
    height: 31px !important;
    padding: 0 3px !important;
  }

  .watch-time {
    font-size: 8px !important;
  }

  .watch-skip-actions {
    right: 8px !important;
    bottom: 52px !important;
  }

  .watch-skip-button {
    min-height: 31px !important;
    padding-inline: 9px !important;
    font-size: 8px !important;
  }

  .watch-native-mobile .watch-player-shell:not(.is-external-provider) .watch-controls,
  .watch-native-mobile .watch-player-shell:not(.is-external-provider) .watch-skip-actions {
    display: none !important;
  }

  .watch-source-panel {
    margin-top: 12px !important;
    border-radius: 16px !important;
  }

  .watch-source-panel__head {
    gap: 10px !important;
    padding: 14px 12px 0 !important;
  }

  .watch-source-panel__head strong {
    font-size: 15px !important;
  }

  .watch-source-state {
    min-height: 28px;
    font-size: 9px;
  }

  .watch-source-panel .watch-options-card {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 12px !important;
  }

  .watch-option {
    min-width: 0;
  }

  .watch-option select {
    height: 40px !important;
    min-width: 0;
    padding: 0 28px 0 9px !important;
    font-size: 11px;
    text-overflow: ellipsis;
  }

  .watch-source-note {
    padding: 0 12px 13px !important;
    font-size: 9px !important;
  }

  .watch-episodes-section {
    padding-top: 26px !important;
  }

  .watch-episodes-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 380px) {
  .navbar .icon-button {
    width: 39px !important;
    min-width: 39px;
    height: 39px !important;
  }

  .hero-v8 .hero-content-v8 h1,
  .hero-v8.has-long-title .hero-content-v8 h1,
  .hero-v8.has-extra-long-title .hero-content-v8 h1 {
    font-size: clamp(27px, 9vw, 35px) !important;
  }

  .anime-primary-actions .button {
    font-size: 10px;
  }

  .watch-source-panel .watch-options-card {
    grid-template-columns: 1fr !important;
  }

  .watch-time,
  #pipButton {
    display: none !important;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  body.watch-page .watch-navbar {
    height: 48px !important;
    min-height: 48px;
  }

  body.watch-page .watch-navbar .brand img {
    width: 34px !important;
    height: 34px !important;
  }

  body.watch-page .watch-main {
    padding-top: 52px !important;
  }

  body.watch-page .watch-titlebar {
    display: none !important;
  }

  body.watch-page .watch-container {
    padding-inline: 0 !important;
  }

  body.watch-page .watch-player-shell {
    width: 100vw !important;
    max-width: 100vw !important;
    height: calc(100dvh - 52px) !important;
    max-height: none !important;
    margin: 0 !important;
    aspect-ratio: auto !important;
  }

  body.watch-page .watch-source-panel,
  body.watch-page .watch-episodes-section {
    margin-inline: 12px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .button,
  .icon-button,
  .anime-card,
  .quick-start-card {
    will-change: auto !important;
  }

  .anime-card:hover,
  .quick-start-card:hover,
  .button:hover,
  .icon-button:hover {
    transform: none !important;
  }
}
